<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ninja Monkeys! &#187; scripts</title>
	<atom:link href="http://ninjamonkeys.co.za/tag/scripts/feed/" rel="self" type="application/rss+xml" />
	<link>http://ninjamonkeys.co.za</link>
	<description>Killing boredom</description>
	<lastBuildDate>Wed, 18 Aug 2010 07:40:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Script to focus and raise window demanding attention</title>
		<link>http://ninjamonkeys.co.za/2010/02/24/script-to-focus-and-raise-window-demanding-attention/</link>
		<comments>http://ninjamonkeys.co.za/2010/02/24/script-to-focus-and-raise-window-demanding-attention/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 17:17:39 +0000</pubDate>
		<dc:creator>Vaughn Dickson</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[gnome]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[openbox]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[scripts]]></category>

		<guid isPermaLink="false">http://ninjamonkeys.co.za/2010/02/24/script-to-focus-and-raise-window-demanding-attention/</guid>
		<description><![CDATA[I&#8217;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&#8217;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 [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m running Openbox with Gnome on Linux, and windows demanding attention show in<br />
the taskbar with a yellow highlight, usually Skype IMs or something.<br />
I&#8217;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!</p>
<pre>for id in `wmctrl -l | cut -d " " -f 1`; do
    xprop -id $id | grep "_NET_WM_STATE_DEMANDS_ATTENTION" 2&gt;&amp;1 &gt; /dev/null
    if [ "$?" = "0" ]; then
        wmctrl -i -a $id
        exit 0
    fi
done
exit 1
</pre>
<p>Requirements: <a href="http://tripie.sweb.cz/utils/wmctrl/">Wmctrl</a> (sudo apt-get install wmctrl)</p>
<p>Here&#8217;s another adaptation I&#8217;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.</p>
<p>First:</p>
<pre>#!/bin/bash
activeWinIdLine=`xprop -root | grep _NET_ACTIVE_WINDOW\(WINDOW\) `
activeWinId="${activeWinIdLine:40}"
echo $activeWinId &gt; ~/activeWinId
for id in `wmctrl -l | cut -d " " -f 1`; do
	xprop -id $id | grep "_NET_WM_STATE_DEMANDS_ATTENTION" 2&gt;&amp;1 &gt; /dev/null
	if [ "$?" = "0" ]; then
		wmctrl -i -a $id
		exit 0
	fi
done
exit 1
</pre>
<p>Second:</p>
<pre>#!/bin/bash
if [ -f ~/activeWinId ]; then
	origWinId=`cat ~/activeWinId`
	wmctrl -i -a $origWinId
fi
</pre>
]]></content:encoded>
			<wfw:commentRss>http://ninjamonkeys.co.za/2010/02/24/script-to-focus-and-raise-window-demanding-attention/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
