13

I would like to write a script to prevent a computer from locking by virtually wiggling the mouse. However, I do not have xdotool on the computer that I am using, and I cannot install since I am not root. Is there a way to move the cursor without using xdotool?

Braiam
  • 35,380
  • 25
  • 108
  • 167
ichbinallen
  • 313
  • 2
  • 4
  • 9
  • 15
    Why do this instead of just disabling your lock screen? – HalosGhost Oct 26 '14 at 02:50
  • Is using `dbus-send` an option to disable the screensaver? [How can I trigger the screensaver's locking feature using D-BUS from the command line?](http://unix.stackexchange.com/questions/107787/how-can-i-trigger-the-screensavers-locking-feature-using-d-bus-from-the-command/107789#107789) – slm Oct 26 '14 at 05:06
  • 5
    Obligatory XKCD: http://xkcd.com/196/ – tpg2114 Oct 26 '14 at 15:08

2 Answers2

11

According to this answer you can move the pointer of your mouse using command-line with the following procedure:

  1. First you need to find mouse input device with

    grep mouse /proc/bus/input/devices | grep event
    

You should see something like H: Handlers=mouse0 event7 in my case. It could output more than one line if you have more than one mouse (e.g. touchpad). The important part is event7, it means you will write to /dev/input/event7.

  1. Then the following will move mouse pointer 100 pixels to the right:

    seconds=$(date +%s)
    type=2      # EV_REL
    code=0      # REL_X
    value=100   # 100 pixels
    
    printf '%08X%04X%04X%08X%08X\n' $value $code $type 0 $seconds | xxd -r -p | \
        perl -0777e 'print scalar reverse <>' > /dev/input/event7
    
    type=0      # EV_SYN
    code=0      # SYN_REPORT
    value=0
    
    printf '%08X%04X%04X%08X%08X\n' $value $code $type 0 $seconds | xxd -r -p | \
        perl -0777e 'print scalar reverse <>' > /dev/input/event7
    

I didn't test whether this procedure is equivalent to real mouse movement in the sense of interrupting locking mechanism.

DimiDak
  • 222
  • 2
  • 7
jimmij
  • 46,064
  • 19
  • 123
  • 136
10

That you cannot install xdotool because you are not root doesn't mean you cannot run the program, for that you don't need any special privileges.

Just download and compile from source.

If you don't have access to a compiler then you can download the package for your system directly and extract the file from the package (for .deb first use ar, extracting from .rpm can be done with rpm2cpio)

Anthon
  • 78,313
  • 42
  • 165
  • 222