KDE Connect – Link your Android device to your KDE desktop

KDE Connect app icon on my Samsung Galaxy Note II

KDE Connect app icon on my Samsung Galaxy Note II

KDE Connect is a nice tool that links your Android phone or tablet seamlessly via WiFi to KDE on your PC (the latter can be connected via WiFi or cable to the network). It allows your KDE desktop to receive notifications, files and media player commands from your Android device. The available KDE Connect plug-ins are:

Battery report
Periodically report battery status

Clipboard sync
Share the clipboard content

Multimedia remote controls
Control audio/video from your phone
(pause; first track; previous track; next track; last track; change volume)

Notification sync
Access your notification from other devices

Ping
Send and receive pings

Telephony notifier
Send notifications from SMS and calls

You will need to install the Android KDE Connect application on your Android device, and the Linux KDE Connect application on your PC.

Install the KDE Connect app on your Android device from the Google Play Store. You will then see the KDE Connect icon on the apps screen of your Android device.

For Gentoo users an ebuild for KDE Connect is available in the Gentoo KDE team’s testing overlay, so here are the instructions on how to install KDE Connect on your PC from there.

Firstly, mask the KDE overlay so that none of the packages in it interferes with the KDE software you installed from the main Portage tree:

# echo "*/*::kde" >> /etc/portage/package.mask

Then unmask the KDE Connect package in the KDE overlay:

# echo "kde-misc/kdeconnect" >> /etc/portage/package.unmask

N.B. If /etc/portage/package.mask is a directory rather than a file (either is possible) in your installation, and if /etc/portage/package.unmask is a directory rather than a file (either is possible) in your installation, use the following commands instead of the above two commands:

# echo "*/*::kde" > /etc/portage/package.mask/kde_overlay
# echo "kde-misc/kdeconnect" > /etc/portage/package.unmask/kdeconnect

Now add the KDE overlay and merge the package:

# layman -a kde
# emerge kdeconnect

If a firewall is running on your PC, you will need to configure it to allow tcp and udp traffic via a specific range of ports (1714 to 1764). I have UFW running on my main laptop, so in my case I used the following commands:

# ufw allow proto tcp to any port 1714:1764
# ufw allow proto udp to any port 1714:1764

The rules should look like this:

# ufw status verbose | grep 1714
1714:1764/tcp ALLOW IN Anywhere
1714:1764/udp ALLOW IN Anywhere
1714:1764/tcp ALLOW IN Anywhere (v6)
1714:1764/udp ALLOW IN Anywhere (v6)

If you have the KConfig Module kcm_ufw installed on your PC then you can instead use System Settings > Firewall to add the UFW rules via the KDE GUI.

By the way, to check which KConfig modules are installed on your PC you can use the following command under your user account:

$ kcmshell4 --list

Using KDE Connect is not difficult, so I will leave you to play with it. Obviously make sure WiFi is enabled on your Android device, and that it and your PC are connected to the same network. Tap on the KDE Connect icon on your Android device to launch the app, and you should see your PC’s name listed under CONNECTED DEVICES. Tap on the PC name and you should see the following screen:

KDE Connect screen

KDE Connect screen

If you tap on ‘Send ping’, the KDE Notification widget on the KDE System Tray should pop up a notification.

You can see what KDE Connect plug-ins are available, and select/deselect them:

KDE Connect plugins

KDE Connect plugins

KDE Connect also enables you to use your Android device as a remote control for media players running on your PC. When you launch a media player in KDE its name will appear in a list of selectable players in KDE Connect, and the name of the track currently playing will also be displayed:

KDE Connect - Remote control

KDE Connect - Remote control

When you select a file on your Android device and tap the Share icon, KDE Connect will be one of the options displayed on the ‘Share via’ menu. This is a handy way to send files from your Android device to your PC. The KDE Notification widget on your PC will notify you when the file has been transferred to ~/Desktop/ on your PC:

KDE on your PC notifies you when a file has been sent via KDE Connect

KDE on your PC notifies you a file has been sent via KDE Connect

You should also get notifications on your KDE desktop when someone phones or sends you an SMS.

Kudos and many thanks to the people responsible for KDE Connect. KDE is already a superb desktop environment, and with the addition of KDE Connect it is better still.

ARTE Live Web videos

The Franco-German cultural Web site ARTE Live Web is an excellent resource for lovers of music (classical, jazz, alternative and World) and dance. The show videos at the site are enjoyable but unfortunately only viewable for a fixed period of time before the site removes them. Back in 2011 I wanted to download the video of a performance I’d attended and loved. I searched for a Linux tool but could not find one, then found a Windows freeware GUI tool called artepupper, and used version 0.2 to download the video. You can read about the tool on the author’s blog pages artepupper 0.1, artepupper 0.2 and artepupper 0.3. The reason for the change from 0.2 to 0.3 was that ARTE Live Web changed the format of an embedded URL inside the XML page for the video on their Web site.

Now, artepupper is based on livewebarte1.1.sh, a 2010 Bash script by Carmelo Ingrao, and a Perl script livewebarte.pl by Juan Domingo based on livewebarte1.1.sh, both of which are still available on line at Carmelo’s download page and which I only discovered after using artepupper in Windows. I tried the Perl script in Linux back in 2011, and it worked for me.

Recently I wanted to download another video from the ARTE Live Web site and found that, although artepupper 0.3 in Windows worked, the Perl script livewebarte.pl no longer worked. Presumably this was because of the aforementioned change to the embedded URL. However, I found that the Bash script livewebarte1.1.sh still worked. Actually, I had to edit the script to replace “./rtmpdump” with “rtmpdump“, as I had installed the command-line tool rtmpdump using the Linux distribution’s package manager and the executable is not stored in the same directory as the Bash script. But, apart from that, it worked.

Carmelo is a star for having deciphered how to access and download videos from the site. However, looking at his Bash script, the part where he parses a line in the XML code and extracts a string between the delimiters “MP4″ and “mp4″ is based on a hard-coded character position, which could change if the Web site’s owners change the format of the URL. So I decided to modify the Bash script to avoid using character positions to extract a string. The Bash script livewebarte1.2.sh is an updated version of Carmelo’s livewebarte1.1.sh script.

#!/bin/bash
# Script pour récupérer les vidéos FLV du site liveweb.arte.tv
# par Carmelo Ingrao <carmelo42@gmail.com> http://c.ingrao.free.fr/code/
# version 1.0
# release date 21 février 2010
## modified by Fitzcarraldo 24 April 2013
## version 1.2
## release date 24 April 2013
# licence : GPLv2
# rtmpdump compilé doit être dans le même répertoire que le script
## rtmpdump must be installed and in user's $PATH (e.g. I have it in /usr/bin/)
# utilisation du script :
#
# ./script.sh url fichier.flv
# _______________

# url --> $1
# fichier --> $2

# fichier de sortie
# on efface l'écran avant de commencer
clear

# on affiche les infos sur le script
echo "livewebarte.sh version 1.0."
echo "(c) 2010 Carmelo Ingrao; License : GPL"
echo "livewebarte.sh version 1.2."
echo "updated from version 1.1 by Fitzcarraldo on 24 April 2013; License : GPL"
echo "usage : ./livewebarte.sh url_concert_sur_liveweb.arte.tv fichier.flv"
echo "rtmpdump must be installed and in your path."

# on télécharge le code source de la page streamant le concert dans le fichier sourceconcert.html
wget $1 -O sourceconcert.html

# on récupère le numéro d'event et on le copie dans eventok.txt
#cat sourceconcert.html | grep "new LwEvent" > event.txt
#cat event.txt | cut -b "15 16 17" > eventok.txt
grep "new LwEvent" sourceconcert.html | grep -E -o -e "[0-9]+" > eventok.txt

# on prend le fichier XML d'arte et on crée l'url avec le bon numéro d'event
# xmloriginal="http://arte.vo.llnwd.net/o21/liveweb/events/event-610.xml"

# url du xml sans le numéro d'event original (pour faciliter)
xmloriginal2="http://arte.vo.llnwd.net/o21/liveweb/events/event-"

# on assigne à la variable b le contenu de eventok.txt --> numéro correct d'event
b=$(cat eventok.txt)

# on créer l'url correct du fichier XML qu'on téléchargera
xmlok=$(echo $xmloriginal2$b)
finxml=".xml"
xmlfinal=$(echo $xmlok$finxml)

# on télécharge le bon XML
wget $xmlfinal -O xmlok.xml
echo "Fichier XML téléchargé"

## I have changed the code in this part:
# on extrait le nom du fichier MP4 depuis le fichier xmlok.xml
mp4hd=$(cat xmlok.xml | grep "urlHd")
# on efface le début de l'url du MP4
# on efface le surplus à la fin du nom du MP4 et on sauve le nom dans la variable mp4hdcut2
mp4hdcut2=${mp4hd#*MP4}
mp4hdcut2=${mp4hdcut2%%mp4*}
mp4hdcut2="MP4"$mp4hdcut2"mp4"
## end of my changes to evaluate mp4hdcut2

# on lance la commande rtmpdump avec les paramètres
# rappel :
# $2 = nom du fichier de sortie
# $mp4hdcut2 = nom du fichier MP4

## Carmelo had ./rtmpdump here, but I removed the "./"
rtmpdump -r rtmp://arte.fcod.llnwd.net:1935/a2306/o25 -a a2306/o25 -f LNX 10,0,45,2 -W http://liveweb.arte.tv/flash/player.swf -t rtmp://arte.fcod.llnwd.net:1935/a2306/o25 -p http://liveweb.arte.tv/ -o $2 -y $mp4hdcut2

# on efface les fichiers crées
rm sourceconcert.html
#rm event.txt
rm eventok.txt
rm xmlok.xml

# Affichage des infos de fin
echo "________"
echo "Voilà, le téléchargement est terminé."
echo "Le fichier se trouve ici :"
echo " "
echo $2
echo " "
echo "Bon visionnage"
echo " "
echo " "
exit 0

Save it in your home directory and make it executable:

$ chmod +x livewebarte1.2.sh

Also make sure you have the package rtmpdump installed and that it is in your $PATH.

Then you can browse the ARTE Live Web site and select the performance video you wish to download. Hover the mouse pointer over the video pane and click on “INTEGRER LA VIDEO” to find the URL for that video, which will be of the form http://liveweb.arte.tv/fr/video/foo/, where “foo” is some string of characters (not literally “foo”, of course). The command to download it is then as shown below. I’ll use a file name foo.flv here, but any prefix would do:

$ ./livewebarte1.2.sh http://liveweb.arte.tv/fr/video/foo/ foo.flv

Note that it is essential to include the forward slash at the end of the URL. The file will be downloaded to your home directory and you can watch it in VLC or any other Linux media player that plays Flash video.

So there you have it; currently you can use artepupper 0.3 in Windows or livewebarte1.2.sh in Linux to download from ARTE Live Web a video of a performance you attended and loved.

Switching the display quickly between a laptop monitor and an external monitor or projector in Linux

laptop_with_external_monitor_and_keyboardI connect my laptop to an external keyboard and an external monitor or projector in various offices and at home, and each of the monitors has a different resolution. Fn-F3 on my laptop keyboard allows me to toggle between monitors, but I want more control (including the ability to specify the resolution of the external display). Now, I find the GPU manufacturer’s application and the Desktop Environment’s GUI for switching monitors and changing screen resolution rather cumbersome, so I wanted an icon on the Desktop that I could double-click to switch monitors without having to enter the root user’s password and fiddle around too much. So I decided to create some simple Bash scripts and associated Desktop Config files with nice-looking icons on the desktop, which I can launch easily and quickly by double-clicking. Obviously the resolutions are limited to the range of resolutions supported by the GPU and external monitor.

The suite of Desktop Config files I created have self-explanatory names:

$ cd ~/Desktop
$ ls -1 Switch*
Switch_OFF_laptop_monitor_if_external_monitor_is_connected
Switch_OFF_laptop_monitor_if_external_monitor_is_connected_auto
Switch_ON_laptop_monitor_and_external_monitor
Switch_ON_laptop_monitor_and_switch_off_external_monitor
$ ls -1 Toggle*
Toggle_display

The difference between Switch_OFF_laptop_monitor_if_external_monitor_is_connected and Switch_OFF_laptop_monitor_if_external_monitor_is_connected_auto is that the former prompts for the resolution of the external monitor whereas the latter tries to find the resolution automatically. I have both because I have found that, for some external display devices (e.g. projectors), it is handy to have the ability to specify the resolution manually.

Switch off the laptop monitor if an external monitor is connected (find resolution automatically)

The Desktop Config file I double-click the most is ~/Desktop/Switch_OFF_laptop_monitor_if_external_monitor_is_connected_auto, and it contains the following text:

[Desktop Entry]
Comment[en_GB]=switch off laptop monitor if external monitor is connected auto
Comment=switch off laptop monitor if external monitor is connected auto
Exec=sh /home/fitzcarraldo/switch_off_laptop_monitor_if_external_monitor_is_connected_auto.sh
GenericName[en_GB]=Switch off laptop monitor if external monitor is connected auto
GenericName=Switch off laptop monitor if external monitor is connected auto
Icon=/home/fitzcarraldo/Pictures/Icons/display.png
MimeType=
Name[en_GB]=Switch_OFF_laptop_monitor_if_external_monitor_is_connected_auto
Name=Switch_OFF_laptop_monitor_if_external_monitor_is_connected_auto
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=

The Bash script it launches, ~/switch_off_laptop_monitor_if_external_monitor_is_connected_auto.sh, contains the following code:

#!/bin/bash
if xrandr -q | grep "CRT1 connected"; then
  xrandr --output LVDS --off
  xrandr --output CRT1 --off
  xrandr --output CRT1 --auto
else
  xrandr --output CRT1 --off
  xrandr --output LVDS --off
  xrandr --output LVDS --mode 1920x1080
# 1920x1080 is the native resolution of my laptop monitor
fi

Don’t forget to make them executable:

$ chmod +x /home/fitzcarraldo/Desktop/Switch_OFF_laptop_monitor_if_external_monitor_is_connected_auto
$ chmod +x /home/fitzcarraldo/switch_off_laptop_monitor_if_external_monitor_is_connected_auto.sh

If you’re wondering how I knew I had to specify ‘CRT1′ and ‘LVDS’ in the Bash script, I used the xrandr command to find out what names the GPU gives the monitors:

$ xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 1920 x 1920
LVDS connected (normal left inverted right x axis y axis)
1920x1080 60.0 +
1680x1050 60.0
1400x1050 60.0
1600x900 60.0
1280x1024 60.0
1440x900 60.0
1280x960 60.0
1280x768 60.0
1280x720 60.0
1024x768 60.0
1024x600 60.0
800x600 60.0
800x480 60.0
640x480 60.0
DFP1 disconnected (normal left inverted right x axis y axis)
CRT1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 476mm x 268mm
1920x1080 60.0*+
1280x1024 75.0 60.0
1280x960 60.0
1280x800 59.8
1152x864 75.0
1280x720 60.0
1024x768 75.0 70.1 60.0
800x600 72.2 75.0 60.3 56.2
640x480 75.0 72.8 67.0 59.9

Switch off the laptop monitor if an external monitor is connected (enter resolution)

The Desktop Config file I double-click is ~/Desktop/Switch_OFF_laptop_monitor_if_external_monitor_is_connected, and it contains the following text:

[Desktop Entry]
Comment[en_GB]=switch off laptop monitor if external monitor is connected
Comment=switch off laptop monitor if external monitor is connected
Exec=sh /home/fitzcarraldo/System_Administration/switch_off_laptop_monitor_if_external_monitor_is_connected.sh
GenericName[en_GB]=Switch off laptop monitor if external monitor is connected
GenericName=Switch off laptop monitor if external monitor is connected
Icon=/home/fitzcarraldo/Pictures/Icons/display.png
MimeType=
Name[en_GB]=Switch_OFF_laptop_monitor_if_external_monitor_is_connected
Name=Switch_OFF_laptop_monitor_if_external_monitor_is_connected
Path=
StartupNotify=true
Terminal=true
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=

The Bash script it launches, ~/switch_off_laptop_monitor_if_external_monitor_is_connected.sh, contains the following code:

#!/bin/bash
if xrandr -q | grep "CRT1 connected"; then
echo -n "Enter resolution width of external monitor (hint 1920 Doha, 1440 home): "
read EXTERNAL_WIDTH
echo -n "Enter resoluton height of external monitor (hint 1080 Doha, 900 home): "
read EXTERNAL_HEIGHT
  xrandr --output LVDS --off
  xrandr --output CRT1 --off
  xrandr --output CRT1 --mode $EXTERNAL_WIDTH"x"$EXTERNAL_HEIGHT
else
  xrandr --output CRT1 --off
  xrandr --output LVDS --off
  xrandr --output LVDS --mode 1920x1080
# 1920x1080 is the native resolution of my laptop monitor
fi

Don’t forget to make them executable:

$ chmod +x /home/fitzcarraldo/Desktop/Switch_OFF_laptop_monitor_if_external_monitor_is_connected
$ chmod +x /home/fitzcarraldo/switch_off_laptop_monitor_if_external_monitor_is_connected.sh

Switch on the laptop monitor and external monitor simultaneously

I don’t need to use this one much, only when I am using an external monitor but suddenly want to use the laptop’s built-in Webcam and so have to open fully the laptop’s lid. The file ~/Desktop/Switch_ON_laptop_monitor_and_external_monitor contains the following text:

[Desktop Entry]
Comment[en_GB]=switch_ON_laptop_monitor_and_external_monitor
Comment=switch_ON_laptop_monitor_and_external_monitor
Exec=sh /home/fitzcarraldo/switch_on_laptop_monitor_and_external_monitor.sh
GenericName[en_GB]=Switch_ON_laptop_monitor_and_external_monitor
GenericName=Switch_ON_laptop_monitor_and_external_monitor
Icon=/home/fitzcarraldo/Pictures/Icons/display.png
MimeType=
Name[en_GB]=Switch_ON_laptop_monitor_and_external_monitor
Name=Switch_ON_laptop_monitor_and_external_monitor
Path=
StartupNotify=true
Terminal=true
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=

and the Bash script it calls, ~/switch_on_laptop_monitor_and_external_monitor.sh, contains the following code:

#!/bin/bash
if xrandr -q | grep "CRT1 connected"; then
  echo "Note that the resolution specified must be the same for both monitors, and must be achievable on both monitors."
  echo -n "Enter resolution width of external monitor (hint 1920 office, 1440 home): "
  read EXTERNAL_WIDTH
  echo -n "Enter resoluton height of external monitor (hint 1080 office, 900 home): "
  read EXTERNAL_HEIGHT
  #xrandr --output LVDS --off
  xrandr --output LVDS --mode $EXTERNAL_WIDTH"x"$EXTERNAL_HEIGHT
  xrandr --output CRT1 --off
  xrandr --output CRT1 --mode $EXTERNAL_WIDTH"x"$EXTERNAL_HEIGHT
else
  xrandr --output CRT1 --off
  xrandr --output LVDS --off
  xrandr --output LVDS --mode 1920x1080
# 1920x1080 is the native resolution of my laptop monitor
fi

Don’t forget to make them executable:

$ chmod +x /home/fitzcarraldo/Desktop/Switch_ON_laptop_monitor_and_external_monitor
$ chmod +x /home/fitzcarraldo/switch_on_laptop_monitor_and_external_monitor.sh

Switch on the laptop monitor and switch off an external monitor

I don’t need to use this one much either, given that the display mode reverts to the laptop monitor after I reboot or shutdown/power-up the laptop. The file ~/Desktop/Switch_ON_laptop_monitor_and_external_monitor contains the following text:

[Desktop Entry]
Comment[en_GB]=switch on laptop monitor and switch off external monitor
Comment=switch on laptop monitor and switch off external monitor
Exec=sh /home/fitzcarraldo/switch_on_laptop_monitor_and_switch_off_external_monitor.sh
GenericName[en_GB]=Switch on laptop monitor and switch off external monitor
GenericName=Switch on laptop monitor and switch off external monitor
Icon=computer-laptop
MimeType=
Name[en_GB]=Switch_ON_laptop_monitor_and_switch_off_external_monitor
Name=Switch_ON_laptop_monitor_and_switch_off_external_monitor
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=

The Bash script it launches, ~/switch_on_laptop_monitor_and_switch_off_external_monitor.sh, contains the following code:

#!/bin/bash
xrandr --output CRT1 --off
xrandr --output LVDS --auto
xrandr --output LVDS --mode 1920x1080
# 1920x1080 is the native resolution of my laptop monitor

I did also create a fifth Desktop Config file and associated Bash script, to toggle between the three modes (laptop monitor only > both monitors > external monitor only) rather than having to double-click three different icons. But, to be honest, it’s quicker and easier to have the three icons and double-click on the one I want rather than toggling through three display modes. Anyway, in case you are interested, the Desktop Config file ~/Desktop/Toggle_Display contains the follow text:

[Desktop Entry]
Comment[en_GB]=Toggle between laptop monitor, external monitor and both
Comment=Toggle between laptop monitor, external monitor and both
Exec=sh /home/fitzcarraldo/toggle_display.sh
GenericName[en_GB]=Toggle between laptop monitor, external monitor and both
GenericName=Toggle between laptop monitor, external monitor and both
Icon=video-display
MimeType=
Name[en_GB]=Toggle_display
Name=Toggle_display
Path=
StartupNotify=false
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=

and the Bash script it launches, ~/switch_on_laptop_monitor_and_external_monitor.sh, contains the following code:

#!/bin/sh

# Using the xrandr command I found that the two video outputs from my laptop are named LVDS
# (the internal display) and CRT1 (the external display driven by the laptop's VGA socket).
# My external monitor at home has a resolution of 1440x900.

CONNECTED=`xrandr | grep -i ' connected' | grep LVDS | awk '{print $1}'`
CONNECTED="${CONNECTED} `xrandr | grep -i ' connected' | grep CRT | awk '{print $1}'`"

ENABLED=`awk '{print;exit}' ~/displays_enabled 2>/dev/null`

if [ "$CONNECTED" = "LVDS" -o "$CONNECTED" = "LVDS " -o "$CONNECTED" = " LVDS" ]; then
        # Only the internal display is connected, so don't do anything.
        echo "LVDS" > ~/displays_enabled
        ENABLED="LVDS"
        xrandr --output CRT1 --off
        xrandr --output LVDS --off
        xrandr --output LVDS --auto
        exit 0
elif [ "$CONNECTED" = "LVDS CRT1" ]; then
        # Both the internal and external displays are connected, so let's toggle
        # LVDS > LVDS,CRT1 > CRT1

        EXTERNALRES=`xrandr | awk 'c&&c--;/ connected/{c=1}' | awk '{print $1}' | grep 1440x900`
        if [ "$ENABLED" = "LVDS" ]; then
        # Switching on both displays.
                xrandr --output LVDS --off
                if [ "$EXTERNALRES" = "1440x900" ]; then
                         xrandr --output LVDS --mode 1440x900
                         xrandr --output CRT1 --off
                         xrandr --output CRT1 --auto
                else
                         xrandr --output LVDS --auto
                         xrandr --output CRT1 --off
                         xrandr --output CRT1 --auto
                fi
                ENABLED="LVDS CRT1"
                echo "LVDS CRT1" > ~/displays_enabled
        elif [ "$ENABLED" = "LVDS CRT1" ]; then
        # Switching on only external display.
                xrandr --output LVDS --off
                xrandr --output CRT1 --off
                xrandr --output CRT1 --auto
                ENABLED="CRT1"
                echo "CRT1" > ~/displays_enabled
        else
        # Switching on only internal display.
                xrandr --output CRT1 --off
                xrandr --output LVDS --off
                xrandr --output LVDS --auto
                ENABLED="LVDS"
                echo "LVDS" > ~/displays_enabled
        fi
fi

As I use KDE, I also used System Settings > Shortcuts and Gestures | Custom Shortcuts to create a keyboard shortcut which I named ‘Toggle display’, with Meta+P as Trigger and sh ~/toggle_display.sh as Action, but I tend to use the mouse rather than the keyboard in any case.

By the way, you might think some of the xrandr commands in the above Bash scripts are redundant. You would be correct in thinking that, but in practice I found that the displays did not switch if I didn’t include the additional commands shown (due to a bug in xrandr, perhaps?). Even then, when I switch to an external monitor, occasionally the screen resolution is slightly too big or too small, so I placed the icons at the top left of the desktop so that they are always accessible and I can just double-click on the same icon again if necessary. As I’m using KDE, I placed a Folder View Plasmoid for ~/Desktop/ at the top left of the desktop, as you can see in the screenshot.

Desktop showing icons for switching between monitors

Footnote

I’ve been using the above method of switching between displays for a couple of years now with an AMD ATI GPU. It works nicely and suits my needs perfectly. AMD has supported xrandr since 2008 (see Ref. 1), whereas NVIDIA only began to support xrandr last year (see Ref. 2) so I’m not sure how well these scripts would work with NVIDIA GPUs.

Ref. 1: AMD Catalyst 8.9 Gets WINE Fix, RandR 1.2 Support, September 18, 2008
Ref. 2: NVIDIA’s 302 Linux Driver Finally Has RandR 1.2/1.3, May 2, 2012

Setting the wireless regulatory domain in Linux on your laptop

I travel internationally and want to make sure that my laptop uses the legal wireless networking frequencies in the country I am visiting. In Linux, CRDA (Central Regulatory Domain Agent) is the udev helper used to communicate between userspace and the kernel, and it enables you to view and alter the wireless regulatory domain your kernel uses. For more information see the Regulatory page on the Linux Wireless Wiki site.

CFG80211 is the Linux wireless LAN (802.11) configuration API. The kernel on my main laptop has the following configuration settings relating to CFG80211:

# cat /usr/src/linux/.config | grep CFG80211
CONFIG_CFG80211=m
# CONFIG_CFG80211_DEVELOPER_WARNINGS is not set
# CONFIG_CFG80211_REG_DEBUG is not set
CONFIG_CFG80211_DEFAULT_PS=y
# CONFIG_CFG80211_DEBUGFS is not set
# CONFIG_CFG80211_INTERNAL_REGDB is not set
CONFIG_CFG80211_WEXT=y

and the cfg80211 module is loaded:

# lsmod | grep cfg80211
cfg80211 145747 3 iwlwifi,mac80211,iwldvm

I have the package crda installed, and I have the following udev rule file /etc/udev/rules.d/regulatory.rules to allow the kernel to communicate with userspace:

KERNEL=="regulatory*", ACTION=="change", SUBSYSTEM=="platform", RUN+="/sbin/crda"

So, how do you check which wireless regulatory domain your kernel is currently using, and switch to another domain if necessary? These tasks are performed using the iw command. You’ll need to install the package iw if it is not already installed.

To see the regulatory domain your laptop is using now, enter the following command as root user:

iw reg get

When I use the above command on my laptop after start-up, I normally see the following:

# iw reg get
country 00:
(2402 - 2472 @ 40), (3, 20)
(2457 - 2482 @ 20), (3, 20), PASSIVE-SCAN, NO-IBSS
(2474 - 2494 @ 20), (3, 20), NO-OFDM, PASSIVE-SCAN, NO-IBSS
(5170 - 5250 @ 40), (3, 20), PASSIVE-SCAN, NO-IBSS
(5735 - 5835 @ 40), (3, 20), PASSIVE-SCAN, NO-IBSS

The country code 00 is not the code of the country I am in at present. To tell the kernel which wireless regulatory domain you wish to use, enter the following command as root user:

iw reg set ISO_3166-1_alpha-2

where ISO_3166-1_alpha-2 is the 2-character code for the country you are in. You can find the list of ISO 3166-1 alpha-2 codes on the Wikipedia page ISO 3166-1 alpha-2.

For example, if I were in the UK then I would enter the following command:

# iw reg set GB

and the regulatory domain would then be reported like this:

# iw reg get
country GB:
(2402 - 2482 @ 40), (N/A, 20)
(5170 - 5250 @ 40), (N/A, 20)
(5250 - 5330 @ 40), (N/A, 20), DFS
(5490 - 5710 @ 40), (N/A, 27), DFS

It is not a big deal to use the command line, but I wanted to make it even easier. I’m using KDE on my main laptop, so I created a Desktop Configuration File /home/fitzcarraldo/Desktop/Set_wireless_regulatory_domain containing the following:

[Desktop Entry]
Comment[en_GB]=
Comment=
Exec=/home/fitzcarraldo/iw_reg.sh
GenericName[en_GB]=Set wireless regulatory domain
GenericName=Set wireless regulatory domain
Icon=/home/fitzcarraldo/national-flags-icon.png
MimeType=
Name[en_GB]=Set_wireless_regulatory_domain
Name=Set_wireless_regulatory_domain
Path=
StartupNotify=true
Terminal=true
TerminalOptions=\s--noclose
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=

and gave it the following file permissions:

# chmod 744 /home/fitzcarraldo/Desktop/Set_wireless_regulatory_domain
# ls -la /home/fitzcarraldo/Desktop/Set_wireless_regulatory_domain
-rwxr--r-- 1 fitzcarraldo users 496 Jan 15 21:53 /home/fitzcarraldo/Desktop/Set_wireless_regulatory_domain

I used a search engine to find a nice PNG icon consisting of several overlapping national flags, and saved it with the file name name national-flags-icon.png in my home directory.

I created a Bash shell script /home/fitzcarraldo/iw_reg.sh containing the following:

#!/bin/bash
echo "First you need to enter the password of your user account..."
sudo echo ""
echo "The ISO 3166-1 alpha-2 codes are listed on Web page https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2"
echo ""
echo "The current wireless regulatory domain is set as: "
echo ""
sudo iw reg get
echo ""
echo -n "Enter the ISO 3166-1 alpha-2 code (upper case) for the country you are in now, and press ENTER: "
read REGULATORYDOMAIN
sudo iw reg set $REGULATORYDOMAIN
echo ""
echo "The current wireless regulatory domain is now set as: "
echo ""
sudo iw reg get
echo ""
echo "All done. You can close this window."

and gave it the following file permissions:

# chmod 744 /home/fitzcarraldo/iw_reg.sh
# ls -la /home/fitzcarraldo/iw_reg.sh
-rwxr--r-- 1 fitzcarraldo users 632 Jan 15 21:33 /home/fitzcarraldo/iw_reg.sh

Now, if I double-click on the icon for Set_wireless_regulatory_domain on my desktop, a Konsole window pops up with a prompt for me to enter my user account password. When I enter my password the window displays the current wireless regulatory domain the kernel is using and prompts me to enter the 2-character code for the regulatory domain I wish to use instead. When I enter the country code the window displays the new regulatory domain, as shown in the sample below.


First you need to enter the password of your user account...
Password:

The ISO 3166-1 alpha-2 codes are listed on Web page https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

The current wireless regulatory domain is set as:

country SA:
(2402 - 2482 @ 40), (N/A, 20)
(5170 - 5250 @ 20), (3, 23)
(5250 - 5330 @ 20), (3, 23), DFS
(5735 - 5835 @ 20), (3, 30)

Enter the ISO 3166-1 alpha-2 code (upper case) for the country you are in now, and press ENTER: GB

The current wireless regulatory domain is now set as:

country GB:
(2402 - 2482 @ 40), (N/A, 20)
(5170 - 5250 @ 40), (N/A, 20)
(5250 - 5330 @ 40), (N/A, 20), DFS
(5490 - 5710 @ 40), (N/A, 27), DFS

All done. You can close this window.

The task of viewing and changing the regulatory domain after start-up is now very easy for me. The only thing that would be easier than this would be if Linux could detect automatically which country I’m in and set the regulatory domain automatically.

Converting ape music files to mp3 in Linux

I had a file in the lossless ape (Monkey’s Audio) file format, and wanted to convert it to a .mp3 file so that I could play it on my portable mp3 player. As is usual in Linux, several alternative solutions exist, and I thought I’d try three of them for fun: shntool, ffmpeg and KDE’s Konvertible (Konvertible is a GUI for ffmpeg).

I already had ffmpeg and Konvertible installed, but not shntool. So first I installed shntool and the Monkey’s Audio codecs it uses:

# emerge media-sound/mac
# emerge media-sound/shntool

Here are the details of these two installed packages:

# eix -I shntool
[I] media-sound/shntool
Available versions: 3.0.10-r1 {alac flac mac shorten sox wavpack}
Installed versions: 3.0.10-r1(08:11:30 19/12/12)(flac -alac -mac -shorten -sox -wavpack)
Homepage: http://www.etree.org/shnutils/shntool/
Description: A multi-purpose WAVE data processing and reporting utility

# eix -I media-sound/mac
[I] media-sound/mac
Available versions: 3.99.4.5.7-r1^m {mmx static-libs}
Installed versions: 3.99.4.5.7-r1^m(07:52:12 19/12/12)(mmx -static-libs)
Homepage: http://etree.org/shnutils/shntool/
Description: Monkey's Audio Codecs

Then I used the following command to convert the file My Band 1971 CoolSounds.ape to mp3:

$ shntool conv -i ape -o 'cust ext=mp3 lame - %f' My\ Band\ 1971\ CoolSounds.ape
Converting [My Band 1971 CoolSounds.ape] (59:15.39) --> [My Band 1971 CoolSounds.mp3] : 100% OK
$

The KDE utility Konvertible was also able to convert it. I double-clicked on the file My Band 1971 CoolSounds.ape in Dolphin to launch Konvertible, selected libmp3lame in the ‘Codec:’ drop-down picklist, 192.00 kbits/s in the ‘Bitrate:’ drop-down picklist, clicked on the folder icon and selected /home/fitzcarraldo as the destination directory, and finally clicked ‘Convert’.

The mp3 files created by shntool and Konvertible were of different sizes:

File created by Konvertible:

$ file My\ Band\ 1971\ CoolSounds.mp3
My Band 1971 CoolSounds.mp3: Audio file with ID3 version 2.4.0, contains: MPEG ADTS, layer III, v1, 192 kbps, 44.1 kHz, Stereo
$ ls -la My\ Band\ 1971\ CoolSounds.mp3
-rw-r--r-- 1 fitzcarraldo users 85334024 Dec 19 08:11 My Band 1971 CoolSounds.mp3
$

File created by shntool:

$ file My\ Band\ 1971\ CoolSounds.mp3
My Band 1971 CoolSounds.mp3: MPEG ADTS, layer III, v1, 128 kbps, 44.1 kHz, JntStereo
$ ls -la My\ Band\ 1971\ CoolSounds.mp3
-rw-r--r-- 1 fitzcarraldo users 56889259 Dec 19 08:29 My Band 1971 CoolSounds.mp3
$

So I added the bitrate to the shntool command:

$ shntool conv -i ape -o 'cust ext=mp3 lame -b 192 - %f' My\ Band\ 1971\ CoolSounds.ape
Converting [My Band 1971 CoolSounds.ape] (59:15.39) --> [My Band 1971 CoolSounds.mp3] : 100% OK
$

and this time the mp3 file created by shntool is comparable to the mp3 file created by Konvertible:

$ file My\ Band\ 1971\ CoolSounds.mp3
My Band 1971 CoolSounds.mp3: MPEG ADTS, layer III, v1, 192 kbps, 44.1 kHz, JntStereo
$ ls -la My\ Band\ 1971\ CoolSounds.mp3
-rw-r--r-- 1 fitzcarraldo users 85333889 Dec 19 08:56 My Band 1971 CoolSounds.mp3
$

The ffmpeg command to do the same thing is:

$ ffmpeg -i My\ Band\ 1971\ CoolSounds.ape -ar 44100 -ab 192000 out.mp3
ffmpeg version 0.10.6 Copyright (c) 2000-2012 the FFmpeg developers
built on Nov 26 2012 07:06:40 with gcc 4.6.3
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --enable-shared --cc=x86_64-pc-linux-gnu-gcc --cxx=x86_64-pc-linux-gnu-g++ --ar=x86_64-pc-linux-gnu-ar --optflags='-O2 -march=native -pipe' --extra-cflags='-O2 -march=native -pipe' --extra-cxxflags='-O2 -march=native -pipe' --disable-static --enable-gpl --enable-version3 --enable-postproc --enable-avfilter --disable-stripping --disable-debug --disable-doc --disable-vaapi --disable-vdpau --enable-runtime-cpudetect --enable-gnutls --enable-libmp3lame --enable-libvo-aacenc --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-libfaac --enable-nonfree --enable-libdc1394 --enable-openal --disable-indev=v4l --disable-indev=oss --enable-x11grab --enable-libpulse --disable-outdev=oss --enable-libfreetype --enable-pthreads --enable-libgsm --enable-libspeex --disable-amd3dnow --disable-amd3dnowext --disable-altivec --disable-avx --disable-mmx2 --disable-ssse3 --disable-vis --disable-neon --cpu=ho
libavutil 51. 35.100 / 51. 35.100
libavcodec 53. 61.100 / 53. 61.100
libavformat 53. 32.100 / 53. 32.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 61.100 / 2. 61.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
Input #0, ape, from 'My Band 1971 CoolSounds.ape':
Metadata:
Album : CoolSounds
Title : C:\1\My Band 1971 CoolSounds
Comment : Exact Audio Copy
Duration: 00:59:15.47, start: 0.000000, bitrate: 829 kb/s
Stream #0:0: Audio: ape (APE / 0x20455041), 44100 Hz, stereo, s16
Output #0, mp3, to 'out.mp3':
Metadata:
TALB : CoolSounds
TIT2 : C:\1\My Band 1971 CoolSounds
Comment : Exact Audio Copy
TSSE : Lavf53.32.100
Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16, 192 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (ape -> libmp3lame)
Press [q] to stop, [?] for help
size= 83334kB time=00:59:15.55 bitrate= 192.0kbits/s
video:0kB audio:83333kB global headers:0kB muxing overhead 0.000892%
$

and, as you can see below, the resulting mp3 file is the same size as the mp3 file created using Konvertible (not surprising, since Konvertible is a GUI front-end for ffmpeg) and virtually the same as the mp3 file created by shntool.

$ file out.mp3
out.mp3: Audio file with ID3 version 2.4.0, contains: MPEG ADTS, layer III, v1, 192 kbps, 44.1 kHz, Stereo
$ ls -la out.mp3
-rw-r--r-- 1 fitzcarraldo users 85334024 Dec 20 18:14 out.mp3
$

So, there you have it: GUI or command line; take your pick!

Selecting different keyboard layouts in Xfce

One of my laptops running Xfce has a British English keyboard. However, I write in Portuguese and Spanish as well and so I need to be able to switch keyboard layouts. Therefore I added the three keyboard layouts by clicking on ‘Applications Menu’ on the Xfce Panel, selecting ‘Settings’ > ‘Keyboard’ and clicking on the ‘Layout’ tab. I also created the file /etc/X11/xorg.conf.d/00-keyboard.conf containing the following:

Section "InputClass"
    Identifier "keyboard"
    MatchIsKeyboard "yes"
    Option "XkbLayout" "gb,br,es"
    Option "XkbVariant" ""
    Option "XkbOptions" "grp:alt_shift_toggle"
EndSection

As you can probably guess from the XkbOptions option I specified, pressing Alt-Shift enables me to toggle between the keyboard layouts declared in the XkbLayout option (‘gb’ = British keyboard layout; ‘br’ = Brazilian Portuguese keyboard layout; ‘es’ = Spanish keyboard layout). This works fine but I could not tell at a glance which keyboard layout was selected, without typing some text and seeing the result. It would be nice to see an icon on the Panel indicating which keyboard layout is currently selected, in the same way as is possible in KDE and GNOME. It turns out that Xfce has a plugin that does precisely this: Keyboard Layouts, which is available by installing the package xfce4-xkb-plugin. I installed it, right-clicked on the Panel and selected ‘Panel’ > ‘Add New Items…’ > ‘Keyboard Layouts’ to display the plugin’s icon on the Panel. Right-clicking on it and selecting ‘Properties’ allows you to configure the plugin, and I selected ‘Show layout as: image’ so that a flag indicating the current keyboard layout is displayed on the Panel, as shown in the snapshot below.

POWERED BY LINUX badge on Mesh Edge DX laptop

Keyboard layout icon on Xfce Panel

I can either use the keyboard shortcut Alt-Shift to toggle between the three keyboard layouts (in which case the flag changes on the Panel), or I can click on the Keyboard Layouts icon on the Panel and select the desired layout from there instead, as shown in the snapshot below.

POWERED BY LINUX badge on Mesh Edge DX laptop

Selecting keyboard layout from Xfce Panel

An easy way to edit the Xfce Application Menu

I recently installed Sabayon Linux with Xfce 4.10 on a couple of laptops. Being a long-time KDE user, I was surprised to find that Xfce does not provide a ‘native’ easy way to edit the Xfce Application Menu. The Xfce Wiki page (Customize the Xfce menu) lists a protracted and complicated procedure for making changes to the Xfce menu files. Fortunately the article also points out that a LXDE tool works for Xfce too:

A GNU-licensed graphical menu editor for LXDE, LXMenuEditor, also works for XFCE, as of XFCE 4.8.0 and LXMenuEditor 20110523.

So I installed LXMenuEditor:

# equo install lxmed

To run LXMenuEditor from the command line you just need to enter the command lxmed. If you do that from your user account you can only use LXMenuEditor to view the menu entries. To be able to edit, add and delete menu entries you must launch lxmed as root user, which of course you can do from the command line too. But I wanted to add LXMenuEditor to the Xfce Application Menu and also make it prompt for the root user’s password when launched from the menu. So I did the following:

1. Open a Terminal window, login as root user and launch LXMenuEditor:

$ su
Password:
# lxmed

2. Click on the ‘System Tools’ entry in the Categories pane. The Menu Items pane will display the current menu entries in the System Tools category.

3. Click on the ‘New Item’ button and a window will pop up.

4. In the Name box enter “Application Menu Editor” (without the quotes).

5. In the Command box enter “gksu lxmed” (without the quotes).

6. In the Comment box enter “Edit entries in the Xfce Application Menu” (without the quotes).

7. Make sure the Visible tick box is ticked.

8. Click the OK button.

(x11-libs/gksu should already be installed, but install it if it is not.)

That’s it. If you click on ‘Applications Menu’ on the Panel there will now be a menu entry System > Applications Menu Editor and, if you click on that, you will be prompted to enter the root user’s password. Once you have done that, LXMenuEditor will be launched with root user previleges and you can view and edit the Xfce applications menu.

Evaluating Sabayon Linux Xfce

Sabayon Linux Xfce on Acer Aspire 5920

EDIT (January 18, 2014): This article refers to an installation of Sabayon Linux from the Version 10 ISO, when the distribution still used OpenRC as the init system, rather than systemd. Therefore some of the commands in this article are no longer applicable to the current versions of the distribution using systemd.

The last time I installed SL (Sabayon Linux) on one of my own machines was 18 months ago, and that was my media centre. I haven’t touched that installation since: “If it ain’t broke, don’t fix it.” My most recent desktop SL installation was on a relative’s Acer Aspire 5738 laptop just over a year ago, but it was disappointing. In the end I did get SL working with the laptop’s NVIDIA GPU but, amongst other things, ALSA didn’t work correctly and even I couldn’t fix it. The owner was understandably unimpressed with SL and ended up installing Ubuntu over it, which worked perfectly out of the box.

Since then I have not used SL much apart from occasionally booting an ISO image of the latest SL LiveDVD in VirtualBox on my main laptop running Gentoo, or on the family PC running Windows Vista. So I was keen to try a recent edition of SL, and the opportunity arose this week as I had to replace an Acer Aspire 5920 laptop belonging to a family member and I thought it would be interesting to install SL Xfce Edition on it. (I bought a Samsung NP350V5C laptop to replace it, if you’re interested.)

That Acer Aspire laptop is 4 years old and had been causing a lot of hassle: a hardware design fault made the display flicker, and Windows Vista often refused to connect via WiFi to my home network. A quick search of the Web turns up plenty of complaints about these two problems with this particular Acer model. Oh, and one more thing, Windows Vista was unbelievably slow on the laptop. You really could go and make a cup of coffee in the time it took to boot.

I got a local PC repair shop to look at the ribbon cable in the lid that is known to cause the flickering display, and decided to wipe the HDD (good riddance, Vista) and install SL 10 64-bit Xfce. Below I list the laptop’s specification.

- Acer Aspire 5920-5A2G25Mi
- 15.4″ (1280 x 800)
- 250 GB SATA HDD
- Intel Core 2 Duo T5550 1.83 GHz
- 2GB DDR2 RAM
- Intel Mobile GM965/GL960 Integrated Graphics Controller with Intel Graphics Media Accelerator X3100 with up to 358 MB Shared Graphics
- Intel 82801H HD Audio Controller
- Broadcom Netlink BCM5787M Gigabit Ethernet PCIe
- Intel PRO/Wireless 3945ABG
- Ricoh RSC832 IEEE 1394 Firewire Controller
- Ricoh R5C822 SD/SDIO/MMC/MS/MSPro Adapter
- Ricoh R5C843 MMC Host Controller
- Ricoh RSC592 Memory Stick Bus Host Adapter
- Ricoh xD-Picture Card Controller
- Suyin Corp. Acer CrystalEye Webcam (0.3 Megapixels)
- CD/DVD reader/writer
- 4 USB2 ports
- 56K ITU V.92 modem port

This model has a Bluetooth button but does not have Bluetooth hardware installed. The Bluetooth button can be configured for other purposes, as I discovered after installing SL.

I downloaded the file Sabayon_Linux_10_amd64_Xfce.iso from the SL Download page, and used UNetbootin version 581 to create a LivePenDrive on a 4GB pen drive. I inserted the pen drive into the Aspire, booted, pressed F2 to get to the BIOS menu, configured the BIOS to boot the pen drive, and rebooted.

The SL Live environment loaded without problem and I was able to access my home network via WiFi with ease.

I launched the SL installer and was pleasantly surprised to see that it is more polished that the version I used a year ago. However, over the years I have found that the SL Installer often crashes when it tries to partition the HDD, and the same thing occurred this time. Normally when this happens I boot up a SystemRescueCd LiveCD and use GParted to partition the HDD and format the partitions, then I reboot the SL LiveDVD and re-run the Installer, which then works. This time, however, I just decided to open a Terminal window from the SL Live environment and use the fdisk command to create the partitions manually. Then I re-ran the SL Installer. I was now able to specify the mount points for the partitions and format them, and installation was completed quickly.

I booted the HDD and was pleasantly surprised. Almost everything worked ‘out of the box’ (including the memory card slot), and the overall impression was of a polished distribution with an attractive Xfce desktop. SL looks great on the laptop’s relatively low resolution 1280×800 screen, and I suspect the Infinality patches make a difference. Most of the applications I needed were already installed, to make life easier. Apart from the positive impression aesthetically, I am very impressed with the speed at which it runs. This is one of the snappiest Linux installations I have used.

I did need to perform a few tweaks, and I’ll mention the main ones throughout the remainder of this article.

As SL is a rolling distribution I wanted to bring the installation bang up to date, so I used the usual Entropy commands in a Terminal window:

$ su
Password:
# equo update && equo upgrade && equo conf update

I did not need to upgrade the kernel using the SL kernel-switcher utility, as the version of the latest kernel in the SL Entropy Weekly repository was the same as the version installed by the LiveDVD.

Tapping on the touchpad didn’t work out of the box, but all I had to do was configure it using Xfce’s ‘Applications Menu’ > Settings > ‘Mouse and Touchpad’ > Touchpad (tick ‘Tap touchpad to click’).

Although the Uncomplicated Firewall was installed, a front-end wasn’t, so I installed UFW Frontends:

# equo install ufw-frontends

I launched ufw-gtk (Firewall Manager) and configured UFW as explained in How to config ufw/ufw-frontends for Samba browsing/printing.

Xfce has some useful plugins and utilities, so I installed some of those:

# equo install xfce4-power-manager xfce4-sensors-plugin xarchiver xfce4-battery-plugin thunar-volman xfburn tumbler

A calculator is always handy too:

# equo install galculator

The system clock was not displaying the correct time (it was one hour ahead of actual time) so I followed the SL Wiki article HOWTO: Clock, Time, UTC, Dual boot with Windows and then used the Linux date command to set the correct date and time:

# date MMDDhhmm

OPTIONAL: To keep the system clock in sync with a remote time server when the laptop is connected to the internet, I installed the package net-misc/ntp:

# equo install ntp

and then edited the file /etc/conf.d/ntpd so it contains NTPD_OPTS="-g" and I added the initscripts for NTP Client (executes once at start up) and the NTP daemon (runs continuously) to the default runlevel:

# rc-update add ntpd default
# rc-update add ntp-client default

The SL Xfce Edition LiveDVD installs the Midori Web browser which is lightweight and good, but not as good as Firefox, my favourite browser, so I replaced Midori with Firefox:

# equo remove midori
# equo install firefox

I found that the film trailers on the iTunes Movie Trailers Web site would not play in the browser, so I installed gecko-mediaplayer and gnome-mplayer (and used Edit > Preferences > Player to set ‘Video Output’ to gl for OpenGL or xv for XVideo) and I disabled the Totem plugin in Firefox (Add-ons > Plugins and disable ‘QuickTime Plug-in 7.6.6 The Totem 3.4.3 plugin handles video and audio streams.’) which solved the problem. An earlier blog post of mine also mentions this: Playing QuickTime videos in Firefox and Chromium + XVideo bug in AMD Catalyst 11.11 and 11.12 driver.

As the volume control thumb wheel on the laptop did not work in SL, I used Xfce’s Settings > Keyboard to configure the two unallocated function keys F9 and F10 to be Decrease Volume and Increase Volume, respectively:

amixer set Master 5%- allocated to F9
amixer set Master 5%+ allocated to F10

and I allocated F8 as the Mute button, as it already had a symbol for that printed on it:

amixer set Master toggle

Sound quality is excellent.

I installed Skype:

# equo install skype emul-linux-x86-medialibs

which works well apart from the video image from the laptop’s Acer CrystalEye Webcam (310,000 pixels, circa 640×480), which has flickering blue horizontal lines. I installed GUVCView, a GUI to configure the uvcvideo driver module.

# equo install guvcview

My adjustments using GUVCView helped slightly, but the image quality is still not great. The image is just about tolerable when the subject is illuminated by daylight, but poor in artificial light. Searching the Web tells me that plenty of Windows users have had problems with this model of Webcam too.

I wanted to be able to access computers running Windows on my home network, and to be able to print on printers connected via USB to those computers, so I added SAMBA to the default runlevel so that it would be started automatically when the laptop boots:

# rc-update add samba default

I also edited the configuration file /etc/samba/smb.conf to be as follows:

[global]
netbios name = Aspire5920
message command = /usr/bin/linpopup "%f" "%m" %s; rm %s
printcap name = cups
printing = cups
printer admin = @adm
log file = /var/log/samba/log.%m
max log size = 50
map to guest = bad user
security = user
encrypt passwords = yes
smb passwd file = /etc/samba/private/smbpasswd
socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192
name resolve order = wins lmhosts bcast
wins support = yes
dns proxy = no

[homes]
comment = Home Directories
read only = no

[netlogon]
comment = Network Logon Service
path = /var/lib/samba/netlogon
guest ok = yes

[printers]
comment = All Printers
path = /var/spool/samba
guest ok = yes
printable = yes
create mask = 0700
print command = lpr-cups -P %p -o raw %s -r   # using client side printer drivers.

[print$]
path = /var/lib/samba/printers
write list = @adm root
guest ok = yes

[PUBLIC]
path = /home/fitzcarraldo/Public/
guest ok = yes
read only = no

I installed the drivers for two of my printers:

# equo install gutenprint

and used the CUPS browser interface http://localhost:631/ to configure CUPS to use a Canon PIXMA MP510 via SAMBA connected to a PC running Vista, and to use a Canon PIXMA MP560 on my home network via WiFi.

When configuring CUPS to use the Canon PIXMA MP510 printer connected to the family PC that is running Windows Vista, I had to specify the printer’s SMB address as follows:

smb://workgroup/username:password@hostname/printername

where username is the name of a user account on the Windows Vista PC, and password is the password of that user account.

For example, let’s say that I configured Windows Vista on the family PC some years ago as follows:

PC name: SA90

Work group name: WORKGROUP

Printer name: Canon_MP510_Printer

User name: Fitzcarraldo

User password: MollyAida

then the SMB address I would specify to the CUPS Manager for the printer would be:

smb://WORKGROUP/Fitzcarraldo:MollyAida@SA90/Canon_MP510_Printer

I configured the Xfce top Panel to show the Xfce LCD brightness plugin, Xfce audio mixer, Xfce sensor plugin, Xfce battery monitor. By the way, Xfce Power Manager works correctly when the laptop is using its battery.

Xfce makes it easy to configure shortcut keys: ‘Applications Menu’ > Settings > Keyboard | ‘Application Shortcuts’. I configured the browser launch key on the left of the laptop’s main keyboard to launch Firefox. And, as I am used to launching Yakuaki in KDE using F12, I set up F12 in Xfce to run /usr/bin/terminal (I could instead have installed Guake and used Xfce’s ‘Applications Menu’ > ‘Session and Startup’ | ‘Application Autostart’ to configure Guake to launch automatically at start up).

Basically, almost everything works well.

Also, I installed superadduser and added another user successfully:

# equo install superadduser

Although the Xfce ALSA Mixer works fine, I installed PulseAudio Volume Control too:

# equo install pavucontrol

Actually you do need both an ALSA mixer and a PulseAudio mixer because you can get into the situation where the ALSA volumes are turned up but the PulseAudio volumes are turned down.

As I sometimes download YouTube videos for offline viewing, I installed the version of the excellent Python script youtube-dl that is in the SL Weekly repository:

# equo install youtube-dl

but it turned out to be the package net-misc/youtube-dl-2012.02.27, which wouldn’t download YouTube videos. I had to download the latest version of the script from the youtube-dl developer’s Web site, made it executable (chmod +x ~/youtube-dl) and copied it to the directory /usr/bin/ to overwrite the 2012.02.27 version installed via Entropy.

Thunar was taking a very long time to open the first time I launched it after each reboot, and was also launching twice. To stop this happening I edited the file /usr/share/gvfs/mounts/network.mount and changed AutoMount=false.

Furthermore, the following message sometimes appears in a pop-up window when launching Thunar:

Failed to open directory “fitzcarraldo”.
Error when getting information for file ‘/home/fitzcarraldo/.gvfs’: Transport endpoint is not connected.

Searching the Web indicated the following command might fix it:

# umount /home/fitzcarraldo/.gvfs

It seems to have helped, but the message does still appear sometimes.

One problem I experienced 18 months ago with the SL 5.4 E17 Edition — and I notice has been reported by several users in the SL Forums since then — is that SL does not always set up the user’s locale correctly. During installation I selected English as the language, the UK as my location and English (UK) for the keyboard, and ended up with the US locale:

# locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

What I want is the British locale. I rectified it by following Steps 3, 4 and 5 in the SL Forums post Re: en_GB language missing after install.. I think the SL Installer probably needs modifying.

Summary

SL 10 Xfce is an attractive installation demonstrating a fair amount of attention to detail, but the Installer has some frustrating problems with partitioning and the set up of the locale. These problems have been present for quite some time now and could be ‘brick walls’ for newcomers to Linux.

I use Xfce in Gentoo on a legacy laptop (Pentium III) and so am familiar with it, but it looks great in SL and just seems that little bit more polished.

But the main impression I get from this installation is just how zippy and responsive it is. Video runs smoothly however fast I jiggle around a media player window, and we’re talking a relatively low-end graphics processor here, not an AMD or NVIDIA GPU. Applications open really fast. Overall, it’s a pleasure to use.

When I think back to how Windows Vista ran on this laptop, the difference is like night and day. It’s like having a new, more powerful laptop. I’ve now added a user account for my wife as she has decided she will use it. Not bad for a laptop I thought I would give to my local repair shop for spares.

Installing and using ZBar in Linux to scan bar codes with your Webcam

ZBar is an application that can scan and decode several bar code symbologies (including QR Code) from sources such as a Webcam or an image file. I had been wanting to install it for some time and was finally spurred on to do it by a request for help to get it working in the Sabayon Linux forums. Here are the steps I used.

1. I installed the package media-gfx/zbar-0.10-r1.
Note for Gentoo users: I merged the package with the imagemagick and v4l USE flags set, so that both zbarimg and zbarcam would be installed. If you only want to use ZBar with a Webcam then turn off the imagemagick flag and zbarimg will not be installed.
Note for Sabayon Linux users: The Entropy package was built with both the above-mentioned USE flags set, so zbarimg and zbarcam will be installed.

2. Then I checked the status of the installed package by using the Portage eix command:

$ eix -I zbar
[I] media-gfx/zbar
Available versions: (~)0.10-r1 {{X gtk imagemagick jpeg python qt4 static-libs +threads v4l xv}}
Installed versions: 0.10-r1(03:56:14 05/10/12)(X gtk imagemagick jpeg qt4 threads v4l xv -python -static-libs)
Homepage: http://zbar.sourceforge.net/
Description: Library and tools for reading barcodes from images or video

Sabayon Linux users could instead use the following command:

$ equo search --verbose zbar

3. Then I checked which video device my laptop’s inbuilt Webcam is:

$ ls /dev/video*
/dev/video0

4. As it is /dev/video0, I launched zbarcam as follows:

$ zbarcam --raw /dev/video0
WARNING: no compatible input to output format
...trying again with output disabled
ERROR: zbar processor in zbar_processor_init():
unsupported request: no compatible image format

Clearly zbarcam was not recognising the Webcam.

5. As I had installed the package with the Video4Linux USE flag set, I then launched zbarcam with the following prefix:

$ LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so zbarcam --raw /dev/video0

The ZBar GUI window popped up and I could see myself in the window. So far, so good.

6. I held a QR Code 2D bar code in front of the Webcam, then held a 1D Interleaved 2 of 5 bar code in front of the Webcam. The following was displayed:

$ LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so zbarcam --raw /dev/video0
http://roho.it/mryt
0161223563

Both the QR Code and the I2of5 bar code were read correctly. If the --raw parameter is omitted then zbarcam displays the symbology of the bar code too:

$ LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so zbarcam /dev/video0
QR-Code:http://roho.it/mryt
I2/5:0161223563

7. Then I tried using ZBar to read a bar code which I had previously saved as a .jpg file:

$ zbarimg --raw ~/zebra04.jpg
01234565
scanned 1 barcode symbols from 1 images in 0.04 seconds

$ zbarimg ~/zebra04.jpg
EAN-8:01234565
scanned 1 barcode symbols from 1 images in 0.04 seconds

To find out the other parameters available, use the commands:

$ man zbarcam
$ zbarcam --help
$ man zbarimg
$ zbarimg --help

ZBar is a nice tool. 8-)

Using Bombono DVD in Linux to create a DVD-Video disc from a MKV file

I had a .mkv file and associated .srt subtitles file, and wanted to create a DVD-Video disc so that I could play it in my stand-alone DVD player and watch the film on my TV set. I tried to create a DVD-Video disc by using Avidemux and following the procedure in Formatting an MKV container into DVD format with Avidemux, Mkvtoolnix, dvdauthor, and K3B, but both Avidemux and Avidemux2 crashed, displaying the error message “Crash. Segfault at line 0, file ??ADM_backTrack”.

So I installed Bombono DVD (package name bombono-dvd) and GNOME Subtitles (package name gnome-subtitles), required by Bombono DVD if you want it to create a DVD-Video disc with subtitles, and was able to burn a DVD-Video disc as follows:

1.  If you want subtitles, open the .srt subtitles file in a GUI text editor to check the character encoding. As I use KDE, I opened the .srt file in KWrite, selected Tools > Encoding, and found that ISO 8859-15 was the character set used in the particular .srt file that I had downloaded from the Web.

2.  Launch Bombono DVD as follows:

$ export VIDEO_FORMAT=PAL && bombono-dvd

(Replace ‘PAL’ with ‘NTSC’ if you want to create an NTSC DVD-Video disc.)

3.  In the top right corner of the Bombono DVD window, select the DVD-Video disc size. In my case, I had a 7.9 GB MKV file which I wished to transcode and burn to a 4.7 GB capacity DVD+R, so I selected ‘DVD 4.3 GB’.

4.  Select ‘Project’ > ‘Preferences…’

4.1  Select ‘Default project type’ as ‘PAL/SECAM’ (or ‘NTSC’ if you want to create an NTSC DVD-Video disc).

4.2  Under ‘Play authoring result in’ select ‘Xine’ (or ‘Totem’, if you use that media player).

4.3  I have a quad-core CPU so I selected ’4′ for ‘Multi-core CPU support’.

4.4  Click ‘Close’.

5.  Click on the ‘Source’ tab.

5.1  Click on the ‘+’ sign and select the MKV file you want to transcode and burn to DVD.

5.2  Right-click on the resulting entry in ‘Media List’ and select ‘Adjust Bitrate to Fit to Disc’.

5.3  If you also have a subtitles file you wish to use, right-click on the entry in ‘Media List’ and select ‘Add Subtitles…’

5.3.1  Select the subtitles file.

5.3.2  Tick ‘Turn on subtitles by default’.

5.3.3  Select the character encoding. In my case I selected ‘ISO-8859-15′ (see Step 1 above).

6.  Click on the ‘Output’ tab.

6.1  Select ‘Write disc image’ and enter a Disc label of up to 15 letters.

6.2  Click on ‘Build DVD-Video’.

If the transcoding, subtitle addition and ISO file creation processes complete successfully, Bombono DVD will pop-up a window informing you and asking if you want to burn the image to a DVD. Make sure a blank DVD is in your optical R/W drive and then click on the appropriate button.

Follow

Get every new post delivered to your Inbox.

Join 43 other followers