Thursday, November 1, 2012

Window Tagging with Openbox

There's few things I like in this world more than CrunchBang Linux. I'd used Ubuntu, Xubuntu, Lubuntu before, but all of them felt like bloated alternatives to bloated Windows and there was little reason to make the switch. Then, I discovered CrunchBang and within a month had deleted my Windows partition.

My favorite part about CrunchBang is Openbox - a damn fine window manager with a lot of room for customization. One (of the very, very few) drawbacks about Openbox is the lack of window tagging - and I'm not about to switch to a whole new WM like i3 or awesome just for this feature. Thankfully though, it's not impossible to implement it!

Here's how my solution works - press Alt-Super-(1-9) to tag a window to that number, and then press Super-(1-9) to switch to that window. This is all done using xdotool and some text files to store window id's, but since Openbox can't do anything too fancy in its execute command we have to do the work in an external shell script. Anyways, here's the goods.

In your rc.xml file (add as many copies as you want, just make sure to change the numbers):
 <keybind key="A-W-1">  
  <action name="Execute">  
      <command>sh ~/.config/winTag/saveTag 1</command>  
  </action>  
 </keybind>  
 <keybind key="W-1">  
  <action name="Execute">  
      <command>sh ~/.config/winTag/recallTag 1</command>  
  </action>  
 </keybind>  

Then, place the following 2 files in ~/.config/winTag/

saveTag
 #!/bin/sh  
 xdotool getwindowfocus > ~/.config/wintag/save$1  



recallTag
 #!/bin/sh  
 xdotool windowactivate $(cat ~/.config/wintag/save$1)  



Enjoy your new found freedom from Alt-Tab hell!

No comments:

Post a Comment

Post a Comment