Screenlock language issue on Ubuntu 18.04

I suffered from this issue for so long that I finally decided to do something about it.

In a nutshell, whenever I lock the screen while using a keyboard layout other than English, I am not able to unlock the screen when I type in the correct password.

This is due to my password being in English and this bug reported years ago. Essentially,the screensaver app seems to ignore the layout chosen on the login screen and uses the layout selected prior the screen being locked.

At first, the lazy fix was to switch to a different session and run:

$ killall gnome-screensaver

Then, switch back to the gnome session, switch the layout to English manually and run:

$ gnome-screensaver-command -l

It got pretty annoying pretty fast though, so finally I figured out a slightly better workaround by setting up a cron script to switch the language back to English when the screensaver is detected. Here it is:

# Allows to avoid situation when on screen lock language other than
# English is selected.
# Set up under user's cron like this:
# */5 * * * * env DISPLAY=:0 /bin/bash /storage/scripts/ > /home/your_user_name/log.txt 2>&1
# Prerequisite:
# Add the following line to you .profile:

source /home/your_user_name/.DBUS_SESSION_BUS_ADDRESS

if (/usr/bin/gnome-screensaver-command -q | /bin/grep "is active");
    /usr/bin/gdbus call --session --dest org.gnome.Shell \
        --object-path /org/gnome/Shell \
        --method org.gnome.Shell.Eval \

Of course the proper, once-and-for-all way of doing that would probably be figuring out and submitting a patch to the package but that’s above my current knowledge.

Leave a Reply

Your email address will not be published. Required fields are marked *