<?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>Do Know Evil - A Blog by Tyler Mulligan &#187; multiple monitors</title> <atom:link href="http://www.doknowevil.net/tag/multiple-monitors/feed/" rel="self" type="application/rss+xml" /><link>http://www.doknowevil.net</link> <description>Tips and Tricks About Computers, Web Development, Linux, the Internet and the Like</description> <lastBuildDate>Sat, 16 Jul 2011 01:25:35 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.0.5</generator> <item><title>Ubuntu Window Management with Multiple Monitors, Window Effects and Default File Associations</title><link>http://www.doknowevil.net/2008/11/25/ubuntu-window-management-with-multiple-monitors-window-effects-and-default-file-associations/</link> <comments>http://www.doknowevil.net/2008/11/25/ubuntu-window-management-with-multiple-monitors-window-effects-and-default-file-associations/#comments</comments> <pubDate>Wed, 26 Nov 2008 02:25:38 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Application Management]]></category> <category><![CDATA[Bash]]></category> <category><![CDATA[Desktop Mods]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[open source]]></category> <category><![CDATA[dual screen]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[multiple monitors]]></category><guid isPermaLink="false">http://www.doknowevil.net/2008/11/25/ubuntu-window-management-with-multiple-monitors-window-effects-and-default-file-associations/</guid> <description><![CDATA[Multiple Monitors Window Management in Ubuntu Moving your applications from one monitor to the next with hotkeys I&#8217;ve been using multiple monitors for a while now, Starting with a 17&#8243; CRT with a 19&#8243; CRT and moving up to two 19&#8243; LCD, then 3, then temporarily one wide screen and back to 2. Something I]]></description> <content:encoded><![CDATA[<h3>Multiple Monitors Window Management in Ubuntu</h3><h4>Moving your applications from one monitor to the next with hotkeys</h4><p>I&#8217;ve been using multiple monitors for a while now, Starting with a 17&#8243; CRT with a 19&#8243; CRT and moving up to two 19&#8243; LCD, then 3, then temporarily one wide screen and back to 2.  Something I always loved having as a utility in <a href="http://www.realtimesoft.com/ultramon/" title="Ultramon - multiple monitors in Windows" target="_blank">ultramon</a> that I couldn&#8217;t find in Ubuntu (Gnome) or any window manager for that matter, was the ability to move applications from monitor to monitor.  I had assumed the search futile until I was searching about some questions I had concerning <a ref="http://compiz-fusion.org/" title="Compiz-fusion - Window Effects in Linux" target="_blank">Compiz-fusion</a> with dual monitors and I came about <a href="http://ubuntuforums.org/showthread.php?t=815925" title="Multiple monitor window handling in Linux">this thread on Ubuntu forums</a> which brightened up my day. A fellow named gfixler posted a bash script that utilizes command line applications to move the windows.</p><p>For you multi-monitor users seeking salvation from removing your hand from the keyboard to move your application from one monitor to another, here&#8217;s the skinny on getting it setup using compiz-fusion, aka Advanced Desktop Effects, to set my keybinds.</p><p>1. Open a terminal and setup your prerequisites with apt-get:</p><pre class="brush:bash">sudo apt-get install wmctrl xprop xwininfo</pre><p>If you get errors about x11-utils, just ignore them, this package will handle your needs.</p><p>2. Next, lets put the script somewhere you can call it, say &#8220;<b>~/scripts</b>&#8221;</p><pre class="brush:bash">mkdir ~/scripts &amp;&amp; cd ~/scripts &amp;&amp; touch movewin.sh &amp;&amp; chmod +x movewin.sh &amp;&amp; gedit movewin.sh</pre><p>2. Paste the following code, find the first function &#8220;<b>getNumberOfMonitors</b>&#8221; and configure it to the number of monitors you have (default 2).</p><div style="height:300px;overflow:auto;padding:2px;"><pre class="brush:bash">
#!/bin/bash
# swap_monitor.sh (original version)
# Moves the active window to the other screen of a dual-screen Xinerama setup.
#
# movewin.sh (modified version)
# allows movement of windows left and right between multiple monitors
#
# Requires: wmctrl, xprop, xwininfo
#
# Original Author: Raphael Wimmer
# raphman@gmx.de
#
# Modified by: Gary Fixler
# gfixler+bash@gmail.com

function getNumberOfMonitors
{
    # simply must be hardcoded
    # e.g. MatroxTripleHead2Go can service 3 screens,
    # but appears as only one monitor to the computer

    # change to your number of monitors
    echo 2
}

function getMonitorWidth
{
    numberOfMonitors=$(getNumberOfMonitors)
    monitorLine=$(xwininfo -root | grep &quot;Width&quot;)
    monitorWidth=$((${monitorLine:8}/$numberOfMonitors ))
    echo $monitorWidth
}

function getActiveWindowID
{
    activeWinLine=$(xprop -root | grep &quot;_NET_ACTIVE_WINDOW(WINDOW)&quot;)
    activeWinID=&quot;${activeWinLine:40}&quot;
    echo $activeWinID
}

function getActiveWindowHorizontalPosition
{
    activeWinID=$(getActiveWindowID)
    xPosLine=$(xwininfo -id $activeWinID | grep &quot;Absolute upper-left X&quot;)
    xPos=${xPosLine:25}
    echo $xPos
}

function getActiveWindowWidth
{
    activeWinID=$(getActiveWindowID)
    xWidthLine=$(xwininfo -id $activeWinID | grep &quot;Width&quot;)
    xWidth=${xWidthLine:8}
    echo $xWidth
}

function getActiveWindowCurrentMonitor
{
    numberOfMonitors=$(getNumberOfMonitors)
    monitorWidth=$(getMonitorWidth)
    activeWinID=$(getActiveWindowID)
    xPos=$(getActiveWindowHorizontalPosition)
    i=&quot;0&quot;
    while [ $xPos -gt $monitorWidth ]
    do
        xPos=$[$xPos-$monitorWidth]
        i=$[$i+1]
    done
    echo $i
}

function getActiveWindowPositionOneMonitorToTheLeft
{
    monitorWidth=$(getMonitorWidth)
    currentMonitor=$(getActiveWindowCurrentMonitor)
    activeWinID=$(getActiveWindowID)
    xPos=$(getActiveWindowHorizontalPosition)
    xPos=$[$xPos-$monitorWidth]
    echo $xPos
}

function getActiveWindowPositionOneMonitorToTheRight
{
    monitorWidth=$(getMonitorWidth)
    numberOfMonitors=$(getNumberOfMonitors)
    currentMonitor=$(getActiveWindowCurrentMonitor)
    activeWinID=$(getActiveWindowID)
    xPos=$(getActiveWindowHorizontalPosition)
    xPos=$[$xPos+$monitorWidth]
    echo $xPos
}

function changeActiveWindowMonitor
{
    activeWinID=$(getActiveWindowID)
    if [ $1 -eq &quot;0&quot; ]
    then
        newXPos=$(getActiveWindowPositionOneMonitorToTheLeft)
        newXPos=$[$newXPos-5]
    else
        newXPos=$(getActiveWindowPositionOneMonitorToTheRight)
        newXPos=$[$newXPos-5]
    fi

    winState=$(xprop -id ${activeWinID} | grep &quot;_NET_WM_STATE(ATOM)&quot; )

    if [[ `echo ${winState} | grep &quot;_NET_WM_STATE_MAXIMIZED_HORZ&quot;` != &quot;&quot; ]]
        then
        maxH=1
        wmctrl -i -r ${activeWinID} -b remove,maximized_horz
    fi

    if [[ `echo ${winState} | grep &quot;_NET_WM_STATE_MAXIMIZED_VERT&quot;` != &quot;&quot; ]]
        then
        maxV=1
        wmctrl -i -r ${activeWinID} -b remove,maximized_vert
    fi

    if [[ `echo ${winState} | grep &quot;_NET_WM_STATE_FULLSCREEN&quot;` != &quot;&quot; ]]
        then
        fulls=1
        wmctrl -i -r ${activeWinID} -b remove,fullscreen
    fi

    # move window (finally)
    wmctrl -i -r ${activeWinID} -e 0,${newXPos},-1,-1,-1

    # restore maximization
    ((${maxV})) &amp;&amp; wmctrl -i -r ${activeWinID} -b add,maximized_vert
    ((${maxH})) &amp;&amp; wmctrl -i -r ${activeWinID} -b add,maximized_horz
    ((${fulls})) &amp;&amp; wmctrl -i -r ${activeWinID} -b add,fullscreen

    # raise window (seems to be necessary sometimes)
    wmctrl -i -a ${activeWinID}

}

function moveActiveWindowOneMonitorToTheLeft
{
    changeActiveWindowMonitor 0
}

function moveActiveWindowOneMonitorToTheRight
{
    changeActiveWindowMonitor 1
}

&quot;$1&quot;

exit 0
</pre></div><p>3. Setup your hot keys with compiz-fusion.  Go to System >> Preferences >> Advanced Desktop Effects.  Inside &#8220;<b>General Options</b>&#8220;, click on the command tab (I apologize for my heinous blue links).</p><p><a href='http://www.doknowevil.net/wp-content/uploads/2008/11/2008-11-25-205445_833x464_scrot.png' title='Compiz-fusion Hotkeys 1'><img src='http://www.doknowevil.net/wp-content/uploads/2008/11/2008-11-25-205445_833x464_scrot.png' alt='Compiz-fusion Hotkeys 1' /></a></p><p><a href='http://www.doknowevil.net/wp-content/uploads/2008/11/2008-11-25-210327_900x435_scrot.png' title='2008-11-25-210327_900x435_scrot.png'><img src='http://www.doknowevil.net/wp-content/uploads/2008/11/2008-11-25-210327_900x435_scrot.png' alt='2008-11-25-210327_900x435_scrot.png' /></a></p><p>Use</p><pre class="brush:bash">scripts/./movewin.sh moveActiveWindowOneMonitorToTheRight</pre><p>and</p><pre class="brush:bash">scripts/./movewin.sh moveActiveWindowOneMonitorToTheLeft</pre><p>respectively</p><h3>Per Application Window Effects in Ubuntu</h3><h4>Bring character and tickle your soul with per application window effects</h4><p>Another cool feature Compiz-fusion has is window animations.  My friend <a href="http://www.realhumanmoments" title="James Lindsay" target="_blank">James Lindsay</a> recently reminded me about Window Effects&#8230; which when I first install Ubuntu on my laptop, I experimented my butt off&#8230; but being a laptop&#8230; I just used simple ones I&#8217;d turn off half the time anyway.  He asked me why I don&#8217;t use them on my desktop and I didn&#8217;t have a good reason.  Well, now I have 2 good reasons to keep using compiz.</p><p><a href='http://www.doknowevil.net/wp-content/uploads/2008/11/2008-11-25-210749_900x591_scrot.png' title='2008-11-25-210749_900x591_scrot.png'><img src='http://www.doknowevil.net/wp-content/uploads/2008/11/2008-11-25-210749_900x591_scrot.png' alt='2008-11-25-210749_900x591_scrot.png' /></a></p><p>I made my Thunderbird use the airplane effect so when I send emails, it flys away and for <a href="http://www.geany.org" title="Geany - My Linux Text Editor of Choice" target="_blank">Geany</a>, I used the magic lamp for open, close, maximize and minimize (different speeds).  It&#8217;s a fun little effect that breaks up the stiffness of the desktop.</p><h3>Default File Associations in Ubuntu</h3><h4>geany > gedit</h4><p>I was tired of gedit popping up when geany&#8217;s just as lightweight but more affective.  So found a command and altered it a bit to make my default editor geany.</p><p>1. Open the terminal and create\open the following file:</p><pre class="brush:bash">gedit ~/.local/share/applications/defaults.list</pre><p>If it&#8217;s blank, add &#8220;<b>[Default Applications]</b>&#8220;.  If it&#8217;s not, find &#8220;<b>[Default Applications]</b>&#8220;.</p><p>2. Then, back to the terminal, grep the default files associations and replace gedit with your editor of choice</p><pre class="brush:bash">grep gedit /usr/share/applications/defaults.list | sed s/gedit/geany/g</pre><p>Copy (ctrl+shift+c) and paste the output into gedit, below the &#8220;<b>[Default Applications]</b>&#8221; header.</p><p>3. Restart nautilus to load the changes (will close all your file managers that are open and blink/freeze your desktop for a second)</p><pre class="brush:bash">pkill nautilus</pre><p>Good luck, have fun and happy coding :)</p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2008/11/25/ubuntu-window-management-with-multiple-monitors-window-effects-and-default-file-associations/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk
Page Caching using disk (enhanced)
Object Caching 384/397 objects using disk

Served from: www.doknowevil.net @ 2012-02-07 08:51:31 -->
