How to display a user’s avatar instead of the generic avatar on the LightDM GTK Greeter screen in Lubuntu 17.10

I recently installed Lubuntu 17.10 on my family’s PC (single-seat, multi-user). The default avatar was displayed for each user on the LightDM greeter screen, rather than each user’s individual avatar. I have experienced this problem in more than one Linux distribution (Gentoo, Sabayon and now Lubuntu 17.10), more than one Desktop Environment (KDE, GNOME and now LXDE), and more than one Display Manager (LightDM and SDDM), so my suspicion is that the problem lies with AccountsService rather than the DE or DM. Anyway, here is how I fixed the problem in Lubuntu 17.10. The example below is for user fitzcarraldo, and I used the same procedure for each username in the installation.

1. Create a 96×96 PNG avatar /home/fitzcarraldo/Pictures/fitzcarraldo.png

2. Edit the file /var/lib/AccountsService/users/fitzcarraldo to contain the following:

[User]
XSession=Lubuntu
SystemAccount=false
Icon=/var/lib/AccountsService/icons/fitzcarraldo	

3. Make sure that the file has 644 permissions:

$ ls -la /var/lib/AccountsService/users/fitzcarraldo
-rw-r--r-- 1 root root 85 Jan  1 02:53 /var/lib/AccountsService/users/fitzcarraldo

4. Copy the avatar to the relevant directory and make sure it has 644 permissions:

$ sudo cp /home/fitzcarraldo/Pictures/fitzcarraldo.png /var/lib/AccountsService/icons/fitzcarraldo
$ ls -la /var/lib/AccountsService/icons/fitzcarraldo
-rw-r--r-- 1 root root 14860 Jan  1 02:54 /var/lib/AccountsService/icons/fitzcarraldo

After rebooting, the desired avatar should be displayed on LightDM’s GTK Greeter screen.

Background reading

  1. KDE Bug Report No. 336994 – User Manager does not show one particular user in the list unless I login as that user
  2. Gentoo Forums – user-manager in plasma desktop not populating users
  3. Gentoo Forums – LightDM greeter username in list stuck and can’t add others
Advertisements

Prevent Lubuntu 17.10 from leaving an external HDD mounted incorrectly for other users

My family’s PC running Lubuntu 17.10 has an external USB HDD connected permanently. There are several user accounts on this machine, i.e. it is a single-seat, multi-user installation. If a user does not unmount this external HDD before logging out, it is still mounted with the privileges of the previous user when another user logs in. If the current user clicks on the media unmount symbol (⏏) in the PCManFM File Manager, LXDE prompts the user to enter the previous user’s password. So I wanted to configure the OS to unmount the external HDD when each user logs out or when another user selects ‘Switch User’. The way I did that was to use the LightDM display manager to unmount the external drive at the end of a session, as explained below. Then the Udisks daemon will mount the drive correctly for any user who either logs in or switches back to his/her session.

Lubuntu 17.10 as installed has an empty directory /etc/lightdm/lightdm.conf.d/ so I created two files in that directory:

$ ls -la /etc/lightdm/lightdm.conf.d/
total 16
drwxr-xr-x 2 root root 4096 Jan  1 06:18 .
drwxr-xr-x 4 root root 4096 Jan  1 05:11 ..
-rw-r--r-- 1 root root   89 Jan  1 06:18 10_lubuntu.conf
-rwxr-xr-x 1 root root   80 Jan  1 05:55 unmount_FREECOM_HDD.sh
$ cat /etc/lightdm/lightdm.conf.d/10_lubuntu.conf
[SeatDefaults]
session-cleanup-script=/etc/lightdm/lightdm.conf.d/unmount_FREECOM_HDD.sh
$ cat /etc/lightdm/lightdm.conf.d/unmount_FREECOM_HDD.sh 
#!/bin/bash
udisksctl unmount --block-device /dev/disk/by-uuid/C6576A087368B015

where ‘C6576A087368B015‘ is the UUID of the external USB HDD as found from the blkid command:

$ sudo blkid | grep "FREECOM HDD"
/dev/sdb1: LABEL="FREECOM HDD" UUID="C6576A087368B015" TYPE="ntfs" PARTUUID="0024db7f-32"

Don’t forget to make the Bash script executable. Then reboot to enable the functionality. From now on the external HDD will be correctly mounted for each user who logs in to his/her account.

Update (Monday, 9 July 2018): Since I wrote the above post I upgraded Lubuntu to 18.04 and I recently noticed the following problems resulting from the above-mentioned modifications:

A. The following error message in the LightDM log file /var/log/lightdm/lightdm.log:

[SeatDefaults] is now called [Seat:*], please update this configuration

So I changed the contents of the file /etc/lightdm/lightdm.conf.d/10_lubuntu.conf from:

[SeatDefaults]
session-cleanup-script=/etc/lightdm/lightdm.conf.d/unmount_FREECOM_HDD.sh

to:

[Seat:*]
session-cleanup-script=/etc/lightdm/lightdm.conf.d/unmount_FREECOM_HDD.sh

B. The following error message in the LightDM log file /var/log/lightdm/lightdm.log when the USB external HDD happened to not be mounted at the time:

DEBUG: Launching process 8569: /etc/lightdm/lightdm.conf.d/unmount_FREECOM_HDD.sh
DEBUG: Process 8569 terminated with signal 11

So I changed the contents of my Bash script /etc/lightdm/lightdm.conf.d/unmount_FREECOM_HDD.sh from:

#!/bin/bash
udisksctl unmount --block-device /dev/disk/by-uuid/C6576A087368B015

to:

#!/bin/bash
STATUS=`mount | grep $(readlink -f /dev/disk/by-uuid/C6576A087368B015 )`
if [[ ! -z $STATUS ]]; then
    udisksctl unmount --block-device /dev/disk/by-uuid/C6576A087368B015
fi
exit 0