Skip to content

Instantly share code, notes, and snippets.

@ob-ivan
Last active September 10, 2017 18:44
Show Gist options
  • Save ob-ivan/958558086f6d1c534bc15129d510aed5 to your computer and use it in GitHub Desktop.
Save ob-ivan/958558086f6d1c534bc15129d510aed5 to your computer and use it in GitHub Desktop.
#!/bin/bash
# USAGE:
# - clone to ~/GitHub/screensaver-layout
# - edit ~/.config/lxsession/LXDE/autoload
# - add line: @~/GitHub/screensaver-layout/screensaver-layout.sh
# - save and exit
# - relogin to desktop environment
SYS_LAYOUTS=$(setxkbmap -query | grep 'layout' | awk '{ print $2 }')
trap "setxkbmap -layout $SYS_LAYOUTS; exit" SIGINT SIGQUIT SIGKILL
xscreensaver-command -watch | while read l
do
if [[ "$l" == *LOCK* ]]
then
setxkbmap -layout us
elif [[ "$l" == *UNBLANK* ]]
then
setxkbmap -layout $SYS_LAYOUTS
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment