Ubuntu – How to have an application automatically display on all desktops with openbox

lxdeopenboxwindow-managementwmctrl

Is it possible to use wmctrl or something else to make a specific window automatically display on all desktops?

I use the Prime Player Google Play Music miniplayer Chrome extension to control music playback. I already have a bash alias I can invoke to make the miniplayer stay on top of other windows, but I want to also have it send the miniplayer window to all desktops so I don't have to right-click and select Send to DesktopAll Desktops (via openbox).

Ideally, I would have a script run something in the background and as soon as it detects the miniplayer window it puts it on top and sends to all desktops. Is this possible?

Best Answer

You can actually do this without a third party script. Openbox supports an extensive range of per-application settings.

Creating an app-specific rule

Application rules are matched against different properties like the window name, class, role or title. Most of these properties can be obtained for a specific window by running

obxprop | grep "^_OB_APP"

and clicking on the window in question.

Seeing how you are planning to specify the rule for a Chrome extension window you might want to supply as many matching properties as possible so as to make the rule as specific as possible. You don't want it to apply to all Chrome windows. Try out different matching properties and see what works best for you.

Having defined the matching window you can set different properties that will exclusively apply to the window/application in question. Here's an excerpt of the default rc.xml which describes all available properties:

# each rule element can be left out or set to 'default' to specify to not 
# change that attribute of the window

<decor>yes</decor>
# enable or disable window decorations

<shade>no</shade>
# make the window shaded when it appears, or not

<position force="no">
  # the position is only used if both an x and y coordinate are provided
  # (and not set to 'default')
  # when force is "yes", then the window will be placed here even if it
  # says you want it placed elsewhere.  this is to override buggy
  # applications who refuse to behave
  <x>center</x>
  # a number like 50, or 'center' to center on screen. use a negative number
  # to start from the right (or bottom for <y>), ie -50 is 50 pixels from
  # the right edge (or bottom). use 'default' to specify using value
  # provided by the application, or chosen by openbox, instead.
  <y>200</y>
  <monitor>1</monitor>
  # specifies the monitor in a xinerama setup.
  # 1 is the first head, or 'mouse' for wherever the mouse is
</position>

<size>
  # the size to make the window.
  <width>20</width>
  # a number like 20, or 'default' to use the size given by the application.
  # you can use fractions such as 1/2 or percentages such as 75% in which
  # case the value is relative to the size of the monitor that the window
  # appears on.
  <height>30%</height>
</size>

<focus>yes</focus>
# if the window should try be given focus when it appears. if this is set
# to yes it doesn't guarantee the window will be given focus. some
# restrictions may apply, but Openbox will try to

<desktop>1</desktop>
# 1 is the first desktop, 'all' for all desktops

<layer>normal</layer>
# 'above', 'normal', or 'below'

<iconic>no</iconic>
# make the window iconified when it appears, or not

<skip_pager>no</skip_pager>
# asks to not be shown in pagers

<skip_taskbar>no</skip_taskbar>
# asks to not be shown in taskbars. window cycling actions will also
# skip past such windows

<fullscreen>yes</fullscreen>
# make the window in fullscreen mode when it appears

<maximized>true</maximized>
# 'Horizontal', 'Vertical' or boolean (yes/no)

In your specific case you will be interested in specifying the layer and desktop of the application. Here's an example of a rule that would designate all windows of a specific application to be always on top and omnipresent on all available desktops:

<application name="miniplayer" class="miniplayer" type="normal">
  <layer>above</layer>
  <desktop>all</desktop>
</application>

I chose an arbitrary application name and class for this example. As stated before you will have to make sure to find the correct values for your specific application.


Edit: I looked into your specific application and came up with a rule that works on my system:

<application name="crx_npngaakpdgeaajbnidkkginekmnaejbi" class="Google-chrome" type="normal" role="pop-up">
  <layer>above</layer>
  <desktop>all</desktop>
</application>

I hope this works for you as well.


Modifiying your openbox configuration to add an app specific rule

To add an application rule open your openbox rc.xml (found under ~/.config/openbox/rc.xml for stock openbox or ~/.config/openbox/lxde-rc.xml for LXDE) and navigate to the <applications> section at the very end of the file.

Insert your application specific rules between the <applications>..</applications> tags. Then save the file and proceed to reload the configuration by executing:

openbox --reconfigure

The application specific rules should be in effect after this and will automatically get applied to newly spawned windows.

Related Question