You are not logged in.

#1 2008-09-17 17:19:18

jarda-wien
Member
Registered: 2008-03-13
Posts: 104

xfce4 keyboard layout switcher

I am having a strange issue with setting up xfce4 on my fathers' laptop. Every time I switch the keyboard layout, the x terminal emulator start acting weird:

[jarda-wien@primator ~]$  whoami
jarda-wien
[jarda-wien@primator ~]$  echo hello
bash: echo hello: command not found
[jarda-wien@primator ~]$  ping www.google.com
bash: ping www.google.com: command not found
[jarda-wien@primator ~]$  echo $PATH
bash: echo /bin:/usr/bin:/sbin:/usr/sbin:/opt/java/jre/bin:/usr/bin/perlbin/site:/usr/bin/perlbin/vendor:/usr/bin/perlbin/core:/opt/qt/bin: No such file or directory

Before switching the keyboard, everything works fine... As this doesn't happen on virtual terminal, it may be an xorg/xfce issue. What do you make of it?

Offline

#2 2008-09-25 14:58:45

jarda-wien
Member
Registered: 2008-03-13
Posts: 104

Re: xfce4 keyboard layout switcher

ok so I've made a workaround for that... The problem seems to be not only xfce4 related as the same behavior can be seen on yakuake running on xfce4 and every other terminal emulator I have tried, as well as on openbox and all the terminals. Anyway, here's the fix:
Remove any

Option     "XkbLayout"     "us,cz"
Option     "XkbOptions"    "grp:alt_shift_toggle"

and install xbindkeys from extra.
Next edit and save the following script somewhere:

#!/bin/bash
# Put your desired layouts, space separated, between the brackets
layout=(us de cz)
# Main code, do not change, unless you know what you're doing
current=$( setxkbmap -print | grep -o 'pc+[a-zA-Z0-9_-/]*' | sed 's/pc+//' )
num=${#layout[@]}
i=0
for use in ${layout[@]} ; do
     i=$[ i + 1 ]
     if [[ $current = $use ]] ; then
    if [[ $i -eq $num ]] ; then
         setxkbmap ${layout[0]}
         break
    else
         setxkbmap ${layout[$i]}
         break
    fi
     fi
done
exit $?

Make the script executable and try it! It should cycle through the specified layouts. The next step is to map the script to a keyboard shortcut in .xbindkeysrc (look up how in the wiki...)
Everything works now, even after switching the layout!!!

Offline

#3 2008-09-25 15:02:02

jarda-wien
Member
Registered: 2008-03-13
Posts: 104

Re: xfce4 keyboard layout switcher

btw before writing the workaround, I've noticed, that one-word commands work fine, but as soon as there is a space character involved on the command line, "command not found" starts to arise. I think that the space character is somehow misinterpreted after performing the switch.

Offline

Board footer

Powered by FluxBB