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
xdotool
can be used this way. Coincidentally I was going to usexdotool
in the script invoked when positioning the mouse cursor. I am not sure exactly what way is best to start thexdotool behave_screen_edge ...
script though. I would like it to be started on login. – DustByte Mar 26 '15 at 20:17