Non XFCE-related stuff
It won't be exactly an answer to your problem, sorry for that, but still should be useful for someone at least. In Gnome it was fixed in recent Ubuntus. By it I mean treating Win not as a modifier key. In the old days, e.g. in Ubuntu 9.04, you had to do following change:
Go to System -> Preferences -> Keyboard
, under Layouts
tab click Layout options...
button and in Alt/Win key behavior
list choose Meta is mapped to Win keys
(or Meta is mapped to Left Win
) instead of Default
.
What it really does? Changes altwin
option in $HOME/.gconf/desktop/gnome/peripherals/keyboard/kbd/%gconf.xml
file (or creates it if it does not exist):
<?xml version="1.0"?>
<gconf>
<entry name="options" mtime="1298496603" type="list" ltype="string">
<li type="string">
<stringvalue>altwin altwin:meta_win</stringvalue>
</li>
</entry>
</gconf>
If you've chosen Left Win
, then there will be following string value:
altwin altwin:left_meta_win
In Ubuntu 10.10 it's not needed as Default
apparently has changed.
But you have XFCE, not Gnome, so this rather won't help you.
XFCE-related stuff
I've downloaded Xubuntu (9.10), played with it a bit and finally found a solution.
Firstly, though, I must say that keyboard settings are really screwed in XFCE. In Settings -> Keyboard
under Layout
tab you don't have too many options. You cannot change XkbOptions
there and even if you do it manually in ~/.config/xfce4/xfconf/xfce-perchannel-xml/keyboard-layout.xml
, it will be overwritten. So I've changed /etc/default/console-setup
by adding altwin:meta_win
to XKBOPTIONS
(use comma as separator if there are some other option(s) already). Still, no luck.
tl;dr
What's the solution?
Do not care about XFCE way of handling keyboard, because it's apparently broken. Use setxkbmap
directly:
setxkbmap -option altwin:meta_win
(or left_meta_win
, whatever you prefer)
Now you have to check that it really solved your problem. :)
How to apply it permanently?
echo -option altwin:meta_win >>~/.Xkbmap
It can be also done for all users by writing to /etc/X11/Xkbmap
instead.
How can I quickly check if altwin:meta_win
or altwin:left_meta_win
has been applied?
setxkbmap -print
Line with xkb_symbols
should have something like altwin(meta_win)
.
Well to change the led indicator on VT console you can use setleds
. So if you're in a VT you can just type
setleds
and you'll get your current led status.
If you don't want to enable numlock, just light it up you can type:
setleds -L +num
It comes trickier in X and this is the "simplest" way to try it. Please note that X is usually ran as root so you'll either have to check permissions on X-windows tty or run it with root privileges. Usually X is tty7. /dev/console
should work being the system console and by that all VTs should be affected.
sudo su -c 'setleds -L +num < /dev/tty7'
I think this will also work:
sudo su -c 'setleds -L +num < /dev/console'
here's list of light options
[{+|-}num] [{+|-}caps] [{+|-}scroll]
If you don't have setleds
in you system, my guess is that you can get it from this emerge package sys-apps/kbd
.
If you are more of person who likes to code stuff here's a link to en example code to change leds in X. I did not test this, but just by looking the code looked ok.
And here's a shell script to do what you originally wanted. To have caps or other leds as HDD indicators.
#!/bin/bash
# Check interval seconds
CHECKINTERVAL=0.1
# console
CONSOLE=/dev/console
#indicator to use [caps, num, scroll]
INDICATOR=caps
getVmstat() {
cat /proc/vmstat|egrep "pgpgin|pgpgout"
}
#turn led on
function led_on()
{
setleds -L +${INDICATOR} < ${CONSOLE}
}
#turn led off
function led_off()
{
setleds -L -${INDICATOR} < ${CONSOLE}
}
# initialise variables
NEW=$(getVmstat)
OLD=$(getVmstat)
##
while [ 1 ] ; do
sleep $CHECKINTERVAL # slowdown a bit
# get status
NEW=$(getVmstat)
#compare state
if [ "$NEW" = "$OLD" ]; then
led_off ## no change, led off
else
led_on ## change, led on
fi
OLD=$NEW
done
Best Answer
Any of the following (in increasing order of complexity):
Use
setxkbmap
to remap the key (does not require a daemon and is independent of your desktop environment or window manager). Don't forget to add the command before theexec gnome-session
(or similar) line in your~/.xinitrc
or~/.xsession
:setxkbmap
can be found in package extra/xorg-setxkbmap.dconf-editor
→org.gnome.desktop.input-sources.xkb-options
→ Addcaps:escape
to the aforementioned field.gnome-session-settings
→ Startup Programs → Add → Name=Remap caps lock to escape, command=setxkbmap -option caps:escape
Create a custom keyboard layout
FYI, I obtained the XKB rule by grepping
/usr/share/X11/xkb/rules
forcaps
andesc
.