<?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>Libre Things &#187; wmctrl</title>
	<atom:link href="http://positon.org/tag/wmctrl/feed" rel="self" type="application/rss+xml" />
	<link>http://positon.org</link>
	<description></description>
	<lastBuildDate>Tue, 23 Feb 2016 20:01:11 +0000</lastBuildDate>
	<language>en-US</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.7.1</generator>
	<item>
		<title>Clever Alt+Tab alternative: a Run or Raise script</title>
		<link>http://positon.org/clever-alttab-alternative-a-run-or-raise-script</link>
		<comments>http://positon.org/clever-alttab-alternative-a-run-or-raise-script#comments</comments>
		<pubDate>Thu, 15 Aug 2013 22:29:00 +0000</pubDate>
		<dc:creator><![CDATA[dooblem]]></dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[wmctrl]]></category>

		<guid isPermaLink="false">http://positon.org:81/?p=122</guid>
		<description><![CDATA[Thanks to: http://vickychijwani.github.io/2012/04/15/blazing-fast-application-switching-in-linux/ I made a few improvements on the script. If you want something with more features (but also more complex). Use /bin/sh so that it may use dash instead of bash (lighter) Use exec to start the command so that it replaces the current script (otherwise you get unneeded bash processes in ps) [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>Thanks to:<br />
<a href="http://vickychijwani.github.io/2012/04/15/blazing-fast-application-switching-in-linux/" title="http://vickychijwani.github.io/2012/04/15/blazing-fast-application-switching-in-linux/">http://vickychijwani.github.io/2012/04/15/blazing-fast-application-switching-in-linux/</a></p>
<p>I made a few improvements on the script. If you want something with more features (but also more complex).</p>
<ul>
<li>Use /bin/sh so that it may use dash instead of bash (lighter)</li>
<li>Use exec to start the command so that it replaces the current script (otherwise you get unneeded bash processes in ps)</li>
<li>Raise all windows of the same class: useful to raise all terminals for example</li>
<li>&#8220;toggle mode&#8221; : when run a second time, the windows are minimized. For that I had to depend on xdotool, because wmctrl can&#8217;t do that (probably coming in a future wmctrl release. the author commited a -Y flag in github for that).</li>
</ul>
<p>Save it to <code>/home/USER/bin/run-or-raise</code>, then add some keyboard shortcuts in your window manager settings and enjoy!</p>
<pre>
&lt;Super&gt;f /home/USER/bin/run-or-raise Navigator.Firefox firefox
</pre>
<pre>
#!/bin/sh
# syntax: run-or-raise WM_CLASS_name COMMAND
#   WM_CLASS_name : the WM_CALL_name of the window (from wmctrl -lx output)
#   COMMAND : the command to run if nothing to raise

#logfile=/tmp/$(basename $0).log
#exec &gt; $logfile 2&gt;&amp;1

# get windows ids matching WM_CLASS_name
WINIDS=$(wmctrl -lx | awk '{ if ($3 == &quot;'&quot;$1&quot;'&quot;) print $1}')

# run if nothing started. exec will end the script
[ -z &quot;$WINIDS&quot; ] &amp;&amp; exec &quot;$2&quot;

# if the window is active, we minimize all the windows of the class
ACTIVEWIN=$(wmctrl -a :ACTIVE: -v 2&gt;&amp;1 | sed -n 's/^Using window: \(.*\)/\1/p')
MINIMIZE=false
if echo &quot;$WINIDS&quot; | grep -q &quot;$ACTIVEWIN&quot;; then
        MINIMIZE=true
fi

for ID in $WINIDS; do
        if $MINIMIZE; then
                xdotool windowminimize &quot;$ID&quot;
        else
                wmctrl -i -a &quot;$ID&quot;
        fi
done
</pre>
]]></content:encoded>
			<wfw:commentRss>http://positon.org/clever-alttab-alternative-a-run-or-raise-script/feed</wfw:commentRss>
		<slash:comments></slash:comments>
		</item>
	</channel>
</rss>
