How to capture a screenshot of the SDDM greeter screen

In my previous post I explained how to capture a screenshot of the LightDM greeter screen. The procedure is essentially the same for the SDDM greeter screen; only the Bash script differs slightly. The procedure is given below.

  1. If they are not already installed, install the packages x11-apps/xwd and media-gfx/imagemagick.

  2. Create the Bash script ~/sddm-greeter-capture.sh containing the following:
    TMPXAUTHORITY=$(ls /var/run/sddm/*)
    sleep 30
    DISPLAY=:0 XAUTHORITY=/var/run/sddm/$TMPXAUTHORITY xwd -root > /tmp/greeter.xwd
    convert /tmp/greeter.xwd /home/fitzcarraldo/greeter.png
    

    Make sure you make it executable:

    user $ chmod +x sddm-greeter-capture.sh

  3. Log out of the Desktop Environment so that the SDDM greeter screen is displayed.

  4. Press Ctrl+Alt+F2 to switch to VT2.

  5. Log in to you user account and enter the following command (do not wait for it to complete):

    user $ sudo /home/fitzcarraldo/sddm-greeter-capture.sh

  6. As soon as you have pressed Enter for the above command, press Ctrl+Alt+F7 to switch back to VT7.

  7. Wait for at least 30 seconds to be sure the Bash script has made a snapshot of the SDDM greeter screen, then log in.

  8. You should now find the file ~/greeter.png containing a snapshot of your SDDM greeter screen.

If you install media-libs/netpbm instead of (or as well as) media-gfx/imagemagick then you can use a different command to convert in the Bash script:

TMPXAUTHORITY=$(ls /var/run/sddm/*)
sleep 30
#DISPLAY=:0 XAUTHORITY=/var/run/sddm/$TMPXAUTHORITY xwd -root | xwdtopnm | pnmtopng > /home/fitzcarraldo/greeter.png

The resulting PNG image looks equally good to my eyes.

How to capture a screenshot of the LightDM greeter screen

  1. If they are not already installed, install the packages x11-apps/xwd and media-gfx/imagemagick.

  2. Create the Bash script ~/ligthdm-greeter-capture.sh containing the following:
    #!/bin/bash
    sleep 30
    DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/$DISPLAY xwd -root > /tmp/greeter.xwd
    convert /tmp/greeter.xwd /home/fitzcarraldo/greeter.png
    

    Make sure you make it executable:

    user $ chmod +x lightdm-greeter-capture.sh

  3. Log out of the Desktop Environment so that the LightDM greeter screen is displayed.

  4. Press Ctrl+Alt+F2 to switch to VT2.

  5. Log in to you user account and enter the following command (do not wait for it to complete):

    user $ sudo /home/fitzcarraldo/lightdm-greeter-capture.sh

  6. As soon as you have pressed Enter for the above command, press Ctrl+Alt+F7 to switch back to VT7.

  7. Wait for at least 30 seconds to be sure the Bash script has made a snapshot of the LightDM greeter screen, then log in.

  8. You should now find the file ~/greeter.png containing a snapshot of your LightDM greeter screen.

If you install media-libs/netpbm instead of (or as well as) media-gfx/imagemagick then you can use a different command to convert in the Bash script:

#!/bin/bash
sleep 30
DISPLAY=:0 XAUTHORITY=/var/run/lightdm/root/$DISPLAY xwd -root | xwdtopnm | pnmtopng > /home/fitzcarraldo/greeter.png

The resulting PNG image looks equally good to my eyes.

Another look at beeps in Linux

Following my previous post I experimented further with the Linux Kernel configuration options for event beeps (sometimes called ‘system beeps’), and I now have a better understanding of how the Kernel options interact (on one of my laptops, at least).

The sound card in my Clevo W230SS laptop has a VIA VT1802S audio codec chip. I looked at the audio circuit schematic in the service manual; one of the digital input pins on the VT1802S is labelled ‘PCBEEP’, and one of its analogue output pins is labelled ‘PCBEEP’ and is connected to the laptop’s speaker circuit. So there is no PC Speaker in this laptop and it emulates the PC Speaker via the laptop’s sound card, as mentioned in my previous post.

Before I describe my latest results, there are a couple of influencing factors I forgot to mention in my previous post:

  • In some computers the BIOS Menu has one or more options for enabling/disabling beeps. The BIOS menu of my Clevo laptop does not have an option to enable/disable all beeps from the (emulated) PC Speaker, but it does have a couple of options to enable/disable ‘Power On Boot Beep’ and ‘Battery Low Alarm Beep’ (I have disabled them both). Anyway, if you are still not getting beeps after trying everything else, be sure to check the BIOS menu just in case it has an option to enable/disable the PC Speaker.

  • Make sure that bell-style is not set to ‘none‘ (you could set it to ‘audible‘ if you wanted to be sure):

    root # grep bell /etc/inputrc
    # do not bell on tab-completion
    #set bell-style none

The Kernel configuration was initially as shown below. With this configuration no beeps were emitted in a VT (Virtual Terminal) or in an X Windows terminal. As explained in my previous post, I therefore configured the XKB Event Daemon to play an audio file (bell.oga) whenever X Windows detects a BEL character (ASCII 007) or Backspace key (ASCII 008).

root # grep PCSP /usr/src/linux/.config
CONFIG_HAVE_PCSPKR_PLATFORM=y
CONFIG_PCSPKR_PLATFORM=y
# CONFIG_INPUT_PCSPKR is not set
# CONFIG_SND_PCSP is not set
root # grep BEEP /usr/src/linux/.config
CONFIG_SND_HDA_INPUT_BEEP=y
CONFIG_SND_HDA_INPUT_BEEP_MODE=1

Then I rebuilt the Kernel with CONFIG_INPUT_PCSPKR=M and CONFIG_SND_PCSP=M:

root # cd /usr/src/linux
root # mount /dev/sda1 /boot
root # make menuconfig
root # make && make modules_install
root # make install
root # grep PCSP /usr/src/linux/.config
CONFIG_HAVE_PCSPKR_PLATFORM=y
CONFIG_PCSPKR_PLATFORM=y
CONFIG_INPUT_PCSPKR=m
CONFIG_SND_PCSP=m
root # grep BEEP /usr/src/linux/.config
CONFIG_SND_HDA_INPUT_BEEP=y
CONFIG_SND_HDA_INPUT_BEEP_MODE=1

Then I created the file /etc/modprobe.d/blacklist.conf in order to blacklist the modules pcspkr and snd-pcsp so that only I could load them after boot:

root # cat /etc/modprobe.d/blacklist.conf
blacklist pcspkr
blacklist snd-pcsp

Then I added the line ‘options snd-pcsp index=2‘ to the file /etc/modprobe.d/alsa.conf so that the virtual sound card pcsp would not become the default sound card:

root # tail /etc/modprobe.d/alsa.conf
alias /dev/midi snd-seq-oss

# Set this to the correct number of cards.
options snd cards_limit=1

# See https://bugs.launchpad.net/ubuntu/+source/alsa-driver/+bug/1313904
options snd-hda-intel patch=,clevo-hda-patch

# See Kernel Help text for CONFIG_SND_PCSP
options snd-pcsp index=2

Then I rebooted and checked that neither module was loaded:

root # lsmod | grep pcsp
root # echo -e '\a'

root #

As neither module was loaded, the situation was the same as before: a) no beep in a VT; b) no beep in Konsole/Yakuake (I will ignore KDE terminal programs anyway because of KDE bug report no. 177861);* c) the same bell.oga beep in xterm due to my use of xkbevd; d) no changes in ALSA Mixer.

* Regarding Konsole and Yakuake, see my update of October 9, 2016 at the bottom of this post.

Then I loaded the module pcspkr:

root # modprobe pcspkr
root # lsmod | grep pcsp
pcspkr                  1875  0
root # echo -e '\a'

root #

There were no changes in ALSA Mixer. But now the BEL character and Backspace in a VT did result in a beep (I’ll call this a ‘pcbeep’ to distinguish it from the different-sounding beep produced using bell.oga). There was the usual bell.oga beep in xterm due to my use of xkbevd. If I stopped xkbevd, there was no pcbeep in X Windows from the shell commands shown in my previous post, although the following commands from any terminal in X Windows (even Konsole/Yakuake) did emit a pcbeep:

user $ sudo sh -c "echo -e '\a' > /dev/console"

user $ sudo sh -c "tput bel > /dev/console"

root # echo -e '\a' > /dev/console

root # tput bel > /dev/console

Then I unloaded the module pcspkr and loaded the module snd-pcsp:

root # modprobe -r pcspkr
root # modprobe snd-pcsp
root # lsmod | grep pcsp
snd_pcsp                7918  1
root # echo -e '\a'

root #

ALSA Mixer showed a new sound card named ‘pcsp‘ (Sound Card 2) with three channels: ‘Master’, ‘Beep’ and ‘BaseFRQ’. I could mute/unmute ‘Beep’ by pressing ‘M’ on the keyboard as usual, and I could toggle ‘BaseFRQ’ between two values:18643 and 37286. The BEL character and Backspace in a VT resulted in a pcbeep. There was the usual bell.oga beep in xterm due to my use of xkbevd. If I stopped xkbevd, there was no pcbeep in X Windows from the shell commands shown in my previous post, although the following commands from any terminal in X Windows (even Konsole/Yakuake) did emit a pcbeep:

user $ sudo sh -c "echo -e '\a' > /dev/console"

user $ sudo sh -c "tput bel > /dev/console"

root # echo -e '\a' > /dev/console

root # tput bel > /dev/console

Muting ‘Beep’ in ALSA Mixer did not mute the bell.oga beeps in X Windows, but it did mute the pcbeeps in the VTs.

Unlike the situation with the pcspkr module, occasionally there were brief low-volume crackles and pops from the laptop’s speakers.

So both drivers worked, but pcspkr performed better, although it could not be muted via ALSA Mixer. My recommendation to use pcspkr rather than snd-pcsp still stands.

Unlike pcspkr, I had to force the unloading of snd-pcsp:

root # modprobe -r snd-pcsp
modprobe: FATAL: Module snd_pcsp is in use.
root # rmmod -f snd_pcsp
root #

I then removed the Kernel’s ‘digital beep’ interface for the Intel HDA driver by rebuilding the Kernel with CONFIG_SND_HDA_INPUT_BEEP=N:

root # cd /usr/src/linux
root # mount /dev/sda1 /boot
root # make menuconfig
root # make && make modules_install
root # make install
root # grep PCSP /usr/src/linux/.config
CONFIG_HAVE_PCSPKR_PLATFORM=y
CONFIG_PCSPKR_PLATFORM=y
CONFIG_INPUT_PCSPKR=m
CONFIG_SND_PCSP=m
root # grep BEEP /usr/src/linux/.config
# CONFIG_SND_HDA_INPUT_BEEP is not set
root #

After I rebooted, the behaviour was exactly the same as for CONFIG_SND_HDA_INPUT_BEEP=Y and CONFIG_SND_HDA_INPUT_BEEP_MODE=1.

So, there you have it. I believe my previous post was essentially correct regarding the functional design of the Kernel options. If you have a computer without a PC Speaker but it emulates one via the computer’s sound card, you have to set either CONFIG_INPUT_PCSPKR or CONFIG_SND_PCSP to get a beep in a VT, not set just CONFIG_SND_HDA_INPUT_BEEP and CONFIG_SND_HDA_INPUT_BEEP_MODE. However, even when my laptop emits beeps in a VT from the (emulated) PC Speaker, no beeps from the (emulated) PC Speaker are emitted in X Windows unless the user is the root user and the output is redirected to /dev/console. So, if you want to emit beeps in X Windows it is still better in my opinion to use xkbevd to play an audio file of a beep, as described in my previous post.

Update (October 9, 2016): Regarding KDE’s terminal applications emitting beeps, I am currently using KDE Plasma 5.7.5 and have been able to configure Konsole and Yakuake to play an audio file of a beep (as opposed to emitting a pcbeep) as follows:

  • In Konsole, click on ‘Settings’ > ‘Configure Notifications…’, select ‘Bell in Visible Session’ and ensure ‘Play a sound’ is ticked and a file is specified there (I specify /usr/share/sounds/freedesktop/stereo/bell.oga). If you wish, do the same for ‘Bell in Non-Visible Session’.
  • For Yakuake, press F12 to display the Yakuake window, click on the ‘Open Menu’ icon, select ‘Configure Notifications…’, select ‘Bell in Visible Session’ and ensure ‘Play a sound’ is ticked and a file is specified there (I specify /usr/share/sounds/freedesktop/stereo/bell.oga). If you wish, do the same for ‘Bell in Non-Visible Session’.

To beep, or not to beep, that is the question

Introduction

If your computer running Linux has the necessary hardware and is configured appropriately, applications and shell scripts can trigger a beep to signal an event such as an invalid keyboard entry, shutdown initiation, and so on. To check the current situation with your computer, enter the command shown below. Try it first in a Linux VT (virtual terminal) and then in a terminal window in X Windows. Do you hear a beep in each case?

user $ echo -e '\a'

The above command outputs the BEL character (ASCII code 007).

An alternative to the above command is:

user $ echo -e '\007'

Another command that should produce a beep is:

user $ tput bel

The tput utility is part of the ncurses package.

If you install the package app-misc/beep you can also use the ‘beep’ command (enter the command ‘man beep‘ to see its options):

user $ beep

Although you can enter the above-mentioned commands on the command line, they are intended to be used in shell scripts to notify the user about something.

There are thousands of posts on the Web regarding beeps in Linux, the majority of them concerned with disabling beeps because many people find them annoying. Historically, such beeps were emitted by the so-called ‘PC speaker‘. Note that the PC Speaker is not the same as the speakers connected to the sound card in your computer; the term refers to a small internal loudspeaker (moving-coil or piezoelectric) wired directly to the motherboard and intended solely to emit beeps to notify the user about something. Many modern computers, especially laptops, do not have a PC Speaker and either emulate one via the sound card or do nothing at all.

The reason people sometimes use the terms ‘bell’ and ‘ring’ instead of ‘beep’ is because old teletypwriters and teleprinters actually had an electromechanical bell which would ring when a certain dedicated character was received. I use the terms ‘beep’ and ‘bell’ interchangeably, although I prefer to use the term ‘beep’ when talking about audible notifications by computers.

I was motivated to write this post after helping a Gentoo Linux user to get his laptop to produce beeps (see the Gentoo Linux Forums thread ‘i want to beep [solved]‘). Producing a beep in Linux turns out to be more complicated than you would expect, and I’m not sure I fully understand the functional design of the applicable configuration options in the Kernel, nor their relevance (if any) to the X Windows server’s bell. Now, on the face of it the functionality of the applicable Kernel configuration options appears straightforward, but that is not the case in practice. Anyway, let’s look at how I believe a beep can be achieved (and disabled) in Linux…

PC Speaker drivers

Four Kernel options relate directly to a PC Speaker:

CONFIG_HAVE_PCSPKR_PLATFORM

If this is not set in the Kernel then CONFIG_PCSPKR_PLATFORM cannot be enabled.

CONFIG_PCSPKR_PLATFORM

Enable PC-Speaker support

This option allows to disable the internal PC-Speaker
support, saving some memory.

CONFIG_INPUT_PCSPKR

PC Speaker support

Say Y here if you want the standard PC Speaker to be used for
bells and whistles.

If unsure, say Y.

To compile this driver as a module, choose M here: the
module will be called pcspkr.

CONFIG_SND_PCSP

PC-Speaker support (READ HELP!)

If you don’t have a sound card in your computer, you can include a
driver for the PC speaker which allows it to act like a primitive
sound card.
This driver also replaces the pcspkr driver for beeps.

You can compile this as a module which will be called snd-pcsp.

WARNING: if you already have a soundcard, enabling this
driver may lead to a problem. Namely, it may get loaded
before the other sound driver of yours, making the
pc-speaker a default sound device. Which is likely not
what you want. To make this driver play nicely with other
sound driver, you can add this into your /etc/modprobe.conf:
options snd-pcsp index=2

You don’t need this driver if you only want your pc-speaker to beep.
You don’t need this driver if you have a tablet piezo beeper
in your PC instead of the real speaker.

Say N if you have a sound card.
Say M if you don’t.
Say Y only if you really know what you do.

If your computer does have a PC Speaker, you would use either CONFIG_INPUT_PCSPKR or CONFIG_SND_PCSP, but not both. When configuring the Kernel you can specify ‘M’ to build the driver as an external module, in which case you can decide in userspace whether or not to load it. Or you can specify ‘Y’ to build the driver into the Kernel (do not specify both as ‘Y’ simultaneously, though).

If your computer does have a PC Speaker, an advantage of using CONFIG_SND_PCSP instead of CONFIG_INPUT_PCSPKR is that the former adds a virtual sound card named ‘pcsp’ with a channel (without volume control) named ‘Beep’, and you should be able to mute it via ALSA Mixer.

If you have a computer that has a sound card but does not have a PC Speaker (a laptop’s internal speakers are connected to a sound card, not a PC Speaker), the above two drivers do not really apply. I have always disabled them both in the Kernel, as my laptop does not have a PC Speaker.  Update (September 29, 2016): This is not always the case: if a computer uses a sound card to emulate a PC Speaker (typically laptops do this), then you do need to use one of these two drivers if you want to be able to hear event beeps in a VT — see my latest post Another look at beeps in Linux.

However, apparently for some laptops ALSA Mixer shows a channel named ‘Beep’ (with volume control) for the Intel HDA (High Definition Audio) sound card if CONFIG_INPUT_PCSPKR is set to ‘Y’ or ‘M’. I believe such laptops were designed to use their sound card to emulate a PC Speaker. I do not know whether or not the ‘digital beep’ Kernel options (see further on) are set in such cases, but Kernel bug report no. 13651 would appear to indicate that the design intention is for them to be set.

So, already things are confusing.

Of course, if your computer does have a PC Speaker and you don’t want it to emit beeps, set both CONFIG_INPUT_PCSPKR and CONFIG_INPUT_PCSP to ‘N’ in the Kernel. If either already exists as an external module and you do not wish to rebuild the Kernel, make sure the modules pcspkr and snd-pcsp are not loaded (blacklist them, for example).

Digital Beep

Now, there are two other Kernel options relating to event beeps. These are not for driving a PC Speaker, they are to enable the ALSA Intel HDA driver to emit event beeps in lieu of a PC Speaker: the so-called ‘digital beep’. In other words, these two options are intended to provide an alternative to using a PC Speaker. The two options are:

CONFIG_SND_HDA_INPUT_BEEP

Support digital beep via input layer

Say Y here to build a digital beep interface for HD-audio
driver. This interface is used to generate digital beeps.

CONFIG_SND_HDA_INPUT_BEEP_MODE

Digital beep registration mode (0=off, 1=on)

Set 0 to disable the digital beep interface for HD-audio by default.
Set 1 to always enable the digital beep interface for HD-audio by
default.

Note that the mode ‘2’ is no longer an option in newer Kernels.

So, if your installation uses the Intel HDA driver and you want your computer’s sound card to be able to emit beeps instead of a PC Speaker (which your computer may or may not have), set these two accordingly in the Kernel configuration:

user $ grep CONFIG_SND_HDA_INPUT_BEEP /usr/src/linux/.config
CONFIG_SND_HDA_INPUT_BEEP=y
CONFIG_SND_HDA_INPUT_BEEP_MODE=1

The functional design of these Kernel options is not clear, but Kernel bug report no. 13651 appears to indicate that the design intention is for CONFIG_SND_HDA_INPUT_BEEP and CONFIG_SND_HDA_INPUT_BEEP_MODE to be used in addition to either CONFIG_INPUT_PCSPKR or CONFIG_SND_PCSP, not instead of them. In other words, if your computer has a PC Speaker but you want beeps to be routed via its Intel HDA sound card instead then I believe you are expected to use either of the following two sets of options:

Option 1
CONFIG_HAVE_PCSPKR_PLATFORM=Y
CONFIG_PCSPKR_PLATFORM=Y
CONFIG_INPUT_PCSPKR=Y (or =M)
CONFIG_SND_HDA_INPUT_BEEP=Y
CONFIG_SND_HDA_INPUT_BEEP_MODE=1

Option 2
CONFIG_HAVE_PCSPKR_PLATFORM=Y
CONFIG_PCSPKR_PLATFORM=Y
CONFIG_SND_PCSP=Y (or =M)
CONFIG_SND_HDA_INPUT_BEEP=Y
CONFIG_SND_HDA_INPUT_BEEP_MODE=1

On the other hand, if your computer has a PC Speaker and your installation uses the Intel HDA driver for a sound card but you do want your computer to emit beeps from the PC Speaker, I think you would set the two options as follows in the Kernel configuration:

CONFIG_SND_HDA_INPUT_BEEP=N
CONFIG_SND_HDA_INPUT_BEEP_MODE=0

If you read the comment by ALSA developer Takashi Iwai quoted in Kernel bug report no. 13651 you’ll see that the functionality is not at all straightforward. For example, on some computers, especially laptops (which normally do not have a PC Speaker), the beep may be emitted via the sound card irrespective of whether or not you set CONFIG_SND_HDA_INPUT_BEEP.

X Windows

A beep can be emitted in X Windows, and I have seen this beep referred to as the ‘X Windows server bell’ or the ‘X Windows keyboard bell’.

Given that X Windows can emit a beep via the sound card when neither the pcspkr module nor the snd-pcsp module is loaded and CONFIG_SND_HDA_INPUT_BEEP=N and CONFIG_SND_HDA_INPUT_BEEP_MODE=0, I assume X Windows emits beeps directly to the default sound card irrespective of the settings of those Kernel options. I could be wrong, but I have not found any explanation on the Web about the underlying mechanism; the X.Org Web site FAQ ‘How can I configure the Xserver bell (xkbbell) to use the sound subsystem of my computer? (ALSA, OSS, etc.)‘ simply states:

Answer (hopefully) goes here..🙂

*shrug*.

Below is a summary of the commands to disable, enable and configure the beep in X Windows.

To disable beeps in X Windows:

user $ xset b off

To enable beeps in X Windows:

user $ xset b on

To change the volume, pitch and duration of the beeps:

user $ xset b <volume> <pitch> <duration>

For example, to set the beep volume to 25% without changing the pitch and duration:

user $ xset b 25

To return to the default settings:

user $ xset b

To view the current settings:

user $ xset q | grep bell

which displays the following (default) values in my case:

bell percent:  50        bell pitch:    400        bell duration:    100

To set the beep automatically each time X Windows starts, add the following line before the last one in the ~/.xinitrc file if you don’t use a Desktop Manager, otherwise use the Desktop Environment’s system settings GUI to run it at login:

xset b 20 400 20 &

PulseAudio

To confuse matters further, note that PulseAudio intercepts X11 beeps (see: PulseAudio Documentation – User Documentation – Modules – X Window system – module-x11-bell). Therefore, if your installation uses PulseAudio and you want the ability to emit event beeps in X Windows, you also need to configure PulseAudio so it does not ignore the beeps. This can either be done from the command line:

user $ pactl upload-sample /usr/share/sounds/freedesktop/stereo/bell.oga x11-bell
user $ pactl load-module module-x11-bell sample=x11-bell display=$DISPLAY

or you can edit /etc/pulse/default.pa and make sure the following lines are included in that file (they may already exist but are commented out):

load-sample-lazy x11-bell /usr/share/sounds/freedesktop/stereo/bell.oga
load-module module-x11-bell sample=x11-bell

On the other hand, if PulseAudio is installed and you want it to ignore event beeps in X Windows, delete or comment out the above-mentioned two lines in /etc/pulse/default.pa. You can achieve the same effect from the command line:

user $ pactl unload-module module-x11-bell

Configuring userspace to emit a ‘digital beep’

Installation of PulseAudio will have created the directory /usr/share/sounds/freedesktop/ and sub-directories containing various Ogg Vorbis audio files, including the ‘digital beep’ file bell.oga. If your installation does not have PulseAudio installed, you can obtain the same file /usr/share/sounds/freedesktop/stereo/bell.oga by installing the package x11-themes/sound-theme-freedesktop instead. You can configure your installation to use this file to emit a ‘digital beep’ in X Windows (but not in a VT) by using the XKB (X Windows keyboard extension) event daemon as explained in a post on the superuser Web site. That post relates to Ubuntu, but the basic principle applies whatever the Linux distribution.

Now, in my case I am using KDE Plasma 5 in Gentoo Linux, and I cannot hear any beep/bell in Konsole and Yakuake. I came across KDE bug report no. 177861 that has been outstanding since 2008, which indicated that KDE’s terminal applications will not emit beeps even if you do have a PC Speaker and your Kernel has been correctly configured to use it, or even if you have configured your installation to use a ‘digital beep’. You may have better luck with a different Desktop Environment but in KDE you will have to use a non-KDE X Windows terminal application if you want to hear beeps produced by shell scripts.

Update (October 9, 2016): Regarding KDE’s terminal applications emitting beeps, I am currently using KDE Plasma 5.7.5 and have been able to configure Konsole and Yakuake to emit a ‘digital beep’ as follows:

  • In Konsole, click on ‘Settings’ > ‘Configure Notifications…’, select ‘Bell in Visible Session’ and ensure ‘Play a sound’ is ticked and a file is specified there (I specify /usr/share/sounds/freedesktop/stereo/bell.oga). If you wish, do the same for ‘Bell in Non-Visible Session’.
  • For Yakuake, press F12 to display the Yakuake window, click on the ‘Open Menu’ icon, select ‘Configure Notifications…’, select ‘Bell in Visible Session’ and ensure ‘Play a sound’ is ticked and a file is specified there (I specify /usr/share/sounds/freedesktop/stereo/bell.oga). If you wish, do the same for ‘Bell in Non-Visible Session’.

Below I explain how I implemented a ‘digital beep’ in KDE Plasma 5.

First I installed the XKB event daemon:

root # emerge xkbevd

The package vorbis-tools was already installed, otherwise I would have installed that too in order to install an audio player for Ogg Vorbis audio files:

root # emerge vorbis-tools

PulseAudio was also already installed, and hence an appropriate audio file for a beep already existed. Had I not previously installed PulseAudio I would have installed the following package to get an appropriate Ogg Vorbis audio file:

root # emerge sound-theme-freedesktop

I created the file /home/fitzcarraldo/.config/autostart/xkbevd.desktop containing the following:

[Desktop Entry]
Comment[en_GB]=Software terminal bell
Comment=Software terminal bell
Exec=xkbevd -bg
GenericName[en_GB]=XKB Event Daemon
GenericName=XKB Event Daemon
Icon=system-run
MimeType=
Name[en_GB]=XKB Event Daemon
Name=XKB Event Daemon
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=fitzcarraldo	

and I changed its permissions:

user $ chmod 755 /home/fitzcarraldo/.config/autostart/xkbevd.desktop

I created the file /home/fitzcarraldo/.xkb/xkbevd.cf containing the following:

soundDirectory="/usr/share/sounds/"
soundCmd="ogg123 -q"

Bell() "freedesktop/stereo/bell.oga"

If the file /usr/share/sounds/freedesktop/stereo/bell.oga does not exist in your installation then you can copy any suitable audio file of your choice into the directory /usr/share/sounds/ or use one of the existing audio files in that directory, and specify its filename in xkbevd.cf. For example:

soundDirectory="/usr/share/sounds/"
soundCmd="aplay -q"

Bell() "beep.wav"

Notice that the choice of audio player is up to you. In the first example of xkbevd.cf I specified the ogg123 player, whereas in the second example I specified the aplay player.

The aforementioned bug in KDE Konsole and Yakuake prevented me from testing the use of the XKB event daemon, so I installed a non-KDE X Windows terminal application to see if the ‘digital beep’ would work in that:

root # emerge xterm

The command echo -e '\a' generates a beep in xterm. So the ‘digital beep’ approach does work, albeit use of the XKB event daemon means you are limited to using it in X Windows. To reiterate, as the XKB event daemon is for X Windows, no ‘digital beep’ is generated if you enter a beep command outside of X Windows (e.g. in a VT).

By the way, I’m currently using Gentoo Stable Branch and hence Version 5.6.5 of KDE Plasma, and there is another KDE bug to complicate matters further: ‘System Settings’ > ‘Autostart’ > ‘Add Program…’ does not save all the entries I make via the GUI to the .desktop file, and does not set the file permissions correctly either. I don’t know if that is an upstream bug or a bug in the Gentoo implementation of Plasma 5.6.5. Anyway, that is why I manually created xkbevd.desktop and manually set the permissions, rather than using System Settings.

Instead of launching the XKB event daemon by using a .desktop file in ~/.config/autostart/, if you don’t use a Desktop Manager you could launch it by adding the command in the file ~/.xinitrc.

Summary

All the following factors govern whether or not your computer will issue a beep for the BEL character:

  • the specific hardware and firmware in your computer;
  • CONFIG_HAVE_PCSPKR_PLATFORM;
  • CONFIG_PCSPKR_PLATFORM;
  • CONFIG_INPUT_PCSPKR;
  • CONFIG_SND_PCSP;
  • CONFIG_SND_HDA_INPUT_BEEP;
  • CONFIG_SND_HDA_INPUT_BEEP_MODE;
  • X Windows settings;
  • PulseAudio configuration (if installed);
  • a bug in KDE’s terminal applications (if installed).

A. If you are hearing event beeps but don’t want them:

  • Preferably, set CONFIG_HAVE_PCSPKR_PLATFORM and CONFIG_PCSPKR_PLATFORM both to ‘N’.
  • Either set both CONFIG_INPUT_PCSPKR and CONFIG_SND_PCSP to ‘N’ in your Kernel, or, if either driver exists as a module (pcspkr and snd-pcsp, respectively), blacklist it.
  • Make sure CONFIG_SND_HDA_INPUT_BEEP is set to ‘N’.
  • Make sure the X Windows bell is turned off.
  • If you also have PulseAudio installed, make sure the PulseAudio module module-x11-bell is not loaded (also check /etc/pulse/default.pa to see if it has been enabled by default).

B. If you are not hearing event beeps but you do want to hear them:

1. If you are sure your computer has a PC Speaker:

  • Make sure CONFIG_HAVE_PCSPKR_PLATFORM and CONFIG_PCSPKR_PLATFORM are set to ‘Y’.
  • Either set CONFIG_INPUT_PCSPKR to ‘M’ and CONFIG_SND_PCSP to ‘N’ in your Kernel, or, if the module snd-pcsp already exists, blacklist it.
  • Make sure the module pcspkr exists and is not blacklisted.
  • Make sure the module pcspkr is loaded after the module snd-hda-intel.
  • Make sure CONFIG_SND_HDA_INPUT_BEEP is set to ‘N’.
  • Make sure the X Windows bell is turned on and the volume is turned up.
  • If you have PulseAudio installed, make sure the PulseAudio module module-x11-bell is loaded (check /etc/pulse/default.pa to ensure it includes the applicable lines, or issue the two commands listed earlier).
  • If you use KDE, use a non-KDE terminal application until KDE bug report no. 177861 is fixed.
  • If, after doing all the above, you still do not hear a beep in X Windows, follow the procedure in the section above titled Configuring userspace to emit a ‘digital beep’.

Above I have recommended using pcspkr. However, an advantage of using snd-pcsp instead is that it adds a virtual sound card with a channel named ‘Beep’ and you should be able to mute that channel via ALSA Mixer as you wish. Therefore, if you do opt to use the module snd-pcsp instead of pcspkr then make sure you specify the module option (or Kernel Quirk if you built the driver into the Kernel) described in the Kernel Help text quoted earlier, so that pcsp does not become the default sound card instead of the Intel HDA sound card.

2. If your computer does not have a PC Speaker:

  • Preferably, set CONFIG_HAVE_PCSPKR_PLATFORM and CONFIG_PCSPKR_PLATFORM both to ‘N’. *
  • If you leave CONFIG_HAVE_PCSPKR_PLATFORM and CONFIG_PCSPKR_PLATFORM both set to ‘Y’, either set CONFIG_INPUT_PCSPKR and CONFIG_SND_PCSP both to ‘N’, or, if either module already exists, blacklist it. *
  • Make sure CONFIG_SND_HDA_INPUT_BEEP is set to ‘Y’ and CONFIG_SND_HDA_INPUT_BEEP_MODE is set to ‘1’ (I’m not sure this step is required for all computers).
  • Make sure the X Windows bell is turned on and its volume is turned up.
  • If you have PulseAudio installed, make sure the PulseAudio module module-x11-bell is loaded.
  • Use the XKB Event Daemon method to play an audio file (‘digital beep’) when the BEL character is detected in X Windows.
  • If you use KDE, use a non-KDE terminal application until KDE bug report no. 177861 is fixed.
    Update (October 9, 2016): Regarding KDE’s terminal applications emitting beeps, I am currently using KDE Plasma 5.7.5 and have been able to configure Konsole and Yakuake to emit a ‘digital beep’ — see my update in the section titled Configuring userspace to emit a ‘digital beep’.

    * If your computer’s hardware and firmware have been designed to emulate a PC Speaker via a sound card, you may find that you can use the pcspkr (or snd-pcsp) driver to generate beeps in a VT. As the saying goes, your mileage may vary.

    And Finally

    If you know precisely how all these Kernel options are supposed to interact, do comment. Or if you know the relationship, if any, between the X Windows beep (a.k.a. ‘bell’) and these Kernel options, please also comment.

    Update (September 29, 2016): See my latest post Another look at beeps in Linux for the results of some experiments with these Kernel options on my laptop, giving more insight into how to configure them and how they work.

Completing PDF forms and adding your signature without having to print the form

A recent post in the Gentoo Forums made me interested to find out what is actually achievable with fillable PDF forms in Gentoo Linux and Windows 10 without being required to purchase a software licence, be it for personal or professional use, in order to be able to complete PDF forms (including forms that have automatically-updating bar codes).

Designing PDF Forms

It is possible to create PDF forms with LibreOffice, although LibreOffice cannot create a form containing bar codes that get updated automatically with the information entered in fields on the form. In order to create PDF forms that contain automatically-updating bar codes it is necessary to purchase Adobe Acrobat DC or Adobe LiveCycle Designer, which are Windows-only applications. As forms usually have several fields, 2D bar code symbologies are used in order to be able to encode the amount of data in a practical way. See the Adobe demonstration video Capture electronic data from printed forms.

Using PDF Forms

However, the enquiry in the above-mentioned forum thread was not about designing PDF forms, it was about being able to complete existing PDF forms (including forms that have automatically-updating bar codes, and including being able to add a written signature to the form without printing it out):

Hi,

I need to sign pdfs, and sometimes fill out pdf forms which also need to be signed. At the moment I get them, print them, sign them and scan them back in to return to the sender. I’d like to simplify that.

I know that on Windows and Mac OS your adobe software can sign the pdf, but I don’t even know how that works exactly.

It would be really neat if there were an app which could handle all that.

Oh yeah, another thing. Some forms (all?) when you fill them out and print them have a bar of machine-readable gobbledygook on the page which lets the recipient of a printed pdf scan the data back in with 100% accuracy. That would be neat too.

Thanks.

Although I have sometimes added my signature to a PDF form before printing it out — more on that later — I had never come across PDF forms with automatically-updating bar codes, so my curiosity was piqued. I decided to investigate if free applications could be used to complete PDF forms (including those with automatically-updating bar codes) and add a written signature. My investigations were carried out in Linux and Windows 10, and my findings are given below. In summary, I discovered that I could do all these things in Linux as well as in Windows 10, although in Linux I had to resort to running a Windows application under WINE if a PDF form contained automatically-updating bar codes. I did not bother trying the GNOME document viewer Evince, as I could find no evidence on the Web of it having the capability of updating bar codes automatically, and I use KDE.

For my tests I used the following four PDF forms I found on the Web:

  1. acrobat8_barcodedforms.pdf, an October 2006 PDF article from Adobe containing three sample form fields and an associated automatically-updating bar code (PDF417 symbology).
  2. barcode_field.pdf, a February 2013 sample PDF form with three fields and three associated bar codes of different symbologies (PDF417, Data Matrix and QR Code).
  3. PdfFormExample.pdf, a June 2013 sample PDF form created using LibreOffice (and therefore not containing automatically-updating bar codes).
  4. sample_barcoded_demo.pdf, a December 2005 sample PDF form from Adobe with an automatically-updating bar code (PDF417 symbology).

1. Windows 10

1.1 Acrobat Reader DC

This is the ubiquitous ‘free’ closed-source application you can download from Adobe.

Below are screenshots of the four sample PDF forms opened in Acrobat Reader DC…

1.1.1 I could enter text in the three fields in acrobat8_barcodedforms.pdf, and the bar code was updated accordingly:

Acrobat Reader DC - acrobat8_barcodedforms.pdf

Acrobat Reader DC - acrobat8_barcodedforms.pdf

I used my smartphone’s Barcode Scanner app to read the bar code on the hard-copy form printed by Acrobat Reader DC:

Text1Text2Text3I am able to change the text in these fields of this form to see how 2D barcodes work.

1.1.2 I could enter text in the three fields in barcode_field.pdf, but the three bar codes were not visible:

Acrobat Reader DC - acrobat8_barcodedforms.pdf

Acrobat Reader DC - barcode_field.pdf

1.1.3 I could enter text in the fields in PdfFormExample.pdf:

Acrobat Reader DC - PdfFormExample.pdf

Acrobat Reader DC - PdfFormExample.pdf

1.1.4 I could enter text in all fields of sample_barcoded_demo.pdf and the field contents were echoed in the box ‘Barcode Contents’ but the bar code itself was not visible:

Acrobat Reader DC - sample_barcoded_demo.pdf

Acrobat Reader DC - sample_barcoded_demo.pdf

So, in summary, Acrobat Reader DC is not a viable option if you have to deal with forms that include automatically-updating bar codes.

1.2 PDF-XChange Editor

This application from Canadian company Tracker Software Products supersedes their deprecated PDF-XChange Viewer and has additional features. Neither application is open-source, though. Some features only work fully if you purchase a software licence and enter the licence key. For example, if you add a signature to a PDF form (‘Document’ > ‘Signatures and Initials’) and then save it, DEMO stamps are added to the new PDF file (which still has editable fields). However, if you print the PDF form (either to a PDF file or to paper) then DEMO stamps are not added (but the new PDF file is not fillable/editable). Click on the two links below to view the sample PDF file PdfFormExample.pdf signed and saved to a new PDF file, and the sample PDF file PdfFormExample.pdf signed and printed to a new PDF file:

PdfFormExample_with_signature_added_then_Saved.pdf

PdfFormExample_with_signature_added_then_Printed_to_PDF.pdf

If you save them to disk and open them in PDF-XChange Editor, you will see the distinction.

As stated on the company’s Web site, the free application can be used for private and work purposes:

The FREE download of the PDF-XChange Editor may be used without limitation for Private, Commercial, Government and all uses, provided it is not: incorporated or distributed for profit/commercial gain with other software or media distribution of any type – without first gaining permission.

Below are screenshots of the four sample PDF forms opened in PDF-XChange Editor…

1.2.1 I could enter text in the three fields in acrobat8_barcodedforms.pdf, and the bar code was updated accordingly:

PDF-XChange Editor - acrobat8_barcodedforms.pdf

PDF-XChange Editor - acrobat8_barcodedforms.pdf

I used my smartphone’s Barcode Scanner app to read the bar code on the hard-copy form printed by PDF-XChange Editor:

Text1Text2Text3
I am able to change the text in these fields of this formto see how 2D barcodes work.

Notice that the layout of the encoded text is slightly different to the bar code generated by Adobe Acrobat Reader DC.

1.2.2 I could enter text in the three fields in barcode_field.pdf, and the three bar codes were visible:

PDF-XChange Editor - barcode_field.pdf

PDF-XChange Editor - barcode_field.pdf

I used my smartphone’s Barcode Scanner app to read the three bar codes on the hard-copy form printed by PDF-XChange Editor:

The PDF417 bar code was read as follows:

text_0:PDF417 barcode:I can enter text in these fields of this form and can see the three barcodes to the right of these fields in PDF-XChange Editor.

The Data Matrix bar code was read as follows:

text_1:Data Matrix barcode:
To change the barcode field to the right, type in this box. The barcode field to the right will reflect the contents of the text field as barcode after the text field lost the focus. To reset the contents of all barcode fields, cick the ‘Rset’ button.

Notice that the words ‘click’ and ‘Reset’ in the field were apparently not encoded correctly.

The QR Code bar code was read as a meaningless apparently random bunch of characters.

The PDF file and the three bar codes were generated on the fly by PHP code calling the pdflib library produced by the company PDFlib GmbH. I do not know how accurate this particular PDF file is, or how accurate is the Bar Code Scanner app on my smartphone.

1.2.3 I could enter text in the fields in PdfFormExample.pdf:

PDF-XChange Editor - PdfFormExample.pdf

PDF-XChange Editor - PdfFormExample.pdf

1.2.4 I could enter text in all fields of sample_barcoded_demo.pdf, and the field contents were echoed in the box ‘Barcode Contents’ and the bar code itself was visible:

PDF-XChange Editor - sample_barcoded_demo.pdf

PDF-XChange Editor - sample_barcoded_demo.pdf

I used my smartphone’s Barcode Scanner app to read the PDF417 bar code on the hard-copy form printed by PDF-XChange Editor:

Brian
S
Fitzgerald
Calle Fitzcarrald, 225
Iquitos

bsf@iquitos.nom.pe

So, in summary, PDF-XChange Editor appears to be a possible option in Windows 10, whether or not you have to deal with forms that include automatically-updating bar codes. I am quite impressed with the application.

2. Linux

2.1 Acrobat Reader 9

This is the free closed-source Linux application you can install via the Portage package manager (the package is app-text/acroread).

Below are screenshots of the four sample PDF forms opened in Acrobat Reader 9 for Linux.

2.1.1 I could enter text in the three fields in acrobat8_barcodedforms.pdf, and the bar code was updated accordingly:

Acrobat Reader 9 Linux - acrobat8_barcodedforms.pdf

Acrobat Reader 9 Linux - acrobat8_barcodedforms.pdf

I used my smartphone’s Barcode Scanner app to read the bar code on the hard-copy form printed by Acrobat Reader 9 for Linux:

Text1Text2Text3I am able to change the text in these fields of this form to see how 2D barcodes work.

2.1.2 I could enter text in the three fields in barcode_field.pdf, but the three bar codes were not visible:

Acrobat Reader 9 Linux - barcode_field.pdf

Acrobat Reader 9 Linux - barcode_field.pdf

2.1.3 I could enter text in the fields in PdfFormExample.pdf:

Acrobat Reader 9 Linux - PdfFormExample.pdf

Acrobat Reader 9 Linux - PdfFormExample.pdf

2.1.4 I could enter text in all fields of sample_barcoded_demo.pdf, and the field contents were echoed in the box ‘Barcode Contents’ but the bar code itself was not visible:

Acrobat Reader 9 Linux - sample_barcoded_demo.pdf

Acrobat Reader 9 Linux - sample_barcoded_demo.pdf

So, in summary, Acrobat Reader 9 for Linux is not a viable option if you have to deal with forms that include automatically-updating bar codes.

2.2 Okular

This is the well-known KDE document viewer application.

Below are screenshots of the four sample PDF forms opened in Okular.

2.2.1 I could enter text in the three fields in acrobat8_barcodedforms.pdf but the bar code was not visible:

Okular - acrobat8_barcodedforms.pdf

Okular - acrobat8_barcodedforms.pdf

2.2.2 I could enter text in the three fields in barcode_field.pdf but the three bar codes were not visible:

Okular - barcode_field.pdf

Okular - barcode_field.pdf

2.2.3 I could enter text in the fields in PdfFormExample.pdf:

Okular - PdfFormExample.pdf

Okular - PdfFormExample.pdf

2.2.4 I could enter text in all fields of sample_barcoded_demo.pdf but the field contents were not echoed in the box ‘Barcode Contents’ and the bar code itself was not visible:

Okular - sample_barcoded_demo.pdf

Okular - sample_barcoded_demo.pdf

So, in summary, Okular is not a viable option if you have to deal with forms that include automatically-updating bar codes. In fact, Okular was the worst of the bunch.

2.3 PDF-XChange Editor

To install this Windows application under WINE in Linux:

$ export WINEPREFIX=$HOME/.wine-pdfxve6
$ export WINEARCH="win32"
$ winecfg # Select Windows 10.
$ cd .wine-pdfxve6/drive_c/
$ # Copy downloaded installer to C: drive:
$ cp ~/Downloads/PDFXVE6.zip .
$ unzip PDFXVE6.zip
$ # Install PDF-XChange Editor:
$ wine PDFXVE6.exe

  • Click ‘Install’.
  • Click ‘Next’.
  • Select ‘I accept the terms in the License Agreement’ and click ‘Next’.
  • Click ‘Custom’.
  • Click ‘Browsers Plugins’ and select ‘Don’t install’. Click ‘Next’.
  • Leave ‘Create a Start Menu folder’ ticked. Untick ‘Create Desktop Icons.’ Untick ‘Set PDF-XChange Editor as default application for PDF files’. Untick ‘Set Printer “PDF-XChange Lite V6” As Default’. Click ‘Next’.
  • Select ‘Free Version’ and click ‘Next’.
  • Click ‘Install’.
  • Untick ‘Launch PDF-XChange Editor’ and click ‘Finish’.
  • Click ‘Close’.

KDE Plasma 5 then has an entry for PDF-XChange Editor in the Application Launcher under ‘Applications’ > ‘Wine’ > ‘Programs’ > ‘Tracker Software’. Alternatively, to launch PDF-XChange Editor from the command line, you should enter:

$ WINEPREFIX="$HOME/.wine-pdfxve6" && WINEARCH="win32" && wine $WINEPREFIX/drive_c/Program\ Files/Tracker\ Software/PDF\ Editor/PDFXEdit.exe

If you also want the Windows application running under WINE to be able to access PDF files on a NAS, i.e. to be able to open Samba shares, see my previous post How to enable a Windows application in WINE to access a Samba share on a NAS.

I will not bother showing screenshots of the four sample PDF files open in PDF-XChange Editor running under WINE in Linux, as the application’s behaviour is the same as in Windows (see the screenshots in sections 1.2.1 to 1.2.4 above). So, in summary, PDF-XChange Editor appears to be a viable option in Linux (albeit running under WINE), irrespective of whether or not you have to deal with forms that include automatically-updating bar codes.

3. Adding a signature to a soft copy of the PDF form

I am referring to a person’s written signature here, not to a digital signature. Rather than having to print the completed form on paper in order to sign it with a pen, then scan the fully-completed form in order to send it via e-mail, fax or whatever, many people wish to add their signature directly to the PDF form without having to print it. Below I explain the method I use to do this in both Linux and Windows.

3.1 Create a PNG file with your signature (one-time operation)

  1. Get a blank white piece of paper.
  2. Sign your name on the page.
  3. Scan the page with your scanner and save the image as a PNG file.
  4. Open the image with GIMP.
  5. Crop the image around the signature.
  6. Select ‘Layer’ > ‘Transparency’ > ‘Add Alpha Channel’.
  7. Select the Fuzzy Select Tool from the toolbox.
  8. Click on each white area and press the Delete key. Do this for the area around the signature and inside any loops. Obviously don’t click on the signature itself.
  9. Select ‘File’ > ‘Export’.
  10. Save the image as a PNG file.

3.2 Signing PDF documents

  1. Launch LibreOffice Draw and open the PDF file you wish to sign.
  2. Select ‘Insert’ > ‘Image…’ and select the PNG file of your signature. The image will be inserted.
  3. To move the signature around on the page, hover the mouse cursor over the image until the cursor changes to a red dot with four arrowheads, then click-and-hold to grab the image drag it.
  4. To reduce the size of the signature, hover the mouse cursor over the image until the cursor changes to a red dot with four arrowheads, then click and release. You will then see small blue ‘handles’ on the outline of the image. Hover the mouse cursor over a handle at one of the four corners of the image until the cursor changes to a Resize cursor. Click-and-hold and move the cursor to increase or decrease the size of the signature whilst maintaining the ratio of width to height.
  5. To save the completed and signed PDF form, select ‘File’ > ‘Export as PDF…’, click on ‘Export’ and give the file a name of your choice.

The new PDF file will contain all the information visible on the previous PDF file plus your written signature. However, unlike the original PDF file, you will not be able to modify any of the data. Therefore I recommend you retain a copy of the original PDF file before you added the signature, in case you wish to change any of field entries in future.

Note that the free PDF-XChange Editor can be used instead of LibreOffice Draw providing the PDF form is not secured or restricted, and providing you print it to a new PDF file using a virtual PDF printer driver. If the PDF form is secured or changes restricted, then use LibreOffice Draw as described above.

If you are using a PDF viewer that refuses to save your completed form as a PDF file after you have entered data in the fields (notice the message in the purple bar in the screenshots of Acrobat Reader 9 for Linux, for example), print the page to a PDF file instead by using the virtual PDF printer (‘Microsoft Print to PDF’ in Windows; CUPS ‘Virtual PDF Printer’ in Linux) at a resolution of e.g. 600 dpi (if possible). You should then be able to open that PDF file in LibreOffice Draw or PDF-XChange Editor to add your signature as explained above and print the signed form to a new PDF file.

How to enable a Windows application in WINE to access a Samba share on a NAS

I recently installed the Windows application PDF-XChange Editor under WINE in Gentoo Linux on one of my laptops. The application works fine but it could not detect the SMB/CIFS (Samba) share folder on my NAS. When I clicked on ‘File‘ > ‘Open...‘ in the application, the left pane of the ‘Open Files‘ dialogue window displayed the following options:

  Favourites
– Desktop
  + My Computer
  + My Documents
    Trash
  + /

If I clicked on ‘My Computer‘, the right pane of the dialogue window then displayed the following options:

Control Panel
(C:)
(D:)
(E:)
(F:)
(G:)
(Z:)

None of the entries in either pane enabled me to get to the Samba shares on my NAS. Anyway, it turned out to be relatively easy to configure the installation on my laptop to enable the Windows application to access the Samba shared folder on the NAS, and the basic procedure was as follows:

  1. Create a mountpoint.
  2. In the directory $WINEPREFIX/dosdevices/ create a symbolic link to the mountpoint.
  3. Mount the network share on the mountpoint.

Let’s look in detail at the procedure…

My Clevo W230SS laptop running Gentoo Linux Stable Branch amd64 currently has KDE Plasma 5.6.5 and WINE 1.9.18 installed. I had used a WINE prefix of ~/.wine-pdfxve6 to install the Windows application in the fitzcarraldo user account. Let us say that the hostname of my Linux NAS is ‘bsfnas1‘, the name of the Samba shared folder on the NAS is ‘brianfolder‘, the Samba username for that shared folder on the NAS is ‘brian‘ and the Samba share password on the NAS is ‘enricocaruso‘.

First I checked which drive letters were already being used by WINE:

$ ls -la ~/.wine-pdfxve6/dosdevices/
total 8
drwxr-xr-x 2 fitzcarraldo fitzcarraldo 4096 Sep 16 23:18 .
drwxr-xr-x 4 fitzcarraldo fitzcarraldo 4096 Sep 17 04:03 ..
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo   10 Sep 16 23:18 c: -> ../drive_c
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    9 Sep 16 23:18 d:: -> /dev/sdb1
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    8 Sep 16 23:18 e:: -> /dev/sdc
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    9 Sep 16 23:18 f:: -> /dev/sdc1
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    8 Sep 16 23:18 g:: -> /dev/sdb
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    1 Sep 16 23:18 z: -> /

As no Windows Y: drive was listed, I decided to use that drive letter for my network Samba share as shown in the steps below.

I created a mountpoint for the share:

$ sudo mkdir -p /media/bsfnas1/brianfolder

Then I created the symlink:

$ ln -s /media/bsfnas1/brianfolder ~/.wine-pdfxve6/dosdevices/y:
$ ls -la ~/.wine-pdfxve6/dosdevices/
total 8
drwxr-xr-x 2 fitzcarraldo fitzcarraldo 4096 Sep 17 15:38 .
drwxr-xr-x 4 fitzcarraldo fitzcarraldo 4096 Sep 17 15:39 ..
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo   10 Sep 16 23:18 c: -> ../drive_c
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    9 Sep 16 23:18 d:: -> /dev/sdb1
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    8 Sep 16 23:18 e:: -> /dev/sdc
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    9 Sep 16 23:18 f:: -> /dev/sdc1
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    8 Sep 16 23:18 g:: -> /dev/sdb
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo   11 Sep 17 15:37 y: -> /media/bsfnas1/brianfolder
lrwxrwxrwx 1 fitzcarraldo fitzcarraldo    1 Sep 16 23:18 z: -> /

Finally, I mounted the network share onto the symlink:

$ sudo mount.cifs //bsfnas1/brianfolder/ -o user=brian,pass=enricocaruso ~/.wine-pdfxve6/dosdevices/y:

As before, I see the following when I click on ‘File‘ > ‘Open...‘ in the Windows application running under WINE:

  Favourites
– Desktop
  + My Computer
  + My Documents
    Trash
  + /

If I click on ‘My Computer‘ in the ‘Open File‘ dialogue window, the following items are displayed in the right pane of the window:

Control Panel
(C:)
(D:)
(E:)
(F:)
(G:)
(Y:)
(Z:)

and I can select the ‘(Y:)‘ and browse the contents of the shared folder brianfolder on the NAS drive.

Although I found it was unnecessary to do it for PDF-XChange Editor, apparently some Windows applications require the use of Windows UNC syntax, so I also did the following:

$ mkdir -p ~/.wine-pdfxve6/dosdevices/unc/bsfnas1
$ ln -s /media/bsfnas1/brianfolder ~/.wine-pdfxve6/dosdevices/unc/bsfnas1/brianfolder

If I wanted to unmount the Samba share explicitly, rather than leaving it to be unmounted automatically when I shutdown the laptop, I would enter the following command:

$ sudo umount ~/.wine-pdfxve6/dosdevices/y\:/

Then the Windows application on my laptop would no longer be able to browse the unmounted network share:

$ ls ~/.wine-pdfxve6/dosdevices/
c:  d::  e::  f::  g::  unc  y:  z:
$ ls -la /media/bsfnas1/brianfolder
total 8
drwxr-xr-x 2 root root 4096 Sep 17 15:35 .
drwxr-xr-x 4 root root 4096 Sep 17 15:35 ..
$

You may be wondering why I did not add an entry in the file /etc/fstab on my laptop, to mount the Samba share automatically when I boot the laptop. The reason I didn’t is because I often use the laptop away from home and the NAS on my home network is then inaccessible in any case. However, to save myself the hassle of having to enter the mount command manually when I am at home and want to use the Windows application to open a file that is in the NAS shared folder, I created two Desktop Configuration files named mount_bsfnas1_brianfolder_share.desktop and umount_bsfnas1_brianfolder_share.desktop with nice icons in my ~/Desktop directory on the laptop:

[Desktop Entry]
Comment[en_GB]=Mount bsfnas1 brianfolder share for PDF-XChange Editor
Comment=Mount bsfnas1 brianfolder share for PDF-XChange Editor
Exec=sh /home/fitzcarraldo/mount_bsfnas1_brianfolder_share.sh
GenericName[en_GB]=Mount bsfnas1 brianfolder share for PDF-XChange Editor
GenericName=Mount bsfnas1 brianfolder share for PDF-XChange Editor
Icon=media-mount
MimeType=
Name[en_GB]=mount_bsfnas1_brianfolder_share
Name=mount_bsfnas1_brianfolder_share
Path=
StartupNotify=true
Terminal=true
TerminalOptions=\s--noclose
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=fitzcarraldo

[Desktop Entry]
Comment[en_GB]=Unmount bsfnas1 brianfolder share for PDF-XChange Editor
Comment=Unmount bsfnas1 brianfolder share for PDF-XChange Editor
Exec=sh /home/fitzcarraldo/umount_bsfnas1_brianfolder_share.sh
GenericName[en_GB]=Unmount bsfnas1 brianfolder share for PDF-XChange Editor
GenericName=Unmount bsfnas1 brianfolder share for PDF-XChange Editor
Icon=media-eject
MimeType=
Name[en_GB]=umount_bsfnas1_brianfolder_share
Name=umount_bsfnas1_brianfolder_share
Path=
StartupNotify=true
Terminal=true
TerminalOptions=\s--noclose
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=none
X-KDE-SubstituteUID=false
X-KDE-Username=fitzcarraldo

and the Bash scripts mount_bsfnas1_brianfolder_share.sh and umount_bsfnas1_brianfolder_share.sh launched by the above two Desktop Configuration files are, respectively:

#!/bin/bash
echo "This will mount the Samba share folder brianfolder on the bsfnas1 machine."
echo
echo "Enter your Linux account password below..."
echo
sudo mount.cifs //bsfnas1/brianfolder/ -o user=brian,pass=enricocaruso ~/.wine-pdfxve6/dosdevices/y:
echo
if grep -q "/media/bsfnas1/brianfolder" /proc/mounts; then
  echo "Samba share //bsfnas1/brianfolder is mounted."
else
  echo "Samba share //bsfnas1/brianfolder is not mounted."
fi
echo
echo "You may now close this window."

#!/bin/bash
echo "This will unmount the Samba share folder brianfolder on the bsfnas1 machine."
echo
echo "Enter your Linux account password below..."
echo
sudo umount ~/.wine-pdfxve6/dosdevices/y:
echo
if grep -q "/media/bsfnas1/brianfolder" /proc/mounts; then
  echo "Samba share //bsfnas1/brianfolder is mounted."
else
  echo "Samba share //bsfnas1/brianfolder is not mounted."
fi
echo
echo "You may now close this window."

Don’t forget to make the two shell scripts executable:

$ chmod +x /home/fitzcarraldo/mount_bsfnas1_brianfolder_share.sh
$ chmod +x /home/fitzcarraldo/umount_bsfnas1_brianfolder_share.sh

If I was doing this on a desktop PC instead of a laptop, instead of creating the above-mentioned .desktop files and Bash scripts I would have added the following line in the file /etc/fstab to mount the NAS Samba shared folder automatically at boot:

//bsfnas1/brianfolder  /media/bsfnas1/brianfolder  cifs  rw,iocharset=utf8,user=brian,pass=enricocaruso  0   0

It works (I’ve tried it).

Further reading
WineHQ Forums – Mapped network drive in wine.
Estendendo suporte a UNC no Wine.

Fixing all-white log-in screen when using the LightDM KDE greeter with Plasma 5 in Gentoo Linux

In a previous post I explained how I got LightDM to work on my Clevo W230SS laptop running KDE Plasma 5 in Gentoo Linux (Stable Branch). However, following a world update a few weeks later, the LightDM log-in screen (‘greeter’) became all white. Searching the Web showed me that this is a common problem with LightDM, although the cause appeared to be different in many other cases, as I could still see the password-entry box and the button to select the session.

To summarise what was already installed:

fitzcarraldo@clevow230ss ~ $ uname -a
Linux clevow230ss 3.18.11-gentoo #47 SMP Thu May 26 11:03:29 BST 2016 x86_64 Intel(R) Core(TM) i7-4810MQ CPU @ 2.80GHz GenuineIntel GNU/Linux
fitzcarraldo@clevow230ss ~ $ eix -I plasma-meta
[I] kde-plasma/plasma-meta
     Available versions:  (5) 5.6.5 ~5.7.3
       {bluetooth +display-manager grub gtk +handbook mediacenter networkmanager pam plymouth pulseaudio +sddm sdk +wallpapers}
     Installed versions:  5.6.5(5)(12:28:08 26/07/16)(bluetooth display-manager gtk handbook networkmanager pam pulseaudio wallpapers -grub -mediacenter -plymouth -sddm -sdk)
     Homepage:            https://www.kde.org/workspaces/plasmadesktop/
     Description:         Merge this to pull in all Plasma 5 packages

fitzcarraldo@clevow230ss ~ $ eix -I lightdm
[I] x11-misc/lightdm
     Available versions:  1.10.5^t 1.16.7^t ~1.17.6^t ~1.18.1^t ~1.19.0^t ~1.19.3^t {audit +gnome +gtk +introspection kde qt4 qt5}
     Installed versions:  1.16.7^t(04:11:41 23/08/16)(introspection kde qt4 qt5 -audit -gnome -gtk)
     Homepage:            https://www.freedesktop.org/wiki/Software/LightDM
     Description:         A lightweight display manager

[I] x11-misc/lightdm-kde
     Available versions:  (4) 0.3.2.1-r1
       {aqua debug L10N="bs cs da de el es et fi fr ga gl hu it ja km lt mr nds nl pl pt pt-BR ro ru sk sl sv tr uk"}
     Installed versions:  0.3.2.1-r1(4)(01:13:13 12/07/16)(-aqua -debug L10N="pt-BR -bs -cs -da -de -el -es -et -fi -fr -ga -gl -hu -it -ja -km -lt -mr -nds -nl -pl -pt -ro -ru -sk -sl -sv -tr -uk")
     Homepage:            https://projects.kde.org/projects/playground/base/lightdm
     Description:         LightDM KDE greeter

Found 2 matches

And this is what I had previously configured:

fitzcarraldo@clevow230ss ~ $ grep -v ^# /etc/lightdm/lightdm.conf
[LightDM]

session-wrapper=/etc/lightdm/Xsession
[Seat:*]
greeter-session=lightdm-kde-greeter
session-wrapper=/etc/lightdm/Xsession
display-setup-script=/etc/X11/Sessions/plasma

[XDMCPServer]

[VNCServer]
fitzcarraldo@clevow230ss ~ $ cat /etc/X11/Sessions/plasma
#!/bin/bash
GPU=`eselect opengl list | grep \* | awk '{ print $2 }'`
if [ "$GPU" = "nvidia" ]; then
    xrandr --setprovideroutputsource modesetting NVIDIA-0
    xrandr --auto
fi

Now, given that I had installed the LightDM KDE Greeter, I would have expected there to be a default configuration file lightdm-kde-greeter.conf for it, but there was none:

fitzcarraldo@clevow230ss ~ $ ls /etc/lightdm/
Xsession  keys.conf  lightdm.conf  users.conf

So I created the file /etc/lightdm/lightdm-kde-greeter.conf with the following contents:

[greeter]
theme-name=classic

[greeter-settings]
Background=/home/fitzcarraldo/Pictures/Wallpaper/Linux/kde-1920x1080.jpg
BackgroundKeepAspectRatio=true
GreetMessage=Welcome to %hostname%

I downloaded a nice KDE wallpaper file from the Web, which I saved as /home/fitzcarraldo/Pictures/Wallpaper/Linux/kde-1920x1080.jpg, but you can save it anywhere you like and give it any name you want.

I found that the package manager had installed two themes, so I could have specified either:

fitzcarraldo@clevow230ss ~ $ ls /usr/share/apps/lightdm-kde-greeter/themes/
classic  userbar

Anyway, the outcome is that the LightDM login screen (greeter) is no longer white and displays a wallpaper of my choice. Mission accomplished.

Text too small in X Windows when using nvidia-drivers

In an earlier post titled ‘Switching between Intel and NVIDIA graphics processors on a laptop with NVIDIA Optimus hardware running Gentoo Linux‘ I described how I am able to switch between the closed-source NVIDIA video driver and the open-source Intel video driver on a Clevo W230SS laptop with NVIDIA Optimus hardware. This works nicely, but one thing had been niggling me for over a year: the size of the fonts in the Desktop Environment were much smaller when using the NVIDIA driver than when using the Intel driver. I could of course increase the font size via KDE’s ‘System Settings’ > ‘Font’ when using the NVIDIA driver, but then I would have to reduce the font size the same way when using the Intel driver. So I resolved to find a better way, and it turned out all I needed to do was add one line to the Monitor section in xorg.conf to specify the DPI (Dots Per Inch) for the X Screen when using the NVIDIA driver:

Section "Monitor"
    Identifier     "Monitor0"
    Option         "DPMS"
    Option         "DPI" "96 x 96"
EndSection

You can read more about this in the NVIDIA Accelerated Linux Graphics Driver README and Installation Guide, Appendix B. X Config Options.

As described in my earlier post, I run a script to copy a file I named xorg.conf.nvidia to xorg.conf when I want to use the NVIDIA driver, and another script to copy a file I named xorg.conf.intel to xorg.conf when I want to use the Intel driver. So all I needed to do was add the line Option "DPI" "96 x 96" to the Monitor section in the file xorg.conf.nvidia and run my script to switch to the NVIDIA driver. Problem finally solved.

Office 2007 mime-type problem in KDE Plasma 5

Further to my 2015 post Office 2007 mime-type problem in KDE, another problem opening Excel .xlsm files in Office 2007 with WINE in Gentoo Linux Stable happened to me recently, this time in KDE Plasma 5.5.5. Whenever I clicked on an Excel macro-enabled spreadsheet file myspreadsheet.xlsm in Dolphin, a pop-up window titled ‘Choose Application – Dolphin’ would prompt me to ‘Select the program you want to use to open the file myspreadsheet.xlsm’. When I selected Microsoft Excel 2007 from the ‘Known Applications’ list and ticked ‘Remember application association for all files of type “Excel macro-enabled spreadsheet” (application/vnd.ms-excel.sheet.macroEnabled.12)’, Excel would launch and load the spreadsheet. However, the next time I double-clicked the file, the pop-up window would prompt me again. So I tried setting the file association via ‘System Settings’ > ‘Applications’ > ‘File Associations’. Now, there are three entries under ‘Known Types’: vnd.ms-excel.sheet.macroEnabled.12, vnd.ms-excel.sheet.macroenabled.12 and x-wine-extension-xlsmhtml. However, there was no application listed in the box ‘Application Preference Order’ for vnd.ms-excel.sheet.macroEnabled.12, and, if I added Microsoft Excel 2007 to the list and clicked ‘Apply’, the new entry would disappear immediately.

Unlike the situation described in the above-mentioned post, the mime type for the .xlsm file appeared correct:

$ file myspreadsheet.xlsm
myspreadsheet.xlsm: Microsoft Excel 2007+
$ xdg-mime query filetype myspreadsheet.xlsm
application/vnd.ms-excel.sheet.macroEnabled.12

The file /usr/share/mime/subclasses contains ‘macroEnabled‘ rather than ‘macroenabled‘:

$ grep macroenabled /usr/share/mime/subclasses
$ grep macroEnabled /usr/share/mime/subclasses
application/vnd.ms-excel.sheet.binary.macroEnabled.12 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
application/vnd.ms-excel.addin.macroEnabled.12 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
application/vnd.ms-powerpoint.slideshow.macroEnabled.12 application/vnd.openxmlformats-officedocument.presentationml.slideshow
application/vnd.ms-excel.sheet.macroEnabled.12 application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
application/vnd.ms-powerpoint.presentation.macroEnabled.12 application/vnd.openxmlformats-officedocument.presentationml.presentation
application/vnd.ms-word.template.macroEnabled.12 application/vnd.openxmlformats-officedocument.wordprocessingml.template
application/vnd.ms-excel.template.macroEnabled.12 application/vnd.openxmlformats-officedocument.spreadsheetml.template
application/vnd.ms-powerpoint.template.macroEnabled.12 application/vnd.openxmlformats-officedocument.presentationml.template
application/vnd.ms-word.document.macroEnabled.12 application/vnd.openxmlformats-officedocument.wordprocessingml.document
application/vnd.ms-powerpoint.slide.macroEnabled.12 application/vnd.openxmlformats-officedocument.presentationml.slide

but the work-around mentioned in my 2015 post (i.e. replacing ‘macroEnabled‘ with ‘macroenabled‘ in the file /usr/share/mime/subclasses) did not fix the latest problem: I was still prompted to choose an application every time I double-clicked on a .xlsm file. So I reverted to the original contents of /usr/share/mime/subclasses (i.e. back to ‘macroEnabled‘) and looked in the directory /usr/share/mime/application/ to see what it contained for Excel spreadsheets:

$ ls -1 /usr/share/mime/application/vnd.ms-excel.sheet.*
/usr/share/mime/application/vnd.ms-excel.sheet.binary.macroenabled.12.xml
/usr/share/mime/application/vnd.ms-excel.sheet.macroenabled.12.xml

As there was no file for vnd.ms-excel.sheet.macroEnabled.12.xml I decided to create one to see if that would solve the problem:

$ sudo cp /usr/share/mime/application/vnd.ms-excel.sheet.macroenabled.12.xml /usr/share/mime/application/vnd.ms-excel.sheet.macroEnabled.12.xml

It did! If I click on a .xlsm file now, Excel 2007 launches and opens the spreadsheet.

Getting KDE Plasma 5 to work with the NVIDIA closed-source driver in Gentoo Linux

Up until a few days ago I had avoided migrating from KDE 4 to KDE Plasma 5, Frameworks 5 and Applications 5 — I’ll refer to the latter three package categories collectively as ‘KDE:5’ — on my main laptop, a Clevo W230SS with NVIDIA Optimus hardware and Gentoo Linux Stable Branch installed. My reluctance to migrate to KDE:5 was because of various problems I experience in KDE:5 on my Compal NBLB2 laptop, which has Gentoo Testing Branch installed (currently Plasma 5.7.1, which you would expect to be less buggy than Plasma 5.5.5 in the Gentoo Stable Branch).

Recently the maintainers of Gentoo’s KDE ebuilds removed some of the KDE 4 ebuilds and made some of the other ebuilds dependent on KDE:5. It became more complicated and convoluted to keep KDE 4 going, so I reluctantly threw in the towel and migrated to KDE:5 on my main laptop. I wish I could have kept KDE 4 on that machine, as KDE 4 worked extremely well (and looked great too).

My first problem after migrating was the infamous black screen in X Windows at start-up. Trying the various suggestions in the Gentoo Wiki did not help and, for the first time since I’ve owned the Clevo laptop, I was glad it has NVIDIA Optimus hardware as I was able to change from using nvidia-drivers to using xf86-video-intel, which got me to a usable Desktop after I switched desktop managers from SDDM (see the system log file error messages below) to LightDM.

Jul 17 04:32:37 clevow230ss sddm-helper[3245]: PAM unable to dlopen(/lib64/security/pam_systemd.so): /lib64/security/pam_systemd.so: cannot open shared object file: No such file or directory
Jul 17 04:32:37 clevow230ss sddm-helper[3245]: PAM adding faulty module: /lib64/security/pam_systemd.so

Although I had merged x11-misc/sddm with USE="-systemd" because my installation uses OpenRC, the above error messages made me suspect that something is wrong with the sddm-0.13.0-r3 ebuild, which is why I switched to LightDM.

However, using solely the Intel driver is not a long-term solution for me because DraftSight CAD software is slower with the Intel driver, so I was keen to get Plasma 5 working with the closed-source NVIDIA driver (I do not want to use Bumblebee).

I managed to get LightDM and Plasma 5 working with nvidia-drivers by doing the following:

  1. Merge x11-misc/lightdm.
  2. Re-merge kde-plasma/plasma-meta with USE="-sddm".
  3. Remove the x11-misc/sddm package and kde-plasma/sddm-kcm package by using the command ‘emerge --ask --depclean‘.
  4. Edit the file /etc/lightdm/lightdm.conf to add the line ‘greeter-session=lightdm-kde-greeter‘ as specified in Gentoo Wiki article LightDM.
  5. Edit the file /etc/lightdm/lightdm.conf to add the line ‘display-setup-script=/etc/X11/Sessions/plasma‘ (any file name would do).
  6. Create the above-mentioned Bash script /etc/X11/Sessions/plasma containing the following:
#!/bin/bash
GPU=`eselect opengl list | grep \* | awk '{ print $2 }'`
if [ "$GPU" = "nvidia" ]; then
    xrandr --setprovideroutputsource modesetting NVIDIA-0
    xrandr --auto
fi

I can now switch between the NVIDIA closed-source driver and the Intel open-source driver using the method described in an earlier post: Switching between Intel and NVIDIA graphics processors on a laptop with NVIDIA Optimus hardware running Gentoo Linux.