jbromley, thanks for the code, it works perfectly.
...
...
I uses two layouts under Window Maker: hungarian and usa. (Yes my favorite window manager is very old, but quick, and small).
I set my wm, when I push the ScrollLock button it is changes the actual layout another and vica versa (flip-flop).
I wrote an example file with doityourself adesklet http://adesklets.sourceforge.net/desklets.html which is check and show the actual Xorg keyboard layout, and can change it (predefinied values) if I click on.
Here is my xkeyboard.sh script:
#!/bin/bash
#
# This is a back-end script for doityourself. It displays the output
# of the setxkbmap layout, and changes from us to hungarian layout
# or from hungarian to us layout
case $1 in
init) echo "<font 'VeraMono/15'/>"
echo "<background.color None/>" ;;
test) keymap=$(setxkbmap -v | awk -F "+" '/symbols/ {print $2}')
echo ${keymap:0:2} ;;
click) if (setxkbmap -v | grep -q hu)
then exec setxkbmap us
else exec setxkbmap -layout "hu(qwerty)"
fi ;;
*) echo "Usage: $0 [ init | test | click ] test-value"
esac
This code should just copy your ~/.desklets/doityourself-0.4.1/scripts/ directory, and should to change a ~/.desklets/doityourself-0.4.1/scripts/ config.txt last lines:
id0 = {'rawmode': False, 'script': 'xkeyboard.sh'}
That's it!
]]>anrxc wrote:veox wrote:thanks for the code, weird there was no such utility already.
So certainly similar software existed, but still there was none that did exactly what I wanted.
Of course it existed, not only it existed as some obscure utility, but was also in the repos. That is all. I don't think your utility is a waste of time.
]]>Just to complete it, I have created a very simple bar applet for ruby-wmii that displays the current layout, and allows me to change it on a click of a mouse:
bar_applet("xkb", 900) do |wmii, bar|
require 'ruby-wmii/xkb'
xkb = Xkb::XKeyboard.new
Thread.new do
loop do
bar.data = xkb.current_group_symbol
sleep 1
end
end
bar.on_click do |name, button|
curr_group = xkb.current_group_num
curr_group += 1
xkb.set_group_by_num curr_group
bar.data = xkb.current_group_symbol
end
end
veox wrote:thanks for the code, weird there was no such utility already.
I looked at it and it was not satisfying. Here is why I wrote the code under discussion.
1. I use xmodmap to modify my keyboard layout. Switching with xxkb (or any other layout switcher, I've tried those from GNOME, KDE, and XFCE) nuked my custom key configuration. I could find no way to make these tools pay attention to my custom layout. This was a huge problem for me.
2. Most switchers are tray apps. At the time I was wrote this I was using wmii, which had (has?) no system tray. These tools also generally require that you use the mouse, something that I avoid.
3. I was writing a bunch of modules for wmii-ruby and I thought, why not?
So certainly similar software existed, but still there was none that did exactly what I wanted.
Regards.
]]>]]>thanks for the code, weird there was no such utility already.
I'd make it GPLv3 (or v2), but as a packager I have no authorito to put a license in. It must be distributed with the code; or, I guess, the authors must at least explicitly specify it on the site.
Alternatively, just say it's in the public domain.
This weekend I'll try to add some license information so you can package it up.
]]>Alternatively, just say it's in the public domain.
]]>I thought a bit and made it into a package: http://aur.archlinux.org/packages.php?ID=29137
There're some issues so far, though: no LICENSE defined, a few improvements needed to be made to the Makefiles (so far done during package build).
You can make the license whatever you'd like. If this code helps anyone then let's just get it out there.
]]>There're some issues so far, though: no LICENSE defined, a few improvements needed to be made to the Makefiles (so far done during package build).
]]>thanks jbromley,
your code really helped me.
...
I'm glad to hear someone has made use of it. I've just patched up the ruby wrappers, so the ruby extension should be working again.
Enjoy.
]]>I don't succeed in building the ruby extension, I get the following errors after using swig and extconf, when running make:
g++ -I. -I/usr/lib/ruby/1.8/i686-linux -I/usr/lib/ruby/1.8/i686-linux -I. -D_FILE_OFFSET_BITS=64 -fPIC -march=i686 -mtune=generic -O2 -pipe -fPIC -c XKeyboard_wrap.cxx XKeyboard_wrap.cxx: In function 'int _wrap_XKeyboard_group_names(void*, Tcl_Interp*, int, Tcl_Obj* const*)': XKeyboard_wrap.cxx:1926: erreur: lvalue required as left operand of assignment XKeyboard_wrap.cxx:1929: erreur: invalid conversion from 'Tcl_Obj*' to 'VALUE' XKeyboard_wrap.cxx:1929: erreur: initializing argument 1 of 'void rb_ary_store(VALUE, long int, VALUE)' XKeyboard_wrap.cxx: In function 'int _wrap_XKeyboard_group_symbols(void*, Tcl_Interp*, int, Tcl_Obj* const*)': XKeyboard_wrap.cxx:1953: erreur: lvalue required as left operand of assignment XKeyboard_wrap.cxx:1956: erreur: invalid conversion from 'Tcl_Obj*' to 'VALUE' XKeyboard_wrap.cxx:1956: erreur: initializing argument 1 of 'void rb_ary_store(VALUE, long int, VALUE)' make: *** [XKeyboard_wrap.o] Erreur 1
Hello there. I realize this is some months late, but just for posterity, I've looked at the problem and it turns out that for some reason the std::vector<std::string> to ruby array mapping in XKeyboard.i wasn't working any more. I fixed the problem and uploaded a new tarball. You can get it here.
Regards.
]]>