I use tint2 as my panel when using standalone openbox. The desktop environment LXDE uses LXPanel as panel and openbox as window manager. I usually keep my panels autohidden to minimize distraction and to maximize screen space. A panel is important to show me a clock and if I need to access network settings (nm-applet) or battery and power-management (mate-power-manager).
Recently I wanted to bind an action to unhide the panel to a shortcut and things started to get difficult. As far as I can tell there is no ready available solution. Openbox ToggleDockAutohide option only works with docks and gave me weird results when I put tint2 in dock-mode.
So it was time for a hack. I quickly found out how to move the mouse cursor with xdotool. It was already installed on my Debian Stretch laptop.
Xdotool has an option to move the mouse cursor to a given position and to restore it to the initial position afterwards.
Following code moves the cursor to X=0 Y=800 (pixel), waits for two seconds and moves the cursor back.
xdotool mousemove 0 800 sleep 2 mousemove restore
Two seconds is usually enough time for me to check the clock or to see if my battery is low or to verify if I lost my wifi connection. Although above solution works well in some use cases I want the cursor to stay on the panel so I can interact with it and sometimes I want to restore cursor position to continue my work.
So I am using the command
xdotool mousemove 600 800
to move the cursor to the panel (X=600 is roughly the middle of the panel on my laptop screen).
And this command to move it right in the middle of the screen:
xdotool mousemove 600 400
These solutions are good enough for me. I found out that there is a way to get X and Y coordinates as shell output (see
man xdotool). Then one could use Shell variables
$Y to restore the initial cursor position and bind it to a shortcut. I have decided that my hack is good enough and I am currently not willing to refine it.
Let’s bind the above commands to keybindings in openbox. I am using a combination of Windows-key and letters typed with the right hand when touch typing. Edit
lxde-rc.xml for Lxde and add following code in the “
<keyboard\>” section. Make sure that the keybindings don’t collide with your other self defined bindings:
<!-- custom bindings of mouse moves --> <keybind key="W-n"> <action name="Execute"> <command>xdotool mousemove 600 800 sleep 2 mousemove restore</command> </action> </keybind> <keybind key="W-j"> <action name="Execute"> <command>xdotool mousemove 600 800</command> </action> </keybind> <keybind key="W-k"> <action name="Execute"> <command>xdotool mousemove 600 400</command> </action> </keybind>
For general information on keybindings in openbox see the wiki.
If you have improvements to my hacky solution or a proper solution, please let me know.
If you have any questions, suggestions, thoughts and comments please feel free to email me.
License of this blog post:
This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.