<?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; Linux</title> <atom:link href="http://www.doknowevil.net/category/computers/software/operating-systems/linux/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>What Makes ASUS and Android an A+?</title><link>http://www.doknowevil.net/2011/01/20/what-makes-asus-and-android-an-a/</link> <comments>http://www.doknowevil.net/2011/01/20/what-makes-asus-and-android-an-a/#comments</comments> <pubDate>Thu, 20 Jan 2011 02:37:17 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Android]]></category> <category><![CDATA[Application Management]]></category> <category><![CDATA[Computers]]></category> <category><![CDATA[Hardware]]></category> <category><![CDATA[Operating Systems]]></category> <category><![CDATA[Organization]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[ASUS]]></category> <category><![CDATA[eee Pad]]></category> <category><![CDATA[eee Slate]]></category> <category><![CDATA[eee Slider]]></category> <category><![CDATA[eee Transformer]]></category> <category><![CDATA[iPad]]></category> <category><![CDATA[Windows]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=964</guid> <description><![CDATA[ASUS has vision, and the eeepc is no doubt a standard setting line of netbooks. Their latest teaming of Android with their latest tablets, eee Pad transformer and the eee Pad Slider provide both ASUS and users with a lightweight familiar system.  It may also be using the same operating system as their phones, possibly]]></description> <content:encoded><![CDATA[<p>ASUS has vision, and the <a href="http://eeepc.asus.com/" target="_blank">eeepc</a> is no doubt a standard setting line of netbooks.  Their latest teaming of <a href="http://www.android.com/" target="_blank">Android</a> with their latest tablets, <a href="http://www.youtube.com/watch?v=CWicMJgOPlk&amp;t=1ms30" target="_blank">eee Pad transformer</a> and the <a href="http://www.youtube.com/watch?v=CWicMJgOPlk&amp;t=2ms30" target="_blank">eee Pad Slider</a> provide both ASUS and users with a lightweight familiar system.  It may also be using the same operating system as their phones, possibly other devices.</p><p>With <a href="http://www.google.com/chromeos/">ChromeOS</a>, Google is also covering a server-side focused solution to a consumer&#8217;s needs.  We see <a href="http://www.infoworld.com/d/mobilize/webos-and-blackberry-are-running-out-time-what-can-they-do-576" target="_blank">Blackberry <i>trying</i> out a similar solution with WebOS</a>, ASUS however, is focusing on hardware, as usual and doing an impressive job, as usual.</p><p>They don&#8217;t completely shy away from Windows either, with the Eee Slate running the most impressive hardware, it should be interesting to see how Microsoft holds onto their market being a direct competitor of the iPad.</p><p><iframe title="YouTube video player" class="youtube-player" type="text/html" width="853" height="510" src="http://www.youtube.com/embed/CWicMJgOPlk" frameborder="0" allowFullScreen></iframe></p><p><iframe title="YouTube video player" class="youtube-player" type="text/html" width="853" height="510" src="http://www.youtube.com/embed/4Zg6AvI2tBE" frameborder="0" allowFullScreen></iframe></p><p>ASUS doesn&#8217;t forget it&#8217;s stake in the software portion of this emerging market, no. They&#8217;ve invested in a &#8220;cloud&#8221; for consumers information to be separate from their phones and separate from their carrier.  Their information is stored and accessible via their device(s) as an app or <a href="http://access.asus.com" target="_blank">access.asus.com</a>.  Now all they need to do is invest in a short domain name, <b>ax.as.us</b>.</p><p><iframe title="YouTube video player" class="youtube-player" type="text/html" width="853" height="510" src="http://www.youtube.com/embed/OwEnkatnQ-U" frameborder="0" allowFullScreen></iframe></p><p>Other Points, these are cool:</p><p><iframe title="YouTube video player" class="youtube-player" type="text/html" width="853" height="510" src="http://www.youtube.com/embed/YiyOs86WiBw" frameborder="0" allowFullScreen></iframe></p><p><iframe title="YouTube video player" class="youtube-player" type="text/html" width="640" height="510" src="http://www.youtube.com/embed/8Xp9fV8DJYs" frameborder="0" allowFullScreen></iframe></p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2011/01/20/what-makes-asus-and-android-an-a/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Tips for Using Bash in the Linux Terminal &#8211; Part 1</title><link>http://www.doknowevil.net/2010/10/23/tips-for-using-bash-in-the-linux-terminal-part-1/</link> <comments>http://www.doknowevil.net/2010/10/23/tips-for-using-bash-in-the-linux-terminal-part-1/#comments</comments> <pubDate>Sat, 23 Oct 2010 10:13:05 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Bash]]></category> <category><![CDATA[Computers]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[OSX]]></category> <category><![CDATA[Operating Systems]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[cli]]></category> <category><![CDATA[shortcuts]]></category> <category><![CDATA[terminal]]></category> <category><![CDATA[tips]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=687</guid> <description><![CDATA[Introduction Bash is the default shell in the terminal on many Linux and UNIX based operating system, such as Ubuntu or Mac OS X. I&#8217;ve mentioned commandlinefu.com before as a great reference for learning some neat tricks with the terminal. I&#8217;ve gained a lot from the site and a few others, such as the Advanced]]></description> <content:encoded><![CDATA[<h2>Introduction</h2><p>Bash is the default shell in the terminal on many Linux and UNIX based operating system, such as Ubuntu or Mac OS X.  I&#8217;ve mentioned <a href="http://www.commandlinefu.com" title="learn to be a terminal master">commandlinefu.com</a> before as a great reference for learning some neat tricks with the terminal.  I&#8217;ve gained a lot from the site and a few others, such as the <a href="http://tldp.org/LDP/abs/html/" target="_blank">Advanced Bash Scripting Guide</a> and <a href="http://wiki.bash-hackers.org" target="_blank">the bash hackers wiki</a>.  I wanted to share some of the tips I use most often, combined with other information that I&#8217;ve compiled through my use of the terminal.</p><p>I think I should mention that I&#8217;ve been using more applications in the terminal recently.  Some people view this as backwards but I argue just the opposite.  Limiting the amount of times I need to use the mouse and the number of keystrokes I need to make drastically increases my efficiency.  Many bash applications are designed around single keystrokes, layered hotkeys and edit &#8220;modes&#8221;.  GUIs have their place but many of my tasks can be completely more accurately and consistently via the terminal.</p><p>With that said, lets dive in.</p><h2>The Basics</h2><h3>Hotkeys</h3><p>Moving:<br /> <b>Ctrl + a</b> -> Go to the beginning of the line you are currently typing on.<br /> <b>Ctrl + e</b> -> Go to the end of the line you are currently typing on<br /> <b>Alt + f</b> -> Move cursor forward one word on the current line.<br /> <b>Alt + b</b> -> Move cursor backward one word on the current line.</p><p>Editing:<br /> <b>Ctrl + u</b> -> Clears from before the cursor position. If you are at the end of the line, clears the entire line.<br /> <b>Ctrl + k</b> -> Clear from after the cursor. If you are at the beginning of the line, clears the entire line.<br /> <b>Ctrl + w</b> -> Delete the word before the cursor.<br /> <b>Ctrl + h</b> -> Same as backspace.<br /> <b>Ctrl + t</b> -> Swap the last two characters before the cursor.<br /> <b>Esc + t</b> -> Swap the last two words before the cursor.</p><p>Other:<br /> <b>Ctrl + l</b> -> Clear screen (same as clear command).<br /> <b>Ctrl + c</b> -> Kill the current command or process.<br /> <b>Ctrl + z</b> -> Puts whatever you are running into a suspended background process, fg to restore it.<br /> <b>Ctrl + d</b> -> Exit the current shell.</p><p>Oddly, unlike many terminal applications, Bash hotkeys don&#8217;t make a lot of sense to me.  There are very few that are &#8220;intuitive&#8221;.</p><h3>History</h3><p>Press the <b>up arrow for the last command</b> or:</p><p><b>!!</b> &#8212; repeat last command</p><pre class="brush:bash">echo &quot;hello&quot;
!!
</pre><p>Outputs:</p><pre class="brush:bash">z@zentury:~$ echo &quot;hello&quot;
hello
z@zentury:~$ !!
echo &quot;hello&quot;
hello</pre><p><b>ctrl+r</b> is one of the best ways to search through your history.  it will initialize a reverse search as you type.  To go to the next result, press ctrl+r again</p><h2>Advanced</h2><h3>History Expansion/Modification</h3><p>!:0 &#8212; will repeat the first token</p><pre class="brush:bash">cd ~
ls -la
!:0
</pre><p>!:1-3 &#8212; defining a range: 1-3 will repeat the 2nd to 4th tokens (count starts at 0).  It&#8217;s important to note that double quotes will group tokens together.</p><pre class="brush:bash">echo &quot;hello there&quot; &amp;&amp; ls ~
!:3-4</pre><p>!!:s/find/replace/ &#8212; will allow you to replace a part of the command</p><pre class="brush:bash">echo &quot;hello there&quot;
!!:s/hello/hi/</pre><p>Outputs:</p><pre class="brush:bash">z@zentury:~$ echo &quot;hello there&quot;
hello there
z@zentury:~$ !!:s/hello/hi/
echo &quot;hi there&quot;
hi there
</pre><p><i>OR even shorter:</i></p><p>^find^replace</p><pre class="brush:bash">echo &quot;hello there&quot;
^hello^hi</pre><p>Outputs:</p><pre class="brush:bash">z@zentury:~$ echo &quot;hello there&quot;
hello there
z@zentury:~$ ^hello^hi
echo &quot;hi there&quot;
hi there
</pre><h3>Sequences and Pattern Expansion</h3><p>Typically in a Linux or UNIX environment you have access to a command line tool name &#8220;seq&#8221; which <a href="http://www.doknowevil.net/2009/08/15/generating-sequences-of-numbers-or-characters-with-bash/" target="_blank">gone over before</a>.  However, it&#8217;s good to know that bash has built-in sequence expansion and you don&#8217;t need to rely on seq.</p><pre class="brush:bash">echo {a..z}
a b c d e f g h i j k l m n o p q r s t u v w x y z</pre><p>by defining a start and end character with the &#8216;..&#8217; in between, we tell bash to fill in the rest and echo a list for us.  Those are all lowercase, what if you wanted uppercase? simple:</p><pre class="brush:bash">echo {A..Z}
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z</pre><p>Or both, with a few extra characters in the mix:</p><pre class="brush:bash">echo {A..z}
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [  ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z</pre><p>It doesn&#8217;t always have to be a-z though,</p><pre class="brush:bash">echo {A..G}
A B C D E F G</pre><p>This also works with numbers:</p><pre class="brush:bash">echo {0..9}
0 1 2 3 4 5 6 7 8 9
echo {0..100}
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100</pre><p>Descending as well as ascending</p><pre class="brush:bash">echo {9..0}
9 8 7 6 5 4 3 2 1 0</pre><p>Echo a specific set</p><pre class="brush:bash">echo {1,4,6,9}
1 4 6 9</pre><p>Applying it</p><h4>Quickly backup a file</h4><pre class="brush:bash">touch file1.txt
cp file1.txt{,.bak}
ls
file1.txt file1.txt.bak</pre><p>explanation: the first parameter is empty, the second is .bak, this expands to >> cp file1.txt file1.txt.bak << and creates the copy</p><h4>Convert an image type</h4><p>If you have image magick installed, you can convert file types pretty easy using this same concept:</p><pre class="brush:bash">sudo apt-get install imagemagick</pre><p>(To install on Ubuntu)</p><pre class="brush:bash">convert file.{jpg,png}</pre><h4>Permutations</h4><pre class="brush:bash">echo {a..c}{a..c}{a..c}
aaa aab aac aba abb abc aca acb acc baa bab bac bba bbb bbc bca bcb bcc caa cab cac cba cbb cbc cca ccb ccc</pre><h2>Stay tuned for Part 2</h2><p>These are some pretty common techniques I use to reduce the amount of typing and thinking required to complete a task in the terminal.  Stay tuned for part 2 and <a href="http://www.commandlinefu.com/commands/by/zed" target="_blank">check out some of my creative usages at commandlinefu.com</a>.<br /> -</p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2010/10/23/tips-for-using-bash-in-the-linux-terminal-part-1/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Customizing Colors for Your .bashrc</title><link>http://www.doknowevil.net/2010/10/21/customizing-colors-for-your-bashrc/</link> <comments>http://www.doknowevil.net/2010/10/21/customizing-colors-for-your-bashrc/#comments</comments> <pubDate>Thu, 21 Oct 2010 08:20:35 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Application Management]]></category> <category><![CDATA[Bash]]></category> <category><![CDATA[Command Line]]></category> <category><![CDATA[Computers]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[OSX]]></category> <category><![CDATA[Operating Systems]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[open source]]></category> <category><![CDATA[colors]]></category> <category><![CDATA[customization]]></category> <category><![CDATA[ps1]]></category> <category><![CDATA[Ubuntu]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=830</guid> <description><![CDATA[I&#8217;m working on organizing my dotfiles and part of that process has led me to clean up the way I address colors. I came across a few good sources, for .bashrc colors and decided it&#8217;d be better to create my own. I would like to have used the ones I found on the Arch wiki]]></description> <content:encoded><![CDATA[<p>I&#8217;m working on organizing my <a title="dot files for linux and unix bashrc, bash_aliases and application configuration files" href="http://github.com/z/dotfiles" target="_blank">dotfiles</a> and part of that process has led me to clean up the way I address colors.  I came across a <a title="for bashrc colors" href="http://tldp.org/LDP/abs/html/sample-bashrc.html" target="_blank">few good sources</a>, <a title="few good sources" href="http://wiki.archlinux.org/index.php/Color_Bash_Prompt" target="_blank">for .bashrc colors</a> and decided it&#8217;d be better to create my own.  I would like to have used the ones I found on the Arch wiki but the aliases were a bit odd to me.  They also break consistency as you scroll down.  I&#8217;m not sure if this is due to it being a collaborative wiki or it&#8217;s a way to teach multiple syntaxes/approaches.  In either case I figured the aliases weren&#8217;t as &#8220;standard&#8221; as I thought they might be in that world.</p><p>So I decided to copy them the best of the bunch into geany and modify them with regular expressions.  I used column selection to speed up some of the tasks, such as Title Case formatting and typing the prefixes.</p><pre class="brush:bash"># define colors
Black=&#039;\e[0;30m&#039;    # Black / Regular
Red=&#039;\e[0;31m&#039;      # Red
Green=&#039;\e[0;32m&#039;    # Green
Yellow=&#039;\e[0;33m&#039;   # Yellow
Blue=&#039;\e[0;34m&#039;     # Blue
Purple=&#039;\e[0;35m&#039;   # Purple
Cyan=&#039;\e[0;36m&#039;     # Cyan
White=&#039;\e[0;37m&#039;    # White

BBlack=&#039;\e[1;30m&#039;   # BBlack / Bold
BRed=&#039;\e[1;31m&#039;     # BRed
BGreen=&#039;\e[1;32m&#039;   # BGreen
BYellow=&#039;\e[1;33m&#039;  # BYellow
BBlue=&#039;\e[1;34m&#039;    # BBlue
BPurple=&#039;\e[1;35m&#039;  # BPurple
BCyan=&#039;\e[1;36m&#039;    # BCyan
BWhite=&#039;\e[1;37m&#039;   # BWhite

UBlack=&#039;\e[4;30m&#039;   # UBlack / Underline
URed=&#039;\e[4;31m&#039;     # URed
UGreen=&#039;\e[4;32m&#039;   # UGreen
UYellow=&#039;\e[4;33m&#039;  # UYellow
UBlue=&#039;\e[4;34m&#039;    # UBlue
UPurple=&#039;\e[4;35m&#039;  # UPurple
UCyan=&#039;\e[4;36m&#039;    # UCyan
UWhite=&#039;\e[4;37m&#039;   # UWhite

BGBlack=&#039;\e[40m&#039;    # BGBlack - background
BGRed=&#039;\e[41m&#039;      # BGRed
BGGeeen=&#039;\e[42m&#039;    # BGGreen
BGYellow=&#039;\e[43m&#039;   # BGYellow
BGBlue=&#039;\e[44m&#039;     # BGBlue
BGPurple=&#039;\e[45m&#039;   # BGPurple
BGCyan=&#039;\e[46m&#039;     # BGCyan
BGWhite=&#039;\e[47m&#039;    # BGWhite

NC=&#039;\e[0m&#039;          # Text Reset / No Color</pre><p>Here is a test case:</p><pre class="brush:bash">for c in {,B,U,BG}{Black,Red,Green,Yellow,Blue,Purple,Cyan,White}; do echo -e ${!c}$c${NC}; done; echo -e &quot;${NC}&quot;</pre><p>Here is the same test case without the aliases</p><pre class="brush:bash">for c in {0,1,4}\;{30..37} {40..47}; do echo -e \\e[${!c}${c}m${c}m\\e[0m; done;</pre><p>Here's a PS1 you can try it with</p><pre class="brush:bash">PS1=&quot;${debian_chroot:+($debian_chroot)}\[${BWhite}\]\u\[${NC}\]\[${Yellow}\]@\[${White}\]\h\[${NC}\]:\[${BBlue}\]\w\[${NC}\]$ &quot;</pre><p>I plan to use these quite often as I build out my .bash_aliases but the most immediate use you might find useful is the PS1 generation tool I&#8217;ve setup an alpha of <a href="http://interwebninja.com/ps1-o-matic">http://interwebninja.com/ps1-o-matic/</a></p><p><a href='http://www.doknowevil.net/wp-content/uploads/2010/10/ps1-o-matic-0.5.ogv'>ps1-o-matic-0.5 video in action</a></p><p><img src="http://www.doknowevil.net/wp-content/uploads/2010/10/screenshot383-300x29.png" alt="" title="screenshot383" width="300" height="29" class="alignnone size-medium wp-image-842" /><br /> <img src="http://www.doknowevil.net/wp-content/uploads/2010/10/screenshot384-300x30.png" alt="" title="screenshot384" width="300" height="30" class="alignnone size-medium wp-image-841" /><br /> <img src="http://www.doknowevil.net/wp-content/uploads/2010/10/screenshot386-300x28.png" alt="" title="screenshot386" width="300" height="28" class="alignnone size-medium wp-image-839" /><br /> <img src="http://www.doknowevil.net/wp-content/uploads/2010/10/screenshot387-300x41.png" alt="" title="screenshot387" width="300" height="41" class="alignnone size-medium wp-image-838" /></p><p>Below is a screenshot of how I&#8217;m revising the script to use only javascript objects rather than relying on html inputs to store values:<br /> <a href="http://www.doknowevil.net/wp-content/uploads/2010/10/screenshot394.png"><img src="http://www.doknowevil.net/wp-content/uploads/2010/10/screenshot394-1024x581.png" alt="" title="screenshot394" width="1024" height="581" class="alignnone size-large wp-image-866" /></a></p><p>I&#8217;m currently at the point where I&#8217;m using jquery ui&#8217;s draggable and sortable to allow segments to be moved around but I have nothing worth sharing yet.  Stay tuned, I&#8217;ll be checking the source into <a href="http://github.com/z" target="_blank">my github account</a> soon.</p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2010/10/21/customizing-colors-for-your-bashrc/feed/</wfw:commentRss> <slash:comments>0</slash:comments> <enclosure url="http://www.doknowevil.net/wp-content/uploads/2010/10/ps1-o-matic-0.5.ogv" length="4806169" type="video/ogg" /> </item> <item><title>Sorry screen, tmux is better (but here are some screen-like hotkeys)</title><link>http://www.doknowevil.net/2010/10/18/sorry-screen-tmux-is-better-but-here-are-some-screen-lik-hotkeys/</link> <comments>http://www.doknowevil.net/2010/10/18/sorry-screen-tmux-is-better-but-here-are-some-screen-lik-hotkeys/#comments</comments> <pubDate>Mon, 18 Oct 2010 22:30:13 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Computers]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Operating Systems]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[open source]]></category> <category><![CDATA[screen]]></category> <category><![CDATA[tmux]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=705</guid> <description><![CDATA[Introduction If you&#8217;re familiar with the command line on Linux or UNIX, you&#8217;ve likely heard of a program called &#8220;screen&#8221;, which allows you to create virtual terminal sessions inside of your current terminal. The major benefit to this is the ability to dettach and reattach screen sessions, leaving your programs to act as if you]]></description> <content:encoded><![CDATA[<h2>Introduction</h2><p>If you&#8217;re familiar with the command line on Linux or UNIX, you&#8217;ve likely heard of a program called <a href="http://www.doknowevil.net/2010/10/18/using-terminal-program-screen-on-linux-unix/" title="screen for UNIX / Linux">&#8220;screen&#8221;, which allows you to create virtual terminal sessions inside of your current terminal</a>.  The major benefit to this is the ability to dettach and reattach screen sessions, leaving your programs to act as if you never left.  Additionally, you can have multiple buffers inside your screen that act like tabs, allowing you to flip between.</p><p>The major difference between screen and tmux is their ability to split and manage splits. Oh yeah, that and hotkeys.  I think they were trying to pay legacy (or force you to change back :-P) by setting up your main key to be &#8220;b&#8221; instead of &#8220;a&#8221;, which is an awkward reach.  Tux Wears Fedora below shares more screen like hotkeys, as do I with some minor tweaks that I combined with the default example in ubuntu /usr/share.</p><p>I became well acquainted at <a href="http://blog.yjl.im/2009/11/migrating-to-tmux-from-gnuscreen.html" target="_blank">Tux Wears Fedora&#8217;s post on tmux migrating from screen</a>.</p><p><a href="http://www.doknowevil.net/wp-content/uploads/2010/06/screenshot109.png"><img src="http://www.doknowevil.net/wp-content/uploads/2010/06/screenshot109-500x312.png" alt="" title="tmux in action" width="500" height="312" class="alignnone size-thumbnail wp-image-712" /></a></p><pre class="brush:bash">
# ~/.tmux.conf
# By Tyler Mulligan. Public domain.
#
# This configuration file binds many of the common GNU screen key bindings to
# appropriate tmux key bindings. Note that for some key bindings there is no
# tmux analogue and also that this set omits binding some commands available in
# tmux but not in screen.
#
# Note this is a good starting point but you should check out the man page for more
# configuration options if you really want to get more out of tmux

### Unbind existing tmux key bindings (except 0-9).

# Set the prefix to ^A.
unbind C-b
set -g prefix ^A
bind a send-prefix

# Bind appropriate commands similar to screen.
# lockscreen ^X x
unbind ^X
bind ^X lock-server
unbind x
bind x lock-server

# screen ^C c
unbind ^C
bind ^C new-window
bind c
bind c new-window

# detach ^D d
unbind ^D
bind ^D detach

# displays *
unbind *
bind * list-clients

# next ^@ ^N sp n
unbind ^@
bind ^@ next-window
unbind ^N
bind ^N next-window
unbind &quot; &quot;
bind &quot; &quot; next-window
unbind n
bind n next-window

# title A
unbind A
bind A command-prompt &quot;rename-window %%&quot;

# other ^A
unbind ^A
bind ^A last-window

# prev ^H ^P p ^?
unbind ^H
bind ^H previous-window
unbind ^P
bind ^P previous-window
unbind p
bind p previous-window
unbind BSpace
bind BSpace previous-window

# windows ^W w
unbind ^W
bind ^W list-windows
unbind w
bind w list-windows

# quit \
unbind \
bind \ confirm-before &quot;kill-server&quot;

# kill K k
unbind K
bind K confirm-before &quot;kill-window&quot;
unbind k
bind k confirm-before &quot;kill-window&quot;

# redisplay ^L l
unbind ^L
bind ^L refresh-client
unbind l
bind l refresh-client

# More straight forward key bindings for splitting
unbind %
bind | split-window -h
bind v split-window -h
unbind &#039;&quot;&#039;
bind - split-window -v
bind h split-window -v

# History
set -g history-limit 1000

# Pane
unbind o
bind C-s down-pane

# Terminal emulator window title
set -g set-titles on
set -g set-titles-string &#039;#S:#I.#P #W&#039;

# Status Bar
set -g status-bg black
set -g status-fg white
set -g status-interval 1
set -g status-left &#039;#[fg=green]#H#[default]&#039;
set -g status-right &#039;#[fg=yellow]#(cut -d &quot; &quot; -f 1-4 /proc/loadavg)#[default] #[fg=cyan,bold]%Y-%m-%d %H:%M:%S#[default]&#039;

# Notifying if other windows has activities
setw -g monitor-activity on
set -g visual-activity on

# Highlighting the active window in status bar
setw -g window-status-current-bg red

# Clock
setw -g clock-mode-colour green
setw -g clock-mode-style 24

# :kB: focus up
unbind Tab
bind Tab down-pane
unbind BTab
bind BTab up-pane

# &quot; windowlist -b
unbind &#039;&quot;&#039;
bind &#039;&quot;&#039; choose-window
</pre><p>Splitting is what initially caused me to migrate but there are plenty of other features that have lead me to stay. <a href="http://blog.hawkhost.com/2010/06/28/tmux-the-terminal-multiplexer/" target="_blank">this article outlines the benefits in detail</a>.  Once you go tmux, you never go back.</p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2010/10/18/sorry-screen-tmux-is-better-but-here-are-some-screen-lik-hotkeys/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>Using Terminal Program &quot;screen&quot; on Linux / UNIX</title><link>http://www.doknowevil.net/2010/10/18/using-terminal-program-screen-on-linux-unix/</link> <comments>http://www.doknowevil.net/2010/10/18/using-terminal-program-screen-on-linux-unix/#comments</comments> <pubDate>Mon, 18 Oct 2010 22:30:06 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Command Line]]></category> <category><![CDATA[Computers]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Operating Systems]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[open source]]></category> <category><![CDATA[screen]]></category> <category><![CDATA[tmux]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=706</guid> <description><![CDATA[Introduction The terminal program &#8220;screen&#8221; for Linux / UNIX, is a command line tool that allows you to emulate terminals inside a currently running session and detach the &#8216;screen&#8217; to the background. This program may seem obscure to new users because of it&#8217;s abstract nature and unusual key bindings but once you start learning the]]></description> <content:encoded><![CDATA[<h2>Introduction</h2><p>The terminal program &#8220;screen&#8221; for Linux / UNIX, is a command line tool that allows you to emulate terminals inside a currently running session and detach the &#8216;screen&#8217; to the background.  This program may seem obscure to new users because of it&#8217;s abstract nature and unusual key bindings but once you start learning the basics, the advanced usages don&#8217;t seem that scary.</p><p><b>If you consider yourself to have an advanced sense of the command line</b> and you&#8217;d like to go more advanced out of gate, <b>you should consider skipping ahead to <a href="http://www.doknowevil.net/2010/10/18/sorry-screen-tmux-is-better-but-here-are-some-screen-lik-hotkeys/">my article on the screen successor, tmux which allows for more advanced splitting</a> (and apparently better code).</b></p><h2>Getting Started</h2><p>Below is a walk through of an average screen scenario I&#8217;ve put together to give you an idea of how you might use this program in your workflow.</p><p>to start a basic screen session type:</p><pre class="brush:bash">
screen
</pre><p>this will put you in a virtual session.</p><p>to detach the screen press: ctrl+a, d</p><p>to reattach the screen type:</p><pre class="brush:bash">
screen -r
</pre><p>detach again, then type:</p><pre class="brush:bash">
screen
</pre><p>and detach this. You now have 2 screen sessions open, so when you type screen -r, instead of reattaching, it will list the possible screens to attach. You&#8217;ll see something like the following:</p><pre class="brush:bash">
There are several suitable screens on:
    31454.pts-2.quadjutsu    (10/10/2009 09:45:51 AM)    (Detached)
    31219.pts-2.quadjutsu    (10/10/2009 09:44:27 AM)    (Detached)
Type &quot;screen [-d] -r [pid.]tty.host&quot; to resume one of them.
</pre><p>So I&#8217;d type:</p><pre class="brush:bash">
screen -r 31454
</pre><p>to attach the first one. On systems with &#8216;pkill&#8217; you can type:</p><pre class="brush:bash">
pkill screen
</pre><p>to kill all the screen sesions.</p><p>That&#8217;s one way to separate screens&#8230; another is virtual &#8220;tabs&#8221; within a screen session.</p><p>so lets create a new screen session with:</p><pre class="brush:bash">
screen
</pre><p>Then type:</p><pre class="brush:bash">
ls
</pre><p>so you have some data to reference for which &#8220;tab&#8221; you&#8217;re in</p><p>Then hit: ctrl+a, c</p><p>This will create a new tab.</p><p>to cycle forward through the tabs (next), hit: ctrl+a, n or ctrl+a, [spacebar]<br /> to cycle backwards through the tabs (previous), hit: ctrl+a, p or ctrl+a, [backspace]</p><p>to kill a tab, type: exit</p><p>I found a <a href="http://www.pixelbeat.org/lkdb/screen.html" title="terminal screen program unix linux">good reference for &#8220;screen&#8221; hotkeys at pixelbeat.org</a> if you&#8217;d like to learn more.</p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2010/10/18/using-terminal-program-screen-on-linux-unix/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Multiple X (Desktop) Sessions in Ubuntu</title><link>http://www.doknowevil.net/2010/10/13/multiple-x-desktop-sessions-in-ubuntu/</link> <comments>http://www.doknowevil.net/2010/10/13/multiple-x-desktop-sessions-in-ubuntu/#comments</comments> <pubDate>Wed, 13 Oct 2010 23:48:23 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Application Management]]></category> <category><![CDATA[Computers]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[X]]></category> <category><![CDATA[outside the box]]></category> <category><![CDATA[x11]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=813</guid> <description><![CDATA[This post has a lot to do with graphics but there are no graphics. It&#8217;s a walk-through explanation and and proof of concept of some very interesting features of Linux as a desktop operating system. If you aren&#8217;t familiar with X, than this webpage might confuse you, the X Window System is what draws the]]></description> <content:encoded><![CDATA[<p>This post has a lot to do with graphics but there are no graphics.  It&#8217;s a walk-through explanation and and proof of concept of some very interesting features of Linux as a desktop operating system.</p><p>If you aren&#8217;t familiar with X, <a href="http://www.x.org" target="_blank" title="X.org">than this webpage might confuse you</a>, the <a href="http://en.wikipedia.org/wiki/X_Window_System" title="X11 Window System" target="_blank">X Window System</a> is what draws the GUI (graphical user interface) for Ubuntu.  On top of this, you may have a <a href="http://xwinman.org/" target="_blank">Window Manager or Desktop Environment</a>, such as Gnome (Ubuntu default) or KDE (Kubuntu).</p><p>When you boot up Ubuntu, it creates a set of &#8220;virtual terminals&#8221;.  These VTs are accessible via a key combination of clt+alt+f1-12.  VT7 (ctrl+alt+f7) is the default and it handles X&#8217;s &#8220;screen 0&#8243;. If you play around, with the key combination, you&#8217;ll notice you drop into consoles with a login prompt (f1-6) or a blank screen (f8-f12, <a href="https://bugs.launchpad.net/ubuntu/+source/linux/+bug/256767" target="_blank">don&#8217;t worry if you see USB errors</a>).</p><p>These virtual terminals used to be handled by X which was slower and more prone to crash (citation needed) but since Ubuntu 8.04, this has been handled by &#8220;<a href="https://wiki.ubuntu.com/X/KernelModeSetting" target="_blank">Kernel Mode&#8221;</a>, where this management is handled by the kernel.  You can switch to another virtual terminal and create another X session.</p><p>Typically in Linux, you could switch to another VT, login [as another user] and type $ <b>startx &#8212; :1</b> (special argument &#8216;<code>--</code>&#8216; marks the end of client arguments and the beginning of server options, :1 defines screen 1).  This will work in Ubuntu but the part where I found it failing was switching between this newly created X session and back to my original :0 on VT7.</p><p>The way I found to do this in Ubuntu seems a bit counter-intuitive.  Before I explain, you should create a new user, if you don&#8217;t have another already.  You can do this by going to System > Administration > Users and Groups.</p><p>To create a second X session in Ubuntu, go to your logout menu (default top right) and select &#8220;switch user&#8221;, and login as another user (you don&#8217;t want to create an error in the user environment).  When you login as another user, Ubuntu creates a screen :1 on VT8.  This means, you can change back to VT7 with ctrl+alt+f7, then back to VT8 with ctrl+alt+f8.  I <i>suspect</i> this is the reason VT8-12 show up as blank screens instead of login terminals.  Ubuntu seems to be leveraging the power of virtual terminals for &#8220;user switches&#8221;.</p><p>I haven&#8217;t noticed much in performance loss doing this and the other big question is practicality.  Why would you ever do this?  Perhaps you are testing software and want isolated test cases or you want a dedicated user for games with a more streamlined window manager and want to be able to flip back and forth.</p><p>Similar areas I came across in my research were <a href="http://en.wikipedia.org/wiki/Xnest" target="_blank">Nested X sessions</a> and <a href="http://en.wikipedia.org/wiki/Multiseat_configuration" target="_blank">Multiseat X</a>.</p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2010/10/13/multiple-x-desktop-sessions-in-ubuntu/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Random gnome-terminal profiles (themes) in Ubuntu</title><link>http://www.doknowevil.net/2010/09/30/random-gnome-terminal-profiles-themes-in-ubuntu/</link> <comments>http://www.doknowevil.net/2010/09/30/random-gnome-terminal-profiles-themes-in-ubuntu/#comments</comments> <pubDate>Thu, 30 Sep 2010 23:20:02 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Application Management]]></category> <category><![CDATA[Bash]]></category> <category><![CDATA[Command Line]]></category> <category><![CDATA[Computers]]></category> <category><![CDATA[GNOME]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Operating Systems]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[Window Management]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=794</guid> <description><![CDATA[Introduction Does it ever confuse you if you have too many terminals open at once that look alike? Perhaps you&#8217;re just looking to express your personality or tickle your brain. In any case, if you&#8217;re using the terminal in ubuntu a lot, you may be interested in having random profiles (colors / settings). The concept]]></description> <content:encoded><![CDATA[<h2>Introduction</h2><p>Does it ever confuse you if you have too many terminals open at once that look alike?  Perhaps you&#8217;re just looking to express your personality or tickle your brain.  In any case, if you&#8217;re using the terminal in ubuntu a lot, you may be interested in having random profiles (colors / settings).</p><p>The concept of the method is pretty simple, define a hotkey that launches a script that picks a random profile you&#8217;ve created and then open the terminal with that profile as a parameter.</p><h2>Prerequisites</h2><p>- Compiz or other hotkey script that will allow you to link to a .sh file<br /> - gnome-terminal<br /> - bash</p><h2>Getting Started</h2><p>You can figure out what Profiles you have by going to <strong>Edit > Profiles</strong> in gnome-terminal.  You likely only have one, &#8220;Default&#8221;, unless you&#8217;re already actively using terminal profiles.  If you only have one, you should create a few, maybe 3 or 4 right now and play with the colors a bit. <strong>Important, don&#8217;t include spaces in the names of the profiles</strong></p><h2>The Script</h2><p>Create a file in your scripts folder (or create a directory if you don&#8217;t have one):</p><pre class="brush:bash">
mkdir ~/scripts
touch ~/scripts/gnome-terminal.sh &amp;&amp; chmod +x ~/scripts/gnome-terminal.sh
gedit ~/scripts/gnome-terminal.sh
</pre><p>Paste the following replacing the Profile names with those of your own (delimited by spaces) and change the number 4 to that of the :</p><pre class="brush:bash">
#!/bin/bash
p=( Default Delta Psi Sigma )
gnome-terminal --window-with-profile ${p[$((RANDOM%${#p[@]}))]}
</pre><p>That ugly looking bit right here is a calculation between a random number (<strong>echo RANDOM</strong>) and the size of the array (<strong>${#p[@]}</strong>), &#8220;random&#8221; % &#8220;length of array&#8221;.  Where % means mod, or remainder of the division. (examples: 7%4 = 3; 6%4 = 2; 5%4 = 1; 4 % 4 = 0; 4 % 3 = 1; 321%321= 0).</p><p>To illustrate more, play with this code:</p><pre class="brush:bash">r=$RANDOM; echo $r; echo $((r % 4))</pre><p>This is how we get a random index value for the array. This value is nested inside the array ${p[r]}, where r is the random, within bounds, array index.  That array then corresponds with a name of our profile and we pass it as a paramater to gnome-terminal with &#8220;&#8211;window-with-profile&#8221;.  So using my define array above, if the random index were &#8220;1&#8243;, &#8220;Delta&#8221; would be echoed.  If the index were &#8220;0&#8243;, Default would be.</p><h2>The Setup</h2><p>Now, I use compiz with the commands plugin, setting my &#8220;command line 0&#8243; to <strong>~/scripts/./gnome-terminal.sh</strong> and my &#8220;run command 0&#8243; under my key bindings tab to <strong>ctrl+alt+t</strong>, but you can associate this script with anything you&#8217;d like to kick it off.  A shortcut icon for example.</p><p>May this inspire you to understand, extend and share.</p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2010/09/30/random-gnome-terminal-profiles-themes-in-ubuntu/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Restricting a user&#8217;s shell permissions on Ubuntu Server 10.04 with lshell</title><link>http://www.doknowevil.net/2010/09/27/lshell-restricting-a-users-shell-permissions-on-ubuntu-server-10-04/</link> <comments>http://www.doknowevil.net/2010/09/27/lshell-restricting-a-users-shell-permissions-on-ubuntu-server-10-04/#comments</comments> <pubDate>Mon, 27 Sep 2010 23:19:37 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Bash]]></category> <category><![CDATA[Command Line]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Operating Systems]]></category> <category><![CDATA[Ubuntu]]></category> <category><![CDATA[open source]]></category> <category><![CDATA[access control]]></category> <category><![CDATA[application permissions]]></category> <category><![CDATA[backups]]></category> <category><![CDATA[game servers]]></category> <category><![CDATA[limited users]]></category> <category><![CDATA[lshell]]></category> <category><![CDATA[security]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=785</guid> <description><![CDATA[As described by apt-cache, the method which I usually begin a package search for in a Ubuntu Server 10.04 environment: z@zentury ~$ apt-cache search lshell lshell - restricts a user&#039;s shell environment to limited sets of commands This is an extremely useful way to restrict a Linux users capabilities. Alternative shells, such as rssh, limit]]></description> <content:encoded><![CDATA[<p>As described by apt-cache, the method which I usually begin a package search for in a Ubuntu Server 10.04 environment:</p><pre class="brush:bash">z@zentury ~$ apt-cache search lshell
lshell - restricts a user&#039;s shell environment to limited sets of commands
</pre><p>This is an extremely useful way to restrict a Linux users capabilities.  Alternative shells, such as rssh, limit you to toggle a specific set of applications, (scp, sftp, cvs, svn, rsync or rdist).  A limited shell is helpful for reasons such as backups or game/application servers where you know/want the user to be able to execute only a specific set of actions. You can however, consider other reasons for restricting users on a Linux based machine.</p><p>A <a href="http://lshell.ghantoos.org/Use%20case" target="_blank">typical use case is provided in the lshell wiki</a>.</p><p>Ubuntu also provides a default in <strong>etc/lshell.conf</strong>, which serves as a good example:</p><pre class="brush:bash"># lshell.py configuration file
#
# $Id: lshell.conf,v 1.20 2009/06/09 19:53:46 ghantoos Exp $

[global]
##  log directory (default /var/log/lshell/ )
logpath         : /var/log/lshell/
##  set log level to 0, 1, 2 or 3  (0: no logs, 1: least verbose)
loglevel        : 2
##  configure log file name (default is %u i.e. username.log)
#logfilename     : %y%m%d-%u

[default]
##  a list of the allowed commands or &#039;all&#039; to allow all commands in user&#039;s PATH
allowed         : [&#039;ls&#039;,&#039;echo&#039;,&#039;cd&#039;,&#039;ll&#039;]

##  a list of forbidden character or commands
forbidden       : [&#039;;&#039;, &#039;&amp;&#039;, &#039;|&#039;,&#039;`&#039;,&#039;&gt;&#039;,&#039;&lt;&#039;, &#039;$(&#039;, &#039;${&#039;]

##  number of warnings when user enters a forbidden value before getting
##  exited from lshell
warning_counter : 2

##  command aliases list (similar to bash’s alias directive)
aliases         : {&#039;ll&#039;:&#039;ls -l&#039;, &#039;vi&#039;:&#039;vim&#039;}

##  a value in seconds for the session timer
#timer           : 5

##  list of path to restrict the user &quot;geographicaly&quot;
#path            : [&#039;/home/bla/&#039;,&#039;/etc&#039;]

##  set the home folder of your user. If not specified the home_path is set to
##  the $HOME environment variable
#home_path       : &#039;/home/bla/&#039;

##  update the environment variable $PATH of the user
#env_path        : &#039;:/usr/local/bin:/usr/sbin&#039;

##  allow or forbid the use of scp (set to 1 or 0)
#scp             : 1

##  allow of forbid the use of sftp (set to 1 or 0)
#sftp            : 1

##  list of command allowed to execute over ssh (e.g. rsync, rdiff-backup, etc.)
#overssh         : [&#039;ls&#039;, &#039;rsync&#039;]

##  logging strictness. If set to 1, any unknown command is considered as
##  forbidden, and user&#039;s warning counter is decreased. If set to 0, command is
##  considered as unknown, and user is only warned (i.e. *** unknown synthax)
#strict          : 1

##  force files sent through scp to a specific directory
#scpforce        : &#039;/home/bla/uploads/&#039;
</pre><p>If this looks like something you would like to be able to do, you can install it with apt-get:</p><pre class="brush:bash">z@zentury ~$ apt-get install lshell</pre><p>You can change a current user to have the limited shell with the following command:</p><pre class="brush:bash">sudo chsh -s /usr/bin/lshell backupbot</pre><p>You can add a new user with a limited shell with the following command (-m creates the home directory):</p><pre class="brush:bash">sudo useradd -m -s /usr/bin/lshell backupbot</pre><p>A <a href="http://lshell.ghantoos.org/Configuration" target="_blank">more detailed configuration guide can be found here</a></p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2010/09/27/lshell-restricting-a-users-shell-permissions-on-ubuntu-server-10-04/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Python Multi-head X (Nvidia TwinView / Dual Monitor) Development Notes</title><link>http://www.doknowevil.net/2010/07/05/python-multi-head-x-nvidia-twinview-dual-monitor-development-notes/</link> <comments>http://www.doknowevil.net/2010/07/05/python-multi-head-x-nvidia-twinview-dual-monitor-development-notes/#comments</comments> <pubDate>Mon, 05 Jul 2010 23:29:24 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Application Management]]></category> <category><![CDATA[Computers]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Operating Systems]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[Software]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=745</guid> <description><![CDATA[Preface The following development notes were written after researching the underlying handling of dual monitors in the X window system on Linux. I&#8217;ve included a code snippet that I built to help demonstrate behavior and create a proof of concept to show I can determine which monitor a window is on using only python and]]></description> <content:encoded><![CDATA[<h2>Preface</h2><p>The following development notes were written after researching the underlying handling of dual monitors in the <a href="http://en.wikipedia.org/wiki/X_Window_System" target="_blank">X window system</a> on Linux. I&#8217;ve included a code snippet that I built to help demonstrate behavior and create a proof of concept to show I can determine which monitor a window is on using only python and no statically set coordinates.</p><h2>Introduction</h2><p>I mentioned in my previous post that I&#8217;m using an nVidia video card with &#8220;<a href="http://www.nvidia.com/object/feature_twinview.html" target="_blank">TwinView</a>&#8221; software that outputs my video as if it were one screen, which it technically is, one X screen.  This means that the distinction between monitors is not mapped in the X tree, it&#8217;s handled by the window manager. Unlike <a href="http://en.wikipedia.org/wiki/Xinerama" target="_blank">Xinerama</a>, which has an x session per monitor and stitches them together.  Xinerama, however, has is being deprecated in favor of <a href="http://en.wikipedia.org/wiki/RandR" target="_blank">RandR</a> but regardless, TwinView is my choice and is not an option for me to change to.</p><p>With all of that said, the decision to bridge python to c that interfaces with compiz is a deadend and would be better implemented based on the new 0.9.0 C++ api.  It would be nice to be able to return a list of windows from a &#8220;monitor&#8221; object.  However, that&#8217;s beyond my current scope.  I was able to whip up some python that to show that implementing the monitor management in python using the gtk module isn&#8217;t /that/ hacky.  I emphasize because I read some posts that claimed window decorations could be an issue in accurate calculations.</p><h2>Some Code</h2><p>Read the comment on line 2. <a href="http://www.pygtk.org/docs/pygtk/" target="_blank">Learn more about pygtk here</a></p><pre class="brush:python">
#!/usr/bin/python
# Print some information about the X environment, the monitor setup, currently active window and cursor position
import gtk.gdk

screen = gtk.gdk.screen_get_default()
print &quot;X default screen size: %d x %d&quot; % (screen.get_width(), screen.get_height())
print &quot;xid of root window: %d&quot; % screen.get_root_window().xid

monitors = int(screen.get_n_monitors())
print &quot;== %d monitors ==&quot; % monitors
for m in range(0, monitors):
    print &quot; - geometry of monitor %d: %s&quot; % (m, screen.get_monitor_geometry(m))

window = screen.get_active_window()
win_x, win_y, win_w, win_h, win_bit_depth = window.get_geometry()
print &quot;active window on monitor: %d&quot; % screen.get_monitor_at_point((win_x+(win_w/2)),(win_y+(win_h/2)))
print &quot;window geometry (x,y,w,h): %d, %d, %d, %d&quot; % (win_x,win_y,win_w,win_h)

display = gtk.gdk.display_get_default()
pointer = display.get_pointer()
print &quot;cursor position (x, y): %d, %d&quot; % (pointer[1], pointer[2])
print &quot;cursor on monitor: %d&quot; % screen.get_monitor_at_point(pointer[1],pointer[2])</pre><p>thanks to those in #compiz-dev and #python on freenode who helped me come around to create this snippet.  I hope it will help others looking to develop for multi-head setups in Linux.  Please let me know if I missed anything or did something incorrectly, this is new territory for me.</p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2010/07/05/python-multi-head-x-nvidia-twinview-dual-monitor-development-notes/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Compiz 0.9.0 Released &#8211; Completely Rewritten in C++</title><link>http://www.doknowevil.net/2010/07/04/compiz-0_9_0-released-completely-rewritten-in-c-plus-plus/</link> <comments>http://www.doknowevil.net/2010/07/04/compiz-0_9_0-released-completely-rewritten-in-c-plus-plus/#comments</comments> <pubDate>Mon, 05 Jul 2010 02:44:16 +0000</pubDate> <dc:creator>Tyler Mulligan</dc:creator> <category><![CDATA[Application Management]]></category> <category><![CDATA[Compiz]]></category> <category><![CDATA[Computers]]></category> <category><![CDATA[Desktop Mods]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Operating Systems]]></category> <category><![CDATA[Programming]]></category> <category><![CDATA[Software]]></category> <category><![CDATA[open source]]></category><guid isPermaLink="false">http://www.doknowevil.net/?p=738</guid> <description><![CDATA[I was doing some in depth research / code hacking regarding the support of multi-headed output (dual monitors) on Linux. I won&#8217;t get into details but my video is being output to my monitors as &#8220;one screen&#8221; with a virtual distinctions handled by the window manager. Because of this, figuring out which of the monitors]]></description> <content:encoded><![CDATA[<p>I was doing some in depth research / code hacking regarding the support of multi-headed output (dual monitors) on Linux.  I won&#8217;t get into <a href="http://forum.compiz.org/viewtopic.php?f=89&#038;t=13362" title="managing windows across dual monitors in compiz?">details</a> but my video is being output to my monitors as &#8220;one screen&#8221; with a virtual distinctions handled by the window manager.  Because of this, figuring out which of the monitors you are on isn&#8217;t as straight forward as you might think.  Originally I was looking for a way to access the c functions in compiz through python but that point is now moot (likely for the better).</p><p>The <a href="http://lists.freedesktop.org/archives/compiz/2010-July/003429.html">first unstable release of the Compiz 0.9 series</a>, completely rewritten in C++.  As said, this &#8220;brings a whole new developer API, splits rendering into plugins, switches the buildsystem from automake to cmake and brings minor functionality improvements. This release represents the first developer and tester preview of what will eventually make the 0.10.x stable series. Please note that as such, it is not yet ready for general use as there are a number of known  ssues, regressions and incomplete functionality.&#8221;</p><p>Here is a <b>SLIGHTLY DATED</b> graph I got <a href="http://santiance.com/2009/10/compiz-code-comparison/">from Santiance.com</a>.</p><p><a href="http://www.doknowevil.net/wp-content/uploads/2010/07/compiz_comparison_chart.png"><img src="http://www.doknowevil.net/wp-content/uploads/2010/07/compiz_comparison_chart.png" alt="" title="compiz_comparison_chart" width="776" height="449" class="alignnone size-full wp-image-739" /></a></p><p>This is a really interesting turning point for the project and I&#8217;m glad I came across this while doing my research for multi-head handling in compiz. Knowing where the future lies could drastically change where I put my efforts in developing to support them.</p> ]]></content:encoded> <wfw:commentRss>http://www.doknowevil.net/2010/07/04/compiz-0_9_0-released-completely-rewritten-in-c-plus-plus/feed/</wfw:commentRss> <slash:comments>0</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 944/1020 objects using disk

Served from: www.doknowevil.net @ 2012-02-04 04:14:53 -->
