You are not logged in.
Hi guys,
I have a question here. Well at the moment I am using axkb for keyboard layout svitching as someone here in the forums has suggested, but I have recently found another way. There is a script called xkbSwitch. This way is better as it does not require many dependancies.
However it does not provide any indicator for the present keyboard layout. So, my question is - is there any software, that could create a user defined icon and changed it according to any bash script?
Thanks in advance.
Last edited by Liuuutas (2009-06-07 10:22:29)
Offline
You could use dzen2 to draw an icon (xpm) for the current layout. Dzen2 could be integrated in to the xkbswitch script without too much trouble.
Offline
Actually it is really easy:
#!/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]} | dzen2 -p -w 30 -fg 'green' &
fi
Offline
Thank you very much...
Offline
Hi guys,
I have a question here. Well at the moment I am using axkb for keyboard layout svitching as someone here in the forums has suggested, but I have recently found another way. There is a script called xkbSwitch. This way is better as it does not require many dependancies.
However it does not provide any indicator for the present keyboard layout. So, my question is - is there any software, that could create a user defined icon and changed it according to any bash script?
Thanks in advance.
Since you mention FVWM, you could do this with FvwmButtons.
-- Thomas Adam
Offline
Thank you for this thought... I even haven't considered it... I guess I was mislead due to the really ugly FvwmButtons looked in the default configuration...
Offline
I faced same problem in Fluxbox but even worse. I have us and ru keyboard layouts and trick wich was described hereabove doesnt work. Any letter keys doesnt work when russian layout is choosen.
I combined answers from Hardik's code, some stuff from Debian forums (dont remember link) and Ashren's dzen feature. Its useful for cyrillic layouts used with latin ones.
I put this in 'keys' file in ~/.fluxbox
Mod4 F5 :ExecCommand ~/.bin/kb_us
Mod4 F6 :ExecCommand ~/.bin/kb_ru
and made two executable files ( 'kb_ru' and 'kb_en') in ~/.bin direcrtory. Of course you can take any directory you want, but put the path in 'keys' file.
kb_ru contains:
#!/bin/bash
killall dzen2
setxkbmap -layout ru | echo ru | dzen2 -p -w 30 -x 1180 -y 768 -fg 'green' &
and kb_us:
#!/bin/bash
killall dzen2
setxkbmap -layout us | echo us | dzen2 -p -w 30 -x 1180 -y 768 -fg 'green' &
save it and restart Fluxbox. Enjoy!
P.S. My laptop screen is 1200x800 so set dzen's -x and -y for you desire.
Last edited by vennen (2009-06-14 13:11:43)
Offline
Why are you piping setxkbmap output to echo ?
Last edited by moljac024 (2009-06-14 13:57:16)
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...
Offline
I'm not programmer and know bash very bad. Maybe its not needed. But it works. It would be nice if you correct me.
Do I need delete pipe symbol '|' and put 'echo ....' on the next line?
Last edited by vennen (2009-06-14 16:47:25)
Offline
Well in Fvwm I also set up the ru layout. I just set a global shortcut key and fvwm understood it no matter the layout was .
Offline
I'm not programmer and know bash very bad. Maybe its not needed. But it works. It would be nice if you correct me.
Do I need delete pipe symbol '|' and put 'echo ....' on the next line?
It's no issue really, but since echo doesn't operate on input but only it's arguments, it's pointless to pipe stuff to it.
You can just replace the pipe symbol with "&&" <- that means execute the next command only if the last one terminated successfully.
Last edited by moljac024 (2009-06-15 11:13:52)
The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...
Offline
OK, thank you, moljac024
Offline
Thank you for this thought... I even haven't considered it... :) I guess I was mislead due to the really ugly FvwmButtons looked in the default configuration... :)
You clearly didn't understand what it was designed for. No surprise there -- no one reads the man page for things these days.
There's no reliable way of getting X11 to tell you what keyboard layout is in use [1] so come up with your own mechanism when you set it, perhaps:
#!/bin/bash
# Redefine/reload keyboard layout.
die()
{
echo "$@" >&2
exit
}
[ -z "$DISPLAY" ] && die "$0: Can't connect to X server"
# No validation is done here...
[ -n "$1" ] && echo "$1" > ~/.xkblayyout || die "$0: Failed to write to ~/.xkblayout"
setxkbmap -layout $(< ~/.xkblayout)
You can improve upon that -- it's just a crappy example. Obviously if you change the layout, or have a mechanism for doing so, then you will have to reload it in the same way -- by echoing the value to the nominated file overwriting the previous contents. For the benefit of this example, this file is: ~/bin/setkeyboard.sh
Anyway -- assume that's how it's going to happen. In terms of FVWM, here's an example FvwmButtons configuration:
DestroyFunc GetKBDLayout
AddToFunc GetKBDLayout
+ I PipeRead `echo SetEnv KBDLAYOUT $(cat ~/.xkblayout)`
DestroyFunc SetKBDLayout
AddToFunc SetKBDLayout
+ I PipeRead `~/bin/setkeyboard.sh $0`
+ I GetKBDLayout
+ I SendToModule FB ChangeButton A Icon $[KBDLAYOUT].png
DestroyModuleConfig FB:*
*FB: Columns 3
*FB: Rows 1
*FB: (1x3, Id A, Title "keyboard layout", Icon $[KBDLAYOUT].png, Action (Mouse 1) SetKBDLayout us, Action (Mouse 3) SetKBDLayout en)
AddToFunc StartFunction I Module FvwmButtons FB
You'd have to ensure that something set KBDLAYOUT at FVWM startup so it's not blank, as no icon would appear until you had pressed the button in FvwmButtons.
-- Thomas Adam
[1] No, really...
Offline
Thank you very much for such a detail answer, Thomas Adam.
About reading the man pages, I read it ocasionally, but succeeded to finish only a small fraction of them. But I must admit, that the documentation of FVWM is really well written...
Well my goal now is to embeed pager, stalonetray, conky and some more stuff to make a nice side bar. Off course I will do it with FvwmButtons, but need time to figure it out...:)
By the way, I noticed recently, that the fvwm.lair.be is not working... it is a nice place full of great examples...
Offline
By the way, I noticed recently, that the fvwm.lair.be is not working... :( it is a nice place full of great examples... :)
Yes, I know.
-- Thomas Adam
Offline