I'm not experienced in scripting but I've made this script:
#!/usr/bin/env bash
# hint: use "xdotool getmouselocation" to get values
if xdotool getwindowfocus getwindowname | grep -Eq " - LibreOffice Calc$"
then
xdotool mousemove --sync 218 144 click 1
fi
The purpose is to have a keyboard shortcut to using the sum
function in LibreOffice Calc 4.4.5. There is no default keyboard shortcut in LibreOffice Calc and it doesn't seem possible to assign one to the sum
function: see Bug 39302.
The shortcut executes mousemove
only when a Calc window is in focus. Otherwise, it should do nothing. (The coordinates are specific to my usage.)
My question is this: is there a better way to check whether the Calc window is in focus?
How do I change key bindings based on which window is focused? seems related but doesn't have an answer.
if
andpipe
, run the subcommands alone first, then chain them. That isxdotool ...
. Thenxdotool ... | grep ... ; echo $?
. Thenif ... then
. You also can run the script withsh -x script
.