Search code examples
linuxraspbianxdotooliceweasel

How to make xdotool work with matchbow-window-manager?


I have trouble using xdotool to simulate simple keypresses in my browser.

Now my browsers starts up on boot by adding the following code in '/home/pi/.xintirc'

#!/bin/sh
xset -dpms
xset s off
xset s noblank

// not sure if this is needed.
killall -TERM matchbox-window-manager 2>/dev/null;
killall -9 matchbox-window-manager 2>/dev/null;

exec matchbox-window-manager -use_titlebar no &
iceweasel [someURL]
python /etc/xdo_test.py

My /etc/xdo_test.py looks as follows:

import time
import subprocess

time.sleep(20)
subprocess.call(["xdotool", "key", "c"]);

I don't have any output of this file while using it on startup but if I excecute this in another console, I get the following output:

Error: Can't open display: (null)
Failed creating new xdo instance

Does anyone have an idea why I get this error and how to solve it?


Solution

  • I got it to work. I eventually found this tutorial and used some ideas from it. I'll post the solutions for the people who may have a similar problem.

    This is what i placed in the /home/pi/.xinitrc file:

    #!/bin/sh
    xset -dpms
    xset s off
    xset s noblank
    
    // not sure if this is needed.
    killall -TERM matchbox-window-manager 2>/dev/null;
    killall -9 matchbox-window-manager 2>/dev/null;
    
    exec matchbox-window-manager -use_titlebar no &
    iceweasel [someURL] &
    sudo /etc/xdo_test.sh
    

    I changed the python script to a shell script an inserted the following code:

    sleep 20
    $WIN=$(xdotool search --onlyvisible --class Iceweasel|head -1)
    xdotool key --window $WIN c
    
    while:
    do
        sleep 300
    done
    

    The while loop at the end is something I added because Xserver crashed from the moment it lost connection to the script. I'm still looking for a cleaner solution to end the script but this works for now. I'll update this awnser when I find one.

    Thanks Sebastian Stigler for the help!