Posts Tagged ‘ubuntu’

Using Nautilus in Xubuntu 11.10

Like many people, I’ve found the new things in the Linux desktop environment world – i.e. GNOME 3 and Unity – to be more of a hindrance than a help. For this reason I’ve switched to Xubuntu, which allows me to stick to my previous multi-window multi-desktop multi-monitor workflow.

People making this transition might not find themselves too comfortable with XFCE’s file manager, Thunar. Switching the default file manager to Nautilus (GNOME’s file manager) is actually pretty simple, however there are a few issues with correctly handling the desktop background and icons. The setup described here will switch the default file manager to Nautilus, but leave XFCE and Thunar in control of the desktop. This is because Nautilus, if allowed to control the desktop icons, will also try and set the desktop background. Complete control of its background settings is only possible by manually editing dconf settings, or using gnome-control-center which depends on the whole of GNOME being installed. Of course if you already have desktop icons disabled you won’t notice any change in desktop handling at all.

So on with the show. Obviously, you first need to install Nautilus:

sudo apt-get install nautilus

Next, you need to tell XFCE to use Nautilus as the default file manager. This can be done through: XFCE menu -> Settings -> Settings Manager -> Preferred Applications -> “Utilities” tab -> “File Manager” drop-down.

Now any time you open a folder you should get Nautilus instead of Thunar. Unfortunately the first time you do this Nautilus will realise it isn’t managing the desktop and will try to do so. This behaviour can be disabled by setting the appropriate dconf entry:

sudo apt-get install dconf-tools
dconf write /org/gnome/desktop/background/show-desktop-icons false

If you have desktop icons enabled in XFCE what you have is an instance of Thunar displaying the contents of ~/Desktop, which means any directory you double-click on will also launch in Thunar. This probably isn’t what we want, but unfortunately we can’t change this default behaviour. What we can do is make it easier to launch the directory in Nautilus by adding a “custom action” – the end result will be a “Open in Nautilus” item in the context menu when you right click directories on the desktop.

Launch Thunar and open the “Custom Actions” dialog (Edit -> Configure custom actions…). Add a new action, setting the command to nautilus %F and making sure only “Directories” is checked on the “Appearance Conditions” tab. Also check “Startup notification” and set the icon to be the correct one for Nautilus. If this is too much like hard work, the following ugly shell one-liner should achieve the same result:

mv .config/Thunar/uca.xml .config/Thunar/uca.xml.bak ; sed 's/<\/actions>$/<action><icon>nautilus<\/icon><name>Open in Nautilus<\/name><command>nautilus %F<\/command><description><\/description><patterns>*<\/patterns><startup-notify\/><directories\/><\/action><\/actions>/' .config/Thunar/uca.xml.bak > .config/Thunar/uca.xml

If you used the shell one-liner, the change will only take effect on new instances of Thunar. If you don’t want to logout of XFCE and login again, this can be achieved by opening the Settings Manager, going to Desktop -> “Icons” tab, and switching “Icon type” to “None” and back to “File/launcher icons”.

Of course the nicest result would have been to have Nautilus managing the desktop instead. At first glance this looks like it should be possible, since there is a /org/gnome/desktop/background/draw-background setting in dconf, however changing this setting has no effect on Nautilus’ behaviour.

Spoofing MAC address on Ubuntu Maverick

Continuing the trend of accidentally disabling hacks that people rely on, it now no longer appears to be possible to set your network card’s MAC by adding a line like the following to /etc/rc.local:

ifconfig eth0 hw ether 00:0C:xx:xx:xx:xx

It seems that for some reason something (presumably NetworkManager) is resetting the device’s MAC address when the computer wakes from suspend. However, at the same time, the “Cloned MAC address” field has been added to NetworkManager’s “Edit connection” dialog, and this is where your desired MAC address should be entered.

Remapping Mouse Buttons on Ubuntu Lucid

For ergonomic reasons (discussed previously) I like a side button on my mouse to act as a middle button instead.  Unfortunately there still doesn’t seem to be an “easy” way to remap mouse buttons in Linux, and what’s more the method of changing such settings seems to keep changing.  To achieve the same results in Ubuntu Lucid, I added an Xorg configuration fragment at /usr/lib/X11/xorg.conf.d/20-logitech-mx1100.conf:

Section "InputClass"
        Identifier "Logitech MX1100 button remap"
        MatchProduct "Logitech USB Receiver"
        MatchDevicePath "/dev/input/event*"
        Option "ButtonMapping" "1 2 3 4 5 6 7 2 9 10"
EndSection

As with the previous method, xinput list should give you the product string to use for MatchProduct.

Fixing ugly Qt fonts in GNOME

So far every time I’ve used Qt applications under GNOME, especially VirtualBox, I’ve found the Qt font rendering to be appalling.  See this screenshot of VirtualBox alongside the GNOME appearance dialog:

screenshot_001

As you can see, most of my font settings are at the default “Sans” font.  The “Sans” and “Sans serif” fonts , at least in recent Ubuntu releases, refer to the corresponding DejaVu font variants (previously it was Bitstream Vera).  However as I found out through experimentation, whilst Qt is obeying my font settings, the generic “Sans” font seems to mean something completely different (at least to Qt4).  If I instead specify the DejaVu fonts directly in my font settings, the correct font rendering is used:

screenshot_002

So that’s it: if you’re using GNOME and you seem to get a Qt font rendering that doesn’t match your GTK font rendering, try using a more specific font.  (Note: I haven’t got a clue what “Sans” actually means to GNOME, but it doesn’t appear to be a font in it’s own right.)

Enable Bitmap Fonts on Ubuntu Jaunty

I like to use tiny bitmap fonts like MonteCarlo for programming, but by default Ubuntu has bitmap font support turned off.  From (at least) Gutsy through to Intrepid, this method worked for enabling bitmap font support, but after installing the Jaunty beta I found this no longer works.

Luckily, after a brief look in /etc/fonts, I found that font configuration now follows the nice pattern of a conf.avail directory containing all the available configuration parts, and conf.d containing symlinks to these parts.  This makes enabling bitmap fonts even simpler now:

# "Un-disable" bitmap fonts
sudo rm /etc/fonts/conf.d/70-no-bitmaps.conf
# Clear the font cache
sudo fc-cache -f -v

Now you should be able to drop bitmap (i.e. PCF) fonts into ~/.fonts as you would with TTF fonts and be able to use them with no extra hassle.

Update: Andreas asked in the comments if there was a way to do this that doesn’t require root access. In fact there is! If you copy /etc/fonts/conf.avail/70-force-bitmaps.conf to ~/.fonts.conf then it has the same effect. (If you already have a ~/.fonts.conf then you’ll want to merge them together – copy everything inside <fontconfig>...</fontconfig> from 70-force-bitmaps.conf and put it just before </fontconfig> in ~/.fonts.conf)

MPD + PulseAudio + Ubuntu Intrepid (8.10)

Update (2009-04-12): It appears that in Jaunty everything now obeys the system-wide setting properly, so you only need to edit /etc/default/pulseaudio and add the user to pulse-access.

I’m a big fan of Music Player Daemon (MPD), and up until the last few months I used it almost exclusively.  It’s lightweight, it’s good at what it does, and there are a lot of different frontends available.  One of the things I like most is that it’s not tied to a graphical session in any way—you don’t need a GUI open for it to be playing music.  Normal usage of MPD involves it being started and stopped as a system service.

Unfortunately, this doesn’t play too nice with the concept of how PulseAudio should be used.  PulseAudio is very user- and session-centric, and the recommended setup means than when nobody is logged in, no sound is going to be playing.  While MPD is capable of playing to a PulseAudio server just fine, having the sound server tied to the graphical session means it doesn’t have a sound device to attach to at boot, and the sound device suddenly disappears if the user logs off.

Ubuntu has used PulseAudio for as many applications as possible by default since Hardy (8.04), and while it can be removed, doing so can make life difficult.  This led me to pursue the option of a system-wide instance which everything uses, and which is always running.  But no matter how hard I tried, I got stuck with the same bug: starting GNOME would always result in a per-session instance being spawned in addition to the system-wide one, the two would fight over the sound card, and I would have to manually kill the new one every time I logged in.  Eventually I’d had enough of this and started using something else.

Today, I decided to take another stab at getting this set up properly and finding out where that second PulseAudio instance was coming from.  Thanks to the help of a couple of people in #pulseaudio on FreeNode IRC, I was able to figure out how to do this, so here is the method I used for the benefit of anybody else in the same position.

Stop PulseAudio spawning per-session

By default PulseAudio puts a script in /etc/X11/Xsession.d which causes a “pulseaudio” instance to be spawned with every X session.  The first step is to move this script somewhere else so it’s never run:

$ sudo mv /etc/X11/Xsession.d/70pulseaudio /root/

The second cause of “pulseaudio” being spawned is less obvious.  There is an Esound compatibility layer for PulseAudio so that applications depending on it still work, transparently.

$ ls -l /usr/bin/esd
lrwxrwxrwx 1 root root 9 2009-03-04 11:03 /usr/bin/esd -> esdcompat

However, as of Ubuntu Intrepid (8.10) there is pretty much nothing which depends solely on Esound, but it still gets spawned when GNOME starts.  This causes a PulseAudio session to be spawned for the current user if one can’t be found.  The simple but ugly fix is to move this link to somewhere else:

$ sudo mv /usr/bin/esd /usr/bin/esd.bak

Set up a system-wide PulseAudio instance

To get PulseAudio to actually start on boot, you need to set a variable to tell the init script you want this to happen. Make sure you have the following line in /etc/default/pulseaudio:

PULSEAUDIO_SYSTEM_START=1

Any users that will be using the system-wide PulseAudio instance need to be members of the correct groups. This will most likely be your own user, plus whatever user MPD is running as (“mpd” by default). For each of these users, do:

$ sudo usermod -a -G pulse-access <user>
$ sudo usermod -a -G pulse <user>
$ sudo usermod -a -G pulse-rt <user>

Getting it up and running

First thing’s first, you need to tell MPD to use PulseAudio. This can be achieved by adding the following to /etc/mpd.conf:

audio_output {
       type    "pulse"
       name    "My MPD PulseAudio Output"
}

If you’re feeling lazy, the easiest thing to do right now would be reboot. Otherwise, you’ll need to kill all “pulseaudio” instances, restart the system-wide instance, and restart MPD.

$ sudo /etc/init.d/mpd stop
 * Stopping Music Player Daemon mpd                   [ OK ]
$ sudo killall -KILL pulseaudio
$ sudo /etc/init.d/pulseaudio restart
 * Stopping PulseAudio Daemon                         [ OK ]
 * Starting PulseAudio Daemon                         [ OK ]
$ sudo /etc/init.d/mpd start
 * Starting Music Player Daemon mpd                   [ OK ]

Finally, log out and log back in again to allow your per-session pulseaudio instance to die and for your new group memberships to take effect.

Caveats

  • You get “real-time” processing without any extra effort; by default the system-wide instance will run with priority -11.
  • Some apps are not PulseAudio-aware, but they can usually use an ALSA output; this guide shows you how to redirect ALSA through PulseAudio if you have any problems with the default setup.
  • Updates may undo the moving-a-file type of changes.