After updating Firefox for Linux, the folder icons in the bookmarks menu disappeared

Only a short post this time, but this problem has been annoying me for a few weeks. I use KDE 4.14 (kde-meta-4.14.3-r1) in Gentoo Linux on my main laptop, and recently upgraded Firefox to Version 46.0. The folder icons in Firefox’s bookmarks menu were no longer visible, although favicons were still visible in the bookmarks menu. The 2011 mozillaZine Forums thread After updating- ff4 bookmark folder icons disappeared [Linux] steered me in the right direction: I checked KDE 4’s ‘System Settings’ > ‘Application Appearance’ > ‘GTK’ and found that ‘Show icons in GTK menus’ was not ticked. I ticked this and clicked on ‘Apply’, and the problem was solved.

Elogviewer: A handy GUI for viewing Portage elog messages in Gentoo Linux

When merging (installing) packages in Gentoo, ebuilds often output console messages with information or warnings from the writer of the ebuild, usually at the end of the installation process. However, these ‘elog’ messages will not be displayed if you have configured the environment variable EMERGE_DEFAULT_OPTS so as to merge packages quietly or in parallel. Even if you did not configure EMERGE_DEFAULT_OPTS that way, it is easy to miss these messages as they scroll up and off screen if several packages are merging, one after the other.

The Gentoo package manager Portage has a logging facility that, if enabled, will log these elog messages to files so that you can review them afterwards. You can enable this facility by editing the file /etc/portage/make.conf and adding the environment variable PORTAGE_ELOG_SYSTEM="save" and the environment variable PORTAGE_ELOG_CLASSES with one or more logging classes. Here are the relevant lines from the file /etc/portage/make.conf on my laptop:

PORT_LOGDIR="/var/log/portage"
PORTAGE_ELOG_SYSTEM="save"
PORTAGE_ELOG_CLASSES="info warn error log qa"

For example, after merging the package www-misc/bluegriffon-bin-1.8 at 06:01:00 on 14 April 2016, I am able to examine the contents of the log file for that specific job:

$ cat /var/log/portage/elog/www-misc:bluegriffon-bin-1.8:20160414-060100.log
INFO: setup
Package: www-misc/bluegriffon-bin-1.8
Repository: local_overlay
USE: abi_x86_64 amd64 elibc_glibc kernel_linux userland_GNU
FEATURES: preserve-libs sandbox userpriv usersandbox
LOG: install
If you use BlueGriffon in KDE, use System Settings > Common Appearance and Behaviour > Application Appearance > GTK
and select any GTK theme other than Oyxgen, otherwise BlueGriffon will crash when you click on any pull-down menu.
QA: other
QA Notice: Pre-stripped files found:
/opt/bluegriffon/libreplace_jemalloc.so
/opt/bluegriffon/libnssdbm3.so
/opt/bluegriffon/libnss3.so
/opt/bluegriffon/bluegriffon-bin
/opt/bluegriffon/libnssutil3.so
/opt/bluegriffon/gmp-clearkey/0.1/libclearkey.so
/opt/bluegriffon/libsmime3.so
/opt/bluegriffon/libplc4.so
/opt/bluegriffon/libnssckbi.so
/opt/bluegriffon/plugin-container
/opt/bluegriffon/libsoftokn3.so
/opt/bluegriffon/libssl3.so
/opt/bluegriffon/libnspr4.so
/opt/bluegriffon/libxul.so
/opt/bluegriffon/libfreebl3.so
/opt/bluegriffon/components/libmozgnome.so
/opt/bluegriffon/components/libdbusservice.so
/opt/bluegriffon/libplds4.so
/opt/bluegriffon/libmozsqlite3.so
/opt/bluegriffon/bluegriffon

Of particular interest is the elog message:

If you use BlueGriffon in KDE, use System Settings > Common Appearance and Behaviour > Application Appearance > GTK
and select any GTK theme other than Oyxgen, otherwise BlueGriffon will crash when you click on any pull-down menu.

Clearly, some of the elog messages are important and must not be missed. After reading such messages, users can take appropriate action.

To facilitate reading Portage elog files, there is a GUI utility called Elogviewer which is easy to install and use:

# emerge elogviewer

$ elogviewer --help
usage: elogviewer [-h] [-p ELOGPATH] [--log {DEBUG,INFO,WARNING,ERROR}]

Elogviewer should help you not to miss important information. You need to
enable the elog feature by setting at least one of PORTAGE_ELOG_CLASSES="info
warn error log qa" and PORTAGE_ELOG_SYSTEM="save" in /etc/make.conf. You need
to add yourself to the portage group to use elogviewer without privileges.
Read /etc/make.conf.example for more information.

optional arguments:
  -h, --help            show this help message and exit
  -p ELOGPATH, --elogpath ELOGPATH
                        path to the elog directory
  --log {DEBUG,INFO,WARNING,ERROR}
                        set logging level

I happen to have configured EMERGE_DEFAULT_OPTS="--jobs=8 --load-average=8" (i.e. perform installation jobs in parallel using all eight cores of the CPU) in my /etc/portage/make.conf file, so I don’t see elog messages on screen, and therefore Elogviewer comes in handy. The output in the Konsole window looks like the following when I merge a package:

# emerge -v bluegriffon-bin

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild   R   ~] www-misc/bluegriffon-bin-1.8::local_overlay  0 KiB

Total: 1 package (1 reinstall), Size of downloads: 0 KiB

>>> Verifying ebuild manifests
>>> Emerging (1 of 1) www-misc/bluegriffon-bin-1.8::local_overlay
>>> Installing (1 of 1) www-misc/bluegriffon-bin-1.8::local_overlay
>>> Jobs: 1 of 1 complete                           Load avg: 0.11, 0.07, 0.13
>>> Auto-cleaning packages...

>>> No outdated packages were found on your system.

 * GNU info directory index is up-to-date.

Notice that the important elog message regarding switching the GTK theme in KDE that is included in the log file was not displayed on the console during installation of the package, because of my setting for EMERGE_DEFAULT_OPTS.

If I then launch Elogviewer, either from the command line or using the KDE launcher, a window pops up as shown below. I can then view a list of recently merged packages and click on each to read the elog output easily. Whether installing only one package or many packages in one session, this makes life easier.

Elogviewer

Elogviewer window

Automatically detecting files placed in my Downloads directory in Gentoo Linux and scanning them for viruses

I have been using Linux for almost a decade and have never been unduly concerned about viruses on my machines running Linux. However, I do receive files from people who use Windows and Mac OS, and some of those files might contain Windows or Mac OS viruses, so, as a matter of courtesy and assistance to others, it would make some sense to scan those files before passing them on. Furthermore, as I use some Windows applications under WINE, it would also make sense to scan received files for Windows viruses if I am going to use those files with a Windows application running under WINE.

External files could get into my Gentoo Linux installations via pen drives, memory cards, optical discs, e-mails, my Dropbox directory and downloads from Web sites. In this post I am going to concentrate on the last of these. All the various e-mail account providers I use already scan e-mails for viruses on their e-mail servers before I even download e-mail into the e-mail client on my laptop (standard practice these days), so e-mail is not a particular worry.

I have had ClamAV and its GUI, ClamTk, installed for a long time. Whilst ClamTk can be used to schedule a daily update of virus signatures and a daily scan of one’s home directory by ClamAV, I normally run ClamTk and ClamAV ad hoc. However, I can see some benefit in launching ClamAV automatically when I download a file from the Internet, so I decided to do the following …

Automatically scan a file downloaded via a Web browser

I use Firefox to browse the Web, and had configured it to download files to the directory /home/fitzcarraldo/Downloads/. I decided to monitor automatically the Downloads directory for the addition of any file. As I use the ext4 file system, the method I opted to use is inotify, specifically the inotifywait command which is available once you install the package sys-fs/inotify-tools.

It is surprisingly easy to create a shell script to detect files downloaded into a directory. The following script, running continuously in a terminal, would detect any files created in my /home/fitzcarraldo/Downloads directory, scan the new files with ClamAV and display a report in the terminal window:

#!/bin/bash

echo
DIR=$HOME/Downloads

inotifywait -q -m -e create --format '%w%f' $DIR | while read FILE
do
     date
     echo "File $FILE has been detected. Scanning it for viruses now ..."
     clamscan $FILE
     echo
done

A usable script would need to be a bit more sophisticated than the one shown above, because an existing file in the directory could be overwritten by one with the same name, or opened and amended. Furthermore, the script above would need a permanently open terminal window. Therefore I created a script to run in the background and use a GUI dialogue tool to pop up a window with the virus scanner’s report when the script detects a new or changed file in the Downloads directory. As this laptop has KDE 4 installed I opted to use KDialog to display the pop-up window, but I could instead have used Zenity. The final script is shown below.

#!/bin/bash

DIR=$HOME/Downloads

# Get rid of old log file
rm $HOME/virus-scan.log 2> /dev/null

inotifywait -q -m -e close_write,moved_to --format '%w%f' $DIR | while read FILE
do
     # Have to check file length is nonzero otherwise commands may be repeated
     if [ -s $FILE ]; then
          date > $HOME/virus-scan.log
          clamscan $FILE >> $HOME/virus-scan.log
          kdialog --title "Virus scan of $FILE" --msgbox "$(cat $HOME/virus-scan.log)"
     fi
done

Now when I download a file in Firefox, a window pops up, displaying a message similar to the following:

Virus scan of /home/fitzcarraldo/Downloads/eicar_com.zip – KDialog

Fri 19 Feb 23:42:02 GMT 2016
/home/fitzcarraldo/Downloads/eicar_com.zip: Eicar-Test-Signature FOUND

———– SCAN SUMMARY ———–
Known viruses: 4259980
Engine version: 0.98.7
Scanned directories: 0
Scanned files: 1
Infected files: 1
Data scanned: 0.00 MB
Data read: 0.00 MB (ratio 0.00:1)
Time: 4.595 sec (0 m 4 s)

Notice in the above message that ClamAV detected a virus in a file eicar_com.zip that I downloaded from the European Expert Group for IT Security Web site (originally ‘European Institute for Computer Antivirus Research’). In fact the executable eicar.com does not contain a real virus; it was designed to contain a known signature that virus scanner creators and users can use in checking anti-virus software. You can find out more about the virus test files on the EICAR Web site.

Of course, if I use applications other than Firefox to download files, I need to make sure they download the files into the applicable directory so that the script can detect and scan the files:

fitzcarraldo@clevow230ss ~ $ cd Downloads/
fitzcarraldo@clevow230ss ~/Downloads $ youtube-dl -o Carnavalito.mp4 -f 18 https://www.youtube.com/watch?v=ZDUL3w7zFD4
ZDUL3w7zFD4: Downloading webpage
ZDUL3w7zFD4: Downloading video info webpage
ZDUL3w7zFD4: Extracting video information
ZDUL3w7zFD4: Downloading MPD manifest
[download] Destination: Carnavalito.mp4
[download] 100% of 16.61MiB in 00:05

So, now I have a shell script that pops up a window informing me whether or not any file I put in $HOME/Downloads/ contains a virus. But I would like the script to be launched automatically when I login to the Desktop Environment. Therefore, as I use KDE 4, I selected ‘System Settings’ > ‘Startup and Shutdown’ and, in the ‘Autostart’ pane, clicked on ‘Add Script…’ and entered the path to my shell script (I left ‘create as symlink’ ticked). Now, every time I use KDE, any file placed (automatically or manually) into $HOME/Downloads/ is scanned for viruses automatically and a window pops up giving the result.

As my laptop is not always connected to the Internet, I prefer to update the ClamAV virus signatures database manually, which I do either using the ClamTk GUI or via the command line using the freshclam command:

fitzcarraldo@clevow230ss ~ $ su
Password:
clevow230ss fitzcarraldo # freshclam
ClamAV update process started at Sat Feb 20 10:51:01 2016
WARNING: Your ClamAV installation is OUTDATED!
WARNING: Local version: 0.98.7 Recommended version: 0.99
DON'T PANIC! Read http://www.clamav.net/support/faq
main.cvd is up to date (version: 55, sigs: 2424225, f-level: 60, builder: neo)
Downloading daily-21375.cdiff [100%]
Downloading daily-21376.cdiff [100%]
Downloading daily-21377.cdiff [100%]
Downloading daily-21378.cdiff [100%]
Downloading daily-21379.cdiff [100%]
Downloading daily-21380.cdiff [100%]
Downloading daily-21381.cdiff [100%]
Downloading daily-21382.cdiff [100%]
Downloading daily-21383.cdiff [100%]
Downloading daily-21384.cdiff [100%]
Downloading daily-21385.cdiff [100%]
Downloading daily-21386.cdiff [100%]
Downloading daily-21387.cdiff [100%]
Downloading daily-21388.cdiff [100%]
Downloading daily-21389.cdiff [100%]
Downloading daily-21390.cdiff [100%]
Downloading daily-21391.cdiff [100%]
daily.cld updated (version: 21391, sigs: 1850214, f-level: 63, builder: neo)
bytecode.cld is up to date (version: 271, sigs: 47, f-level: 63, builder: anvilleg)
Database updated (4274486 signatures) from db.UK.clamav.net (IP: 129.67.1.218)
WARNING: Clamd was NOT notified: Can't connect to clamd through /var/run/clamav/clamd.sock: No such file or directory

KDE Connect on a hotel Wi-Fi network

KDE Connect

I am a fan of KDE Connect (see my 2014 post about an earlier version), but had previously been unable to use it with a hotel network. However today I managed to do that, and here is how I did it …

I first connected my laptop and my Samsung Galaxy Note 4 to the hotel’s Wi-Fi network, then used the ifconfig command in Linux on my laptop to find the IP address of my laptop on the hotel’s network. Note that the IP address one sees if one uses a Web site such as WhatIsMyIPAddress will be the laptop’s outward-facing IP address, not the IP address of the laptop on the hotel network. For example, the ifconfig command has just shown me that my current DHCP-allocated IP address is 10.154.245.40 on this hotel’s network for this session whereas the Web site WhatIsMyIPAddress is showing my IP address as 78.100.57.102.

By the way, I can also use the excellent Android utility Fing on my Galaxy Note 4 to find the IP address of my laptop on the hotel’s network. It is quite interesting to use Fing to see what other devices (their hostname and IP address) are currently connected to the hotel’s network.

Anyway, then I launched KDE Connect on the Galaxy Note 4, tapped and ‘Add devices by IP’, and entered the laptop’s IP address (10.154.245.40 in this specific case). I was able to pair with KDE Connect running on my laptop and send files from my phone to the laptop, and vice versa.

Automatically log off inactive users in Windows 10

Although I use Linux on my own machines, the family PC in my lounge runs Windows 10. It has five user accounts and the other members of my family never bother to log out (‘sign out’ in Windows 10 parlance), usually leaving a browser window open. If I logged in to my account and clicked on my icon in the top left corner of the Start Menu, ‘Signed in’ was shown below any of the other users who had not bothered to log out. I found this behaviour somewhat frustrating and resolved to configure the PC to log out a user after a specified period of inactivity by that user. Although it is generally not recommended to forcibly logout someone in case e.g. they have a document open, in my family’s case it would be unlikely to cause a problem and is preferable to leaving several accounts unnecessarily active (albeit requiring each user to re-enter their password in order to access the account, as the default setting for ‘Require a password on wake-up’ is ‘Yes’). Below I explain how I configured Windows 10 to log out each user automatically after a period of inactivity.

First I downloaded the application idlelogoff.exe using the following link:

http://ftp.intelliadmin.com/release/idlelogoff.exe

See the Web page Automatically log off inactive users for details of that application.

I used the Windows 10 File Explorer to copy the file to the root directory C:\ and then I created a batch file IDLELOGOFF.BAT by right-clicking on the Windows 10 Start Menu icon, selecting ‘Command Prompt (Admin)’ and entering the following commands in the Command Prompt window:

cd C:\
notepad IDLELOGOFF.BAT

I made the contents of the batch file IDLELOGOFF.BAT the following, so that a user would be logged out automatically after 900 seconds of inactivity in their session:

start /min C:\idlelogoff.exe 900 logoff

and I changed the owner of the batch file to Users by right-clicking on it in File Explorer and then clicking ‘Properties’ > ‘Security’ > ‘Advanced’ > ‘Owner: Change’ and specifying ‘Users’.

Then I created a standard shortcut to the batch file for each user by getting each user in turn to log in to their account and following the instructions on the Web page Windows 10 – How to Run Program Automatically at Startup. Basically, you press the Windows Key and the R key simultaneously and enter ‘shell:startup‘ to open the user’s Start-up folder, and from there you right-click and select ‘New’ > ‘Shortcut’.

After that, the application idlelogoff.exe should be started automatically the next time a user logs in. You can check by pressing Ctrl-Alt-Delete in each user’s session, selecting ‘Task Manager’, clicking on the ‘Processes’ tab and idlelogoff.exe should be in the list of background processes. If you then log in to your own account and click on your account icon in the top left corner of the Start Menu, you’ll notice ‘Signed in’ is shown below the other user’s icon. If you check again after fifteen minutes, you’ll see that the ‘Signed in’ has gone, indicating that the user has been forcibly logged off.

SDDM keyboard layout

I am using Plasma 5 in Gentoo Linux ~amd64 with OpenRC on my Compal NBLB2 laptop. The Display Manager I am using is SDDM, and the log-in screen was using the US keyboard layout, the only keyboard layout available in the log-in screen’s keyboard menu. Searching the Web told me that SDDM uses the keyboard layout specified in the file /etc/X11/xorg.conf.d/00-keyboard.conf. The trouble is, it doesn’t (at least not in my case). The file already existed in my installation, and its contents are listed below:

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

The X.Org keyboard layouts specified in the file are available once I have logged in to the Plasma 5 Desktop, but none of the four keyboards (gb, us, br and es) were displayed by SDDM in its log-in screen menu. Eventually I discovered it is possible to specify the keyboard layouts in the file /usr/share/sddm/scripts/Xsetup which, by default, contains only the following:

#!/bin/sh
# Xsetup - run as root before the login dialog appears

I edited the file to contain the list of keyboards I wanted SDDM to allow me to choose from on the log-in screen:

#!/bin/sh
# Xsetup - run as root before the login dialog appears
setxkbmap gb,us,br,es

Now the SDDM log-in screen displays the national flags of those four keyboard languages in its keyboard menu, and I can select which keyboard layout to use for typing my password to log in to the Plasma 5 Desktop.

NetworkManager: Failed to activate – The name org.freedesktop.NetworkManager was not provided by any .service files

Because I need to connect quickly and easily to numerous wired and wireless networks (DHCP or static IP addressing), I use NetworkManager in my Gentoo Linux amd64 installation running OpenRC and KDE 4. My Clevo W230SS laptop has an Intel Dual Band Wireless-AC 7260 Plus Bluetooth adapter card, and my installation uses the iwlwifi module:

# lspci -knn | grep Net -A2
03:00.0 Network controller [0280]: Intel Corporation Wireless 7260 [8086:08b1] (rev bb)
        Subsystem: Intel Corporation Dual Band Wireless-AC 7260 [8086:4070]
        Kernel driver in use: iwlwifi
# lsmod | grep iwl
iwlmvm                143919  0
iwlwifi                75747  1 iwlmvm

As I am using NetworkManager instead of netifrc, in accordance with the instructions in the Gentoo Wiki article on NetworkManager I do not have any net.* services enabled (not even net.lo):

# rc-update show -v
       NetworkManager |      default                 
                acpid |                              
            alsasound |                              
         avahi-daemon |                              
       avahi-dnsconfd |                              
               binfmt | boot                         
            bluetooth |      default                 
             bootmisc | boot                         
         busybox-ntpd |                              
     busybox-watchdog |                              
                clamd |                              
          consolefont |                              
           consolekit |      default                 
               cronie |      default                 
         cups-browsed |      default                 
                cupsd |      default                 
                 dbus |      default                 
                devfs |                       sysinit
               dhcpcd |                              
                dhcpd |                              
             dhcrelay |                              
            dhcrelay6 |                              
                dmesg |                       sysinit
              dropbox |                              
           fancontrol |                              
                 fsck | boot                         
                 fuse |                              
           git-daemon |                              
                  gpm |                              
              hddtemp |                              
             hostname | boot                         
              hwclock | boot                         
            ip6tables |                              
             iptables |                              
              keymaps | boot                         
            killprocs |              shutdown        
    kmod-static-nodes |                       sysinit
           lm_sensors |                              
                local |      default                 
           localmount | boot                         
             loopback | boot                         
      mit-krb5kadmind |                              
          mit-krb5kdc |                              
       mit-krb5kpropd |                              
              modules | boot                         
             mount-ro |              shutdown        
                 mtab | boot                         
                mysql |                              
                  nas |                              
         net.enp4s0f1 |                              
               net.lo |                              
             netmount |      default                 
           ntp-client |                              
                 ntpd |                              
           nullmailer |                              
              numlock |                              
  nvidia-persistenced |                              
           nvidia-smi |                              
              osclock |                              
              pciparm |                              
               procfs | boot                         
              pwcheck |                              
            pydoc-2.7 |                              
            pydoc-3.4 |                              
               rfcomm |                              
                 root | boot                         
               rsyncd |                              
            s6-svscan |                              
                samba |      default                 
                saned |                              
            saslauthd |                              
            savecache |              shutdown        
                 sntp |                              
                 sshd |      default                 
             svnserve |                              
                 swap | boot                         
            swapfiles | boot                         
              swclock |                              
               sysctl | boot                         
                sysfs |                       sysinit
            syslog-ng |      default                 
        teamviewerd10 |                              
         termencoding | boot                         
             timidity |                              
         tmpfiles.dev |                       sysinit
       tmpfiles.setup | boot                         
               twistd |                              
                 udev |                       sysinit
                  ufw | boot                         
              urandom | boot                         
       wpa_supplicant |                              
                  xdm |      default                 
            xdm-setup |

I have left the netmount service enabled in case I want to use network-attached file shares at home or in one of the various office locations where I work.

Networking works fine on my laptop with the many wired and wireless networks I have used except for one particular public wireless network (it is in an airport, has multiple Access Points, and its Access Points only support 802.11a/b/g, which may or may not be relevant) for which the following message would usually appear in a pop-up window when I tried to connect to the network from the KDE network management GUI after start-up:

Failed to activate
The name org.freedesktop.NetworkManager was not provided by any .service files

Error message displayed by KDE when trying to connect to one specific network

Error message displayed by KDE when trying to connect to one specific network


This occurred with both networkmanager-1.0.2-r1 and networkmanager-1.0.6, the two Stable Branch releases of NetworkManager currently available in Gentoo Linux.

The wireless network is not the only network at that particular location, and the ‘Failed to activate’ message occurred whichever network (wireless or wired) I tried to access at that location. When this problem occurred, it transpired that the NetworkManager service was not running (it had crashed):

$ nmcli d
Error: NetworkManager is not running.
$ rc-status
Runlevel: default
 dbus                   [  started  ]
 NetworkManager         [  crashed  ]
 netmount               [  started  ]
 syslog-ng              [  started  ]
 cupsd                  [  started  ]
 samba                  [  crashed  ]
 consolekit             [  started  ]
 cronie                 [  started  ]
 bluetooth              [  started  ]
 xdm                    [  started  ]
 cups-browsed           [  started  ]
 sshd                   [  started  ]
 local                  [  started  ]
Dynamic Runlevel: hotplugged
Dynamic Runlevel: needed
 xdm-setup              [  started  ]
 avahi-daemon           [  started  ]
Dynamic Runlevel: manual

(I am not bothered that Samba crashes in that particular location. It crashes even if a connection is established, because the public wireless network does not provide network file systems. Samba works fine when I connect the laptop to an office network or to my home network.)

Even if the ‘Failed to activate’ message occurred, sometimes (but not always) the laptop could still connect to networks after I restarted the NetworkManager service (albeit sometimes it was necessary to restart it more than once):

# /etc/init.d/NetworkManager restart

When it is possible to connect to networks, the NetworkManager service is of course running:

$ nmcli d
DEVICE    TYPE      STATE        CONNECTION           
sit0      sit       connected    sit0                 
wlp3s0    wifi      connected    Free_Airport_Internet
enp4s0f1  ethernet  unavailable  --                   
lo        loopback  unmanaged    --        
$ rc-status
Runlevel: default
 dbus                   [  started  ]
 NetworkManager         [  started  ]
 netmount               [  started  ]
 syslog-ng              [  started  ]
 cupsd                  [  started  ]
 samba                  [  crashed  ]
 consolekit             [  started  ]
 cronie                 [  started  ]
 bluetooth              [  started  ]
 xdm                    [  started  ]
 cups-browsed           [  started  ]
 sshd                   [  started  ]
 local                  [  started  ]
Dynamic Runlevel: hotplugged
Dynamic Runlevel: needed
 xdm-setup              [  started  ]
 avahi-daemon           [  started  ]
Dynamic Runlevel: manual

I searched the Web for the error message and, based on a recommendation on the Web page ‘nm-applet gives errors‘ claiming the problem is due to the iwlwifi driver when used with an Intel 7260 controller, I created a file /etc/modprobe.d/iwlwifi.conf containing the following line, and rebooted:

options iwlwifi power_save=0

However, the error message still occurred. So I changed the iwlwifi module options line to the following, as also recommended on that page, and rebooted:

options iwlwifi 11n_disable=1 power_save=0

However, the error message still occurred.

The default value for OpenRC’s rc_depend_strict variable is YES if rc_depend_strict is not declared in the file /etc/rc.conf, but I do not think that is the cause of the problem:

# Do we allow any started service in the runlevel to satisfy the dependency
# or do we want all of them regardless of state? For example, if net.eth0
# and net.eth1 are in the default runlevel then with rc_depend_strict="NO"
# both will be started, but services that depend on 'net' will work if either
# one comes up. With rc_depend_strict="YES" we would require them both to
# come up.
#rc_depend_strict="YES"

As already mentioned, sometimes just restarting the NetworkManager service once or more did enable the laptop to connect to the network. This made me wonder whether the problem had something to do either with the timing of the launch of the NetworkManager service or with the timing of the service establishing a connection. As netmount is the only other network-related service enabled at start-up, I checked the netmount service’s configuration file /etc/conf.d/netmount to see what it contained (it’s the same in both the latest stable openrc-0.17 and the latest testing openrc-0.18.2):

# You will need to set the dependencies in the netmount script to match
# the network configuration tools you are using. This should be done in
# this file by following the examples below, and not by changing the
# service script itself.
#
# Each of these examples is meant to be used separately. So, for
# example, do not set rc_need to something like "net.eth0 dhcpcd".
#
# If you are using newnet and configuring your interfaces with static
# addresses with the network script, you  should use this setting.
#
#rc_need="network"
#
# If you are using oldnet, you must list the specific net.* services you
# need.
#
# This example assumes all of your netmounts can be reached on
# eth0.
#
#rc_need="net.eth0"
#
# This example assumes some of your netmounts are on eth1 and some
# are on eth2.
#
#rc_need="net.eth1 net.eth2"
#
# If you are using a dynamic network management tool like
# networkmanager, dhcpcd in standalone mode, wicd, badvpn-ncd, etc, to
# manage the network interfaces with the routes to your netmounts, you
# should list that tool.
#
#rc_need="networkmanager"
#rc_need="dhcpcd"
#rc_need="wicd"
#
# The default setting is designed to be backward compatible with our
# current setup, but you are highly discouraged from using this. In
# other words, please change it to be more suited to your system.
#
rc_need="net"

As I am using NetworkManager rather than netifrc, I followed the instructions in the file’s comments and changed the file’s contents from:

rc_need="net"

to:

rc_need="networkmanager"

After making the above change, the console messages at boot-up included a new message:

* ERROR: netmount needs service(s) networkmanager

That message made sense: rc_need had been set to "networkmanager" and, obviously, netmount can only do its job if NetworkManager is running (AND a network connection has been established). However, notice that the name of the NetworkManager service initscript is /etc/init.d/NetworkManager, not /etc/init.d/networkmanager. In other words, the instructions in /etc/conf.d/netmount are wrong: the name of the service is actually ‘NetworkManager‘, not ‘networkmanager‘. So I changed /etc/conf.d/netmount to contain rc_need="NetworkManager" instead of rc_need="networkmanager" and, unsurprisingly, the above-mentioned error message no longer occurs. I have filed Gentoo Bugzilla Bug Report No. 564846 requesting that the comment in the configuration file be changed.

Nevertheless, the ‘Failed to activate’ message still occurred when I tried to connect to any network at that location by using the DE’s network management GUI, and therefore I still needed to restart the NetworkManager service manually in order to be able to connect to any network there. Although I am not yet sure of the root cause and solution, I have found a work-around which avoids me having to manually restart the NetworkManager service, as explained below.

Although OpenRC correctly launches the NetworkManager service, that service remains inactive until it actually establishes a network connection. This is not a bug, it is the way OpenRC and NetworkManager work (see the explanation in the Gentoo Forums thread NetworkManager has started, but is inactive). This is why the following console message appears during boot-up:

* WARNING: NetworkManager has already started, but is inactive

If you did not configure NetworkManager to connect automatically to a network, after logging-in to the DE you will need to use the DE’s network management GUI (plasma-nm in the case if KDE, nm-applet in the case of e.g. Xfce) to tell NetworkManager to connect to the desired network. However, I found that waiting that long before trying to connect is too late to avoid the ‘Failed to activate’ problem, i.e. NetworkManager crashes after a while. I do not know why this happens, but it usually happens only when I am at the location covered by one specific wireless network (which is why I wonder if the problem is a result of that network only supporting 802.11a/b/g). By configuring NetworkManager to connect automatically to the wireless network which seemed to trigger the problem, the NetworkManager service tries to connect earlier. It is possible to configure NetworkManager to do this either by using the DE network GUI and ticking ‘Automatically connect to this network when it is available’ for the relevant network connection, or by directly editing the relevant connection’s file in the directory /etc/NetworkManager/system-connections/.

Of the various wired and wireless connections I had configured on the laptop, I had named the problematic wireless network’s connection ‘Free_Airport_Internet’. So I edited the file /etc/NetworkManager/system-connections/Free_Airport_Internet and deleted the line ‘autoconnect=false‘ in the [connections] section of the file (the default value of the autoconnect variable is TRUE – see man nm-settings). I could instead have done this by using the DE’s network manager GUI and ticking ‘Automatically connect to this network when it is available’ for that network connection. Now, when the laptop boots, NetworkManager tries to connect to that network and the ‘Failed to activate’ problem is avoided. This works with or without the iwlwifi driver options I mentioned above, so, despite the claim on the Web page I referenced above, the root cause of the problem does not appear to be the iwlwifi driver. What I don’t understand is why the problem only seems to occur with one particular network (a public wireless network which happens to only support 802.11a/b/g), i.e. even if none of the NetworkManager connection files in my installation have been configured to try to establish a connection automatically, with all the other wireless networks I have used in other locations (I believe those all support at least 802.11a/b/g/n) I have been able to establish a connection manually by using the DE’s network management GUI.

The bottom line

If your installation uses NetworkManager and you experience the ‘Failed to activate’ message when trying to connect to networks from the DE’s network management GUI, check if the NetworkManager service is running. You can check by using the command ‘nmcli d‘ in a console. If it is not running, try to restart the NetworkManager service from the command line. If the connection is not already configured to start automatically, configure it to start automatically in order to try to make NetworkManager become active at an early stage.

POSTSCRIPT (November 6, 2015)

The two links below are to old bug reports regarding earlier versions of NetworkManager having trouble using wireless networks with multiple Access Points. I wonder if the problem I saw with NetworkManager crashing when not configured to connect automatically to the specific network I mentioned above is somehow related to those problems:

background scanning causes drivers to disassociate – WiFi roaming causes NetworkManager to lose routing

network-manager roams to (none) ((none)) – background scanning

Roaming to BSSID “(none)” certainly happens with this particular network too, as shown by the messages in the laptop’s system log from yesterday when I was using the laptop with that network (the laptop was stationary the whole time):

# cat /var/log/messages | grep "Nov  5 11" | grep NetworkManager | grep \(none\)
Nov  5 11:01:22 clevow230ss NetworkManager[2459]:   (wlp3s0): roamed from BSSID 04:C5:A4:C3:F9:EE (Free_Airport_Internet) to (none) ((none))
Nov  5 11:01:22 clevow230ss NetworkManager[2459]:   (wlp3s0): roamed from BSSID (none) ((none)) to B8:BE:BF:69:89:6E (Free_Airport_Internet)
Nov  5 11:13:23 clevow230ss NetworkManager[2459]:   (wlp3s0): roamed from BSSID B8:BE:BF:69:89:6E (Free_Airport_Internet) to (none) ((none))
Nov  5 11:13:23 clevow230ss NetworkManager[2459]:   (wlp3s0): roamed from BSSID (none) ((none)) to 04:C5:A4:C3:F9:EE (Free_Airport_Internet)
Nov  5 11:15:23 clevow230ss NetworkManager[2459]:   (wlp3s0): roamed from BSSID 04:C5:A4:C3:F9:EE (Free_Airport_Internet) to (none) ((none))
Nov  5 11:15:23 clevow230ss NetworkManager[2459]:   (wlp3s0): roamed from BSSID (none) ((none)) to B8:BE:BF:69:89:6E (Free_Airport_Internet)
Nov  5 11:19:22 clevow230ss NetworkManager[2459]:   (wlp3s0): roamed from BSSID B8:BE:BF:69:89:6E (Free_Airport_Internet) to (none) ((none))
Nov  5 11:19:23 clevow230ss NetworkManager[2459]:   (wlp3s0): roamed from BSSID (none) ((none)) to B8:BE:BF:69:89:6E (Free_Airport_Internet)
Nov  5 11:49:50 clevow230ss NetworkManager[2459]:   (wlp3s0): roamed from BSSID B8:BE:BF:69:89:6E (Free_Airport_Internet) to (none) ((none))
Nov  5 11:49:50 clevow230ss NetworkManager[2459]:   (wlp3s0): roamed from BSSID (none) ((none)) to 68:BC:0C:A1:3C:DE (Free_Airport_Internet)
Nov  5 11:51:51 clevow230ss NetworkManager[2459]:   (wlp3s0): roamed from BSSID 68:BC:0C:A1:3C:DE (Free_Airport_Internet) to (none) ((none))
Nov  5 11:51:51 clevow230ss NetworkManager[2459]:   (wlp3s0): roamed from BSSID (none) ((none)) to B8:BE:BF:69:89:6E (Free_Airport_Internet)

Today I’m using a hotel network in my hotel room, and that does not roam to BSSID “(none)”, but I don’t know if my room is within range of more than one Access Point:

# cat /var/log/messages | grep "Nov  6" | grep NetworkManager | grep \(none\)
#

Anyway, with the work-around described in this post I have not had any further trouble accessing the particular network, but it would be interesting to know the root cause.

Using a keyboard shortcut in Linux to add an e-mail signature giving current location and local time

In my previous post I showed how to find the current time at any town or city Worldwide from the command line in Gentoo Linux. My interest in a command to do this is not to use it on the command line per se, but to use the command in a keyboard shortcut to insert a signature at the end of my e-mails.

I have to travel internationally frequently because of my work, but I leave my laptop’s hardware clock set to UTC and the system clock set to the local time of my home town. This means that, irrespective of where I am in the World, the e-mail client (Thunderbird, in my case) uses the local time of my home town in e-mail headers and calenders. It is not practical to reconfigure Linux for each timezone I happen to be in (see my post Configuring the Linux clock), and, in any case, I want the file system’s timestamps to use one timezone only and all the timestamps in my e-mails and the e-mail client’s calender to use one timezone only, so there is less chance of me getting confused. I could have configured the installation to use UTC for the system clock, but I prefer the system clock to use the timezone of my home town. Of course, even though the system clock is always set to the timezone of my home town, on the Panel clock I select the timezone of the location where I happen to be, so that the Panel clock displays the local time in that timezone.

I wanted to be able to insert a signature at the end of each e-mail, stating my current location and the current time at that location, so that the person receiving the e-mail could tell from where in the World I sent the e-mail and the local time it was sent, as that local time could differ from the time shown in the e-mail header. For example, let us assume that Jane, who lives in the UK and whose system clock is configured for the timezone Europe/London, is making a brief visit to Perth, Australia and sends an e-mail to Dave in the UK at 06:36 on 11 October (Perth time). The e-mail below illustrates the type of signature I wanted to achieve.

Subject: Site visit
From: Jane <jane@acompany.com>
To: Dave <dave@acompany.com>
Date: Sat Oct 10 2015 23:36:40 GMT+0100 (BST)

Hello Dave,

This is to let you know that I have just arrived in Perth and will be
visiting site at 09:00 local time to speak to the client. Tomorrow p.m.
I have a meeting scheduled with our local project manager, so I would
appreciate it if you would e-mail the latest documentation to me. I will
not have spare time until I’m in my room at the hotel tonight but will
read the documents tomorrow a.m. in readiness for the meeting with
the local project manager. Thanks in advance.

Regards,
Jane
Current location: Perth (Australia)
Local time now: Sat Oct 11 06:36:31 2015 AWST

As you can see above, because the OS on Jane’s and Dave’s laptops is configured for the timezone Europe/London, the e-mail header shows the current time in the UK when the e-mail was sent, which was October 10, 23:36 British Summer Time (22:36 UTC), and the signature shows the corresponding local time in Perth, Australia, which was October 11, 06:36 Australian Western Standard Time. It becomes even more confusing if the computer of the person receiving the e-mail is configured for a third timezone. For example, let’s say Dave is based in Seattle, USA rather than the UK. His e-mail client would then display the time in that timezone when the e-mail was sent. This is usually my case, i.e. my Linux installation is configured for Timezone1 but I happen to be in Timezone2 when I send an e-mail to someone who is based in Timezone3 and whose OS is configured for that timezone.

I wanted to use a keyboard shortcut to add a signature to the end of my e-mails, as shown above. I therefore created the Bash script listed below, which I named timezone_signature_GeoNames.sh:

#!/bin/bash

location=$(kdialog --title "Current Location" --inputbox "Enter your location:")

localtime=$(perl /home/fitzcarraldo/now1.pl $location)
place=`echo $localtime | cut -d'|' -f1`
place=$place" "`echo $localtime | cut -d'|' -f2`
timezone=`echo $localtime | cut -d'|' -f4`

if [ $location != "" ]; then
  echo -n "Current location: "
  echo $place
  echo -n "Local time now:"
  /usr/sbin/zdump ${timezone} | cut -d' ' -f2-
fi
echo

Notice that the Bash script uses the GUI dialogues utility kdialog to display a pop-up window prompting me to enter the name of a town/city. As I am using KDE I opted to use a dialogues utility developed for use in KDE, but I could have used Zenity instead.

The Perl script now1.pl is a variant of the Perl script now.pl described in my previous post, modified very slightly in order to facilitate formatting of the output by the Bash script, and is listed below.

#!perl

use strict;
use warnings;

use DateTime;
use Geo::GeoNames;
use URI::Escape;
use Encode;

binmode STDOUT, ':encoding(UTF-8)';

my $city = decode("UTF-8", @ARGV ? shift : 'London');
# N.B. Replace London with your home town/city.

my $geo = Geo::GeoNames->new( username => '************' );
# N.B. Replace the asterisks with your GeoNames user name.

my $result = $geo->search(
q       => uri_escape_utf8($city),
maxRows => 1,
style   => 'FULL'
);

defined $result->[0] or die "Unrecognized city '$city'\n";

my $city_name    = $result->[0]->{name};
my $country_name = $result->[0]->{countryName};
my $time_zone    = $result->[0]->{timezone}{content};
my $time_now     = DateTime->now( time_zone => $time_zone );

#print "$city_name ($country_name) $time_now ($time_zone)\n";

print "$city_name|($country_name)|$time_now|$time_zone\n";

exit 0;

The only thing remaining was to configure a keyboard shortcut to launch the Bash script. I opted to use the key combination Ctrl-Alt-z for the shortcut. As I am using KDE I could have used KDE’s ‘System Settings’ > ‘Shortcuts and Gestures’> ‘Custom Shortcuts’ to specify the shortcut and the name of the script it launches. However, as I also use AutoKey for various shortcuts, I opted to use that instead, so I used the AutoKey GUI to create a shortcut named ‘Insert Current Time’ to use the following command:

output = system.exec_command("/home/fitzcarraldo/timezone_signature_GeoNames.sh")
keyboard.send_keys(output)

Use

I compose my e-mails as usual, and, after entering my name at the end of the e-mail, I press Ctrl-Alt-z. A window then pops up prompting me to enter my current location, which I do and then click on ‘OK’. The location and current time at that location are then added to the end of the e-mail, and it just remains for me to click on the ‘Send’ button in the e-mail client’s window. As the Perl script now1.pl uses the Internet to access the GeoNames database, my laptop must be connected to the Internet when I use the shortcut.

KDialog window that pops up when I use the keyboard shortcut

KDialog window that pops up when I use the keyboard shortcut

If the town/city name consists of more than one word (Rio de Janeiro, for example) then replace spaces with hyphens when you enter the location name in the pop-up window (Rio-de-Janeiro, for example) and then the keyboard shortcut will return the correct location and local time:

Current location: Rio de Janeiro (Brazil)
Local time now: Fri Oct 16 09:28:19 2015 BRT

How to group the entries in the right-click menu of a KDE file manager

This is easier to explain by giving an example. I will use PeaZip as my example, but the principle applies whatever the menu entries.

Immediately after installing PeaZip Portable on my main laptop running Gentoo Linux by using the steps in one of my earlier posts, the resulting right-click menu in KDE Dolphin looks like the screenshot below. Notice that the PeaZip entries in the Actions sub-menu are not listed contiguously.

Actions sub-menu of right-click menu in KDE

But in KDE it is relatively easy to group menu entries tidily in a sub-menu, as shown in the screenshot below.

Sub-menu of Actions sub-menu for right-click menu in KDE

The peazip*.desktop files for the five PeaZip actions shown in the above screenshots are located in the directory ~/.kde4/share/kde4/services/ServiceMenus/ and each file includes the line ‘X-KDE-Submenu='.

All I had to do was edit each of the five peazip*.desktop files and change that line in each file to ‘X-KDE-Submenu=PeaZip‘.

That’s it!

Making the X Windows cursor theme the same for KDM and KDE

For a long time it irritated me that the X Windows cursor theme on the KDM log-in screen differed to the X Windows cursor theme on the KDE Desktop. The former was usually the old-fashioned core X Windows cursor theme (or perhaps the ‘KDE Classic’ theme, I’m not sure which), whereas the latter is the theme I selected via ‘System Settings’ > ‘Workspace Appearance’ > ‘Cursor Theme’. To confuse me further, when I upgraded X Windows recently the X Windows cursor theme on the KDM log-in screen was Adwaita when I next booted my laptop, but susequently reverted to the classic cursor theme.

Anyway, I had to do the following in order to make the KDM cursor theme the same as the KDE cursor theme:

1. Create a directory /usr/share/icons/default if it does not already exist (it did not in my case):

# mkdir /usr/share/icons/default

2. Check which X Windows cursor themes are currently installed:

# ls /usr/share/icons
Adwaita HighContrast Humanity KDE_Classic Oxygen_Black Oxygen_Blue Oxygen_White Oxygen_Yellow Oxygen_Zion default gnome hicolor locolor mono nuvola oxygen ubuntu-mono-dark ubuntu-mono-light

I also find the three X Windows cursor themes ‘handhelds’, ‘redglass’ and ‘whiteglass’, installed when I installed the package x11-themes/xcursor-themes using the Portage package manager, in a different directory:

# ls /usr/share/cursors/xorg-x11/
Adwaita handhelds redglass whiteglass

The ‘Adwaita’ cursor theme was already in /usr/share/cursors/xorg-x11/ before I installed the package x11-themes/xcursor-themes, and also in the directory /usr/share/icons/ but I do not know why only that specific cursor theme is in both directories.

3. Create a file /usr/share/icons/default/index.theme with the following contents (I opted to use the Oxygen_White cursor theme, but you can choose whichever you want from the list of installed cursor themes):

[Icon Theme]
Name = Oxygen_White
Comment = Default icon theme
Inherits = Oxygen_White

4. Make sure ‘System Settings’ > ‘Worskspace Appearance’ > ‘Cursor Theme’ has the theme selected that you want for the KDE Desktop (I opted to use the Oxygen_White cursor theme).

For example, if I had wanted the cursor theme to be Adwaita, I would have selected Adwaita in KDE using ‘System Settings’ > ‘Worskspace Appearance’ > ‘Cursor Theme’ and then I would have edited /usr/share/icons/default/index.theme to contain the following:

[Icon Theme]
Name = Adwaita
Comment = Default icon theme
Inherits = Adwaita

Easy when you know how.

According to the Arch Linux Wiki, for user-specific configuration you should create or edit the file ~/.icons/default/index.theme, whereas for system-wide configuration you should create or edit the file /usr/share/icons/default/index.theme but the latter file is owned by libXcursor and user changes to it will be overwritten on update. However, in Gentoo Linux it would be possible to get around that by creating a script file in the directory /etc/local.d/ to revert the file change. For example, I could make the file /usr/share/icons/default/index.theme contain the following:

[Icon Theme]
Name = Oxygen_White
Comment = Default icon theme
Inherits = Oxygen_White

Then copy that file to somewhere safe that will not be overwritten:

# cp /usr/share/icons/default/index.theme /home/fitzcarraldo/

Then create a script file named, say, 80-xcursor.start in /etc/local.d/ with the following contents:

#!/bin/bash
# Make sure X windows cursor theme on the KDM screen is the one I want:
cp /home/fitzcarraldo/index.theme /usr/share/icons/default/index.theme

and make the script file executable:

# chmod +x /etc/local.d/80-xcursor.start

Then, if something does overwrite or delete /usr/share/icons/default/index.theme in future, the script in /etc/local.d/ will restore it before the KDM log-in screen appears, so you would always see the cursor theme specified in /home/fitzcarraldo/index.theme.

Follow

Get every new post delivered to your Inbox.

Join 68 other followers