Skip to content

Instantly share code, notes, and snippets.

@lulu-berlin
Created March 27, 2017 03:53
Show Gist options
  • Save lulu-berlin/d78b746b435378580e8c1c22b6127755 to your computer and use it in GitHub Desktop.
Save lulu-berlin/d78b746b435378580e8c1c22b6127755 to your computer and use it in GitHub Desktop.
fix for gnome-screensaver lock not allowing to change keyboard layout
#!/usr/bin/env bash
# This bug is well documented and still not fixed for a long time:
# https://bugs.launchpad.net/gnome-screensaver/+bug/872701
# This script is inspired by two scripts that were submitted on askubuntu.com
# to fix this issue in Gnome and in Unity:
# http://askubuntu.com/a/803418/472924
# http://askubuntu.com/a/857652/472924
# It should be set to run in the background as a startup application.
KBLAYOUT=$(setxkbmap -query | grep layout | awk '{print $2}')
dbus-monitor --session "type=signal,interface=org.gnome.ScreenSaver" |
while read MSG; do
LOCK_STAT=$(echo $MSG | grep boolean | awk '{print $2}')
if [[ -n $LOCK_STAT ]]; then
if [[ "$LOCK_STAT" == "true" ]]; then
KBLAYOUT=$(setxkbmap -query | grep layout | awk '{print $2}')
setxkbmap us
else
setxkbmap $KBLAYOUT
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment