[openbox] activate/deactive shortcuts on the fly

Mikael Magnusson mikachu at gmail.com
Mon Oct 19 05:02:32 EDT 2020


On 10/18/20, Ɓukasz Grabowski <graboluk at gmail.com> wrote:
> Hello,
>
> I use xournal for delivering online lectures with a wacom tablet. It
> has quite bad shortcuts with no possibility of adjusting them without
> recompiling.
>
> Right now I use openbox/obhotkey/xdotool instead like so: in my rc.xml
> I have
>
> <keybind key="C-A-k">
>  <action name="execute">
>   <command>/home/luke/bin/xournal-mode.sh</command>
>  </action>
> </keybind>
>
> <keybind key="C-A-l">
>  <action name="execute"><command>/home/luke/bin/xournal-mode-off.sh
>  </command></action>
> </keybind>
>
> xournal-mode.sh has a bunch of lines like
>
> obhotkey 1  "xdotool key alt+t c b"
>
> which means that changing pen colour to blue is done by pressing 1.
>
> Similarly, xournal-mode-off.sh has lines like
>
> obhotkey 1 ""
>
> Mostly this works, but it just feels flimsy. For example, there seem to
> be a bug in obhotkey: if I turn on xournal mode and then turn it off,
> then there's one extra blank line in rc.xml. So right now I have 100s
> or more blank lines in my rc.xml. Also once or twice I ended with more
> severely damaged rc.xml where I had to edit it (I guess this happened
> when I went into panic mode trying to switch-on switch off the xournal
> mode several times in a row in a short amount of time, because I went to
> another widnow without deactivating xournal mode)
>
> So I'm looking for a different, more robust solution. For example could
> I turn caps lock into "xournal-mode activator", and additionally force
> those shortcuts to be active only in xournal"?
>
> Other ideas welcome (however I really do want to use single stroke
> keys, as this is for live lectures, so single stroke just makes it
> smoother for me - I have only left hand at keyboard, and while, say
> Left alt + key would work fine for left-hand side keys, I have too many
> shortcuts, so need to use entire keyboard)
>
> (recompiling xournal isn't really feasible: while changing shortcuts is
> fairly easy, xournal has its own text tool, where, say, the key "1" is
> supposed to be used for entering symbol "1", and I wouldn't know how to
> achieve it)

Would the keybinding chroot functionality help you out here? Ie,
simply nest the keybindings under another keybinding that activates
the xournal mode, then they will be active until you press the keybind
to leave the chroot (probably ctrl-g by default?). The downsides to
this are you will have a little box in the top left reminding you that
you are in chroot mode, and your other keybindings will not be active
(unless you copy them into the chroot).

Some examples:
I use this to disable openbox keybinds which is useful if i need to
alt-tab in vnc or something,
    <keybind key="W-M-C-S-F12" chroot="yes">
      <!-- Nothing -->
    </keybind>

Running various stuff that i don't use that often, to avoid eating up
a lot of normal binds
    <keybind key="W-C-r" chroot="yes">
      <keybind key="p">
        <action name="execute">
          <command>gimp --pdb-compat-mode=on</command>
        </action>
        <action name="breakchroot"/>
      </keybind>
      <keybind key="t">
        <action name="execute">
          <command>urxvt -name htop -e htop</command>
        </action>
        <action name="breakchroot"/>
      </keybind>
      ... etc ...
    </keybind>

The reason I use chroot + breakchroot is just to avoid the timeout
normal keychains have. You would obviously not put the breakchroot
action in your usecase.

More details here: http://openbox.org/wiki/Help:Bindings#Key_chains

-- 
Mikael Magnusson


More information about the openbox mailing list