Screen
January 19th, 2010
I love when I find useful built-in commands that I never knew about. When starting out with Linux, I heard about the typical heavy hitters like grep, sed, and awk. Then I discovered some variations on common commands, such as htop and less. And then every so often, someone mentions a command in passing that causes me to say “Wait… what is that?”
Screen is one of those sorts of tools. I was watching a VNC demo of one of our team’s sprint reviews and was distracted by the fact that he had a tab bar on the bottom of a terminal. It turns out that was just part of the coolness of “screen”.
Screen is basically a window manager that runs in a terminal, letting multiple shells run within the single terminal. I’m sure there are other features that I’d find awesome, but there are two that immediately stood out.
As I mentioned, screen allows you to run multiple shells inside of a single terminal. Instead of starting up a handful of separate SSH sessions to a server, I now just use screen to manage multiple shells inside of a single connection. Each call to screen creates a new shell, with a simple emacs-like syntax to switch between them:
ctrl + a + n # next ctrl + a + p # previous ctrl + a + 0 # select screen 0
One side note on this, by default the tab bar displaying the running shells isn’t displayed. Adding the following to ~/.screenrc enables a visual indicator of the current and possible shells that are open:
hardstatus on
hardstatus alwayslastline "%{-b gk}%-w%{+b kg}%50>%n %t%{-b gk}%+w%< %= %{w}%D %M %d %C%a"
While useful, it can still get a little confusing when a bunch of shells are opened. The title can be set by:
ctrl + a A

The second major piece of awesomeness is the ability to detach from a running screen and reattach later. Going back to the SSH example, this lets me leave some shells running, detach, completely disconnect from the server, and then reattach to the screen later (with everything left exactly as it was).
Again, an emacs-like syntax for detaching from a running screen:
ctrl + a + d
Later, to reattach to the running screen detached from earlier:
screen -dr
Like I said, I’m not trying to make this post sound like I’ve discovered some hidden black magic in Linux. It’s just an attempt to let new users know about this awesomeness.
From Java to Python
January 13th, 2010
I’m not completely sure why, but I’m a bit embarrassed to admit to Planet Fedora how little my Python experience is; the majority of my experience is in Java. I was able to read and bug fix the Python code in Spacewalk, but I hadn’t really dug deep into my own project. Now that I’m not teaching any longer and have some free time (one of my main reasons for quitting), I can finally sit down and dork around with the language. After spending some time working on some basic games and a simple IRC bot, I figured I’d step back and think about what the transition from Java to Python has felt like.
Don’t Fear The Whitespace
I constantly hear people mention the indentation in Python as the first thing when talking about moving to the language. Not only is it not as jarring of an experience as people make it out to be, it’s downright awesome. I’ve always been compulsive about my code format anyway, so the biggest difference is the lack of curly braces.
Collections Are Awesome
It’s much lighter-weight to throw things into a list or map (dictionary in Python) than it is in Java. Get out of the mentality that you have to jump through import hoops and rigid notation to create, access, or return collections. In Python, they even let you do cool things like assign multiple variables as a return from a call:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
Looping Feels Weird At First
I got a little thrown off by this initially. Most loops read really well:
for square in openSquares:
However, when looping through a set of numbers, you need to use the range method:
for i in range(0, 10):
Looking at both of those examples brings me to my next point…
Don’t Forget The Colon
This keeps throwing me off, but after declaring a function*, loop, or if statement, don’t forget to end the line with a colon. I’m happy to be rid of curly braces, but I get over-ambitious and forget the colon too.
Don’t Over-engineer Configuration
Depending on what you’re doing, you can likely just stuff configuration values into a script and import it (not needing to compile really is liberating in this respect). That’ll also give you the use of lists and maps by default. If you’re not reading between the lines I’ll spell it out: no need for XML-based configuration, which is one of the more evil trends in Java.
There are definitely more things I could mention; don’t take this to be the only lessons I’ve learned (any other hints/tips are appreciated). But I do want to avoid a mammoth blog post that causes readers to go into a zombie-like trance, so I’ll stop it here for now. I do want to thank Devan (dgoodwin) and Jesus (zeus) for dealing with the Java-veteran-turned-Python-noob and not finding a way to crash my chat client to avoid more questions.
* I haven’t seen a solid explanation of “Call them ‘functions’ because you’ll sound like a Java guy calling them ‘methods’”, but this feels like something where using the wrong term will make me stand out as a Java developer in a Python world. So I’ve been advised to take a militant approach of “Yes, I’m a Java guy learning Python, deal with the occasional terminology missteps.”
Dangers of working at home
January 8th, 2010
My mouse died yesterday, so I’m using an old trackball. My 2 year old daughter just came in to say goodbye before they went out. She took one look at the it, grabbed the ball out of the rest of the mouse, and ran out of my office to go play with it.
Since it fully renders my mouse useless, this is actually more crippling than the last such incident. I keep my RSA FOB on a lanyard. A few months ago, my daughter saw the lanyard and then ran around the house showing off her “new jewelry”.
Removing desktop icons in Gnome
December 11th, 2009
A friend of mine is migrating from Windows to Fedora and has been asking me a bunch of questions about my setup. As I was looking over my wiki for notes I’ve taken, I realized one of the tasks I always find myself doing in Gnome is to disable the default desktop icons. My reasoning is a combination of the fact that I try to use the mouse as little as possible and a compulsive desire to have an empty desktop. I should probably seek some psychiatric help on the compulsion, but since I was able to disable the icons the doctor will have to wait until my next episode.
There is unfortunately no menu option for this in preferences, so I had to use gconf-editor. That’s not installed by default, but it’s easy enough to fix that.
sudo yum -y install gconf-editor
Once it’s installed, run it and navigate to apps -> nautilus -> desktop. Uncheck the *_icon_visible options until your compulsion subsides and you’re good to go.
Child’s Play Charity
December 10th, 2009

http://www.childsplaycharity.org/
I’m not the type to get preachy about charity and donations and Christmas and all that stuff. But since this is the time of year where people are more inclined to give to charity, I wanted to drop a quick note about Child’s Play Charity just to increase awareness. More information can be found on their site, but I’ll mention a quick snippet to summarize what they are:
Since 2003, we’ve set up and organized Child’s Play, a game industry charity dedicated to improving the lives of children with toys and games in our network of over 60 hospitals worldwide. In five short years, you as a community have answered the call and come together to raise millions of dollars.
And just to be clear, I’m not affiliated with them in any way. I’m a video game geek and have a soft spot for children, so this initiative has always resonated with me.
Devil’s Pie
December 9th, 2009
I’ve been using Gnome for almost a year and a half now, and while I have grown to love a lot of the advantages it has, there are still some things I miss about FVWM. From a keyboard shortcut standpoint, many of them were alleviated when I discovered Gnome Do. However, I still found myself missing sticky, transparent shells that would give me a constant view into certain data, be it htop or tailing some files. It was really quick to set up in FVWM, but I had trouble finding a way to remove window decorations from windows in Gnome.
Sure, there are other ways to get the data I’m looking for, but having text rendered directly on the desktop like that just looks damn cool to me. It also intimidates the crap out of non-geeks when they see my office, which I fully admit is a big plus.
I came across a package called Devil’s Pie that gave me a lot more control over windows. Although I was looking for something that would let me actively select a window to give it certain properties (sticky, no decorations, etc), Devil’s Pie instead passively detects new windows and applies settings to them. It’s a mentality shift from my initial thoughts, but I think over time this model will actually be really useful. Plus, it has “pie” in the name, which is just awesome.
With a combination of gnome-terminal profiles/flags and Devil’s Pie configuration, I was able to get my desktop to automatically populate my desktop with all sorts of data. The following description of how is kinda wordy, but it’s really not complicated at all.
Install and Configure Devil’s Pie
sudo yum -y install devilspie mkdir ~/.devilspie touch ~/.devilspie/console.ds
Devil’s Pie reads all configuration files (I believe they have to end in .ds, but don’t quote me on that) in the above directory on startup. Those files define the rules that will be applied to new windows that are created (there’s also a way to ask it to apply rules to all existing windows as well). For this example, I put my rules in a file named console.ds.
(if (contains (window_name) "console" ) (begin (undecorate) (pin) (skip_pager) (skip_tasklist) ) )
There are two main parts to the above configuration. The first is the matching expression to decide if a window should have the rules applied. In this case, I indicate to apply the actions if the window name contains the string “console” (there are also options for “is” and “matches”). I’ll cover where that rule comes into play in a bit.
The actions do the following:
- undecorate – This is primarily what I was going for, I want the window decorations removed. This includes the title bar and border, though you can still use the shortcut key (alt+F8 by default) to resize a window without decorations.
- pin – Make this window available on all workspaces. There are also attributes to control putting a window on a particular workspace, which could be useful in my case since I use 12 workspaces and am, well, pretty anal retentive about having certain applications in certain workspaces.
- skip_pager – Don’t let the window show up in the pager. It removes the clutter in my pager since I don’t consider this a “real” application, just a status-type window.
- skip_tasklist – A little more useful than skip_pager, this keeps the window off the taskbar, for the same rationale as above.
Needless to say, I’m only scratching the surface of all of the actions supported. I haven’t found a good way to find this list yet; the man page says the -l flag will list symbols but when I try it, it just doesn’t do anything.
Run Devil’s Pie
devilspie
Not much to say about that. I’ll talk more about enabling a debug mode later, but I mention it now to say it’s not done through flags. You’ll need to restart it every time you change your confguration files, but once you’re set add it to System -> Preferences -> Startup Applications and you’re good to go on reboots.
Create Gnome Terminal Profile
To summarize above, Devil’s Pie will take care of removing window decorations and keeping it on the visible workspace. We still need to configure Gnome terminal to add some slickness to how it looks. Since I don’t want this slickness on all of my terminals, I created a new profile named “console” with the following changes:
- Background – Transparent background, with the slider set all the way to none.
- Scrolling – Scrollbar is: Disabled
That gives us a completely transparent shell, reflective of its use to simply throw data at me.
Start the Terminal
Now we just need to make sure we start the terminal such that it will use the right profile and will trigger the window detection from Devil’s Pie. Here’s where the matching expression from above comes into play. I don’t want all of my terminals to have no decorations, just specific ones I want to treat in this fashion. When starting the terminal, tell it to use a specific window title that will match our Devil’s Pie rule from above.
gnome-terminal -t console --profile=console --geometry=140x20+1680-0 -e htop
A quick explanation of above:
- -t – Sets the title of the terminal window. This value should match up to the window_name value from the Devil’s Pie configuration.
- –profile – Tells the terminal to use the slick console profile in all of its transparent goodness.
- –geometry – Initially size and place the terminal on my screen.
- -e – Run a specific command when it starts, in this case
htop.
My screenshot above simply uses a similar call to gnome-terminal, passing a tail command to -e and different geometry to get the log tail on the top of the screen.
Two other notes on Devil’s Pie:
There is a UI for editing the configuration files: gdevilspie. It’s handy because you can easily see the different types of matching expressions and actions, however the files it generated didn’t run for me. For some reason, even with one matching expression it still added a blank condition and an “and” statement and closed the conditions block too early. I haven’t looked to closely yet to see what is wrong.
Enabling debugging is as simple as adding another configuration file. I added one named “debug.ds” to my ~/.devilspie directory that contained simply:
(debug)
Once that is in place, running the devilspie executable from the command line output some really useful window information whenever a new window was created.
Dear Lazyweb: I need a new printer
December 3rd, 2009
I’ve had my printer since 1998. That’s a damn good run for any piece of hardware. It still works insofar as it prints, but in 2009, we know it could do more. As it is, I only have one desktop left in the house with the old school printer connector so I can actually use it (it doesn’t have a network connection).
We’re not looking for anything crazy, just a fairly standard all-in-one:
- Direct connection to the network. Wired is fine, it’s gonna sit next to a big ass gigabit switch.
- Printer (duh). Standard paper size, we don’t have much of a need to print anything bigger.
- Scanner for the five times a year we actually want to scan something.
- Fax for the two times a year we actually need to fax something.
- Ability to make coffee (we’re willing to bend on this one).
I’m looking at the HP all-in-ones, but I wanted to throw this out there to see if anyone had any recommendations and comments on Linux support.
Any advice is appreciated. Happy Holidays

