Script to focus and raise window demanding attention
I’m running Openbox with Gnome on Linux, and windows demanding attention show in
the taskbar with a yellow highlight, usually Skype IMs or something.
I’ve created the following bash script that I bind to a hotkey win-j, and pressing it changes to the correct desktop, raises the window, and focuses it. Huge time saver!
for id in `wmctrl -l | cut -d " " -f 1`; do
xprop -id $id | grep "_NET_WM_STATE_DEMANDS_ATTENTION" 2>&1 > /dev/null
if [ "$?" = "0" ]; then
wmctrl -i -a $id
exit 0
fi
done
exit 1
Requirements: Wmctrl (sudo apt-get install wmctrl)
Here’s another adaptation I’ve added. Two scripts, one bound to Win-r to jump to the window demanding attention, and another bound to W-Shift-r that jumps back to the window you were busy with.
First:
#!/bin/bash
activeWinIdLine=`xprop -root | grep _NET_ACTIVE_WINDOW\(WINDOW\) `
activeWinId="${activeWinIdLine:40}"
echo $activeWinId > ~/activeWinId
for id in `wmctrl -l | cut -d " " -f 1`; do
xprop -id $id | grep "_NET_WM_STATE_DEMANDS_ATTENTION" 2>&1 > /dev/null
if [ "$?" = "0" ]; then
wmctrl -i -a $id
exit 0
fi
done
exit 1
Second:
#!/bin/bash if [ -f ~/activeWinId ]; then origWinId=`cat ~/activeWinId` wmctrl -i -a $origWinId fi Download these scripts and more from my Github.
2010.02.24