Ask Ubuntu Asked by Mister G on December 17, 2021
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?
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
Answered by Izack on December 17, 2021
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
Answered by Vladislav on December 17, 2021
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.
Answered by Eyal on December 17, 2021
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
Answered by user627771 on December 17, 2021
[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
Answered by ozma on December 17, 2021
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)
Answered by Fabby on December 17, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP