layout.sh (433B)
1 #!/bin/bash 2 3 # Read the XKBLAYOUT value from /etc/default/keyboard 4 xkblayout=$(setxkbmap -query | grep layout | awk -F " " '{print $2}') 5 #xkblayout=$(cat /etc/default/keyboard | grep XKBLAYOUT | awk -F"\"" '{print $2}') 6 7 # Check if XKBLAYOUT is "us" 8 if [ "$xkblayout" == "us" ]; then 9 setxkbmap es 10 # Check if XKBLAYOUT is "pt" 11 elif [ "$xkblayout" == "es" ]; then 12 setxkbmap us 13 else 14 echo "Keyboard layout is not 'us' or 'pt'." 15 fi