shell script to jump or exec an application under X window manager
jump-or-exec
tries to see if an application is already running, and if so, bring the application's window to the front, otherwise launch an instance.
Bind it to a shortcut key and it will be useful!
jump-or-exec command [window_name]
This script is written in sh
.
You just need to download jump-or-exec.sh
, and put it into your $PATH
,
probably after renaming to jump-or-exec
and chomd a+x
.
This script uses wmctrl, which is a UNIX/Linux command line tool to interact with an EWMH/NetWM compatible X Window Manager.
This script is based on the version in eshock/.bashrc.d, in which window_name
cannot be omitted.
There are also other scripts based on wmctrl, for example, jumpapp and brocket. Both are more complex^w feature rich. And I failed to make them work with some applications. Thus I wrote this script.
Besides wmctrl, it is also possible to implement jump or exec
in Xlib directly.
For example, here is a Python script.
The script runs as a daemon, to avoid possible delays when invoking shell script and wmctrl.
The post is written in Chinese, but don't worry, you can read code in Python and code comments in English.
On my machine, wmctrl
is fast enough.
Thus I consider I don't need a persistent daemon.