Is it possible to configure Lubuntu (i.e. Openbox) such that some action is performed when the mouse cursor is moved to a certain position?
In particular, I would like to run a script when I move the mouse cursor to the top-left corner and keep pushing it up and left. This is similar to some window managers that let you switch to another display when pushing the mouse cursor to either side of the screen.
One way to accomplish this is via xdotool
. From xdotool
's manual:
behave_screen_edge [options] where command ...
Bind an action to events when the mouse hits the screen edge or corner.
Options are:
--delay MILLISECONDS
Delay in milliseconds before running the command. This allows you to require a given edge or corner to be held for a short period before your command will run. If you leave the edge or corner before the delay expires then the time will reset.
--quiesce MILLISECONDS
Delay in milliseconds before the next command will run. This helps prevent accidentally running your command extra times; especially useful if you have a very short --delay (like the default of 0).
Event timeline
- Mouse hits an edge or corner.
- If delay is nonzero, the mouse must stay in this edge or corner until delay time expires.
- If still in the edge/corner, trigger.
- If quiesce is nonzero, then there is a cool-down period where the next
trigger cannot occur
Valid 'where' values are:
left
top-left
top
top-right
right
bottom-left
bottom
bottom-right
You can combine the behave_screen_edge
option with any of xdotool
's inbuilt commands, including the exec
command:
exec [options] command [...]
Execute a program. This is often useful when combined with behave_screen_edge to do things like locking your screen.
Options:
--sync
Block until the child process exits. The child process exit status is then passed to the parent process (xdotool) which copies it.
So to trigger a script when hitting the top left corner of your screen you would use the following command:
xdotool behave_screen_edge top-left exec --sync script.sh
The --sync
switch ensures that xdotool
waits until the script exits before triggering the action again.
xdotool
is part of the official Ubuntu repositories and may be installed via:
sudo apt-get install xdotool
No comments:
Post a Comment