sidux.com
Menu

News

Give back
Last 3 Contributions
30-11-2008 20.00
25-11-2008 100.00
25-11-2008 20.00

Donate


Sponsor
hetzner.de

Languages
Preferred language:



Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Author Message
rangalo
Post subject: Small script to cycle through different Keyboard layouts  PostPosted: Apr 25, 2008 - 04:41 PM



Joined: May 27, 2007
Posts: 85
Location: Germany
Status: Offline
Hi,

When I started using fluxbox, I missed this functionality in kde to be able to cycle through all the available keyboard layouts with ctrl+alt+k.

I have to generally switch between us and de (German) keyboard layouts because I can blind-type in us layout but sometimes also need the German layout.

I hope somebody will find this useful.

[EDIT]
For this you will need to create a dir ~/xkbSwitch and a file ~/.xkbSwitch/xkb_layouts which contains your keyboard layouts separated by a newline.

e.g.

Code:

us
de


Code:
#!/bin/bash

#############
# @author: Hardik
# @purpose: Cycle through the keyboard layouts sotored in
# ~/.xkbSwitch/xkb_layouts file
# This script is called on Ctrl + Alt + k key-combination in fluxbox
################

LAYOUTS_FILE=~/.xkbSwitch/xkb_layouts
INDEX_FILE=~/.xkbSwitch/index

if [ ! -r $LAYOUTS_FILE ]; then
    echo "File $LAYOUTS_FILE does not exist"
    exit 1
fi

# if the script is running the frist time
if [ ! -r $INDEX_FILE ]; then
    echo '0' > $INDEX_FILE
fi

read line < $INDEX_FILE

let "INDEX=$line+1"
INNER_INDEX=0

while read line
do
    LAYOUTS[$INNER_INDEX]=$line
    let "INNER_INDEX +=1"
done <$LAYOUTS_FILE

if [ $INDEX -ge $INNER_INDEX ]; then
    let "INDEX -=$INNER_INDEX"
fi

setxkbmap -layout ${LAYOUTS[$INDEX]}

if [ $? = "0" ]; then
    echo $INDEX >$INDEX_FILE
    echo ${LAYOUTS[$INDEX]}
fi


Please let me know about possible bugs and I will also appreciate any suggestion to improve it.


regards,
Hardik
 
 View user's profile Send private message  
Reply with quote Back to top
Display posts from previous:     
Jump to:  
All times are GMT
Post new topic   Reply to topic
View previous topic Printable version Log in to check your private messages View next topic
Powered by PNphpBB2 © 2003-2007 The PNphpBB Group
Credits
 
Logos and trademarks are the property of their respective owners, comments are property of their posters, the rest is © 2006-2008 by sidux e.V., 10407 Berlin, Kniprodestr. 104. sidux e.V. is a Berlin, Germany based non-profit foundation. Consult Impressum and Legal Terms for details. sidux™ is Free Software released under the GNU/GPL license and other compatible licenses.
powered by Zikula & Zafenio