9

I'm Xubuntu 14.04.2 user. I have two keyboard layouts: Russian and English. Sometimes when I close my laptop and then go back and try to continue to work, Xubuntu wants me to enter my user password (my password consist of English letters and numbers).

However, often my keyboard layout was set to Russian and switching keyboards doesn't work.

I need restart my laptop to fix it.

How should I proceed?

2
  • Which is your default keyboard? Russian? If yes, use Cyrillic characters for your password...
    – Fabby
    Mar 24, 2015 at 19:03
  • Thanks for a comment, but keyboard layout don't always is Russian...
    – Mister G
    Mar 27, 2015 at 10:44

6 Answers 6

5

I have the exact same problem as you and I get around by doing this:

  • get rid of gnome-screensaver by:

    sudo apt-get purge gnome-screensaver
    
  • Install the X screensaver by:

    sudo apt-get install xscreensaver xscreensaver-data xscreensaver-gl
    

Whenever you forgot to switch back to English before the system locks itself, hit Ctrl+Alt+F1 log in as your admin user and kill -9 xscreensaver and you're back in!

(It's just a workaround and not a real "solution" but it works for me and is definitely better then shutting down and restarting)

3
  • this solution somehow messed my graphics-card configuration. reversing to prev state solved it.
    – ozma
    Jul 26, 2016 at 10:54
  • @ozma sorry to hear that. Above is in no way related to graphics card subsystem so shouldn't have had any effect. Good to hear you solved it though... ;)
    – Fabby
    Aug 15, 2016 at 23:43
  • 1
    Thanks @Fabby. I believe it is more a greeter issue rather than graphics (lightdm, sddm etc.). Anyway, I've upgraded to 16.04 and this greater issue has gone.
    – ozma
    Aug 16, 2016 at 6:38
2

I'm running Ubuntu 21.04 and the "dbus-monitor" solution didn't work for me, So I'm sharing the way I approached it.
using xscreensaver-command we can monitor status changes of the screensaver.
Then when the status change to LOCK, we can change the layout to us and change it back once the screensaver "release" the desktop

Once I had the script, I set it to run during login.

xscreensaver-command --watch | 
  while read MSG; do
    CMD=`echo $MSG | awk '{print $1}'`
    if [[ "$CMD" == "LOCK" ]]; then
        ##### CURRENTL=$(setxkbmap -query | grep layout | awk '{print $2}')
        echo "Locked with current layout ${CURRENTL}"
        setxkbmap us
    fi

    if [[ "$CMD" == "UNBLANK" ]]; then
        ##### setxkbmap $CURRENTL
        setxkbmap us,il,us
        echo -n "Returning to "
        setxkbmap -query | grep layout | awk '{ print $2 }'
    fi
    # echo $CMD
  done
1
  • it works like a charm! I changed the line setxkbmap us,il,us to setxkbmap us since I don't mind changing the keyboard layout to another language after logging in from the lock screen. It hardly takes a moment.
    – vrgovinda
    Jan 24 at 14:11
1

[Edit] This might be a workaround but right now its messing with other layout switching keybindings

[Original] This one worked for me BUT I couldn't run it on startup and keep it running in background.

Listen to lock signal and change layout to the one of your password. (ugly workaround but seem to work)

dbus-monitor --session "type=signal,interface=org.gnome.ScreenSaver" | 
  while read MSG; do
    LOCK_STAT=`echo $MSG | grep boolean | awk '{print $2}'`
    if [[ "$LOCK_STAT" == "true" ]]; then
        setxkbmap us
    else
        setxkbmap -option grp:switch,grp:alt_shift_toggle,grp_led:scroll us,il
    fi
  done
1

Ubuntu 16.04 use another interface name:

dbus-monitor --session "type=signal,interface=com.canonical.Unity.Session" | 
  while read MSG; do
    LOCK_STAT=`echo $MSG | egrep -o member='.*' | cut -d '=' -f 2`
    if [[ "$LOCK_STAT" == "Locked" ]]; then
        CURRENTL=$(setxkbmap -query | grep layout | awk '{print $2}')
        echo "Locked with current layout ${CURRENTL}"
        setxkbmap us
    fi
    if [[ "$LOCK_STAT" == "Unlocked" ]]; then
        setxkbmap $CURRENTL
        echo -n "Returning to"
        setxkbmap -query | grep layout
    fi
  done
0

xscreensaver is great but the maintainer, JWZ, has made clear that he has no intention of supporting multiple keyboards.

xsecurelock is a better solution. It supports switch keyboard layouts from within the screen saver and will also give you a bold red notice if caps lock is on. It doesn't have a built-in timer like xscreensaver does so you'll need to follow the instructions on their webpage to get it to run automatically after a timeout.

2
  • how to make xsecurelock as the default locker?
    – vrgovinda
    Jan 23 at 16:12
  • how can I switch keyboard layouts in xsecurelock?
    – vrgovinda
    Jan 23 at 16:56
0

I just improved the previous examples for Ubuntu 20.04

dbus-monitor --session "type=signal,interface=org.gnome.ScreenSaver" | 
  while read MSG; do
    LOCK_STAT=`echo $MSG | grep boolean | awk '{print $2}'`
    if [[ "$LOCK_STAT" == "true" ]]; then
        CURRENTL=$(setxkbmap -query | grep layout | awk '{print $2}')
        echo "Locked with current layout ${CURRENTL}"
        setxkbmap us
    fi

    if [[ "$LOCK_STAT" == "false" ]]; then
        setxkbmap $CURRENTL
        echo -n "Returning to "
        setxkbmap -query | grep layout | awk '{ print $2 }'
    fi
  done

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .