MTB3: Yet another (very simple) background switcher for Gnome 3

Way back when I started playing around with Python, one of the first applications I wrote was a transitioning background application. It worked quite nicely, but it was very tied to the Gnome 2 way of doing things and not particularly suited to a conversion to Gnome 3.

So now I have a simplified version which (after a bit of frustration) works quite nicely by simply displaying a random picture from my ~/Pictures/Backgrounds folder. The script, as it stands, looks like this:

#! /usr/bin/python
""" Yet another, veryt simple background switcher for the Gnome 3 Desktop
 Copyright (C) Paul Pritchard 2013 
 MTB3 is free software: you can redistribute it and/or modify it under the 
 terms of the GNU General Public License as published by the Free Software 
 Foundation, either version 3 of the License, or (at your option) any 
 later version.
 MTB3 is distributed in the hope that it will be useful, but WITHOUT ANY 
 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
 You should have received a copy of the GNU General Public License along
 with this program.  If not, see ."""

import os
import random
import mimetypes

backgrounds = os.environ['HOME'] + "/Pictures/Backgrounds/"
pictures = []

for filename in os.listdir(backgrounds):
    mimetype = mimetypes.guess_type(filename)[0]
    if mimetype and mimetype.split('/')[0] == "image":
        pictures.append (filename)

picture = random.randrange (0, len(pictures))
fullpath = '"file:///' + backgrounds + pictures[picture] + '"'
os.system("DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.background picture-uri '%s'" % (fullpath))

I then put a short script in /usr/local/bin so that I could execute it with the mtb command and, since everything was working swimmingly, I turned to cron to launch the app every 20 minutes.

The crontab line looks like this:

*/20 * * * * mtb

And it works, even if I have spent far too long finding my way around gsettings.

There are a couple of points worth noting, if only for my own future sanity.

Firstly, gsettings needs to know what screen to run on. This is fine when the command is executed from a terminal because it knows to run on the screen the terminal is sitting in. But when launching the same command from crontab, there is no terminal. You need, therefore, to include the DISPLAY=:0 GSETTINGS_BACKEND=dconf to tell gsettings where to run.

Secondly, the crontab environment settings are not always as complete as those found in Bash. So while I am able to enter just the command in Frugalware, other distributions may require you to use the full path to the command.

Fixing the GRUB menu in Frugalware

Somewhere between installing Frugalware last September and last month, the Windows partition went missing from my laptop. More accurately, the option to boot into Windows vanished from my GRUB menu.

Clever GRUB, I hear you say.

I don’t often boot into Windows, so I can’t say for sure when this happened but I would guess that it was when I upgraded to Cinna back in February. Either way, though, it’s surprisingly easy to fix once you have figured out where to look.

There are plenty of guides on t’interwebs that guide you through re-installing GRUB, but since it was just the menu I wanted to fix I went straight to the final step which involves rebuilding the grub.cfg file.

This file can be found in /boot/grub so…

First, take a copy of your current file just in case things go completely pear-shaped:

# cd /boot/grub
# mv grub.cfg grub.cfg.sav

Then rebuild your grub.cfg:

# grub-mkconfig -o grub.cfg

And that’s it.

And now that I have successfully booted into both partitions, I have deleted the grub.cfg.sav backup file.

Enable NetworkManager in Frugalware

When I installed Frugalware, way back in August, I mentioned that the network Manager wasn’t starting up automatically. Starting it manually is easy enough, but it’s something that really should be starting up automatically.

Finally, after spending way too much time reading up on systemd, I have gotten around to doing this. Inevitably, the command to achieve automatic starting of the network manager is ridiculously simple:

# systemctl enable NetworkManager.service

… but I’m noting this here so I have something to refer back to for next time.

Note to self: Xorg and Frugalware

Just so that I don’t forget about this when Frugalware 1.8 is released:

xorg merge

Xorg upgrades have been merged to current. There is some manual intervention required due to strict version depends. You will need to remove some packages by force before you can complete your next system upgrade. This command should assist you in this:

pacman-g2 -Rd ffmpeg-compiletime ffmpeg-0.6 ffmpeg-0.6-compiletime

Changing the hostname in Frugalware

This is just a quick note so that I know where to look next time break things badly enough to need to reinstall. The default hostname used by Frugalware is not the hostname I want to use and after a bit of poking around, I have found that there are two files that need to be amended in order to change this.

The files are:

  • /etc/hostname
  • /etc/NetworkManager/nm-system-settings.conf

The actual change you need to make will be obvious as soon as you open the file.

Some more Bash customisations

Following on from yesterday’s post I have spent a bit of time playing around with the various Bash configuration options. The ArchWiki has proved invaluable in this (especially the Bash and Color Bash Prompt pages). Also worth a mention is nixCraft’s How to: Change / Setup bash custom prompt (PS1) and Bash Shell PS1: 10 Examples from The Geek Stuff.

The upshot of all this is that I have removed my mods out of /etc/profile and into ~/.bashrc. This means that I have a persistent script1 and one that I can easily share by pointing you towards my Configurate repository on GitHub.

1 When I say persistent in this context, I am referring to the fact that I have a seperate /home partition so that anything in /home (like, my data) will remain untouched by any future upgrades or re-installs.

Frugalware 1.7: First impressions and some notes on configuration

Last night, I finally found the time to upgrade my Frugalware install from 1.6 to 1.7. Truth be told, I gave up on upgrading and simply installed 1.7, but the effect is the same.

My first impressions are good – it looks lovely and a lot of the minor glitches I was struggling with appear to have been ironed out. So I shall stick with it for a bit and see how I get on.

This means, it’s time to start removing some of Bash aliases and this post is largely so that I can look up what I did just in case I find myself needing to do it again.

First off, the ls command. By default, this command is aliased to a collection of options, one of which (-F) causes a trailing slash to be appended to directory names. This annoys me and it has to go.

The alias command reveals that ls is aliased to ls='/usr/bin/ls $LS_OPTIONS'
So all I need to do is amend $LS_OPTIONS so that the -F switch is removed:

LS_OPTIONS='--color=auto -b -T 0'

Next to go is the manual confirm. The cp, mv and rm commands all have the -i flag switched on. This causes a stream of prompts when I am dealing with multiple files and it has to go:

unalias mv
unalias rm
unalias cp

And that’s it.

As for Frugalware itself, there is a lot to like about the distro and I can see myself sticking with it for a while. But for now, here’s a screenshot.

And now for the inevitable update.

Obviously, the changes described above only affect the current terminal session. As soon as you start a new session, everything is reset. So you need to edit your /etc/profile file to make the changes permanent.

The interactive mode for mv, cp and rm is easy enough. The aliases are defined at the bottom of the file and simply need to be suppressed:

# Aliases for newbies:
# alias rm='rm -i'
# alias cp='cp -i'
# alias mv='mv -i'

And then I added a line to make the ls command look the way I wanted:

# A nicer way to ls
export LS_OPTIONS='--color=auto -b -T 0'

And I really am done this time.

And… We’re back

It is stating the obvious to say that no operating system is perfect. But one of the things that I really like about being a Linux user is that I have enough control of my system that I am able to fix problems, even when I do something really stupid.

Having a separate /home partition meant that I could re-install from my Frugalware 1.6 DVD to get back to where I was this time last night.

I shall upgrade to Gaia at the weekend when I have a little more time.

Upgrading without backups, or: How I learned to stop worrying and break my system

I have to admit that, when it comes to keeping my laptop up to date, I have been spoiled by Sabayon’s rolling release model. Put simply, I never needed to worry about upgrading to the next release because the cumulative weekly updates took care of this for me.

However, I now have Frugalware installed and, yesterday, version 1.7 was released. The upgrade process looked pretty straightforward so I pushed the button.

Installing the new improved pacman-g2 went fine, but then things turned a little pear-shaped. The actual upgrade threw a couple of dependency issues at me. I wouldn’t be surprised to learn that these were caused my me tinkering over the last few days, but it was late and I was too tired to resolve them properly, so I figured the next best thing would be to ignore them. What could possibly go wrong?

So, it was with a pacman-g2 -Sud --noconfirm, that I started the upgrade.

Did I mention that I hadn’t bothered to back anything up? Or that I was using a wifi connection?

Inevitably the connection dropped about two-thirds the way through.

Oh happy, happy days.

Once things were up and running again, however, Pacman did successfully pick up where the connection broke and I now have Frugalware 1.7: Gaia running on my laptop.

Apart from the fact that Gnome desktop won’t start (hey, remember those dependency issues?)

By this point, it was late and I was tired, so I went to bed. This means that tonight, I will be mainly unbreaking my laptop.

Distrohopping: Frugalware

I have been using Sabayon for a while, and there is a lot to like about this distro. It’s fast, rapidly updated and works well out of the box and, for someone like me (who wants all the latest shiny for minimal effort) it is an excellent fit. But no operating system is perfect and I have, over the past few days, been poking around Distrowatch to see what else is out there.

The upshot of all this is that August strikes me as a good time to take a look at Frugalware Linux. According to the Frugalware Wiki, the Frugalware philosophy is about…

simplicity, multimedia, design. We try to make Frugalware as simple as possible while not forgetting to keep it comfortable for the user. We try to ship fresh and stable software, as close to the original source as possible, because in our opinion most software is the best as is, and doesn’t need patching.

Which certainly appeals to me.

The Install

Looking through the Frugalware documentation, everything I could see indicated that the installer was text based. So it was a pleasant surprise to find a GUI option when I booted into the install disk. Unfortunately, the GUI fell apart when I reached the package selection step. So, back to the default option.

That said, the installation itself proved to be pretty painless. The hardware detection worked well, coming up with the correct defaults where necessary, and the installer guides you through the partitioning process with the minimum of fuss.

Then onto the package selection. Being a bit of a Gnome fanboy, I decided not to bother with either KDE or XFCE but for everything else I accepted the defaults.

The install itself is very fast indeed. Frugalware uses the Pacman package manager and I have seen people talk about how fast this is. It is impossible fully appreciate this until you have watched the installation updates shoot past faster than you can actually read them.

And, we’re in.

First Impressions

It’s Beautiful. Seriously. I don’t think I’ve ever booted up a laptop and been instantly blown away by the desktop. It’s so subtle, so consistent and so nicely done that I find myself liking it all over again every time I launch another application.

And on the subject of applications, take a look at these icons. Are they not gorgeous?

On a less positive note, it appears that the network manager isn’t starting up automatically for some reason. After I’d finished drooling over the icons I realised that I had no wireless icon and when I went to the Network Settings, it told me: “The system network services are not compatible with this version.”

Not great. I can start the network manager manually by firing up a terminal and entering # NetworkManager, but this is not something I want to be doing on a regular basis.

But first, I shall restore my data and then start finding my way around Pacman.