At least on ubuntu 14.04 with gnome the following worked for me:

   1. Created folder: mkdir ~/.startup
   2. And a file touch ~/.startup/xscreensaver-reset-kbd-us.pl
   3. Chmodded it chmod 755 ~/.startup/xscreensaver-reset-kbd-us.pl
   4.

   Edit (copy&paste the code below) gedit ~/.startup/
   xscreensaver-reset-kbd-us.pl

   #!/usr/bin/perl

   my $blanked = 0;
   open (IN, "xscreensaver-command -watch |");
   while (<IN>) {
       if (m/^(BLANK|LOCK)/) {
           if (!$blanked) {
              system "setxkbmap -layout us";
              $blanked = 1;
           }
       } elsif (m/^UNBLANK/) {
           system "setxkbmap -layout us,ru";
           $blanked = 0;
       }
   }

   5.

   Added the script to startup applications

It watches the events from xscreensaver and resets keyboard layout to
english only on lock, and adds the ru layout back upon unblank.

For an unknown reason I can't change the keyboard layout when xscreensaver
prompts for password. This helps.

Reply via email to