Detect mouse movement in bash script

fixit7

Member
Joined
Mar 4, 2019
Messages
63
Reaction score
18
Credits
55
Syntax error near unexpected token `('
I would like to create a bash script that can detect any mouse movement and then execute a command.

detect_mouse_mvt.sh
/home/andy/bin/detect_mouse_mvt.sh: line 4: syntax error near unexpected token `('
/home/andy/bin/detect_mouse_mvt.sh: line 4: `fh = file('/dev/input/mice')'

#!/bin/bash
#
#
fh = file('/dev/input/mice')
while True:
fh.read(3)
print 'Mouse moved!'
 


That code is part of a python script.

https://man.openbsd.org/xidle.1

I think xidle would work, but I need help with it.

andy@7_~$ xidle -area 5 -delay 5 secs -program /home/andy/bin/test.sh -timeout 1 sec
Usage:
xidle [-area pixels] [-delay secs] [-display host:dpy] [-ne | -nw | -sw | -sw]
[-program path] [-timeout secs]
 
Last edited:

Staff online

Members online


Top