Change the mp3 bitrate for ripping in K3b

I’ve been using K3b successfully (it’s currently at version 2.0.3-r1 in Gentoo Linux) to rip Audio CDs to mp3 files, but despite changing the bitrate to 192 kbps in the ‘K3b Lame Mp3 Encoder’ plugin settings, K3b was still ripping mp3 files at 128 kbps. I found out that I needed to make another change too.

The default bitrate for ripped mp3 tracks is 128 kbps in K3b. To use a different bitrate, I needed to do the following:

1. ‘Settings’ > ‘Configure K3b…’

2. Click on ‘Plugins’

3. Click on the spanner next to ‘K3b Lame Mp3 Encoder’, and change the bitrate on the Settings tab to 192 (or whatever you want). However, this alone does not have any effect, so also click on the spanner next to ‘K3b External Audio Encoder’, click on ‘Mp3 (Lame)’ in the list of ‘Configured Encoders’, click on ‘Edit’ and insert ‘-b 192‘ (or whatever bitrate you want) in the list of lame options, like so:

lame -r --bitwidth 16 --little-endian -b 192 -s 44.1 -h --tt %t --ta %a --tl %m --ty %y --tc %c --tn %n - %f

Here’s what happens before I added the ‘-b 192‘ to the settings for ‘Mp3 (Lame)’ in ‘K3b External Audio Encoder':

$ file 01\ -\ Meu\ Bem\ Querer.mp3
01 - Meu Bem Querer.mp3: Audio file with ID3 version 2.3.0, contains: MPEG ADTS, layer III, v1, 128 kbps, 44.1 kHz, JntStereo

And after adding the ‘-b 192‘ to the settings for ‘Mp3 (Lame)’ in ‘K3b External Audio Encoder':

$ file 01\ -\ Meu\ Bem\ Querer.mp3
01 - Meu Bem Querer.mp3: Audio file with ID3 version 2.3.0, contains: MPEG ADTS, layer III, v1, 192 kbps, 44.1 kHz, JntStereo

Notice the bit rate of the file has changed.

A new laptop

At the beginning of this month my trusty Compal NBLB2 laptop completed five years of heavy use. The HDD was almost full (mostly with my work files) and the laptop’s size and weight were starting to become troublesome on my frequent work trips. So I decided to bite the bullet and buy a new laptop. As Compal is an OEM and I was able to specify various components when buying the NBLB2, I decided to buy an OEM laptop again this time. In the end I decided on the Clevo W230SS, which I ordered from pcspecialist. The configuration I specified is listed below:

  • 13.3″ matte full HD LED IPS widescreen (1920×1080).
  • Intel Core i7 quad-core mobile processor i7-4810MQ (2.80GHz) 6MB.
  • 16GB Kingston SODIMM DDR3 1600MHz (2 x 8GB).
  • NVIDIA GeForce GTX 860M – 2.0GB DDR5, 640 CUDA cores.
  • 750GB WD Scorpio Black WD7500BPKX, SATA 6 Gb/s, 16MB cache (7200 rpm).
  • 8x Samsung slim USB 2.0 external DVD-RW.
  • Integrated 6-in-1 memory card reader (SD/MiniSD/SDHC/SDXC/MMC/RSMMC).
  • Arctic MX-4 Extreme thermal conductivity compound.
  • Intel 2-channel High Definition Audio + mic & headphone jacks.
  • Gigabit LAN & Wireless Intel AC-7260 HMC (867Mbps, 802.11AC) + Bluetooth.
  • 3 USB 3.0 ports + 1 USB 2.0 port.
  • Backlit UK keyboard.
  • 2-button touchpad.
  • 2.0 megapixel Webcam.
  • 6-cell lithium ion battery (62.16WH).
  • Power lead & 120W AC adaptor.
  • 3-year warranty (1 year collect & return; 1 year parts; 3 years labour).
  • 1-year dead pixel guarantee inc. labour & carriage.
  • No operating system required.

The laptop has both a VGA port and an HDMI port. The VGA port is important to me because I need to connect to various models of legacy monitors and projectors in the various offices where I work.

The time from ordering the laptop to its delivery was nine days, and I was impressed with the service by pcspecialist; I received e-mails at each stage of building, testing and delivery (including the option to change the delivery date), and was informed of the name of the courier company, the time of delivery and even the name of the van driver!

My two previous laptops were configured to dual-boot Linux and Windows, but this time I decided not to bother with Windows and install only Gentoo Linux. I virtually never use Windows on the Compal anyway, opting instead to run Microsoft Office 2007 with WINE in Linux, so I decided to save some money this time. I followed the Gentoo AMD64 Handbook to install the operating system and, with one exception which I will mention further on, the Handbook is a very accurate guide.

I have the Testing branch of Gentoo (‘~amd64′) installed on the Compal, but decided to install the Stable branch of Gentoo (‘amd64′) on the Clevo. Since several of the packages I wanted to install are in the Testing branch, I would declare them in /etc/portage/package.accept_keywords/ in order to be able to install them regardless.

Below are some rough notes on what I did, in case they are of any interest to others contemplating installing Gentoo on a laptop with a similar specification. I have to say I like the Clevo W230SS very much so far, although I find the NVIDIA Optimus hardware and driver more complicated to configure than the AMD ATI GPUs on my previous two laptops, and the NVIDIA driver does not work as well with the xrandr command as does the AMD FGLRX driver for ATI GPUs.

When I pressed F2 at boot to check the configuration of the American Megatrends BIOS, I found that UEFI was turned off, and I left it that way. The HDD was apparently MBR not GPT. I was happy to use PC BIOS and MBR rather than UEFI and GPT as that meant I would not have to fiddle with new technology with which I am unfamiliar, and GPT is not necessary as the HDD capacity is less than 2 TiB.

I then booted the HDD for the first time to check if pcspecialist had left anything on it after testing, and the Windows 7 Home Premium ‘Setup is preparing your computer for first use’ screen was displayed. As I had not ordered Windows and therefore had no Microsoft key, and as I did not want Windows on the laptop in any case, I used GParted on a SystemRescueCD Live pen drive to repartition and format the HDD.

I followed the Gentoo AMD64 Handbook but used SystemRescueCd rather than a Gentoo LiveCD or LiveDVD, and therefore I did not have to perform the installation procedure from the very beginning of the Handbook. After downloading the latest SystemRescueCd ISO and installing it to a pen drive (see the instructions on the SystemRescueCd Web site), I booted SystemRescueCd from the pen drive and connected the SystemRescueCd Xfce Live environment to the Web via WiFi. I did not bother to connect an Ethernet cable to the laptop and performed the entire installation of Gentoo to the HDD under WiFi.

I did not need to use the method given in the Gentoo Handbook for creating partitions; I used GParted on SystemRescueCD instead of fdisk or parted on the command line. I was therefore able to ignore the first few pages and started following the Handbook in earnest from Activating the swap partion onwards.

The Handbook recommends creating a ‘BIOS boot partition’ as well as a ‘boot partition’. This is really only necessary for UEFI machines or if the GRUB Embedding Area on the HDD is too small (the GNU Grub Manual 2.00 says the space reserved for the GRUB Embedding Area has to be at least 31 KiB). I did not need to create a ‘BIOS boot partition’, as GParted would only let me create the first partition starting 1 MiB from the beginning of the HDD. Actually, GParted will not let you create /dev/sda1 right at the beginning of the disk; it always seems to want the partition to start 1 MiB from the beginning of the HDD, so I don’t understand why the Handbook wants you to create a ‘BIOS boot partition’ before the Boot partition in the case of MBR HDDs, as there would still be 1 MiB of empty space before the ‘BIOS boot partition’, rendering the latter a waste of space and effort. (As I understand it, the situation is different in the case of GPT because the EFI boot partition must be FAT32, so you have no choice but to create a ‘BIOS boot partition’ if you’re using a GPT HDD.) Perhaps if you are using fdisk or parted on the command line then the situation is different and those commands do allow you to put the first partition right at the beginning of the HDD. So I created the following partitions by using GParted:

/dev/sda1 /boot (Primary Partition)
/dev/sda2 swap (Primary Partition)
/dev/sda3 (Extended Partition)
/dev/sda5 / (Logical Partition)
/dev/sda6 /home (Logical Partition)
/dev/sda7 NTFS partition (Logical Partition)

I specified the ext2 file system for /boot, and ext4 for / and /home. I have used these file systems for many years on previous laptops, and they are very reliable. I decided to add an NTFS partition to store my work files separately from my home files, and in case I ever want to access the laptop using Windows from e.g. a bootable external USB drive or whatever.

When creating the logical partitions sda5, sda6 and sda7, GParted always left 1 MiB unallocated before each logical partition. And I don’t know why GParted would not create a partition named /dev/sda4.

The precise partition configuration is listed below:

# fdisk -l

Disk /dev/sda: 698.7 GiB, 750156374016 bytes, 1465149168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0x291ba0e7

 
Device     Boot     Start        End    Sectors   Size Id Type
/dev/sda1            2048     264191     262144   128M 83 Linux
/dev/sda2          264192   33822719   33558528    16G 82 Linux swap / Solaris
/dev/sda3        33822720 1465147391 1431324672 682.5G  5 Extended
/dev/sda5        33824768  302260223  268435456   128G 83 Linux
/dev/sda6       302262272  839133183  536870912   256G 83 Linux
/dev/sda7       839135232 1465147391  626012160 298.5G  7 HPFS/NTFS/exFAT

# blkid
/dev/sda1: LABEL="BOOT" UUID="f6ffc085-66fe-4bbe-b080-cec355749f85" TYPE="ext2" PARTUUID="291ba0e7-01"
/dev/sda2: UUID="c49e011a-bb8b-4ade-8fda-6c11ca53d660" TYPE="swap" PARTUUID="291ba0e7-02"
/dev/sda5: LABEL="ROOT" UUID="525a90f1-8ad2-44a3-ade3-20f18a0a9595" TYPE="ext4" PARTUUID="291ba0e7-05"
/dev/sda6: LABEL="HOME" UUID="5b60d470-a92a-45b3-9607-3ff3ab483b97" TYPE="ext4" PARTUUID="291ba0e7-06"
/dev/sda7: LABEL="NTFS" UUID="16F4D9B04A85A7E5" TYPE="ntfs" PARTUUID="291ba0e7-07"

The output from the lspci command in SystemRescueCd was as follows:

# lspci
00:00.0 Host bridge: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor DRAM Controller (rev 06)
00:01.0 PCI bridge: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor PCI Express x16 Controller (rev 06)
00:02.0 VGA compatible controller: Intel Corporation 4th Gen Core Processor Integrated Graphics Controller (rev 06)
00:03.0 Audio device: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller (rev 06)
00:14.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB xHCI (rev 05)
00:16.0 Communication controller: Intel Corporation 8 Series/C220 Series Chipset Family MEI Controller #1 (rev 04)
00:1a.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #2 (rev 05)
00:1b.0 Audio device: Intel Corporation 8 Series/C220 Series Chipset High Definition Audio Controller (rev 05)
00:1c.0 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #1 (rev d5)
00:1c.2 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #3 (rev d5)
00:1c.3 PCI bridge: Intel Corporation 8 Series/C220 Series Chipset Family PCI Express Root Port #4 (rev d5)
00:1d.0 USB controller: Intel Corporation 8 Series/C220 Series Chipset Family USB EHCI #1 (rev 05)
00:1f.0 ISA bridge: Intel Corporation HM87 Express LPC Controller (rev 05)
00:1f.2 SATA controller: Intel Corporation 8 Series/C220 Series Chipset Family 6-port SATA Controller 1 [AHCI mode] (rev 05)
00:1f.3 SMBus: Intel Corporation 8 Series/C220 Series Chipset Family SMBus Controller (rev 05)
01:00.0 3D controller: NVIDIA Corporation GM107M [GeForce GTX 860M] (rev a2)
03:00.0 Network controller: Intel Corporation Wireless 7260 (rev bb)
04:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. Device 5287 (rev 01)
04:00.1 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller (rev 12)

The output from the lsusb command in SystemRescueCd was as follows:

# lsusb
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 004: ID 5986:055c Acer, Inc <-- The Webcam!
Bus 003 Device 003: ID 8087:07dc Intel Corp.
Bus 003 Device 002: ID 0dd8:17c0 Netac Technology Co., Ltd
Bus 003 Device 005: ID 090c:3261 Silicon Motion, Inc. - Taiwan (formerly Feiya Technology Corp.)
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 002: ID 8087:8000 Intel Corp.
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:8008 Intel Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

The output from the lsmod command in SystemRescueCd was as follows:

# lsmod
Module                  Size  Used by
nilfs2                117674  0 
ccm                    16515  2 
arc4                   12390  2 
iwlmvm                149978  0 
mac80211              421465  1 iwlmvm
btusb                  24725  0 
iwlwifi                88602  1 iwlmvm
bluetooth             258391  2 btusb
cfg80211              320349  3 iwlwifi,mac80211,iwlmvm
x86_pkg_temp_thermal    12390  0 
6lowpan_iphc           16649  1 bluetooth
coretemp               12390  0 
iTCO_wdt               12390  0 
mei_me                 12576  0 
iTCO_vendor_support    12938  1 iTCO_wdt
crct10dif_pclmul       12479  0 
crc32_pclmul           12483  0 
crc32c_intel           16568  0 
i2c_i801               16533  0 
ghash_clmulni_intel    12523  0 
mei                    58244  1 mei_me
tpm_infineon           12437  0 
joydev                 16535  0 
tpm_tis                16533  0 
rfkill                 18094  3 cfg80211,bluetooth
serio_raw              12439  0 
tpm                    26448  2 tpm_tis,tpm_infineon
lpc_ich                20629  0 
shpchp                 29571  0 
microcode              41719  0 
raid10                 37123  0 
raid456                57671  0 
async_raid6_recov      12621  1 raid456
async_pq               12640  2 raid456,async_raid6_recov
async_xor              12573  3 async_pq,raid456,async_raid6_recov
async_memcpy           12464  2 raid456,async_raid6_recov
async_tx               12840  5 async_pq,raid456,async_xor,async_memcpy,async_raid6_recov
raid1                  28900  0 
raid0                  16515  0 
multipath              12390  0 
linear                 12390  0 
usb_storage            52365  2 
nouveau               793903  0 
i915                  586099  2 
ttm                    66567  1 nouveau
drm_kms_helper         37632  2 i915,nouveau
drm                   216971  5 ttm,i915,drm_kms_helper,nouveau
i2c_algo_bit           12633  2 i915,nouveau
i2c_core               28421  6 drm,i915,i2c_i801,drm_kms_helper,i2c_algo_bit,nouveau
rtsx_pci_sdmmc         16538  0 
mmc_core               80530  1 rtsx_pci_sdmmc
rtsx_pci_ms            12442  0 
memstick               13784  1 rtsx_pci_ms
mxm_wmi                12672  1 nouveau
r8169                  49390  0 
rtsx_pci               35470  2 rtsx_pci_ms,rtsx_pci_sdmmc
mii                    13085  1 r8169
mfd_core               12807  2 lpc_ich,rtsx_pci
wmi                    13114  2 mxm_wmi,nouveau
video                  16832  2 i915,nouveau

The output from the SystemRescueCd lsmod command told me that the nouveau driver works with this laptop, that the iwlwifi driver works too, and that the r8169 driver was the likely driver I would need for the wired Ethernet connection (I did not bother to connect an Ethernet cable whilst using SystemRescueCd).

The output from the SystemRescueCd ifconfig command told me the new names of the eth0 and wlan0 interfaces: enp4s0f1 and wlp3s0. I force udev/eudev to use interface names eth0 and wlan0 on my Compal laptop (by adding the parameter net.ifnames=0 to the kernel boot line and by using the command ‘ln -s /dev/null /etc/udev/rules.d/80-net-setup-link.rules‘). However, although I dislike freedesktop.org’s so-called ‘predictable network interface names‘, I decided to stick with the new interface naming scheme on the Clevo.

As shown in the Handbook, make sure you cd into the directory /mnt/gentoo/ before downloading the Gentoo Stage 3 tarball, otherwise you will end up with the tarball in the wrong directory.

I stuck with the CPU FLAGS specified in the default make.conf file to start with, then, as soon as it was possible during the installation process, I installed app-portage/cpuinfo2cpuflags, ran it to obtain the correct CPU flags and modified /etc/portage/make.conf accordingly (I duplicated the CPU flags in USE="..." and CPU_FLAGS_X86="..." as recommended in Gentoo news item 2015-01-28-cpu_flags_x86-introduction).

I found configuring make.conf for USE flags confusing (see Configuring the USE variable). Although the KDE profile I eselected already contained quite a few of the global USE flags I thought I wanted/needed, I ended up duplicating several of them in make.conf rather than going through the output from the emerge --info command to see which USE flags are already included. I will clean up make.conf sometime in the future. The way to check which USE flags are provided by the profile is to temporarily comment out the USE variable lines in make.conf (and presumably any in /etc/portage/package.use/*) then run the emerge --info command. Anyway, here is what make.conf looked like after I had edited it:

CFLAGS="-O2 -march=native -pipe"
CXXFLAGS="${CFLAGS}"
LDFLAGS="-Wl,-O1,--as-needed"
# WARNING: Changing your CHOST is not something that should be done lightly.
# Please consult http://www.gentoo.org/doc/en/change-chost.xml before changing.
CHOST="x86_64-pc-linux-gnu"
MY_CPUFLAGS="aes avx avx2 fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3"
CPU_FLAGS_X86="aes avx avx2 fma3 mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3"

UNWANTED="-apm -branding -eds -evo -kerberos -gnome -gtk -libav -mono -nepomuk -oss -qt5 -systemd"
MY_MEDIA="alsa audiofile cdda cddb cdr dri dvb dvd dvdr dvdread jack ipod musicbrainz pulseaudio sdl v4l wmf xine"
MY_CODECS="a52 aac dts dv ffmpeg flac gsm lame matroska mp3 musepack ogg openal speex theora x264 xvid"
MY_SYSTEM="acl acpi avahi bash-completion bidi bluetooth bzip2 cjk dbus gcj gnutls icu lm_sensors lzo networkmanager nptl pam policykit udev unicode usb wifi xcb zeroconf"
MY_FILESYS="inotify"
MY_PRINT="cups foomaticdb gimp ppds scanner"
MY_XSYS="cairo dga gphoto2 gtk openexr opengl png qt4 svg tiff X xinerama"
MY_DESKTOP="gmp kde libnotify pda rdesktop semantic-desktop startup-notification"
MY_BROWSER="nsplugin"
MY_COMMS="aim icq imap jabber mbox msn rss slp yahoo"
USE="${USE} ${UNWANTED} ${MY_MEDIA} ${MY_CODECS} ${MY_SYSTEM} ${MY_FILESYS} ${MY_PRINT} ${MY_XSYS} ${MY_DESKTOP} ${MY_BROWSER} ${MY_COMMS} ${MY_CPUFLAGS}"

PORTDIR="/usr/portage"
DISTDIR="${PORTDIR}/distfiles"
PKGDIR="${PORTDIR}/packages"
# The following line is for Layman:
source /var/lib/layman/make.conf
# The following line is for my local overlay:
PORTDIR_OVERLAY="/usr/local/portage ${PORTDIR_OVERLAY}"
LINGUAS="en en_GB pt_BR es_ES"
GRUB_PLATFORMS="pc"
MAKEOPTS="-j9"

INPUT_DEVICES="evdev synaptics"
VIDEO_CARDS="intel modesetting nvidia"

GENTOO_MIRRORS="rsync://mirror.bytemark.co.uk/gentoo/ http://mirror.qubenet.net/mirror/gentoo/ rsync://rsync.mirrorservice.org/distfiles.gentoo.org/"
SYNC="rsync://rsync.uk.gentoo.org/gentoo-portage"

I don’t have the ‘source’ line and ‘SYNC’ line in my ~amd64 installation on the Compal because they are running later versions of Portage and Layman, for which the method has changed.

When following the Gentoo Handbook and merging some packages, sometimes messages about required USE flags were displayed. In some of those cases, after studying the messages carefully I repeated the merge command but included the --autounmask-write option, then used the etc-update command to apply the edits to the /etc/portage/package.use/* files, then repeated the merge command. In some cases, e.g. if only one or two USE flag changes needed, I created the new file /etc/portage/package.use/* and performed the edit manually. For example, /etc/portage/package.use/networkmanager containing:

net-misc/networkmanager nss -dhclient dhcpcd -gnutls modemmanager

I am not sure which modules to declare in /etc/conf.d/modules, since the only ones I have to declare in that file in my Compal laptop installation are VirtualBox modules and other modules are loaded automatically. Anyway, I added the r8169, nvidia and fuse modules to that file to start with. Later I added some more and it currently looks like this:

modules="r8169 nvidia fuse agpgart bnep rfcomm hidp mmc_block uvcvideo cifs"

I added ‘agpgart‘ because of what user Arthanis wrote in his post in the Gentoo Forums thread [SOLVED] Optimus and Nvidia but there is no module named agpgart in my installation, so I am not sure to what he was referring.

The modules loaded so far are listed below:

# lsmod
Module                  Size  Used by
cifs                  438492  0 
mmc_block              25911  0 
mmc_core               85695  1 mmc_block
hidp                   14125  0 
rfcomm                 32181  12 
bnep                   10116  2 
fuse                   76386  2 
nvidia               8385213  33 
ecb                     1921  1 
iwlmvm                143855  0 
r8169                  67544  0 
btusb                  22292  0 
bluetooth             281605  33 bnep,hidp,btusb,rfcomm
uvcvideo               71061  0 
videobuf2_vmalloc       2800  1 uvcvideo
videobuf2_memops        1799  1 videobuf2_vmalloc
videobuf2_core         34587  1 uvcvideo
mii                     3875  1 r8169
iwlwifi                75755  1 iwlmvm
x86_pkg_temp_thermal     4567  0

The rest of the drivers are in-kernel.

Version 216 of sys-fs/udev was installed, which predates the change in udev to stop loading firmware (see the Gentoo Forums thread udev-217 stalls booting) so I may have trouble with loading CPU microcode and WiFi firmware (and video firmware? — see further on) in future when sys-fs/udev-217 becomes stable in the Gentoo Portage tree.

I configured netifrc for enp4s0f1 only (I didn’t bother with WiFi) for DHCP, as per Gentoo Handbook section Configuring the system, as I only wanted to be sure of a network connection after rebooting until I could get NetworkManager working, at which I point I would ditch the netifrc stuff completely. As I have to travel frequently because of my work, I find NetworkManager more convenient.

Apart from configuring the kernel (I lost count of how many times I had to rebuild it), the only problem was when I installed GRUB 2 (Gentoo Handbook section Configuring the bootloader). There appears to be an error in the Gentoo Handbook; see Gentoo Forums thread grub2 install for the fix.

X Windows and NVIDIA Optimus

However, getting X Windows working was a major hassle. First I followed the Gentoo Wiki article X server to install the packages xorg-server and xorg-drivers, then I followed the Gentoo Wiki article NVIDIA Driver with Optimus Laptops to try and get the closed-source NVIDIA driver working, but X Windows could not find a screen. (I have no idea what sys-apps/qingy is or whether it is needed, but, as the Wiki article mentions it, I installed it anyway but did not add the xrandr commands to the end of the /etc/X11/Sessions/KDE-4 file, but I did add the xrandr commands to the /usr/share/config/kdm/Xsetup file.) Then I followed Gentoo user Arthanis‘ Gentoo Forums post [SOLVED] Optimus and Nvidia (changing the edid_firmware name to suit). I was confused by his reference to rcu_idle_delay, by which he meant CONFIG_RCU_FAST_NO_HZ (see Understanding RCU when Configuring the Linux Kernel). Thank goodness for his post, though, as I would never have worked it out myself. All my main laptops since 2000 have had ATI GPUs, and they were easier to set up than this NVIDIA Optimus stuff. Although the laptop has both Intel and NVIDIA graphics hardware, I think the laptop is muxless (i.e. does not have hybrid graphics/NVIDIA HybridPower), so I left CONFIG_VGASWITCHERROO=n in the kernel, but I have no idea if that is correct. This whole dual GPU/APU switching thing confuses me.

After I followed Arthanis‘ post and rebooted, the KDM screen consisted of tiled ‘mini-screens’, with the KDM log-in window in the top left mini-screen. I solved this by adding a Virtual command in xorg.conf — see the Gentoo Forums post XOrg refusing to start after a fresh build by user qweb.ric.

Below are the current contents of xorg.conf:

Section "ServerLayout"
    Identifier     "Layout0"
    Screen      0  "nvidia" 0 0
    Inactive       "intel"
    InputDevice    "Keyboard0" "CoreKeyboard"
    InputDevice    "Mouse0" "CorePointer"
EndSection

#Section "Files"
#EndSection

Section "InputDevice"
    Identifier     "Mouse0"
    Driver         "mouse"
    Option         "Protocol"
    Option         "Device" "/dev/input/mice"
    Option         "Emulate3Buttons" "no"
    Option         "ZAxisMapping" "4 5"
EndSection

Section "InputDevice"
    Identifier     "Keyboard0"
    Driver         "kbd"
EndSection

Section "Monitor"
    Identifier     "Monitor0"
    Option         "DPMS"
EndSection

Section "Device"
    Identifier     "nvidia"
    Driver         "nvidia"
    BusID          "PCI:1:0:0"
EndSection

Section "Device"
    Identifier     "intel"
    Driver         "modesetting"
    BusID          "PCI:0:2:0"
EndSection

Section "Screen"
    Identifier     "nvidia"
    Device         "nvidia"
    Monitor        "Monitor0"
    DefaultDepth    24
    Option         "UseDisplayDevice" "none"
    SubSection     "Display"
        Depth       24
#        Modes      "nvidia-auto-select"
        Virtual     1920 1080
    EndSubSection
EndSection

Section "Screen"
    Identifier     "intel"
    Device         "intel"
    Monitor        "Monitor0"
EndSection

To get tapping to work on the touchpad I had to create the file /etc/X11/xorg.conf.d/50-synaptics.conf as usual:

Section "InputClass"
    Identifier "touchpad catchall"
    Driver "synaptics"
    MatchIsTouchpad "on"
    MatchDevicePath "/dev/input/event*"
    Option "TapButton1" "1"
    Option "TapButton2" "2"
    Option "TapButton3" "3"
    Option "VertEdgeScroll" "on"
    Option "VertTwoFingerScroll" "on"
    Option "HorizEdgeScroll" "on"
    Option "HorizTwoFingerScroll" "on"
    Option "CircularScrolling" "on"
    Option "CircScrollTrigger" "0"
    Option "EmulateTwoFingerMinZ" "40"
    Option "EmulateTwoFingerMinW" "8"
    Option "CoastingSpeed" "0"
    Option "FingerLow" "35"
    Option "FingerHigh" "40"
EndSection

Section "InputClass"
    Identifier "touchpad ignore duplicates"
    MatchIsTouchpad "on"
    MatchDevicePath "/dev/input/mouse*"
    Option "Ignore" "on"

And I also created the file /etc/X11/xorg.conf.d/30-keyboard.conf:

Section "InputClass"
    Identifier "keyboard"
    # See /usr/share/X11/xkb/rules/base.lst for Options.
    MatchIsKeyboard "yes"
    Option "XkbLayout" "gb,us,br,es"
    Option "XkbModel" "pc104"
    Option "XkbVariant" ""
    Option "XkbOptions" "grp:alt_shift_toggle"
EndSection

and the file /etc/X11/xorg.conf.d/10-evdev.conf:

Section "InputClass"
        Identifier "evdev pointer catchall"
        MatchIsPointer "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
EndSection

Section "InputClass"
        Identifier "evdev keyboard catchall"
        MatchIsKeyboard "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
EndSection

#Section "InputClass"
#        Identifier "evdev touchpad catchall"
#        MatchIsTouchpad "on"
#        MatchDevicePath "/dev/input/event*"
#        Driver "evdev"
#EndSection

Section "InputClass"
        Identifier "evdev tablet catchall"
        MatchIsTablet "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
EndSection

Section "InputClass"
        Identifier "evdev touchscreen catchall"
        MatchIsTouchscreen "on"
        MatchDevicePath "/dev/input/event*"
        Driver "evdev"
EndSection

(See my post about xorg.conf for a later version (not Stable in the Portage tree yet) of X Windows on the Compal, Fixing unperceived errors in my X Windows configuration.)

I forgot to do the following:

# rc-update add dbus default
# rc-update add consolekit default

See the Gentoo Forums thread [ConsoleKit session] Failed to connect to socket (resolved) for the error message I was getting when the KDE Desktop appeared. In addition to the aforementioned error message, a window with a KDE Daemon crash message popped-up at log-in and KDE Plasma would crash when I dragged the System Tray widget to the Panel. Once the dbus and consolekit services were added to the default runlevel, all was good.

NetworkManager

After I merged NetworkManager I forgot to do:

# rc-update add NetworkManager default

but once I did that and the following:

# rc-update del net.enp4s0f1 default

then NetworkManager worked.

There was no /etc/NetworkManager/NetworkManager.conf, so I created that manually:

[main]
plugins=keyfile
dhcp=dhcpcd
no-auto-default=*

[keyfile]
hostname=clevow230ss

KDE plasma-nm crashes most times I try to create or edit a connection, so sometimes I have to edit the file /etc/NetworkManager/system-connections/* using nano. The current Stable version of plasma-nm in Gentoo is 0.9.3.4 and I believe the latest version of plasma-nm has fixed this bug, so eventually it should work correctly.

Audio

I followed Gentoo Wiki article ALSA and compiled ALSA into the kernel rather than modules. Card 0 is HDMI and Card 1 is HDA (the opposite to what is usually expected). KDE Multimedia settings worked when I selected Analogue Audio, but I had to install pavucontrol in order to be able to switch off HDMI and get audio in the Web browser etc. to be played via the laptop speakers/headphones. Later I will try the Gentoo Wiki ALSA article’s suggestion of adding snd-hda-intel.index=1,0 to the kernel boot line to switch the order of the cards.

Although I set what I think are the relevant MMC parameters in the kernel configration, the Memory Card slot does not work. Perhaps some kernel configuration settings remain to be set. I will have a look later. Gentoo Forums thread SD card under Gentoo Linux may help.

Bluetooth

Bluetooth is working after I made some kernel configuration settings and loaded the modules bnep, rfcomm and hidp via /etc/conf.d/modules (lsmod showed that btusb and bluetooth were already loaded automatically, but I added them anyway to /etc/conf.d/modules). I also had to do:

# rc-update bluetooth add default

The external portable USB portable CD/DVD writer (Samsung SE-208GB/RSBD) I bought from pcspecialist works well. I have tried it so far with an Audio CD, a data DVD and burning data to a CD-R.

Webcam

The built-in Webcam does not work. Update (April 29, 2015): I discovered today that the Webcam works fine; the problem was a bug in the version of the guvcview application I tried. So all is good. According to lsusb the Webcam is:

Bus 001 Device 010: ID 5986:055c Acer, Inc

The lsmod command shows the uvcvideo module is loaded. When I ‘rmmod uvcvideo‘ then ‘modprobe uvcvideo‘ the dmesg command shows the following:

[ 6508.624505] uvcvideo: Found UVC 1.00 device BisonCam, NB Pro (5986:055c)
[ 6508.627349] input: BisonCam, NB Pro as /devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.4/1-1.4:1.0/input/input43
[ 6508.627425] usbcore: registered new interface driver uvcvideo
[ 6508.627427] USB Video Class driver (1.1.1)

The application guvcview displays a black window, and the Konsole from which guvcview was launched displays repeated ‘Ignoring empty buffer ...‘ messages:

$ guvcview
guvcview 1.6.1
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.28/work/alsa-lib-1.0.28/src/pcm/pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.28/work/alsa-lib-1.0.28/src/pcm/pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.28/work/alsa-lib-1.0.28/src/pcm/pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.28/work/alsa-lib-1.0.28/src/pcm/pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.28/work/alsa-lib-1.0.28/src/pcm/pcm.c:2239:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
ALSA lib /var/tmp/portage/media-libs/alsa-lib-1.0.28/work/alsa-lib-1.0.28/src/pcm/pcm_dmix.c:1022:(snd_pcm_dmix_open) unable to open slave
video device: /dev/video0
Init. BisonCam, NB Pro (location: usb-0000:00:1a.0-1.4)
{ pixelformat = 'MJPG', description = 'MJPEG' }
{ discrete: width = 640, height = 480 }
        Time interval between frame: 1/30, 
{ discrete: width = 160, height = 120 }
        Time interval between frame: 1/30, 
{ discrete: width = 176, height = 144 }
        Time interval between frame: 1/30, 
{ discrete: width = 320, height = 240 }
        Time interval between frame: 1/30, 
{ discrete: width = 352, height = 288 }
        Time interval between frame: 1/30, 
{ discrete: width = 640, height = 360 }
        Time interval between frame: 1/30, 
{ discrete: width = 1280, height = 720 }
        Time interval between frame: 1/30, 
{ discrete: width = 1280, height = 1024 }
        Time interval between frame: 1/30, 
{ discrete: width = 1920, height = 1080 }
        Time interval between frame: 1/30, 
{ discrete: width = 640, height = 480 }
        Time interval between frame: 1/30, 
{ pixelformat = 'YUYV', description = 'YUV 4:2:2 (YUYV)' }
{ discrete: width = 640, height = 480 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 160, height = 120 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 176, height = 144 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 320, height = 240 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 352, height = 288 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 640, height = 360 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 1280, height = 720 }
        Time interval between frame: 1/10, 
{ discrete: width = 1280, height = 1024 }
        Time interval between frame: 1/5, 
{ discrete: width = 1920, height = 1080 }
        Time interval between frame: 1/5, 
{ discrete: width = 640, height = 480 }
        Time interval between frame: 1/30, 1/15, 
{ pixelformat = 'RGB3', description = 'RGB3' }
{ discrete: width = 640, height = 480 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 160, height = 120 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 176, height = 144 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 320, height = 240 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 352, height = 288 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 640, height = 360 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 1280, height = 720 }
        Time interval between frame: 1/30, 
{ discrete: width = 1280, height = 1024 }
        Time interval between frame: 1/30, 
{ discrete: width = 1920, height = 1080 }
        Time interval between frame: 1/30, 
{ pixelformat = 'BGR3', description = 'BGR3' }
{ discrete: width = 640, height = 480 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 160, height = 120 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 176, height = 144 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 320, height = 240 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 352, height = 288 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 640, height = 360 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 1280, height = 720 }
        Time interval between frame: 1/30, 
{ discrete: width = 1280, height = 1024 }
        Time interval between frame: 1/30, 
{ discrete: width = 1920, height = 1080 }
        Time interval between frame: 1/30, 
{ pixelformat = 'YU12', description = 'YU12' }
{ discrete: width = 640, height = 480 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 160, height = 120 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 176, height = 144 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 320, height = 240 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 352, height = 288 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 640, height = 360 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 1280, height = 720 }
        Time interval between frame: 1/30, 
{ discrete: width = 1280, height = 1024 }
        Time interval between frame: 1/30, 
{ discrete: width = 1920, height = 1080 }
        Time interval between frame: 1/30, 
{ pixelformat = 'YV12', description = 'YV12' }
{ discrete: width = 640, height = 480 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 160, height = 120 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 176, height = 144 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 320, height = 240 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 352, height = 288 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 640, height = 360 }
        Time interval between frame: 1/30, 1/15, 
{ discrete: width = 1280, height = 720 }
        Time interval between frame: 1/30, 
{ discrete: width = 1280, height = 1024 }
        Time interval between frame: 1/30, 
{ discrete: width = 1920, height = 1080 }
        Time interval between frame: 1/30, 
vid:5986 
pid:055c
driver:uvcvideo
checking format: 1196444237
VIDIOC_G_COMP:: Inappropriate ioctl for device
fps is set to 1/30
drawing controls

fps is set to 1/30
Checking video mode 640x480@32bpp : OK
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
Ignoring empty buffer ...
< Here I pressed Ctrl-C >
write /home/fitzcarraldo/.guvcviewrc OK
free controls
cleaned allocations - 100%
Closing portaudio ...OK
Closing GTK... OK

I tried all the available uvcvideo quirks (see Linux UVC driver and tools – FAQ: What are quirks and how do I use them?) but the result was always the same.

# rmmod uvcvideo
# modprobe uvcvideo quirks=0x00000200
# rmmod uvcvideo
# modprobe uvcvideo quirks=0x00000100
# rmmod uvcvideo
# modprobe uvcvideo quirks=0x00000080
# rmmod uvcvideo
# modprobe uvcvideo quirks=0x00000020
# rmmod uvcvideo
# modprobe uvcvideo quirks=0x00000010
# rmmod uvcvideo
# modprobe uvcvideo quirks=0x00000008
# rmmod uvcvideo
# modprobe uvcvideo quirks=0x00000004
# rmmod uvcvideo
# modprobe uvcvideo quirks=0x00000002
# rmmod uvcvideo
# modprobe uvcvideo quirks=0x00000001

There is possibly a bug in the uvcvideo driver (see [Kernel-packages] [Bug 1362358] Re: uvcvideo doesn’t work with USB webcam with linux 3.16), so I will have to try a later kernel at some point.

Update (April 29, 2015): I discovered today that nothing is wrong with the uvcvideo driver or the Webcam. The problem I described above was caused by a bug in the guvcview application itself. The Gentoo Stable version is guvcview-1.6.1, so I specified Gentoo Testing version guvcview-2.0.1 in /etc/portage/package.accept_keywords/guvcview and installed it, and now guvcview displays the Webcam output perfectly.

Transferring Thunderbird account settings and e-mails

My Compal laptop dual-boots Gentoo and Windows 7. Thunderbird is installed in both OSs, and both Windows Thunderbird and Linux Thunderbird use the same Mail folder on the NTFS Windows partition, but with different prefs.js files (i.e. Windows Thunderbird uses a prefs.js file on the Windows partition, and Linux Thunderbird uses a prefs.js file in the /home partition). In order to port my Thunderbird e-mails from the Windows partition on the Compal to the /home partition on the Clevo, I did the following:

  1. Installed Thunderbird on the Clevo.
  2. Launched Thunderbird and cancelled the Thunderbird wizard for creating a new account.
  3. Closed Thunderbird.
  4. Copied the Mail folder from the Compal’s Windows Thunderbird folder into the new Linux Thunderbird profile folder on the Clevo.
  5. Copied the prefs.js file from the Windows Thunderbird folder into the new Linux Thunderbird profile folder on the Clevo.
  6. Edited the prefs.js file to change all the Windows paths to Linux paths.

I also copied the three Address Book files abook.mab, history.mab and impab.mab across, but the first e-mail address in the Address Book differed between the two laptops so I exported the address books from Thunderbird in Linux (‘Address Book’ > ‘Tools’ > ‘Export…’ to create .ldif files) on the Compal and imported them into Thunderbird on the Clevo, but the result was no different to copying the .mab files, so it looks correct (the number of entries in the address books on each laptop was the same). Looking at a fresh installation of Thunderbird, I notice there is no impab.mab file, only the other two, and also the impab.mab file on the Compal has a 2011 date whereas the abook.mab and history.mab have current dates, so I wonder if the impab.mab file is redundant in the latest versions of Thunderbird.

A few panics (mine and the kernel’s!)

I had a couple of panic moments when rebooting after making changes to the kernel: if I had left a USB pen drive or a USB HDD plugged into the Clevo when I rebooted, the kernel would oops during boot-up. I initially thought these kernel panics were due to my mis-configuration of the kernel, but finally realised what was causing the oops when one of the error messages referred to a partition sdc1 on a pen drive. Actually, I had enabled too many kernel options in my first kernel build so it was probably better that I restarted the Gentoo installation anyway (I only restarted the installation from scratch once). The Compal boots normally if it has USB storage devices plugged in when it boots, so I’m not sure why it happens on the Clevo. Both laptops have the HDD first in the boot order, so I don’t know why the Clevo complains.

External monitor

I used xrandr commands to get my external monitor (an Acer AL1916W with a max resolution of 1440×900) to display the Clevo’s desktop correctly. I used the following command to view the available monitors and modes:

$ xrandr -q
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 16384 x 16384
eDP-1-0 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 282mm x 165mm
   1920x1080     60.00*+  40.00  
   1400x1050     59.98  
   1280x1024     60.02  
   1280x960      60.00  
   1024x768      60.04    60.00  
   960x720       60.00  
   928x696       60.05  
   896x672       60.01  
   800x600       60.00    60.32    56.25  
   700x525       59.98  
   640x512       60.02  
   640x480       60.00    59.94  
   512x384       60.00  
   400x300       60.32    56.34  
   320x240       60.05  
VGA-1-0 disconnected (normal left inverted right x axis y axis)
DisplayPort-1-0 connected (normal left inverted right x axis y axis)
   1920x1080     60.00 +  40.00  
HDMI-1-0 disconnected (normal left inverted right x axis y axis)

I don’t know why the connected AL1916W monitor is shown as having only one display mode, and why that mode is 1920×1080. The AL1916W supports several modes up to 1440×900, and these are all displayed by the xrandr command on the Compal. It seems the NVIDIA driver is unable to read the external monitor’s EDID whereas the AMD ATI FGLRX driver is able to do so. Anyway I did the following to force the NVIDIA driver to display the Desktop correctly, which I later automated in a Bash script launched from a Desktop Configuration File:

$ xrandr --output DisplayPort-1-0 --off
$ xrandr --newmode "1440x900" 106.50 1440 1528 1672 1904 900 903 909 934 -hsync +vsync # Only need to add new mode once per X session.
$ xrandr --addmode DisplayPort-1-0 1440x900
$ xrandr --output eDP-1-0 --off && xrandr --output DisplayPort-1-0 --mode 1440x900

I pressed the AL1916W monitor’s MENU button and selected AUTO to make sure the monitor’s display is as sharp as possible.

Scanners

I have an HP ScanJet 3400C scanner and my Canon PIXMA MP560 MFP also has a scanner. I had to install hplip in order to be able to use XSane, gscan2pdf and Simple Scan with the HP ScanJet 3400C scanner. I also found that the HP ScanJet 3400C must be switched off in order to be able to use the Canon MP560 scanner, whereas I don’t need to switch off the Canon MP560 in order to be able to use the HP ScanJet 3400C!

Skype and PulseAudio

As Qt 4.8.5 has not yet been marked stable in Gentoo, and therefore there is not a stable version of Qt with the abi_x86_32 USE flag, I installed Skype using the hack given by Gentoo user pablo_supertux in his Gentoo Forums post [SOLVED] Skype and the new multilib, which works well.

The laptop’s volume settings jumped to 100% periodically, and this is another of PulseAudio’s irritating quirks. To stop this happening I edited the file /etc/pulse/daemon.conf and changed:

; flat-volumes = yes

to:

flat-volumes = no

i.e. I uncommented the line and changed ‘yes‘ to ‘no‘.

I had disabled Skype from automatically adjusting audio settings. If I still find that PulseAudio is causing volume levels to change at start-up (see my earlier posts), I will create a script in /etc/local.d/ to set them automatically for me.

Things left for me to do:

  1. Get the Webcam working. Update (April 29, 2015): Done! It turned out there was nothing wrong with the uvcvideo driver or the hardware; the guvcview application had a bug. I installed a newer version of guvcview and it works correctly. So all is good.
  2. Get the Memory Card slot working. Boot SystemRescueCd and see if SDHC and/or SDXC memory cards are accessible. Update (April 28, 2015): Done! See my next post Realtek 5287 PCIe controller for memory card reader for the changes I made to the kernel configuration.
  3. Check the Bash backup scripts I created for the Compal and edit them if necessary so that they work on the Clevo. Update (April 29, 2015): Done!
  4. When Qt 4.8.6 is made Stable in the Portage tree, install Skype using Portage. Update (May 16, 2015): Done!
  5. Check which other applications and utilities I installed on the Compal need to be installed on the Clevo. Update (April 29, 2015): Done!
  6. Install the Samsung Unified Printer driver and get it working with the Samsung printers in the office. Update (April 29, 2015): Done!
  7. Investigate why the Clevo cannot print to my Canon PIXMA MP560 via WiFi. Update (May 15, 2015): Done! The problem was with the printer, not the Clevo. The printer was not always connecting to my home WiFi network.
  8. Install UFW and either a) the KDE KControl Module for UFW or b) UFW Frontends, and add firewall rules for Samba/CIFS and KDE Connect. Update (June 30, 2015): Done! Finally got around to doing it. ufw was giving an error message for IPv6, though, but I fixed that by rebuilding the kernel with some more parameters selected: CONFIG_NETFILTER_XT_TARGET_HL=m, CONFIG_IP6_NF_MATCH_RT=m and CONFIG_IP6_NF_TARGET_HL=m.
  9. Investigate why Samba cannot access the family Acer Aspire XC600 running Windows 8.1. The Samba service is running on the Clevo, and both Samba 3 and Samba 4 on the Compal can access shares on the Aspire XC600 and on the Clevo, so something must be wrong with the installation on the Clevo. Update (May 17, 2015): Done! The problem was that I had not merged kde-base/kdebase-kioslaves with the samba USE flag. Once I did that, Dolphin could browse Samba shares on the family PC running Windows 8.1.
  10. Find out the manual commands for switching between the Intel APU and NVIDIA GPU that Gentoo user Arthanis mentioned in his post [SOLVED] Optimus and Nvidia. Update (June 30, 2015): Done! See the latest post in the aformentioned Gentoo Forums thread. Sometime in the next month or so I’ll post in this blog the full details of my solution.
  11. Investigate why the KDE Network widget plasma-nm is crashing when I add/edit connections (see a recent KDE blog post Plasma-nm 0.9.3.6 release about the last update to plasma-nm-4.* which fixes some bugs). I suppose I need to wait for plasma-nm-0.9.3.5 to become stable in the Portage main tree. Update (April 30, 2015): Done! I got fed up with the buggy ‘Stable’ plasma-nm-0.9.3.4 so I added plasma-nm-0.9.3.5 to /etc/portage/package.accept_keywords/plasma-nm and Version 0.9.3.5 is no longer crashing.
  12. Get qr-tools (QR Code application) working on the Clevo. Update (April 29, 2015): Done!

Downloading YouTube video or only audio

One of my favourite Linux applications is the command-line utility youtube-dl, which I use quite often to download YouTube videos or extract only the audio, either for leisure or work purposes.

Downloading a video

  1. Copy the URL of the YouTube video from the browser’s address bar. I’ll use the video ‘Como fazer um bom churrasco de Picanha‘ as an example.

  2. Ascertain the types and resolutions available for that particular video:

    $ youtube-dl -F https://www.youtube.com/watch?v=8BuQCD8eh9k
    8BuQCD8eh9k: Downloading webpage
    8BuQCD8eh9k: Extracting video information
    8BuQCD8eh9k: Downloading DASH manifest
    [info] Available formats for 8BuQCD8eh9k:
    format code extension resolution  note
    171         webm      audio only  DASH audio  118k , audio@128k (44100Hz), 5.05MiB
    140         m4a       audio only  DASH audio  129k , m4a_dash container, aac @128k (44100Hz), 5.99MiB
    141         m4a       audio only  DASH audio  256k , m4a_dash container, aac @256k (44100Hz), 11.90MiB
    160         mp4       256x144     DASH video  111k , 15fps, video only, 5.03MiB
    242         webm      426x240     DASH video  190k , 1fps, video only, 7.19MiB
    133         mp4       426x240     DASH video  248k , 30fps, video only, 11.33MiB
    243         webm      640x360     DASH video  378k , 1fps, video only, 13.83MiB
    134         mp4       640x360     DASH video  465k , 30fps, video only, 12.98MiB
    244         webm      854x480     DASH video  744k , 1fps, video only, 27.11MiB
    135         mp4       854x480     DASH video  873k , 30fps, video only, 25.98MiB
    247         webm      1280x720    DASH video 1378k , 1fps, video only, 49.45MiB
    136         mp4       1280x720    DASH video 1837k , 30fps, video only, 58.40MiB
    17          3gp       176x144
    36          3gp       320x240
    5           flv       400x240
    43          webm      640x360
    18          mp4       640x360
    22          mp4       1280x720 (best)

  3. Chose which video resolution you would like to download. For example I’ll download the highest resolution available for this particular video (Format 22, which is a 1280×720 MPEG-4 file):

    $ youtube-dl -f 22 -o Como_fazer_um_bom_churrasco_de_Picanha.mp4 https://www.youtube.com/watch?v=8BuQCD8eh9k
    8BuQCD8eh9k: Downloading webpage
    8BuQCD8eh9k: Extracting video information
    8BuQCD8eh9k: Downloading DASH manifest
    [download] Destination: Como_fazer_um_bom_churrasco_de_Picanha.mp4
    [download] 100% of 83.77MiB in 07:09

Extracting audio from YouTube videos

Let’s say you just want an audio file of the video’s sound track. There are several options, so I’ll just show a few simple examples here:

  1. MP3 file at default quality:

    $ youtube-dl --extract-audio --audio-format mp3 -t https://www.youtube.com/watch?v=8BuQCD8eh9k
    8BuQCD8eh9k: Downloading webpage
    8BuQCD8eh9k: Extracting video information
    8BuQCD8eh9k: Downloading DASH manifest
    [download] Destination: Como fazer um bom churrasco de Picanha-8BuQCD8eh9k.m4a
    [download] 100% of 11.90MiB in 00:56
    [ffmpeg] Correcting container in "Como fazer um bom churrasco de Picanha-8BuQCD8eh9k.m4a"
    [ffmpeg] Destination: Como fazer um bom churrasco de Picanha-8BuQCD8eh9k.mp3
    Deleting original file Como fazer um bom churrasco de Picanha-8BuQCD8eh9k.m4a (pass -k to keep)

    You can see from the console output above that youtube-dl downloads an M4A file and then uses ffmpeg to convert it to the audio file type you specified. You can check the file’s properties:

    $ file Como\ fazer\ um\ bom\ churrasco\ de\ Picanha-8BuQCD8eh9k.mp3
    Como fazer um bom churrasco de Picanha-8BuQCD8eh9k.mp3: Audio file with ID3 version 2.4.0, contains: MPEG ADTS, layer III, v1, 64 kbps, 44.1 kHz, Stereo

  2. MP3 file of 128 kbps:

    $ youtube-dl --extract-audio --audio-format mp3 --audio-quality 128K -t https://www.youtube.com/watch?v=8BuQCD8eh9k
    8BuQCD8eh9k: Downloading webpage
    8BuQCD8eh9k: Extracting video information
    8BuQCD8eh9k: Downloading DASH manifest
    [download] Destination: Como fazer um bom churrasco de Picanha-8BuQCD8eh9k.m4a
    [download] 100% of 11.90MiB in 01:23
    [ffmpeg] Correcting container in "Como fazer um bom churrasco de Picanha-8BuQCD8eh9k.m4a"
    [ffmpeg] Destination: Como fazer um bom churrasco de Picanha-8BuQCD8eh9k.mp3
    Deleting original file Como fazer um bom churrasco de Picanha-8BuQCD8eh9k.m4a (pass -k to keep)
    $ file Como\ fazer\ um\ bom\ churrasco\ de\ Picanha-8BuQCD8eh9k.mp3
    Como fazer um bom churrasco de Picanha-8BuQCD8eh9k.mp3: Audio file with ID3 version 2.4.0, contains: MPEG ADTS, layer III, v1, 128 kbps, 44.1 kHz, Stereo

  3. M4A file at best quality available for that particular video:

    $ youtube-dl --extract-audio --audio-format best -t https://www.youtube.com/watch?v=8BuQCD8eh9k
    8BuQCD8eh9k: Downloading webpage
    8BuQCD8eh9k: Extracting video information
    8BuQCD8eh9k: Downloading DASH manifest
    [download] Destination: Como fazer um bom churrasco de Picanha-8BuQCD8eh9k.m4a
    [download] 100% of 11.90MiB in 01:07
    [ffmpeg] Correcting container in "Como fazer um bom churrasco de Picanha-8BuQCD8eh9k.m4a"
    Post-process file Como fazer um bom churrasco de Picanha-8BuQCD8eh9k.m4a exists, skipping

To see the many options available in youtube-dl:

$ man youtube-dl

or:

$ youtube-dl --help

Have fun!

Intel HD Audio clicks when a laptop is running on battery power

Yet another audio problem in Linux on my laptop. There were clicks in the audio output from headphones and the built-in speakers while running the laptop on battery power and listening to music. Details of my laptop’s two sound cards are given below:

# lspci | grep -i audio
00:1b.0 Audio device: Intel Corporation 5 Series/3400 Series Chipset High Definition Audio (rev 05)
01:00.1 Audio device: Advanced Micro Devices, Inc. [AMD/ATI] Redwood HDMI Audio [Radeon HD 5000 Series]

# hwinfo --sound
17: PCI 1b.0: 0403 Audio device
[Created at pci.328]
Unique ID: u1Nb.sEm8vDosIQF
SysFS ID: /devices/pci0000:00/0000:00:1b.0
SysFS BusID: 0000:00:1b.0
Hardware Class: sound
Model: "Intel 5 Series/3400 Series Chipset High Definition Audio"
Vendor: pci 0x8086 "Intel Corporation"
Device: pci 0x3b56 "5 Series/3400 Series Chipset High Definition Audio"
SubVendor: pci 0x14c0 "COMPAL Electronics Inc"
SubDevice: pci 0x0043
Revision: 0x05
Driver: "snd_hda_intel"
Driver Modules: "snd_hda_intel"
Memory Range: 0xd8100000-0xd8103fff (rw,non-prefetchable)
IRQ: 31 (17929 events)
Module Alias: "pci:v00008086d00003B56sv000014C0sd00000043bc04sc03i00"
Driver Info #0:
Driver Status: snd_hda_intel is active
Driver Activation Cmd: "modprobe snd_hda_intel"
Config Status: cfg=new, avail=yes, need=no, active=unknown

28: PCI 100.1: 0403 Audio device
[Created at pci.328]
Unique ID: NXNs.nzRufOXHPI0
Parent ID: 3hqH.Db2_i3v_bw2
SysFS ID: /devices/pci0000:00/0000:00:03.0/0000:01:00.1
SysFS BusID: 0000:01:00.1
Hardware Class: sound
Model: "ATI Redwood HDMI Audio [Radeon HD 5000 Series]"
Vendor: pci 0x1002 "ATI Technologies Inc"
Device: pci 0xaa60 "Redwood HDMI Audio [Radeon HD 5000 Series]"
SubVendor: pci 0x0000
SubDevice: pci 0xaa60
Driver: "snd_hda_intel"
Driver Modules: "snd_hda_intel"
Memory Range: 0xd8020000-0xd8023fff (rw,non-prefetchable)
IRQ: 32 (87 events)
Module Alias: "pci:v00001002d0000AA60sv00000000sd0000AA60bc04sc03i00"
Driver Info #0:
Driver Status: snd_hda_intel is active
Driver Activation Cmd: "modprobe snd_hda_intel"
Config Status: cfg=new, avail=yes, need=no, active=unknown
Attached to: #9 (PCI bridge)

The audio codecs in use are as follows:

# cat /proc/asound/card0/codec* | grep Codec
Codec: Realtek ALC272
# cat /proc/asound/card1/codec* | grep Codec
Codec: ATI R6xx HDMI

The kernel modules loaded are as follows:

# lsmod | grep codec
snd_hda_codec_realtek 50367 1
snd_hda_codec_hdmi 32069 1
snd_hda_codec_generic 40974 1 snd_hda_codec_realtek
snd_hda_codec 76106 5 snd_hda_codec_realtek,snd_hda_codec_hdmi,snd_hda_codec_generic,snd_hda_int
el,snd_hda_controller
snd_hwdep 5373 1 snd_hda_codec
snd_pcm 67896 4 snd_hda_codec_hdmi,snd_hda_codec,snd_hda_i
ntel,snd_hda_controller
snd 49659 16 snd_hda_codec_realtek,snd_hwdep,snd_timer,snd_hda_codec_hdmi,snd_pcm,snd_h
da_codec_generic,snd_hda_codec,snd_hda_intel

The Linux kernel has a power-saving feature for Intel HD Audio cards. Each time the audio card goes into the power-saving state, or wakes up from the power-saving state when playing audio, it may produce a clicking noise. Kernel parameter CONFIG_SND_HDA_POWER_SAVE_DEFAULT is used to specify the default time-out in seconds, and setting it to zero disables power-saving mode. Similarly, kernel parameter CONFIG_SND_AC97_POWER_SAVE_DEFAULT is used to specify the default time-out in seconds for AC97 power-saving mode, and setting it to zero disables AC97 power-saving mode. As you can see below, I have both of those parameters set to zero in the kernel:

# grep POWER_SAVE /usr/src/linux/.config
CONFIG_SND_AC97_POWER_SAVE=y
CONFIG_SND_AC97_POWER_SAVE_DEFAULT=0
CONFIG_SND_HDA_POWER_SAVE_DEFAULT=0

Yet I still heard clicks when the laptop was running under battery power. To disable the HD Audio power-save mode for good, I added ‘snd_hda_intel.power_save=0‘ to the end of the kernel boot line in /etc/default/grub and regenerated the grub.cfg file:

# grep GRUB_CMDLINE_LINUX /etc/default/grub
GRUB_CMDLINE_LINUX="BOOT_IMAGE=/kernel-genkernel-x86_64-3.17.1-gentoo-r1 root=/dev/ram0 ramdisk=8192 real_root=/dev/sda6 init=/linuxrc splash=silent,theme:Emergance console=tty1 quiet resume=swap:/dev/sda5 real_resume=/dev/sda5 intel_iommu=off net.ifnames=0 snd_hda_intel.power_save=0"

# mount /dev/sda3 /boot # My boot directory is on its own partition.
# grub2-mkconfig -o /boot/grub/grub.cfg

After rebooting, there are no more clicks when listening to audio under battery power. Problem solved.

Audio in Linux becomes annoying again (continued)

Well, it turned out that the problem playing some system sounds in Thunderbird, described in my previous post, was due to PulseAudio.

Despite sounding fine when played by SMPlayer, the audio clips that sounded distorted/scratchy and too loud when played by Thunderbird also sounded that way when played by VLC. Then I discovered several other .wav files on various Web sites that sounded distorted when played by the browser’s Windows Media Player plug-in (Gecko Media Player). So the problem clearly was not caused by Thunderbird itself. I began to wonder if PulseAudio was the cause. So I adjusted PulseAudio’s sampling frequency, number of fragments and fragment size, and all the clips that previously sounded distorted and too loud now play fine. Here is what I did to fix the problem…

1. Check what PulseAudio is configured to use:

$ pulseaudio --dump-conf
### Read from configuration file: /etc/pulse/daemon.conf ###
daemonize = no
fail = yes
high-priority = yes
nice-level = -11
realtime-scheduling = yes
realtime-priority = 5
allow-module-loading = yes
allow-exit = yes
use-pid-file = yes
system-instance = no
local-server-type = user
cpu-limit = no
enable-shm = yes
flat-volumes = no
lock-memory = no
exit-idle-time = 20
scache-idle-time = 20
dl-search-path = /usr/lib64/pulse-5.0/modules
default-script-file = /etc/pulse/default.pa
load-default-script-file = yes
log-target =
log-level = notice
resample-method = auto
enable-remixing = yes
enable-lfe-remixing = no
default-sample-format = s16le
default-sample-rate = 44100
alternate-sample-rate = 48000
default-sample-channels = 2
default-channel-map = front-left,front-right
default-fragments = 4
default-fragment-size-msec = 25
enable-deferred-volume = yes
deferred-volume-safety-margin-usec = 8000
deferred-volume-extra-delay-usec = 0
shm-size-bytes = 0
log-meta = no
log-time = no
log-backtrace = 0
rlimit-fsize = -1
rlimit-data = -1
rlimit-stack = -1
rlimit-core = -1
rlimit-rss = -1
rlimit-as = -1
rlimit-nproc = -1
rlimit-nofile = 256
rlimit-memlock = -1
rlimit-locks = -1
rlimit-sigpending = -1
rlimit-msgqueue = -1
rlimit-nice = 31
rlimit-rtprio = 9
rlimit-rttime = 1000000
$

2. Check PulseAudio’s output sample rate:

$ pacmd list-sinks | grep sample
sample spec: s16le 2ch 44100Hz
$

So the sample rate is 16 bits @ 44100 Hz and there are 2 output channels (Stereo). My laptop does indeed have two built-in stereo speakers. ‘s16le‘ means ‘signed 16-bit little-endian’.

3. Check PulseAudio’s input sample rate:

$ pacmd list-sources | grep sample
sample spec: s16le 2ch 44100Hz
sample spec: s16le 2ch 44100Hz
$

So the sample rate is 16 bits @ 44100 Hz and there are 2 input channels (Stereo). My laptop does indeed have two built-in microphones. ‘s16le‘ means ‘signed 16-bit little-endian’.

4. Find out the audio card’s maximum sample rate (Hz):

$ arecord -f dat -r 60000 -D hw:0,0 -d 5 test.wav
Recording WAVE 'test.wav' : Signed 16 bit Little Endian, Rate 60000 Hz, Stereo
Warning: rate is not accurate (requested = 60000Hz, got = 48000Hz)
please, try the plug plugin
$

5. As the console output shows that my audio card supports a sample rate of 48000 Hz, edit /etc/pulse/daemon.conf and change the sample rate accordingly:

$ su
Password:
# grep sample-rate /etc/pulse/daemon.conf
; default-sample-rate = 44100
; alternate-sample-rate = 48000
# nano /etc/pulse/daemon.conf
# grep sample-rate /etc/pulse/daemon.conf
default-sample-rate = 48000
; alternate-sample-rate = 48000
# exit
exit
$

6. Find the buffer size and fragment size for each sound card:

$ echo autospawn = no >> ~/.config/pulse/client.conf
$ pulseaudio --kill
$ LANG=C timeout --foreground -k 10 -s kill 10 pulseaudio -vvvv 2>&1 | grep device.buffering -B 10
I: [pulseaudio] sink.c: alsa.driver_name = "snd_hda_intel"
I: [pulseaudio] sink.c: device.bus_path = "pci-0000:00:1b.0"
I: [pulseaudio] sink.c: sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
I: [pulseaudio] sink.c: device.bus = "pci"
I: [pulseaudio] sink.c: device.vendor.id = "8086"
I: [pulseaudio] sink.c: device.vendor.name = "Intel Corporation"
I: [pulseaudio] sink.c: device.product.id = "3b56"
I: [pulseaudio] sink.c: device.product.name = "5 Series/3400 Series Chipset High Definition Audio"
I: [pulseaudio] sink.c: device.form_factor = "internal"
I: [pulseaudio] sink.c: device.string = "front:0"
I: [pulseaudio] sink.c: device.buffering.buffer_size = "19200"
I: [pulseaudio] sink.c: device.buffering.fragment_size = "4800"
--
I: [pulseaudio] source.c: alsa.driver_name = "snd_hda_intel"
I: [pulseaudio] source.c: device.bus_path = "pci-0000:00:1b.0"
I: [pulseaudio] source.c: sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
I: [pulseaudio] source.c: device.bus = "pci"
I: [pulseaudio] source.c: device.vendor.id = "8086"
I: [pulseaudio] source.c: device.vendor.name = "Intel Corporation"
I: [pulseaudio] source.c: device.product.id = "3b56"
I: [pulseaudio] source.c: device.product.name = "5 Series/3400 Series Chipset High Definition Audio"
I: [pulseaudio] source.c: device.form_factor = "internal"
I: [pulseaudio] source.c: device.string = "front:0"
I: [pulseaudio] source.c: device.buffering.buffer_size = "19200"
I: [pulseaudio] source.c: device.buffering.fragment_size = "4800"
$ sed -i '$d' ~/.config/pulse/client.conf # You can just delete the file instead if it didn't exist in the first place.
$

N.B. Depending on your distribution, the PulseAudio file client.conf (if it exists) may be in a different sub-directory of the user’s home directory.

The console output shows that the buffer size was 19200 bits and the fragment size was 4800 bits.

7. Calculate the number of fragments and the fragment size (msec):

default-fragments = 19200 / 4800 = 4

default-fragments-size-msec

= device.buffering.fragment_size [bits] / (sample rate [Hz] x sample width [bits] x number of channels)

= 4800 / ( 48000 x 16 x 2 )

= 0.003125 seconds = 3.125 msec = 3 msec to the nearest integer

8. Edit /etc/pulse/daemon.conf to set these two parameters to the above-mentioned values:

# grep default-fragment /etc/pulse/daemon.conf
; default-fragments = 4
; default-fragment-size-msec = 25
# nano /etc/pulse/daemon.conf
# grep default-fragment /etc/pulse/daemon.conf
default-fragments = 4
default-fragment-size-msec = 3
# exit
exit
$

9. Restart PulseAudio:

$ pulseaudio --kill
$ pulseaudio --start # Only needed if you have 'autospawn = no' in ~/.config/pulse/client.conf
$

10. Check the PulseAudio configuration:

$ pulseaudio --dump-conf
### Read from configuration file: /etc/pulse/daemon.conf ###
daemonize = no
fail = yes
high-priority = yes
nice-level = -11
realtime-scheduling = yes
realtime-priority = 5
allow-module-loading = yes
allow-exit = yes
use-pid-file = yes
system-instance = no
local-server-type = user
cpu-limit = no
enable-shm = yes
flat-volumes = no
lock-memory = no
exit-idle-time = 20
scache-idle-time = 20
dl-search-path = /usr/lib64/pulse-5.0/modules
default-script-file = /etc/pulse/default.pa
load-default-script-file = yes
log-target =
log-level = notice
resample-method = auto
enable-remixing = yes
enable-lfe-remixing = no
default-sample-format = s16le
default-sample-rate = 48000
alternate-sample-rate = 48000
default-sample-channels = 2
default-channel-map = front-left,front-right
default-fragments = 4
default-fragment-size-msec = 3
enable-deferred-volume = yes
deferred-volume-safety-margin-usec = 8000
deferred-volume-extra-delay-usec = 0
shm-size-bytes = 0
log-meta = no
log-time = no
log-backtrace = 0
rlimit-fsize = -1
rlimit-data = -1
rlimit-stack = -1
rlimit-core = -1
rlimit-rss = -1
rlimit-as = -1
rlimit-nproc = -1
rlimit-nofile = 256
rlimit-memlock = -1
rlimit-locks = -1
rlimit-sigpending = -1
rlimit-msgqueue = -1
rlimit-nice = 31
rlimit-rtprio = 9
rlimit-rttime = 1000000
$

Notice that PulseAudio is now configured to use new values for default-sample-rate, default-fragments and default-fragment-size-msec.

$ echo autospawn = no >> ~/.config/pulse/client.conf
$ pulseaudio --kill
$ LANG=C timeout --foreground -k 10 -s kill 10 pulseaudio -vvvv 2>&1 | grep device.buffering -B 10
I: [pulseaudio] sink.c: alsa.driver_name = "snd_hda_intel"
I: [pulseaudio] sink.c: device.bus_path = "pci-0000:00:1b.0"
I: [pulseaudio] sink.c: sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
I: [pulseaudio] sink.c: device.bus = "pci"
I: [pulseaudio] sink.c: device.vendor.id = "8086"
I: [pulseaudio] sink.c: device.vendor.name = "Intel Corporation"
I: [pulseaudio] sink.c: device.product.id = "3b56"
I: [pulseaudio] sink.c: device.product.name = "5 Series/3400 Series Chipset High Definition Audio"
I: [pulseaudio] sink.c: device.form_factor = "internal"
I: [pulseaudio] sink.c: device.string = "front:0"
I: [pulseaudio] sink.c: device.buffering.buffer_size = "2304"
I: [pulseaudio] sink.c: device.buffering.fragment_size = "576"
--
I: [pulseaudio] source.c: alsa.driver_name = "snd_hda_intel"
I: [pulseaudio] source.c: device.bus_path = "pci-0000:00:1b.0"
I: [pulseaudio] source.c: sysfs.path = "/devices/pci0000:00/0000:00:1b.0/sound/card0"
I: [pulseaudio] source.c: device.bus = "pci"
I: [pulseaudio] source.c: device.vendor.id = "8086"
I: [pulseaudio] source.c: device.vendor.name = "Intel Corporation"
I: [pulseaudio] source.c: device.product.id = "3b56"
I: [pulseaudio] source.c: device.product.name = "5 Series/3400 Series Chipset High Definition Audio"
I: [pulseaudio] source.c: device.form_factor = "internal"
I: [pulseaudio] source.c: device.string = "front:0"
I: [pulseaudio] source.c: device.buffering.buffer_size = "2304"
I: [pulseaudio] source.c: device.buffering.fragment_size = "576"
$ rm ~/.config/pulse/client.conf # I didn't have a client.conf to begin with, so I just deleted it.
$ pulseaudio --start
$

Notice that PulseAudio is now using new values for device.buffering.buffer_size and device.buffering.fragment_size.

11. Check PulseAudio’s output sample rate:

$ pacmd list-sinks | grep sample
sample spec: s16le 2ch 48000Hz
$

Notice that PulseAudio is now using a new output sample rate.

12. Check PulseAudio’s input sample rate:

$ pacmd list-sources | grep sample
sample spec: s16le 2ch 48000Hz
sample spec: s16le 2ch 48000Hz
$

Notice that PulseAudio is now using a new input sample rate.

Audio in Linux becomes annoying again

At the moment I seem to be having more audio problems than usual. Last month I blogged about having to fix the ALSA Speaker volume level resetting to zero at boot, and recently two other audio problems have cropped up.

Thunderbird

I have been having trouble with Thunderbird’s ‘system sound’ that announces the arrival of a new e-mail. Lately, Thunderbird has started playing too loud and with significant distortion the audio clip it had been playing perfectly for the last four years. This is especially strange because I created that audio clip with Audacity from another audio clip that sounded too loud when Thunderbird played it. Ironically, the work-around for this latest problem was to switch to the original, much louder sound clip alert.wav instead of the quieter alert_quiet.wav. Not only does Thunderbird now play alert.wav at a lower volume than alert_quiet.wav, but the sound of alert.wav is not distorted when Thunderbird plays it. Yet if I play alert.wav and alert_quiet.wav using SMPlayer, the former is much louder than the latter and neither is distorted. Figure that one out.

The event notification sound that Thunderbird uses to remind me about an impending meeting scheduled in the calendar has now started sounding very distorted too. I still have not found a work-around for that. Event sounds played by the desktop environment I use (KDE) are not distorted, so what is Thunderbird doing? Perhaps the problem is not Thunderbird itself but the audio library it uses, so I need to investigate further.

Skype

Yet another audio problem cropped up this morning when I connected my laptop to an external monitor and keyboard (and thus I left the laptop’s lid almost closed) in an open-plan office and booted the laptop. I entered my username and password on the KDM log-in screen, and the KDE splash screen appeared as usual. After a few seconds the laptop’s speakers suddenly emitted a piercing, continuous howl; the well-known sound of audio feedback from speakers to microphone. It was LOUD. The volume control buttons on the keyboard made no difference, and the sound was so loud that everyone in the office noticed and several people came over to tell me to reset the BIOS (apparently that had fixed the problem for their laptops running Windows).

I kept my finger on the laptop’s power switch and, after several seconds, the laptop powered off. My laptop dual boots Windows 7 and Gentoo Linux, and the audio feedback did not occur when I booted Windows 7. After booting Linux again a couple of times and annoying everyone in the office even more, I discovered I could open the laptop’s lid far enough back to reduce the feedback to a low whine, so I could let KDE finish launching and display the Desktop. I then launched ALSAMixer and discovered that ‘Internal Mic Boost’ was set to 100%. So I immediately lowered it to zero. Then the penny dropped: I had used Skype the previous night without bothering to connect my headphones and external microphone, and Skype had automatically raised ‘Internal Mic Boost’ all the way up to 100%. So I immediately launched Skype, selected ‘Options’ > ‘Sound Devices’ and unticked ‘Allow Skype to automatically adjust my mixer levels’. The next thing I did was add the following lines to the script /etc/local.d/20set_alsa_volume.start mentioned in my previous blog post Fix for ALSA Speaker volume level resetting to zero at boot:

su -c "amixer -c 0 -- sset 'Internal Mic Boost' 0%" -s /bin/sh fitzcarraldo
su -c "amixer -c 0 -- sset 'Internal Mic' 0%" -s /bin/sh fitzcarraldo
su -c "amixer -c 0 -- sset 'Mic Boost' 0%" -s /bin/sh fitzcarraldo
su -c "amixer -c 0 -- sset 'Mic' 0%" -s /bin/sh fitzcarraldo

From now on, only I am allowed to adjust microphone settings! To avoid any possibility of feedback loops in future, the above-mentioned script sets all the microphone channels to zero and I will have to adjust them myself before use. I already have ALSAMixerGUI in the KDE Launcher menu, so it won’t be a big deal to do that.

This fiasco with Skype got me thinking: if Skype is set to automatically adjust mixer levels when you are in a conversation, when you exit Skype why doesn’t it automatically set mixer levels back to the way they were when Skype was launched? It could be done easily and would be more user-friendly than the current way Skype works.

Interrelationship between PulseAudio and ALSA

The final thing I did (yet again) was to adjust all the various ALSA channels and PulseAudio channels to try and get the resulting audio input and output sounding reasonable. This is easier said than done. I often have to mess around with ALSAMixer and PulseAudio Volume Control in order to get audio input and output working satisfactorily in all applications that use audio. It is actually more difficult than it sounds (ouch!) to get ALSA and PulseAudio ‘balanced’ (for want of a better word). In the days before PulseAudio existed, one only had to adjust ALSA. Now, with two agents controlling audio, the task turns out to be surprisingly awkward sometimes.

To sum up, boo to Thunderbird (or whatever it uses to play sounds), boo to Skype and boo to PulseAudio. I’m fed up with audio issues in Linux at the moment. :-x

Update (January 19, 2015): It turns out that the problem in Thunderbird was due to PulseAudio. See my next post for details of how I fixed it.

Fix for ALSA Speaker volume level resetting to zero at boot

Up until 2011 the problem of the volume level in ALSA resetting to zero at boot was a common occurrence in my Linux installations. Actually it was a common occurrence in Linux, full stop; search the Web using keywords such as “alsa reset volume” and you’ll find umpteen links. In 2012 the situation improved and I thought the problem had become a thing of the past, but it resurfaced in 2013 on my main laptop and has plagued me through every update since (well, apart from in one release of KDE). Every time I reboot, the ALSA Speaker channel’s volume is zero when I log-in to KDE. And, as KMix is a PulseAudio mixer by default these days, I have to launch ALSAMixer and raise the volume of the Speaker channel manually.

I don’t know if the source of the problem lies in KDE, PulseAudio or ALSA itself. It did disappear after one upgrade to KDE earlier this year (I don’t recall which release of KDE) but returned in the next KDE upgrade, so I suspect it is a KDE issue. In earlier days I could resolve the problem using the commands alsactrl store and alsactl restore and similar approaches. However, this time none of those fixes work for me. The problem never bothered me much, as I always connect external speakers to my laptop’s headphone socket when I’m at home, and I don’t want my laptop emitting sounds at the office. Nevertheless, the fact the problem exists niggled me, so I decided to try and fix it. Rather than expending any more effort trying to get the usual approaches to work (the Web is littered with suggested fixes over the years), I decided to reset the Speaker volume to the same level at each boot by using an automatically-launched shell script. The method I use is given below, and should work with either OpenRC or systemd in Gentoo Linux.

1. Create the file /etc/local.d/20set_alsa_volume.start containing the following:

#!/bin/bash
# Reset ALSA Speaker channel on the first sound card to 90% after booting.
su -c "amixer -c 0 -- sset Speaker playback 90%" -s /bin/sh fitzcarraldo

(Replace “fitzcarraldo” with your own user name, of course.)

2. Make the script executable:

# chmod +x 20set_alsa_volume.start

That’s all there is to it. The volume of the ALSA Speaker channel is always set to 90% after I reboot and login to the desktop environment. KMix remembers the PulseAudio volume setting from the previous session, so I can still avoid blasting the laptop’s speakers.

By the way, the manual pages for the amixer and alsamixer commands make useful reading:

$ man amixer
$ man alsamixer

For example, the first audio card (Card 0) in my main laptop has the following controls:

$ amixer -c 0 scontrols
Simple mixer control ‘Master’,0
Simple mixer control ‘Headphone’,0
Simple mixer control ‘Speaker’,0
Simple mixer control ‘PCM’,0
Simple mixer control ‘Mic’,0
Simple mixer control ‘Mic Boost’,0
Simple mixer control ‘Beep’,0
Simple mixer control ‘Capture’,0
Simple mixer control ‘Auto-Mute Mode’,0
Simple mixer control ‘Digital’,0
Simple mixer control ‘Internal Mic’,0
Simple mixer control ‘Internal Mic Boost’,0

Update (January 29, 2015): I found the cause of the problem: PulseAudio. I edited the file /usr/share/pulseaudio/alsa-mixer/paths/analog-output.conf as per user agmg‘s January 2013 post Re: [SOLVED] Problems with PulseAudio 3.0 in the PCLinuxOS Forums:

Again, I had to edit the file: /usr/share/pulseaudio/alsa-mixer/paths/analog-output.conf

and change this:

[Element Speaker]
switch = mute
volume = off

to this:

[Element Speaker]
switch = mute
volume = merge

I realized that editing the [Element Desktop Speaker] section of the above file, has no effect on the issue. Only the edit to [Element Speaker] is needed in my case.

In my case this change forces the ALSA Speaker channel volume to 100% after rebooting (irrespective of the volume levels I set via ALSAMixer and KMix before shutdown).

The contents of the file /usr/share/pulseaudio/alsa-mixer/paths/analog-output.conf also include the following comment:

; See analog-output.conf.common for an explanation on the directives

The contents of the file analog-output.conf.common include the following comment:

; volume = ignore | merge | off | zero | <volume step> # What to do with this volume: ignore it, merge it into the device
;                                                      # volume slider, always set it to the lowest value possible, or always
;                                                      # set it to 0 dB (for whatever that means), or always set it to
;                                                      # <volume step> (this only makes sense in path configurations where
;                                                      # the exact hardware and driver are known beforehand).

So I could have tried volume = <volume step> instead of volume = merge, although I have no idea what value <volume step> would need to be. Anyway, the Bash script /etc/local.d/20set_alsa_volume.start that I created does the job in a different way without me having to tinker with the troublesome PulseAudio, so I reverted to volume = off in the file analog-output.conf and reverted to using /etc/local.d/20set_alsa_volume.start as explained earlier.

WebRTC – A viable alternative to Skype

webrtc_logoSkype for Linux 4.3 and upwards requires the use of PulseAudio, which has caused discontent amongst those Linux users who do not use PulseAudio. Although I do use PulseAudio, I recently found out about WebRTC, an API (application programming interface) for browser-based communication offering most of the functions provided by Skype, namely: voice calling, video chat, text chat, file sharing and screen sharing. The official WebRTC site states:

WebRTC is a free, open project that enables web browsers with Real-Time Communications (RTC) capabilities via simple JavaScript APIs. The WebRTC components have been optimized to best serve this purpose.

Our mission: To enable rich, high quality, RTC applications to be developed in the browser via simple JavaScript APIs and HTML5.

WebRTC was originally released by Google but is now a draft standard of the World Wide Web Consortium, and is supported by Chrome, Firefox and Opera browsers. Several commercial Web sites offer WebRTC-based communications to fee-paying customers, but I thought I would try WebRTC by using one of the so-called ‘demo’ WebRTC pages. AppRTC is a WebRTC demo page which can be reached from a link on the official WebRTC site, but I prefer Multi-Party WebRTC Demo by TokBox which offers a more polished experience with better features. Both are free to use and viable substitutes to Skype for video chatting (one-to-one or conference).

So, how do you actually use WebRTC-based sites? Below is a quick guide to get you going.

Text and video chatting

Open the following URL in Chrome or Firefox:

https://opentokrtc.com/

Enter a Room Name that is likely to be unique. I used ‘fitzchat’ (without the quotes), but you can use any name you want.

The other party or parties can do the same thing, i.e. they enter the same Room Name as you, and you will all become connected.

Alternatively, to send an e-mail invitation to someone, click on the URL at the top of the pane on the right-hand side (which is Invite: https://opentokrtc.com/fitzchat in this example, as I chose to name the Room ‘fitzchat’). The partially visible pane at the right-hand side of the browser window will slide into full view when you click on it.

That’s all there is to it. You should see a video window showing each party, and they should see the same. Each party should also be able to hear the other parties. In the top right-hand corner of each video window is an icon (microphone for you; speaker for each of the other parties) which you can click on to mute/un-mute that party.

Click on the partially visible pane at the right-hand side of the browser window. Notice the ‘chat bar’ at the bottom where you enter commands and chat text. Read the grey instructions listed near the top of the pane:

Welcome to OpenTokRTC by TokBox
Type /nick your_name to change your name
Type /list to see list of users in the room
Type /help to see a list of commands
Type /hide to hide chat bar
Type /focus to lead the group
Type /unfocus to put everybody on equal standing

For example, to give myself a meaningful name instead of the default username Guest-0120e48c which was given to me automatically, I entered the following:

           /nick Fitz

Screen sharing

I found that screen sharing already works well in Chrome 36.0.1985.125 but is not yet supported in Firefox 31.0. It will be supported in Firefox 32 or 33, apparently, or you can already use Firefox Nightly providing you add the appropriate preferences via about:config.

To be able to share screens in Chrome, I had to perform two steps: enable a Chrome flag and install a Chrome extension. The two steps, which do not need to be repeated, are given below (see Ref. 1).

To enable screen sharing in Chrome, do the following:

  1. Open a new tab or window in Chrome.
  2. Copy the following link: chrome://flags/#enable-usermedia-screen-capture and paste it in the location bar.
  3. Click on the ‘Enable’ link below ‘Enable screen capture support in getUserMedia().’ at the very top of the screen.
  4. Click on the ‘Relaunch Now’ button at the bottom of the page to restart Chrome.

To install the screen sharing extension in Chrome, do the following:

  1. Launch Chrome and click on the Menu icon.
  2. Click on ‘Settings’.
  3. Click on ‘Extensions’.
  4. Click on ‘Get more extensions’ and search for ‘webrtc’.
  5. Download ‘WebRTC Desktop Sharing’.
  6. This places an icon to the right of the URL bar in Chrome.

To share your screen or just a window, do the following in Chrome:

  1. Click on the ‘Share Desktop’ icon to the right of the URL bar and select either ‘Screen’ or the window you wish to share.
  2. Click ‘Share’.
  3. When sharing has started in a new Chrome window, select the URL of the relevant tab in that window and send it to the other parties via the chat pane on the right-hand side of the first browser window.

To stop sharing, click on ‘Stop sharing’ and click on the ‘Share Desktop’ icon to the right of the URL bar to get it to return to displaying the ‘Share Desktop’ icon instead of the || (Pause) icon.

File sharing

I did not bother to try file sharing using WebRTC, but there are various Web sites you can use to do that. One such is ShareDrop, and googling will find others.

Caveats

Chrome 36.0.1985.125 and Firefox 31.0 were used in this trial (I did not try Opera). I found that video chat worked faultlessly when both parties were using Chrome, and when both parties were using Firefox. However, when one of the parties was using Firefox and the other was using Chrome, I could not see myself in one of the video boxes in the browser window (although I could see the other party in the other video box in the browser window). Furthermore, there was a grey bar across the middle of the video images in the AppRTC demo, whereas the Multi-Party WebRTC Demo video images were normal. Other than those two issues, the experience was smooth and straightforward. My recommendation would therefore be to use Multi-Party WebRTC Demo and for all the parties to use the same browser, be it Chrome or Firefox. If you want to share your screen or a window, the logical choice at the moment would be Chrome.

References

1 LiveMinutes Blog – Beta Testers: How To Activate Screen Sharing!

UPDATE (January 2, 2015): Mozilla has added a button to Firefox 34 to provide account-free video chat using WebRTC. Mozilla calls this feature ‘Firefox Hello’.

https://support.mozilla.org/en-US/kb/where-firefox-hello-button

I have it in Firefox 34.0.5 (I had to drag the ‘Hello’ button from ‘Customise’ | ‘Additional Tools and Features’). It works quite well. I didn’t bother creating an account; I just clicked on the ‘Email’ button to e-mail the automatically-generated URL to someone, and he clicked on the URL in the e-mail he received, which launched Firefox on his laptop and rang Firefox on my laptop. We tried both video and audio-only conversations, and both worked well. Firefox Hello is not as polished as Skype but, if Mozilla keeps working on it, they could end up with a good product.

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!

A guided tour of my KDE 4.8.4 desktop (Part 2)

In A guided tour of my KDE 4.8.4 desktop (Part 1) I gave a brief overview of the KDE desktop on my main laptop. This time I’m going to cover some applications, KDE and non-KDE, that I use. Just to prove that I don’t look at KDE through rose-tinted spectacles, I’ll also mention a few problems too.

I don’t use a desktop PC. This laptop is my main PC and I use it for all my professional and personal tasks. I travel frequently and have to connect to public and private networks (wired, wireless and broadband modems) and to many different network printers, so a reliable desktop environment and reliable network management software are essential. KDE satisfies the first requirement. The desktop environment-independent NetworkManager and its KDE front-end, the Plasma widget NetworkManagement, satisfy the second requirement. I also use my laptop for the usual leisure activities such as watching DVDs, video files and TV programmes; listening to music files, Audio CDs and Internet radio; messaging/telephony (PC-to-PC and PC-to-landline/mobile internationally); browsing the Web, blogging and so on.

So this is very much a mission-critical machine for me. The fact that I’m using KDE successfully for all these tasks is a testament to the power of KDE (and Linux, of course). I should also point out that, for a mission-critical machine, I’m living a little dangerously as I use the testing branch (a.k.a. unstable branch), rather than the stable branch, of Gentoo Linux. I’ve been using the unstable branch for several years on this laptop and its predecessor, with only a few hiccups, although I do have to keep an eye on the Gentoo forums in case someone reports a problem.

Office suites

Microsoft Word and LibreOffice Calc

Snapshot 1 - Microsoft Word and LibreOffice Calc

I use both LibreOffice and Microsoft Office 2007, the latter under WINE (see WINE tips: Giving each Windows application its own environment). Office 2007 guarantees me 100 per cent compatibility at work but I also find it easier and more reliable than LibreOffice with the large, complex documents and spreadsheets I create. That said, I also have many Word 97 documents and Excel 97 spreadsheets that I still need to access, and LibreOffice opens some of them that Office 2007 cannot. I prefer to use Writer rather than Word for simple tasks such as typing a letter, as I dislike the Ribbon Interface. And I’m happy to use Calc rather than Excel in the majority of cases.

Once I got Office 2007 running under WINE I did not have to boot into Windows any more, although recently that changed for one very specific task on one work project: checking out (downloading) a Microsoft Word file from a Microsoft SharePoint repository, editing it locally and checking it back in (uploading it). Using Firefox in Linux I can upload a Word file to the SharePoint repository initially, but I have to boot into Windows and use Internet Explorer and Word to check-out, edit and check-in the revised document. I’ve used third-party document management and collaboration software in the past that does not require the use of Internet Explorer and Word. I can see how Microsoft lock you into their product line, and I don’t like that.

For schematic diagrams and flowcharts I usually use an old version of Visio (5 Professional) I bought in 1999, again under WINE. I find Visio easier and faster to use than Dia, a GNOME application I also use sometimes for simple diagrams.

E-mail client

I use Thunderbird to access several POP3 e-mail accounts and, via the excellent DavMail, a couple of Microsoft Exchange OWA (Outlook Web Access) accounts at different companies. DavMail is a life-saver. Having to access those two accounts via a Web browser was a hassle and inefficient. A single e-mail client which can be used to access and manage all my e-mail accounts is a godsend. I still have work e-mails from more than ten years ago, and Thunderbird enables me to find information in them with ease. For professional use by ‘power users’, WebMail cannot hold a candle to a good e-mail client such as Thunderbird. I use a number of Thunderbird extensions which I find essential: Lightning (calendar); Provider for Google Calendar (bidirectional access to Google Calendar); Timezone definitions for Mozilla Calendar; Change quote and reply format (why isn’t this functionality built-in to Thunderbird?); ConfigDate (ditto); Enigmail (encyption/decryption of e-mails); ImportExportTools (conversion tools for different e-mail formats); Dictionaries for several languages.

One of the reasons I chose Thunderbird was because it is available for both Linux and Windows. As I can dual boot this laptop, I put Thunderbird’s data files on the Windows NTFS partition (Windows cannot access Linux file systems), and Thunderbird in either OS accesses the same data files. I virtually never boot into Windows, but it is good to know that I can access my e-mail accounts from either operating system using the same application.

Scanning

I occasionally use SANE scanner interface software and its GUI front-end XSane for scanning images and documents to create image files. But I am much more likely to use the GUI front-end gscan2pdf, as I often need to create PDF files for work. gscan2pdf is another application I find indispensable.

Web browsing

Browsers and Google Earth

Snapshot 2 - Browsers and Google Earth

I use Firefox and the KDE browser/file manager/universal viewer Konqueror. I configured Konqueror to use the WebKit rendering engine instead of KHTML (Install the package kwebkitpart then launch Konqueror, select Settings > ‘Configure Konqueror…’ and select ‘WebKit’ as the ‘Default web browser engine’ on the General tab). There have been a few times when Firefox has not been able to display a Web page properly or at all, and Konqueror came to the rescue. The KIO Slaves I mentioned in Part 1 also add to Konqueror’s versatility.

I use the Oxygen KDE Firefox extension (see Snapshot 2), a theme for Firefox that makes it look like a native KDE application. Very nice indeed.

Google Earth needs no introduction. It runs well in KDE on my laptop, and I find it useful both in my work and for personal use.

I have the KDE blogging client Blogilo installed and it was easy to configure it to synchronise with my blog. In fact I started preparing this article in Blogilo but had to abandon it as Blogilo would not save reliably my incomplete work to my hard disk. After losing changes several times I gave up and turned to my tried and tested KWrite to draft the article offline first. Shame, really, as Blogilo looks really handy for preparing blog posts offline and then uploading them. Hopefully the next release will work for me.

For Web site creation and editing I use KompoZer. It’s not as sophisticated as Dreamweaver, but is easy to use and does a good job for my purposes.

Messaging and telephony

I use Skype for Linux for PC-to-PC and PC-to-phone communication domestically and internationally. There is simply no alternative if I want to communicate with my Windows-using friends, family and work colleagues: they are not going to switch to anything else. Actually, I find Skype for Linux perfectly usable (unlike Skype for Android on my Motorola Xoom tablet, which has a fiddly and rather annoying user interface). In some countries the state-owned telecom provider blocks Skype for commercial reasons, but I have been able to circumvent this using Tor (see How to install and use Tor for anonymous browsing or to access country-restricted content from another country). Furthermore, some office networks I use also block Skype, to enforce the use of another product or to stop personal communication, but Tor has helped me out there too.

Graphics

I use the GIMP quite a lot, mostly for photo editing/retouching for work purposes but sometimes to edit/retouch personal photos. I have only used the vector graphics application Inkscape a few times at work and at home. I enjoyed using it to produce the graphics for a laptop ‘Powered by’ sticker.

Gwenview

Snapshot 3 - Gwenview

Apart from the excellent KDE image viewer Gwenview, which gets better with every release of KDE, I use GQView. GQview has been around for many years and its UI looks rather dated, but it has some powerful features which I find useful at work (and at home). GQview makes it easy for me to assign keywords to image files and to search on keywords; to examine EXIF data; to print thumbnail proof sheets; to view multiple image files and page through directories of image files, and so on. This application has often been of help to me at work.

Okular and Adobe Reader

Snapshot 4 - Okular and Adobe Reader

KDE’s Okular document viewer and Adobe Reader are in frequent use on my laptop. I use them both but resort to Adobe Reader for the huge PDF files I sometimes have to view at work, as they load quicker in Adobe Reader. Also, Okular has had a rather irritating habit of printing Landscape pages in Portrait, and vice versa. This problem seems to come and go with different releases of Okular.

CAD

I hardly ever need to use CAD applications, but occasionally I do need to view some old AutoCAD files. For this I use an old version (2009-en-1.06-1) of VariCAD Viewer which opens those old files although it can’t open newer AutoCAD files. I tried unsuccessfully to install newer versions of VariCAD Viewer in the past, but have not tried again recently.

E-books

I only recently began reading e-books. The EPUBReader Firefox extension is an excellent and easy-to-use e-book reader, library manager and shop window for both free and commercical e-books in ePub format. The display of book pages when using the extension as a reader is better than many of the dedicated e-book applications I have seen.

Calibre is an excellent dedicated e-book reader and format converter that I discovered by accident when reading a review of the Amazon Kindle. If you are looking for an application that can handle all the various e-book formats, convert between them, manage your e-book library, upload and download e-books, and act as a reader, look no further. Even the application’s Web site oozes class.

Multimedia

SMPlayer multimedia player, and YouTube in Firefox

Snapshot 5 - SMPlayer multimedia player, and YouTube in Firefox

I have far too many multimedia players installed, but I like to alternate between them. In any case it’s useful to have several players installed because sometimes one of them is able to play a certain file that another cannot.

SMPlayer, VLC and Xine play DVDs, CDs, music files, video files, Internet radio, and digital TV (DVB). I like all three.

Miro is a music and video player, torrent downloader, Internet TV and podcast viewer, and more. Another very polished application I enjoy using.

Dragon Player is a KDE player for CDs, DVDs, audio and video files. It plays DVDs, audio and video files well on my laptop, but cannot play Audio CDs for some reason. It is not as versatile or as polished as the multimedia players mentioned above, so I rarely use it.

UPDATE (January 10, 2014): As of KDE 4.11.3, Dragon Player can play Audio CDs on my laptop. I believe this was due to an update to KDE’s Phonon and/or the Phonon backends.

Clementine music player

Snapshot 6 - Clementine music player

The music players I have installed are Audacious, Clementine and Amarok. These three applications focus on playing and managing collections of music files, Audio CDs and streaming Internet radio.

In the days of KDE 3 I used exclusively Amarok 1.4, which was darn near a perfect music player. But new releases of Amarok were buggy in early releases of KDE 4, and today Amarok still does not work as well for me as the KDE 3 version did. Some of the album covers disappear randomly from the album cover manager, and it is irritating to have to restore covers. Clementine, on the other hand, has no trouble managing album covers and I find it is more polished than Amarok and nicer to use all round. I cannot get Amarok to play Audio CDs with the KDE GStreamer Phonon backend, only with the KDE VLC Phonon backend. Even then the optical drive in my laptop spins very fast and produces a loud noise, making listening to Audio CDs painful. Audacious, on the other hand, plays Audio CDs quietly and perfectly on my laptop. Although Clementine is superb in other respects, for some reason it cannot play Audio CDs on my laptop, whichever KDE Phonon backend is selected. All three players can stream Internet radio without problem, although the long pre-configured list of radio stations in Clementine is simply excellent. If Clementine could play Audio CDs on my laptop, it would be my favourite music player.

UPDATE (January 10, 2014): As of KDE 4.11.3, Clementine can play Audio CDs on my laptop. I believe this was due to an update to KDE’s Phonon and/or the Phonon backends.

MIDI players and Karaoke

I have four different MIDI players installed. PyKaraoke (see HOWTO: PyKaraoke) and KDE’s own KMid can both play MIDI files with and without embedded karaoke lyrics. TiMidity++ is a MIDI file player, as well as an ALSA sequencer which can be used by the other MIDI player applications here. Drumstick has three applications: a MIDI player, a drumkit sequencer and a virtual piano keyboard. I enter the following command once before launching any of them:

modprobe snd_seq && timidity -iA -Os

Actually, I have put the above command in a Desktop Configuration File with a nice icon in my Desktop directory, so I just double-click on it. I could have instead loaded the snd_seq module automatically at startup by specifying it in the file /etc/conf.d/modules.

Audio CDs

KsCD is a simple KDE application with a sole purpose: to play Audio CDs. For me it fails miserably in this task, and has done in several releases of KDE. The last time I remember it working for sure was in KDE 4.3.3, and here we are today with KDE 4.8.4. The KDE Bug Tracking System has quite a few bug reports regarding KsCD. I don’t know if the application itself has a bug, or if the KDE Phonon backends are buggy, or if KDE has a bug, or if there is a problem with udev, or a combination. Anyway, whatever the reason, in my case KsCD is useless. Come to that, for Audio CDs Amarok is next to useless. Luckily for me, Audacious, SMPlayer, VLC and Xine can play Audio CDs perfectly on my laptop.

UPDATE (January 10, 2014): As of KDE 4.11.3, KsCD can play Audio CDs on my laptop. I believe this was due to an update to KDE’s Phonon and/or the Phonon backends.

YouTube

I should mention the excellent command line tool youtube-dl (‘YouTube download’) which is great for downloading videos from YouTube. You can specify the resolution, extract the audio, and various other tricks. Well worth adding to your set of mutlimedia tools. Or, if you prefer a GUI, Minitube is a cracking application for watching and streaming YouTube videos without using a Web browser, and also enables you to download them.

Backing up CDs/DVDs or ripping audio and video

K3b is a superb KDE application. It’s a one-stop shop for making back-ups of CDs and DVDs, creating data CDs and DVDs, and ripping CDs and DVDs. I use K3b to rip my Audio CDs to mp3 files.

Another well-known KDE application is the excellent K9Copy DVD ripper. Unfortunately the developer stopped working on it in July 2011. I hope someone else picks it up, as K9Copy has an intuitive GUI and I have used it on a number of occasions to rip my DVDs to my hard disk so that I could watch them when travelling.

dvd::rip does just what the name suggests, and I’ve used this excellent application too. The GUI is intuitive and the online documentation is very good.

Winki the Ripper is a good application for ripping DVDs to MKV files (it can also rip to AVI files). I have used it but noticed recently that the Web site is up for sale, so I hope the application is still being developed.

WINE

WINE menu in Lancelot Launcher

Snapshot 7 - WINE menu in Lancelot Launcher

I have mentioned Office 2007 already, but I have a few other Windows applications installed under WINE, such as IE7 (so that I can see how a Web site looks in a Windows browser), IrfanView, Lotus ScreenCam Player (so that it is still possible to view some videos of a specialist application running in Windows 95 many years ago), Notepad, Pinball and a few applications and utilities I need that are not available in Linux. WINE is not perfect, but it is wonderful software that also makes it possible to run some older Windows applications that are probably not able to run in Windows Vista and 7.

Utilities

Some utilities

Snapshot 8 - Some utilities

I used to use the brilliant command line utility ImageMagick to scale image files, but have not had to resort to the command line since the GUI front-end Converseen was released (see Converseen, a GUI batch image converter and resizer using Qt4 and ImageMagick).

I encrypt and decrypt some of my sensitive files using GnuPG GUI front-ends KGpg and Kleopatra. Kleopatra is slightly easier to use than KGpg, but they’re much of a muchness. The Enigmail extension I use in Thunderbird also uses GnuPG.

KAlarm is a handy KDE utility to produce sounds or pop-up reminder messages, or issue commands, at specific times or time intervals. The GUI is easy to use and KAlarm can be used in many cases as an alternative to setting up a cronjob. It was simple to configure it as a talking clock (see Setting up a talking clock easily in Linux).

AutoKey is a macro utility I use frequently. It can be used in a number of ways, but I use it to insert text in documents and e-mails. For example, I have configured AutoKey to insert the output of the Linux date command where my cursor is in an open document or e-mail if I press Ctrl-Alt-D: Sun Jul 22 14:41:25 BST 2012. For another example, I have configured AutoKey to enter my full postal address when I type “adr” and press the Space key (but puts it back to “adr” if I press the Backspace key). It is a very handy utility and can be configured to execute simple or complex scripts.

Easystroke is the mouse equivalent of AutoKey. For example, I have configured Easystroke to type “———- Original Message ———-” when I press the mouse scroll wheel and move the mouse pointer diagonally from left to right on the screen. As another example, I have configured it to launch an instance of DavMail to access a specific company’s OWA Exchange Server when I trace the first letter of the company’s name on the screen with the mouse cursor. It’s a clever utility!

BasKet Note Pads is a KDE application for recording and reading notes. The notes can be simple text or complex with embedded pictures, hyperlinks and so on. I switched to BasKet from Tomboy as the latter is a GNOME application and requires some GNOME-specific packages that I didn’t want cluttering up my hard disk. However, I can’t say I like BasKet: I miss the simplicity and easy-to-use UI of Tomboy which was a pleasure to use. I think I may have to try another KDE application (KJots) instead of BasKet, as it may fit my needs better.

KRename is a batch file renamer for KDE that has come in handy both at work and at home.

Filelight is a KDE utility that shows you graphically how much of each partition is occupied and how much is free. I like it because it makes it easy for me to see at a glance how much disk space I have left.

JDiskReport is another utility for showing you disk occupancy graphically. You can select pie carts, segment charts or bar charts. It is freeware but not open-source, but is nevertheless a nice utility to have in your set of tools.

Antivirus software

BitDefender Antivirus for Unices

Snapshot 9 - BitDefender Antivirus for Unices

As I run some Windows applications under WINE, and as I dual boot with Windows 7, I use both BitDefender Antivirus Scanner for Unices and ClamTk, the GUI front-end to ClamAV. That way I can scan my Windows directories from Linux. My work colleagues sometimes pass work files to me on USB pen drives, and I use these two anti virus utilities to scan the pen drives just to be a bit safer. Yes, it has flagged the occasional malware in Windows files.

Games

Games

Snapshot 10 - Games

I hardly ever play games, but still installed the entire KDE Games suite (you never know, after all!). Of the KDE games, I play KPatience, KCheckers, KBlocks (a Tetris clone), KBreakOut (takes me back to playing BreakOut written in Applesoft BASIC on an Apple II+!) and KMahjongg, a solitaire game using beautifully rendered Mahjong tiles.

I have also installed a few non-KDE arcade games such as Missile Command and Pacman Arena (nicely done in 3D). I loved Pac-Mania on my Acorn Archimedes in the early 1990s, so I also use SDLMame and its GUI front-end GMameUI to play Pac-Mania and a few other old favourites such as Frogger.

As far as chess is concerned, I installed the 3D DreamChess, as well as the older but perfectly decent XBoard and eboard.

Scrabble and Boggle are popular games in my family, so I installed XScrabble and GBoggle, the latter being one of only a handful of the packages mentioned in this article that I had to install outside the Portage package manager because there is no ebuild (another being the commercial game Machinarium, which is available for Linux, beautiful and I recommend highly).

I occasionally play TORCS, which is not bad for a car racing game.

There are a lot more Linux games to discover, if you’re that way inclined.

Summary

I’ve just scratched the surface, but hopefully have given you a taste of how I use KDE (and Linux). Of course my needs and uses are different from everyone else’s, but I hope this and the previous article have shown you the breadth of KDE and Linux applications, and that they are completely viable on the desktop. If you have not tried KDE yet, I hope this has tempted you. And, if you’re new to Linux, I hope this has tempted you to try Linux too.

Follow

Get every new post delivered to your Inbox.

Join 60 other followers