Note to Self: Customizing Buttons in CrunchBang / Openbox
I have a plan to write a pretty in-depth post about how happy CrunchBang makes me one of these days weeks, but I want to post the following just so I don’t forget it. I also post in the hopes that it will be useful for random Googlers, but I provide no guarantees.
The Problem
The volume control buttons (Up, Down, Mute) on my Dell Latitude D610 don’t work. Also, I want to add a few more keyboard shortcuts, like having Meta-P launch a terminal with Python already running, and Meta-Q close a window (it’s easier to reach than Alt-F4).
Note: It would be pretty hard to make a grievous error with this, but it’s never a bad idea to back config files up before editing them.
The Volume Solution
Er, Google. Oh, right, I’m posting this so that that isn’t required… For the volume buttons, you need to find out what their names are. To do this, open up a terminal and run xev. Click in the black square of the window that pops up, and then press one of the buttons you need. Then, find it’s name in the terminal output. Like so:
So for this button, the name is XF86AudioRaiseVolume. Remember that and repeat with the other ones. For me, the three names were XF86AudioRaiseVolume, XF86AudioLowerVolume, and XF86AudioMute.
Now, open up your rc.xml file in a text editor. It’s here: ~/.config/openbox/rc.xml .
Locate the section between <keyboard> and </keyboard>, and paste in the following being sure not to splice other tags:
<keybind key="XF86AudioMute"> <action name="Execute"> <execute>amixer sset Master toggle</execute> </action> <action name="Execute"> <execute>amixer sset Headphone toggle</execute> </action> </keybind> <keybind key="XF86AudioRaiseVolume"> <action name="Execute"> <execute>amixer sset Master 5+</execute> </action> <action name="Execute"> <execute>amixer sset Headphone 5+</execute> </action> </keybind> <keybind key="XF86AudioLowerVolume"> <action name="Execute"> <execute>amixer sset Master 5-</execute> </action> <action name="Execute"> <execute>amixer sset Headphone 5-</execute> </action> </keybind>
(Obviously if your buttons have different names, or if you want to accomplish something other than twiddling with the volume, you’ll have to edit as needed.)
The Other Solution
If you’re kind of impatient, you can just look at rc.xml and figure out how to do everything else you want. But here are a few protips:
- Use your head: I wanted to add a new keybinding for launching an application, so I found the section with a whole bunch of other keybindings for launching applications…hard, no? It even had this nifty comment/title at the top:
<!-- Keybindings for running applications -->Also, you probably figured out that C, A, S and W stand for Control, Alt, Shift and Meta (Windows key). And that you can chain them together with hyphens.
- Copy and paste are your friend: Copy an existing entry, change the key value of the <keybind> tag, and change all the unique parts into whatever you want.
So, for my relatively low-key example of adding binding for Python (W-p) and closing the window (W-q), I added:
<keybind key="W-q"> <action name="Close"/> </keybind> <keybind key="W-p"> <action name="Execute"> <startupnotify> <enabled>true</enabled> <name>Python!</name> </startupnotify> <command>terminator --command=python</command> </action> </keybind>
I also changed the bindings for moving windows between workspaces: editing these lines:
<keybind key="S-C-A-Left"> <action name="SendToDesktopLeft"> <dialog>no</dialog> <wrap>no</wrap> </action> </keybind> <keybind key="S-C-A-Right"> <action name="SendToDesktopRight"> <dialog>no</dialog> <wrap>no</wrap> </action> </keybind> <keybind key="S-C-A-Up"> <action name="SendToDesktopUp"> <dialog>no</dialog> <wrap>no</wrap> </action> </keybind> <keybind key="S-C-A-Down"> <action name="SendToDesktopDown"> <dialog>no</dialog> <wrap>no</wrap> </action> </keybind>
Then just save rc.xml, and restart Openbox.
Again, this really isn’t that hard, but I’d rather trust my writing than my memory.



















































