SwitchApp

switch_app is a small tool I wrote in ruby to have shortcuts on my linux-desktop like I'm used to have on butler on Mac OS X. This isn't an attempt to have all the features butler has on Mac OS, but rather an attempt to make me as productive on linux as I am on the Mac.

How does it work?

It basically is an intelligent shortcut utility. If I press a hotkey a program is launched. But this is not all it does (this is pretty usual), if I press that hotkey again at any time, the current instance of that program is being brought to the front on my desktop. This means, switching between applications is just a matter of pressing hotkeys, instead of clicking or alt-tabbing 20 times per program. This saves me a lot of time, and once you know all your hotkeys by heart, you're really quick in switching applications.

Requirements

You need a couple of tools in order to make this work:

  • ruby - switch_app is written in ruby
  • wmctrl - wmctrl is the tool that I (abuse) to tell me window-information of the current desktop
  • xbindkeys - xbindkeys is the hotkey-utility that I use for capturing shortcut-commands and sending those commands to the switch_app.

Configuration

Here's my ~/.xbindkeysrc - I use an apple keyboard, and basically I always press alt + cmd (which is what m:0x8 + m:0x40 means) and a single character I possibly can remember. The tile (~) switches to other instances of the current switched-to program (if you have more than one console window open, for example).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
"switch.rb 'gedit'"    
m:0x8 + m:0x40 + t 
"switch.rb 'firefox-bin'"    
m:0x8 + m:0x40 + w 
"switch.rb empathy"    
m:0x8 + m:0x40 + f 
"switch.rb tomboy"    
m:0x8 + m:0x40 + n 
"switch.rb evolution"    
m:0x8 + m:0x40 + c 
"switch.rb gnome-terminal"    
m:0x8 + m:0x40 + j 
"switch.rb thunderbird-bin"    
m:0x8 + m:0x40 + m 
"switch.rb chromium-browser"    
m:0x8 + m:0x40 + s 
"switch.rb linphone-3"    
m:0x8 + m:0x40 + k 
"switch.rb nx-Terminal"    
m:0x8 + m:0x40 + z 
"switch.rb nautilus"    
m:0x8 + m:0x40 + o 
"switch.rb __NEXT"   
Mod4 + grave 

That is basically it. You will have to put xbindkeys and switch_daemon.rb into your autostart utility (it is important that you are running X already and start switch_daemon.rb afterwards), and if you have any troubles running switch_daemon.rb edit it and set debug to true, it won't fork and put messages to stdout. This program comes licensed in the GPLv3, if you don't have a copy of it, you better get one :) I would love to see improvements in this little tool, I know it's far from perfect, rather hacked together quickly without security in mind (calling system() is never a good Idea, heh?), so if you improve it, let me know, I am willing to host a subversion repository if it takes off :)

Download

Download the switch_app here: switch_app

Letzte Änderung: 20.09.2013