User:Spoiledbroth/xdotool

From Openbox

< User:Spoiledbroth(Difference between revisions)
Jump to: navigation, search
(alpha)
 

Latest revision as of 04:03, 22 February 2018

Copied from ArchWiki's Openbox page.

[edit] Desktop menu as a panel menu

xdotool is a package that can issue commands to simulate key presses / keybinds, meaning that it is possible to use it to invoke keybind-related actions without having to actually press their assigned keys. As this includes the ability to invoke an assigned keybind for the Openbox desktop menu, it is therefore possible to use XDoTool to turn the Openbox desktop menu into a panel menu. Especially where the desktop menu is heavily customised and feature-rich, this may prove very useful to:

  • Replace an existing panel menu
  • Implement a panel menu where otherwise not provided or possible (e.g. for Tint2)
  • Compensate where losing access to the desktop menu due to the use of an application like xfdesktop to manage the desktop.

Once XDoTool has been installed - if not already present - it will be necessary to create a keybind to access the root menu in ~/.config/openbox/rc.xml, and again below the <!–– Keybindings for running aplications ––> heading. For example, the following code will bring up the menu by pressing CTRL + m:

<keybind key="C-m">
    <action name="ShowMenu">
       <menu>root-menu</menu>
    </action>
</keybind>

Openbox must then be re-configured. In this instance, XDoTool will be used to simulate the CTRL + m keypress to access the desktop menu with the following command (note the use of + in place of -):

xdotool key control+m

How this command may be used as a panel launcher / icon is largely dependent on the features of panel used. While some panels will allow the above command to be executed directly in the process of creating a new launcher, others may require the use of an executable script. As an example, a custom executable script called obpanelmenu.sh will be created in the ~/.config folder:

$ text editor ~/.config/obpanelmenu.sh

Once the empty file has been opened, the appropriate XDoTool command must be added to the empty file (i.e. to simulate the CTRL + m keypress for this example):

xdotool key control+m

After the file has been saved and closed, it may then be made into an executable script with the following command:

$ chmod +x ~/.config/obpanelmenu.sh

Executing it will bring up the Openbox desktop menu. Consequently, where using a panel that supports drag-and-drop functionality to add new launchers, simply drag the executable script onto it before changing the icon to suit personal taste.

[edit] Notes

  1. Personally I like to employ this pattern in tint2 using the executor- for one this allows you to spawn a different menu when the icon is right clicked, and two it allows some text to accompany the icon (which doesn't seem possible with the tint2 launcher).
  2. If you opt for, say, tint2 using the launcher method as originally described on ArchWiki, ensure you DO NOT enable startup notifications by default in your launcher. With tint2,
    $ cat ~/.config/tint2/tint2rg | grep startup
    should return
    startup_notifications = 0