Term has now finished, and I haven’t yet posted a blog post since my first one announcing the new site. So forgive me in advance for any mistakes, or anything that isn’t written perfectly, or not explained well… I need to find my footing with this whole blog thing. Of course corrections are welcome!
It’s December, so it’s time to turn my computer desktop into a catalyst for festive spirits. Just because it’s the holidays, it does not mean I’m going to be using my computer less, or even working less. If anything it means that I’ll be using my computer more, as I will not be doing academic work on paper (eww paper!).
I find that ensuring that you listen to plenty of Christmas music, have decorations up, and have plenty of green red and yellow on your monitors can really help get you in the Christmas Spirit, lift your mood, and keep you there! A couple of years before, I hadn’t done any of this, listened to my usual music while coding, and had my usual bland (in comparison) desktop. This resulted in the feeling that I had effectively missed Christmas. Christmas day came around and I didn’t even feel like it was Christmas, I had none of the “build up” and excitement beforehand, didn’t watch any Christmas films, and come January, I felt like I had missed out. I vowed never again to let Christmas slip by my this way again!
Before I start explaining what’s what, here’s a screenshot of the setup when I have an additional monitor plugged into my laptop
Now, the Wallpaper is probably the most attractive feature of this whole setup, it is certainly the centrepiece. You can grab your own copy of it here: http://overkill766.deviantart.com/art/Xmas-Wallpaper-187303984. I use feh to set my wallpaper in my x session.
I’ve been using Linux for quite a while now (specifically Fedora). A while a go, I noticed Gnome was beginning to freeze sporadically, for minutes at a time sometimes, and I was starting to get tired of the feel for gnome, and the “clunkyness” of it. It was certainly time for a new window manager. A mate of mine introduced me to the window manager dwm, and I have to say it is a work of art. Less than 2000 lines of C code, the idea is you edit a configuration file config.h (which is yet another c script) and compile whenever you want to change anything, as a result, it is blazing fast and works brilliantly with no dependencies other than X itself. The developers also encourage patching (modifying the source code) by it’s users to add/remove features and customise functionality. I am using a patched version (I’ve forgotten what was patched, it may have been the colours for the tabs). I start dwm in run-level 3 after starting X (I haven’t set up my own login manager yet… mey do that if/when I switch to arch linux).
Status Bar Text
DWM allows you to change the text in the top right hand corner of the active screen (this is it’s placement in an unmodified version of dwm) via the command
xsetroot which is part of the X library. Specifically using the
-name parameter. DWM uses the current name of the root window as the text for this status area, this allows you to write programs using anything you like that call this system command to change the status text.
For example, this shell command will set the status text to my name:
> xsetroot -name Sam\ Lanning
You can quickly see how you can easily have a lot of fun with this… I decided to create a python script that would have a loop, and wait 1 second at the end of each iteration. It would be super basic, not have a large footprint, and I got an excuse to write a little python script. This is not the most beautiful of python scripts, and there’s plenty of string manipulation and concatenation, I needed something quick and dirty at the time of writing, and have no real need to change it because well… it works, and i dont need any more functionality for the time being…
''' Custom Status Bar Program for DWM ''' import subprocess import time import re while True: status = u'' # Battery acpi_1 = subprocess.Popen('acpi', shell=False, stdout=subprocess.PIPE) batt_status_all = acpi_1.communicate() if batt_status_all == '': status += 'NO BATT' else: batt_status = batt_status_all[11:-1] # Trim batt number and \n batt_status_split = re.compile('(,?)\s').split( batt_status ) batt_percent = batt_status_split[:-1] no_batt = len( batt_status_split ) batt_low = batt_percent < 20 batt_discharging = batt_status_split == 'Discharging' if batt_discharging: if batt_low: status += 'LOW BATT: ' + batt_status_split else: status += batt_status_split if len( batt_status_split ) >= 5: status += ' | Remaining: ' + batt_status_split else: status += 'CHARGING: ' + batt_status_split # Termal acpi_2 = subprocess.Popen(['acpi','-t'], shell=False, stdout=subprocess.PIPE) temp_status = acpi_2.communicate()[11:-1]; temp_status_split = re.compile("(,?)\s").split( temp_status ) if temp_status_split == 'ok': status += u' | ' + temp_status_split + u'C' else: status += ' | TEMP ERROR ' # Time status += ' | ' + time.strftime('%A %d/%m/%Y %I:%M:%S %p') # Update Status Bar subprocess.Popen(['xsetroot','-name',status]) time.sleep(1)
I plan to add stuff like Dropbox statuses, network connectivity and what I have mounted later on, at which point I will probably make it a little more prettier.
How it all works together
As my computer is set to boot into run level 3 (multi user mode with no graphics), the first thing I get is a shell asking for username and password. After I login, I am immediately in bash, so run
startx which launches the x server and session, and then runs
#!/bin/sh # # ~/.xinitrc # # Executed by startx (run your window manager from here) python ~/Programs/desktop-environment/status/status.py & feh --bg-center '/home/sam/wallpapers/xmas/screen1.jpg' '/home/sam/wallpapers/xmas/screen2.jpg' & dwm
I’ve packaged my patched version of dwm, slock and dmenu along with the config header for dwm, my status script and additional scripts I use for media control. I cant remember exactly what I’ve changed from the original, and producing diffs would take too much time and could be something you do yourself if you are interested in that. I would also encourage you to download the latest versions of dwm, slock and dmenu, and then modify them yourself. It’s the proper way to do it.
Now what I consider probably the most important part of this makeover, the terminal emulator. Now some of you might cringe at this but… I use
gnome-terminal. Now hold up, the reason I still use it is, well, because it works, and it works nicely. It has good customisation options and works straight out of the box with fonts and well, it’s there. I haven’t found a need to switch, it works, it’s not slow enough that i can tell a difference, and it plays nicely with dwm. In fact, most of the gnome apps play nicely, I use
gnome-calculator when I need a calculator, and I use
gnome-control-center when I need to manage stuff like audio cards or networks. Anyway enough of the excuses, I have basically changed the colour scheme, as you can tell in the screenshot, and I think it’s pretty… Some people may not like the colours, but it’s difficult to keep the colours sensibly ranged over christmas-y colours while making the distinguishable enough and readable. I think I have struck a right balance here, and its entirely up to you to agree or disagree otherwise…
Here’s a preview:
That’s about as festive as my desktop goes! Hope you liked the post, there’s much more to come!