Tips and Tricks About Computers, Web Development, Linux, the Internet and the Like
Linux
What Makes ASUS and Android an A+?
Jan 20th
Posted by Tyler Mulligan in Android
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 other devices.
With ChromeOS, Google is also covering a server-side focused solution to a consumer’s needs. We see Blackberry trying out a similar solution with WebOS, ASUS however, is focusing on hardware, as usual and doing an impressive job, as usual.
They don’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.
ASUS doesn’t forget it’s stake in the software portion of this emerging market, no. They’ve invested in a “cloud” 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 access.asus.com. Now all they need to do is invest in a short domain name, ax.as.us.
Other Points, these are cool:
Tips for Using Bash in the Linux Terminal – Part 1
Oct 23rd
Posted by Tyler Mulligan in Bash
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’ve mentioned commandlinefu.com before as a great reference for learning some neat tricks with the terminal. I’ve gained a lot from the site and a few others, such as the Advanced Bash Scripting Guide and the bash hackers wiki. I wanted to share some of the tips I use most often, combined with other information that I’ve compiled through my use of the terminal.
I think I should mention that I’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 “modes”. GUIs have their place but many of my tasks can be completely more accurately and consistently via the terminal.
With that said, lets dive in.
The Basics
Hotkeys
Moving:
Ctrl + a -> Go to the beginning of the line you are currently typing on.
Ctrl + e -> Go to the end of the line you are currently typing on
Alt + f -> Move cursor forward one word on the current line.
Alt + b -> Move cursor backward one word on the current line.
Editing:
Ctrl + u -> Clears from before the cursor position. If you are at the end of the line, clears the entire line.
Ctrl + k -> Clear from after the cursor. If you are at the beginning of the line, clears the entire line.
Ctrl + w -> Delete the word before the cursor.
Ctrl + h -> Same as backspace.
Ctrl + t -> Swap the last two characters before the cursor.
Esc + t -> Swap the last two words before the cursor.
Other:
Ctrl + l -> Clear screen (same as clear command).
Ctrl + c -> Kill the current command or process.
Ctrl + z -> Puts whatever you are running into a suspended background process, fg to restore it.
Ctrl + d -> Exit the current shell.
Oddly, unlike many terminal applications, Bash hotkeys don’t make a lot of sense to me. There are very few that are “intuitive”.
History
Press the up arrow for the last command or:
!! — repeat last command
echo "hello" !!
Outputs:
z@zentury:~$ echo "hello" hello z@zentury:~$ !! echo "hello" hello
ctrl+r 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
Advanced
History Expansion/Modification
!:0 — will repeat the first token
cd ~ ls -la !:0
!:1-3 — defining a range: 1-3 will repeat the 2nd to 4th tokens (count starts at 0). It’s important to note that double quotes will group tokens together.
echo "hello there" && ls ~ !:3-4
!!:s/find/replace/ — will allow you to replace a part of the command
echo "hello there" !!:s/hello/hi/
Outputs:
z@zentury:~$ echo "hello there" hello there z@zentury:~$ !!:s/hello/hi/ echo "hi there" hi there
OR even shorter:
^find^replace
echo "hello there" ^hello^hi
Outputs:
z@zentury:~$ echo "hello there" hello there z@zentury:~$ ^hello^hi echo "hi there" hi there
Sequences and Pattern Expansion
Typically in a Linux or UNIX environment you have access to a command line tool name “seq” which gone over before. However, it’s good to know that bash has built-in sequence expansion and you don’t need to rely on seq.
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 zby defining a start and end character with the ‘..’ 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:
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 ZOr both, with a few extra characters in the mix:
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 zIt doesn’t always have to be a-z though,
echo {A..G}
A B C D E F GThis also works with numbers:
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 100Descending as well as ascending
echo {9..0}
9 8 7 6 5 4 3 2 1 0Echo a specific set
echo {1,4,6,9}
1 4 6 9Applying it
Quickly backup a file
touch file1.txt
cp file1.txt{,.bak}
ls
file1.txt file1.txt.bakexplanation: the first parameter is empty, the second is .bak, this expands to >> cp file1.txt file1.txt.bak << and creates the copy
Convert an image type
If you have image magick installed, you can convert file types pretty easy using this same concept:
sudo apt-get install imagemagick
(To install on Ubuntu)
convert file.{jpg,png}Permutations
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 cccStay tuned for Part 2
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 check out some of my creative usages at commandlinefu.com.
-

Customizing Colors for Your .bashrc
Oct 21st
Posted by Tyler Mulligan in Application Management
I’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’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’m not sure if this is due to it being a collaborative wiki or it’s a way to teach multiple syntaxes/approaches. In either case I figured the aliases weren’t as “standard” as I thought they might be in that world.
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.
# define colors Black='\e[0;30m' # Black / Regular Red='\e[0;31m' # Red Green='\e[0;32m' # Green Yellow='\e[0;33m' # Yellow Blue='\e[0;34m' # Blue Purple='\e[0;35m' # Purple Cyan='\e[0;36m' # Cyan White='\e[0;37m' # White BBlack='\e[1;30m' # BBlack / Bold BRed='\e[1;31m' # BRed BGreen='\e[1;32m' # BGreen BYellow='\e[1;33m' # BYellow BBlue='\e[1;34m' # BBlue BPurple='\e[1;35m' # BPurple BCyan='\e[1;36m' # BCyan BWhite='\e[1;37m' # BWhite UBlack='\e[4;30m' # UBlack / Underline URed='\e[4;31m' # URed UGreen='\e[4;32m' # UGreen UYellow='\e[4;33m' # UYellow UBlue='\e[4;34m' # UBlue UPurple='\e[4;35m' # UPurple UCyan='\e[4;36m' # UCyan UWhite='\e[4;37m' # UWhite BGBlack='\e[40m' # BGBlack - background BGRed='\e[41m' # BGRed BGGeeen='\e[42m' # BGGreen BGYellow='\e[43m' # BGYellow BGBlue='\e[44m' # BGBlue BGPurple='\e[45m' # BGPurple BGCyan='\e[46m' # BGCyan BGWhite='\e[47m' # BGWhite NC='\e[0m' # Text Reset / No Color
Here is a test case:
for c in {,B,U,BG}{Black,Red,Green,Yellow,Blue,Purple,Cyan,White}; do echo -e ${!c}$c${NC}; done; echo -e "${NC}"Here is the same test case without the aliases
for c in {0,1,4}\;{30..37} {40..47}; do echo -e \\e[${!c}${c}m${c}m\\e[0m; done;Here's a PS1 you can try it with
PS1="${debian_chroot:+($debian_chroot)}\[${BWhite}\]\u\[${NC}\]\[${Yellow}\]@\[${White}\]\h\[${NC}\]:\[${BBlue}\]\w\[${NC}\]$ "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’ve setup an alpha of http://interwebninja.com/ps1-o-matic/
ps1-o-matic-0.5 video in action
![]()
![]()
![]()
![]()
Below is a screenshot of how I’m revising the script to use only javascript objects rather than relying on html inputs to store values:

I’m currently at the point where I’m using jquery ui’s draggable and sortable to allow segments to be moved around but I have nothing worth sharing yet. Stay tuned, I’ll be checking the source into my github account soon.
Sorry screen, tmux is better (but here are some screen-like hotkeys)
Oct 18th
Posted by Tyler Mulligan in Computers
Introduction
If you’re familiar with the command line on Linux or UNIX, you’ve likely heard of a program called “screen”, 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 never left. Additionally, you can have multiple buffers inside your screen that act like tabs, allowing you to flip between.
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 “b” instead of “a”, 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.
I became well acquainted at Tux Wears Fedora’s post on tmux migrating from screen.
# ~/.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 " " bind " " next-window unbind n bind n next-window # title A unbind A bind A command-prompt "rename-window %%" # 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 "kill-server" # kill K k unbind K bind K confirm-before "kill-window" unbind k bind k confirm-before "kill-window" # 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 '"' 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 '#S:#I.#P #W' # Status Bar set -g status-bg black set -g status-fg white set -g status-interval 1 set -g status-left '#[fg=green]#H#[default]' set -g status-right '#[fg=yellow]#(cut -d " " -f 1-4 /proc/loadavg)#[default] #[fg=cyan,bold]%Y-%m-%d %H:%M:%S#[default]' # 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 # " windowlist -b unbind '"' bind '"' choose-window
Splitting is what initially caused me to migrate but there are plenty of other features that have lead me to stay. this article outlines the benefits in detail. Once you go tmux, you never go back.
Using Terminal Program "screen" on Linux / UNIX
Oct 18th
Posted by Tyler Mulligan in Command Line
Introduction
The terminal program “screen” for Linux / UNIX, is a command line tool that allows you to emulate terminals inside a currently running session and detach the ‘screen’ to the background. This program may seem obscure to new users because of it’s abstract nature and unusual key bindings but once you start learning the basics, the advanced usages don’t seem that scary.
If you consider yourself to have an advanced sense of the command line and you’d like to go more advanced out of gate, you should consider skipping ahead to my article on the screen successor, tmux which allows for more advanced splitting (and apparently better code).
Getting Started
Below is a walk through of an average screen scenario I’ve put together to give you an idea of how you might use this program in your workflow.
to start a basic screen session type:
screen
this will put you in a virtual session.
to detach the screen press: ctrl+a, d
to reattach the screen type:
screen -r
detach again, then type:
screen
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’ll see something like the following:
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 "screen [-d] -r [pid.]tty.host" to resume one of them.
So I’d type:
screen -r 31454
to attach the first one. On systems with ‘pkill’ you can type:
pkill screen
to kill all the screen sesions.
That’s one way to separate screens… another is virtual “tabs” within a screen session.
so lets create a new screen session with:
screen
Then type:
ls
so you have some data to reference for which “tab” you’re in
Then hit: ctrl+a, c
This will create a new tab.
to cycle forward through the tabs (next), hit: ctrl+a, n or ctrl+a, [spacebar]
to cycle backwards through the tabs (previous), hit: ctrl+a, p or ctrl+a, [backspace]
to kill a tab, type: exit
I found a good reference for “screen” hotkeys at pixelbeat.org if you’d like to learn more.
Multiple X (Desktop) Sessions in Ubuntu
Oct 13th
Posted by Tyler Mulligan in Application Management
This post has a lot to do with graphics but there are no graphics. It’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’t familiar with X, than this webpage might confuse you, the X Window System is what draws the GUI (graphical user interface) for Ubuntu. On top of this, you may have a Window Manager or Desktop Environment, such as Gnome (Ubuntu default) or KDE (Kubuntu).
When you boot up Ubuntu, it creates a set of “virtual terminals”. These VTs are accessible via a key combination of clt+alt+f1-12. VT7 (ctrl+alt+f7) is the default and it handles X’s “screen 0″. If you play around, with the key combination, you’ll notice you drop into consoles with a login prompt (f1-6) or a blank screen (f8-f12, don’t worry if you see USB errors).
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 “Kernel Mode”, where this management is handled by the kernel. You can switch to another virtual terminal and create another X session.
Typically in Linux, you could switch to another VT, login [as another user] and type $ startx — :1 (special argument ‘--‘ 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.
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’t have another already. You can do this by going to System > Administration > Users and Groups.
To create a second X session in Ubuntu, go to your logout menu (default top right) and select “switch user”, and login as another user (you don’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 suspect 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 “user switches”.
I haven’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.
Similar areas I came across in my research were Nested X sessions and Multiseat X.
Random gnome-terminal profiles (themes) in Ubuntu
Sep 30th
Posted by Tyler Mulligan in Application Management
Introduction
Does it ever confuse you if you have too many terminals open at once that look alike? Perhaps you’re just looking to express your personality or tickle your brain. In any case, if you’re using the terminal in ubuntu a lot, you may be interested in having random profiles (colors / settings).
The concept of the method is pretty simple, define a hotkey that launches a script that picks a random profile you’ve created and then open the terminal with that profile as a parameter.
Prerequisites
- Compiz or other hotkey script that will allow you to link to a .sh file
- gnome-terminal
- bash
Getting Started
You can figure out what Profiles you have by going to Edit > Profiles in gnome-terminal. You likely only have one, “Default”, unless you’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. Important, don’t include spaces in the names of the profiles
The Script
Create a file in your scripts folder (or create a directory if you don’t have one):
mkdir ~/scripts touch ~/scripts/gnome-terminal.sh && chmod +x ~/scripts/gnome-terminal.sh gedit ~/scripts/gnome-terminal.sh
Paste the following replacing the Profile names with those of your own (delimited by spaces) and change the number 4 to that of the :
#!/bin/bash
p=( Default Delta Psi Sigma )
gnome-terminal --window-with-profile ${p[$((RANDOM%${#p[@]}))]}
That ugly looking bit right here is a calculation between a random number (echo RANDOM) and the size of the array (${#p[@]}), “random” % “length of array”. 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).
To illustrate more, play with this code:
r=$RANDOM; echo $r; echo $((r % 4))
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 “–window-with-profile”. So using my define array above, if the random index were “1″, “Delta” would be echoed. If the index were “0″, Default would be.
The Setup
Now, I use compiz with the commands plugin, setting my “command line 0″ to ~/scripts/./gnome-terminal.sh and my “run command 0″ under my key bindings tab to ctrl+alt+t, but you can associate this script with anything you’d like to kick it off. A shortcut icon for example.
May this inspire you to understand, extend and share.
Restricting a user’s shell permissions on Ubuntu Server 10.04 with lshell
Sep 27th
Posted by Tyler Mulligan in Bash
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'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 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.
A typical use case is provided in the lshell wiki.
Ubuntu also provides a default in etc/lshell.conf, which serves as a good example:
# 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 'all' to allow all commands in user's PATH
allowed : ['ls','echo','cd','ll']
## a list of forbidden character or commands
forbidden : [';', '&', '|','`','>','<', '$(', '${']
## 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 : {'ll':'ls -l', 'vi':'vim'}
## a value in seconds for the session timer
#timer : 5
## list of path to restrict the user "geographicaly"
#path : ['/home/bla/','/etc']
## set the home folder of your user. If not specified the home_path is set to
## the $HOME environment variable
#home_path : '/home/bla/'
## update the environment variable $PATH of the user
#env_path : ':/usr/local/bin:/usr/sbin'
## 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 : ['ls', 'rsync']
## logging strictness. If set to 1, any unknown command is considered as
## forbidden, and user'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 : '/home/bla/uploads/'
If this looks like something you would like to be able to do, you can install it with apt-get:
z@zentury ~$ apt-get install lshell
You can change a current user to have the limited shell with the following command:
sudo chsh -s /usr/bin/lshell backupbot
You can add a new user with a limited shell with the following command (-m creates the home directory):
sudo useradd -m -s /usr/bin/lshell backupbot
Python Multi-head X (Nvidia TwinView / Dual Monitor) Development Notes
Jul 5th
Posted by Tyler Mulligan in Application Management
Preface
The following development notes were written after researching the underlying handling of dual monitors in the X window system on Linux. I’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.
Introduction
I mentioned in my previous post that I’m using an nVidia video card with “TwinView” 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’s handled by the window manager. Unlike Xinerama, which has an x session per monitor and stitches them together. Xinerama, however, has is being deprecated in favor of RandR but regardless, TwinView is my choice and is not an option for me to change to.
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 “monitor” object. However, that’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’t /that/ hacky. I emphasize because I read some posts that claimed window decorations could be an issue in accurate calculations.
Some Code
Read the comment on line 2. Learn more about pygtk here
#!/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 "X default screen size: %d x %d" % (screen.get_width(), screen.get_height())
print "xid of root window: %d" % screen.get_root_window().xid
monitors = int(screen.get_n_monitors())
print "== %d monitors ==" % monitors
for m in range(0, monitors):
print " - geometry of monitor %d: %s" % (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 "active window on monitor: %d" % screen.get_monitor_at_point((win_x+(win_w/2)),(win_y+(win_h/2)))
print "window geometry (x,y,w,h): %d, %d, %d, %d" % (win_x,win_y,win_w,win_h)
display = gtk.gdk.display_get_default()
pointer = display.get_pointer()
print "cursor position (x, y): %d, %d" % (pointer[1], pointer[2])
print "cursor on monitor: %d" % screen.get_monitor_at_point(pointer[1],pointer[2])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.
Compiz 0.9.0 Released – Completely Rewritten in C++
Jul 4th
Posted by Tyler Mulligan in Application Management
I was doing some in depth research / code hacking regarding the support of multi-headed output (dual monitors) on Linux. I won’t get into details but my video is being output to my monitors as “one screen” with a virtual distinctions handled by the window manager. Because of this, figuring out which of the monitors you are on isn’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).
The first unstable release of the Compiz 0.9 series, completely rewritten in C++. As said, this “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.”
Here is a SLIGHTLY DATED graph I got from Santiance.com.
This is a really interesting turning point for the project and I’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.

