4

I am using LXDE and in my .config/openbox/lxde-rc.xml I have action for ALT-F4 defined:

<keybind key="A-F4">
  <action name="Close"/>
</keybind>

This works, as expected, for all applications. When ALT-F4 is pressed, the window is closed.

I have one application, lets call it foo, which I would like to be unaffected by ALT-F4. i.e. when ALT-F4 is pressed, I want the window to stay open (the action should be completely ignored).

Is it possible to create such rule?

EDIT: Based on the answer from @Michael Homer I have added following into my .config/openbox/lxde-rc.xml:

<keybind key="A-F4">
  <action name="If">
    <title>foo</title>
    <then>
      <!-- Do nothing for foo -->
    </then>
    <else>
      <action name="Close"/>
    </else>
  </action>
</keybind>

This works great, but I would need to match foo or bar.

What would be the simplest solution to achieve that?

  • Not according to the manual - but I'm no expert (hence, comment not answer). – EightBitTony Jun 30 '14 at 10:56
  • same problem, but i don't need to ..do nothing.., i need to do what do Escape button by default, what action is it? Thank you. xdotool key Escape didn't work – user84105 Sep 14 '14 at 1:14
3

It is possible with an If action:

<keybind key="A-F4">
 <action name="If">
  <title>* foo</title>
  <then><!-- Do nothing for foo --></then>
  <else>
   <action name="Close" />
  </else>
 </action>
</keybind>

The <title> condition will match a window title ending " foo". There are variations <title type="regex"> and <title type="exact"> for other kinds of match. When the window matches, the action will do nothing, and when it doesn't (for every other window) it will close as usual.

Openbox 3.6 and newer include additional selector tags <class>, <name>, and <role> which can help to identify your window more precisely if the title isn't unique. They support the same type attribute and content as <title>, but are tested against the relevant X property instead.


If you're using an earlier version of Openbox and your window can't be identified by title, you're in less luck, but it's possible to hack something together with xdotool: bind the A-F4 action to a script that identifies the window more precisely, and then send a secret key combination that's bound to the actual close action if it doesn't match.

  • my application has title set to "None". But can I use other tags, such as class or name ? – Martin Vegter Jun 30 '14 at 11:58
  • That title is probably uncommon enough that you could use <title type="exact">None</title>, but otherwise there isn't anything built in for dealing with class. You could piece it together with xdotool at a pinch. – Michael Homer Jun 30 '14 at 20:36
  • I know that, but it always looks like playing the wise guy with such minor typo fixes. :) I normally only do that with bigger issues: bad layout,. bad grouping etc. – syntaxerror Oct 14 '14 at 7:37
  • @Michael Homer - is it possible to match <title>* foo</title> or <title>* bar</title>? – Martin Vegter Mar 7 '15 at 21:25
  • Use a regular expression. – Michael Homer Mar 7 '15 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.