lundi 2 février 2015

xdotool and xbindkeys


I have an Acrobat reader that does not zoom on Control+plus but rather on Control+acute (Control-plus annoyingly rotates the document).


I would like to fix this using xbindkeys and xdotool but the complication is that Control-plus is also used by other applications.


So the idea is to intercept Control-plus, check if Acrobat is the active window. If so send Acrobat a Control-acute, otherwise send the Control-plus.


Here my current attempt for the script that xbindkeys starts on Control+plus:



WM_CLASS=$(xprop -id `xdotool getactivewindow` WM_CLASS |awk '{print $4}')

if [ "$WM_CLASS" = "\"Acroread"\" ];
then
sleep 0.1s;
xdotool key --clearmodifiers ctrl+acute
else
killall xbindkeys
xdotool key --clearmodifiers ctrl+plus
xbindkeys
fi


This actually works but the problem is that if I would not kill xbindkeys than xdotool sending ctrl-plus would again trigger xbindkeys and so on.


But of course this means that every time I hit Control+plus in a non-acrobat window xbindkeys needs to be killed and restarted...


Is there a better way to do this?


Many thanks!



Aucun commentaire:

Enregistrer un commentaire