#!/bin/bash # # by: Sebastian 'gonX' Jensen # # changes between two languages depending on what they're currently set to # works great with a hotkey in the X environment. # this code probably isn't production ready, but it works great on my desktop FIRSTLANG=us SECONDLANG=dk check(){ lookFor1="pc+" lookFor2="+inet(evdev)" CURRENTLANG=`setxkbmap -v | grep symbols | awk '{ print $2 }'` CURRENTLANG=`echo $CURRENTLANG | sed s/$lookFor1//` echo `echo $CURRENTLANG | sed s/$lookFor2//` } if [ `check` == "$FIRSTLANG" ]; then mylang=$SECONDLANG setxkbmap "$SECONDLANG" xset led 3 if [ `check` != "$SECONDLANG" ]; then sleep 1.5 setxkbmap "$SECONDLANG" fi elif [ `check` == "$SECONDLANG" ]; then mylang=$FIRSTLANG setxkbmap "$FIRSTLANG" xset -led 3 if [ `check` != "$FIRSTLANG" ]; then sleep 1.5 setxkbmap "$FIRSTLANG" fi fi if [ "$mylang" == "" ]; then setxkbmap us fi echo now on $mylang