xdotool with chromium browser on RaspberryPi

7,556 views
Skip to first unread message

heinrich....@gmail.com

unread,
Apr 14, 2015, 5:16:17 PM4/14/15
to xdotoo...@googlegroups.com
Hi,

I've burned days combing through the documentation without fruitful result.
I have Chromium browser running with 3 tabs and i'm trying to send key ctrl+Tab to cycle through the tabs.

I'm running xdotool version 2.20100701.2961

command: $ xdotool search --class chromium
or command : $ xdotool search --classname chromium
both result in:
20099555
18814407
18874369
18874371
18874399
20524551

command : $ xdotool search --name chromium
results in:
20099555
18814407
18874369
18874371
18874399
18874420
20099071
20523492
20524551

ive tried $ xdotool search --name chromium --windowfocus
however I can't seem to get command chaining to work.

Any and all help is welcome.

Justin Chaschowy

unread,
Apr 15, 2015, 8:07:30 AM4/15/15
to xdotoo...@googlegroups.com, heinrich....@gmail.com
This works for me

xdotool search --sync --onlyvisible --class "Firefox" windowactivate key alt+Tab

heinrich....@gmail.com

unread,
Apr 16, 2015, 5:50:31 PM4/16/15
to xdotoo...@googlegroups.com, heinrich....@gmail.com
The --sync argument does not work.
I removed it and now it works like a charm. The final code to cycle through the browser tabs:
xdotool search --onlyvisible --class "Firefox" windowactivate key alt+Tab

Justin, YOU ROCK.

Thanks

dban...@gmail.com

unread,
Sep 21, 2016, 1:38:08 AM9/21/16
to xdotool-users, heinrich....@gmail.com
This info really helps!  Thanks a lot.  I can run this command from a terminal window in Raspbian Jessie and it works great.  Actually, I can run it using a watch -n 10 and it scrolls through the tabs every 10 seconds.  My only problem is I need this to run unattended and can't get it to work in LXDE desktop environment with autostart or with a bash script.  I have a bash script that sleeps just for 20 seconds to let chromium-browser load but when I add the line watch -n 10 'xdotool search --onlyvisible --class "chromium" windowfocus; xdotool key ctrl+Tab' it doesn't work.  I've tried a lot of different combinations but have not found one to work yet.  Any thoughts??

Thanks!   Doug

der...@derrickisonline.com

unread,
Mar 29, 2017, 2:41:30 PM3/29/17
to xdotool-users, heinrich....@gmail.com
Same here, any luck or updates on this?  I know this thread is old but hoping someone figured it out.

G.W. Haywood

unread,
Mar 30, 2017, 4:11:43 AM3/30/17
to der...@derrickisonline.com, xdotool-users
Hi there,

On Wed, 29 Mar 2017, der...@derrickisonline.com wrote:

> Same here, any luck or updates on this? I know this thread is old but
> hoping someone figured it out.
>
> On Wednesday, September 21, 2016 at 1:38:08 AM UTC-4, Douglas Banker wrote:
> > ...
> > bash script that sleeps just for 20 seconds to let chromium-browser load
> > but when I add the line watch -n 10 'xdotool search --onlyvisible --class
> > "chromium" windowfocus; xdotool key ctrl+Tab' it doesn't work. I've tried
> > a lot of different combinations but have not found one to work yet. Any
> > thoughts??

I'm in no way an xdotool expert. I only really used xdotool once, a
few years ago, for a customer who has an old Microsoft keyboard which
he wanted to carry on using although it had been unsupported for many
years. I've remained on the list because it's always been possible
that I will need to use xdotool again - and it's a low volume list. :)

So I'm answering from a very general perspective. On the plus side, I
have been using and coding on Unix-based systems since the 1970s.

Several things come immediately to mind.

1. Bash (etc.) scripts are often run in an environment which differs
from the one which the developer uses while he's developing it. Those
new to scripting on a Unix-based OS often fall foul of this issue. At
its simplest, this means that when an executable is called from the
script, you might need to give the full path to the executable instead
of the bare executable name; in this case perhaps '/usr/bin/watch' and
'/usr/local/bin/xdotool' instead of 'watch' and 'xdotool'. The paths
maight not be the same on your system, it depends on how the packages
were installed. There may be other important considerations, such as
the terminal capabilities to be expected. You might even need to set
up the script's environment so that it mirrors fairly closely the one
you usually have in your login session.

2. If you focus on a single solution to your problem (even assuming
that you've properly identified the problem) you might ignore a whole
bunch of other possible solutions. For example I came across xdotool
after trying half a dozen similar utilities, all of which had their
own distinct set of failings, quirks and gotchas. In some cases I
tried more than a dozen different ways of attacking the problem (in my
case it was to get some proprietary buttons on the keyboard to emulate
other key combinations - different combinations for each button). In
the present case, the CTRL+TAB key combination may be one of many ways
of achieving the desired result, and even if the alternatives do not
"work" they might with sufficient perspiration allow another coin to
be shaken out of the piggy bank of clues which lead to a solution. It
took me two weeks to get three buttons on that accursed Microsoft
keyboard to do what the customer wanted - cut and paste in Paintshop,
running on a Windows 7 VM - but the customer is still a customer. :)

3. Mr. Banker says only "it doesn't work". This is a very common and
almost universally useless problem description. The precise way in
which it doesn't work is a very important clue to finding out what is
happening. Does the executable even run? If it runs, does it produce
any debugging/logging/output of any kind at all? If not, what can be
done to create some of that stuff?

4. Mr. Banker said he tried "a lot of different combinations". But he
has *not* said what they were, so we don't even know what direction(s)
he's been going in, never mind how far along the path(s) he got. As a
purely mailing-list-support consideration, this isn't very helpful to
the people who might be trying to help. And "same here" doesn't add a
whole lot to the sum of human knowledge. :(

Finally, my notes tell me that the tool that I eventually used to get
my customer's keyboard doing what he wanted it to do was not xdotool.
It was evrouter. It was five years ago, I'd forgotten.

Keep notes. If that's the only thing you take away from this message,
it was worth the trouble of writing it.

HTH

--

73,
Ged.

Banker, Douglas CTR MDA/ESO

unread,
Apr 5, 2017, 1:44:08 AM4/5/17
to g...@jubileegroup.co.uk, der...@derrickisonline.com, xdotool-users
So sorry Mr. Haywood. But you have to realize we are all of very different levels of expertise. What seems intuitively obvious to you might be like a pig looking at a wristwatch for someone else. We all need to be a little bit patient with each other. When I said it "didn't work" I meant xdotool never tried to launch...no processes, no log files...nothing. My next attempt involved thinking the autostart was running too quickly for the rest of the system during boot. I may be totally off, but here goes.

At the risk of being long, here is what finally worked for me.

In my home directory (for me it is /home/pi) /.config/lxsession/LXDE-pi the autostart file is:

@lxpanel -profile LXDE-pi

@pcmanfm --desktop --profile LXDE-pi

@xscreensaver -no-splash

@xset s off

@xset -dpms

@xset s noblank

@sed -I 's/"exited_cleanly": false/"exited_cleanly" true /~.config/chromium/Default/Preferences

@chromium-browser -noerrdialogs --disable-session-crashed-bubble --disable-infobars --kiosk http://<path to online html document #1> OR file:////<path to file on the pi>

****On the line above I used the file://// on my pi because the wifi connection at the remote location is not that reliable. I chose to remotely copy the files needed directly to the pi so it would run as I expected whether the wifi is up or not, as long as it is up when I do the copy. I found that if the wifi went down during the kiosk operation that chromium locked up on me. I'm sure there is a more elegant solution but for me this method is extremely reliable. For remotely uploading files to the pi I use winscp and remot3.it, both free applications. This combination works great and is just as easy as loading my html documents to a file server and then having the pi access them from there. I should say that remot3.it is free for up to 5 remote pi locations. After that there is a fee schedule. *****

@lxterminal --command "home/pi/scripts/sleep.sh" ***This is where I launch xdotool after a short delay. Xdotool always worked in a terminal window for me. ****

My scripts reside in ~/scripts. sleep.sh uses xdotool to do a control + Tab every 10 seconds. Change to meet your needs. This moves the kiosk from one tab to the next.

sleep.sh

#!bin/bash

xdotool search --onlyvisible --class Chromium windowfocus

watch -n 10 xdotool key ctrl+Tab ***this went from tab to tab every 10 seconds. For my final version I'll probably use 30 seconds so my 90 year-old mother has time to read each screen*****

For my application I put the kiosk screen to sleep at night using this script and running it in crontab.

xsetoff.sh

#!/bin/bash

/usr/bin/xset -display :0 dpms force off


And turn it back on in the morning using

xseton.sh

#!/bin/bash

/usr/bin/xset -display :0 dpms force on

To set up crontab:

At a command prompt type crontab -e: crontab opens in edit mode.


Add the following lines:

0 4 * * * ~/scripts/xseton.sh (this turns the screen on at 4:00 A.M. every day)

0 19 * * * ~/scripts/xsetoff.sh (this turns the screen off at 7:00 P.M. every day)

That, my friends, is the whole enchilada that reliably suits my need.

Doug Banker

Henning Bekel

unread,
Apr 5, 2017, 2:30:08 AM4/5/17
to douglas.b...@mda.mil, xdotool-users
@lxterminal --command "home/pi/scripts/sleep.sh"

Doug, is that an absolute path? Maybe a leading slash is missing? Is the script executable? does running "lxterminal --command home/pi/scripts/sleep.sh" from another lxterminal work? Do you have to run the script in a terminal window at all? Wouldn't

@/home/pi/scripts/sleep.sh

be enough here? (Don't know the specifics of the lx startup scripts).

Also, you could use

while sleep 10; do xdotool key ctrl+Tab; done

instead of using watch. I've checked that watch does run without a controlling tty, so this should work, but it's kind of the wrong tool for the job :)

Hope this helps,
Henning



--

73,
Ged.

--
You received this message because you are subscribed to the Google Groups "xdotool-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xdotool-users+unsubscribe@googlegroups.com.
To post to this group, send email to xdotoo...@googlegroups.com.
Visit this group at https://groups.google.com/group/xdotool-users.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages