Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am setting up openbox on my laptop running Linux Mint 13. I want my Caps Lock key to act as an additional control key. I put the required settings in my ~/.Xmodmap file and checked it by running

xmodmap ~/.Xmodmap

It works correctly.

However when I relogin to my openbox session, these key changes are not present. Running the above xmodmap command gets it working again, but I want it to happen automatically at startup.

What's interesting is that I added a test zenity command as following to my ~/.config/openbox/autostart file

zenity --info --text=Hello

This produces a small dialog window and exits only after the dialog is closed.

Now, when I relogin to my openbox session, the Caps Lock acts as a Ctrl key, until the zenity dialog is closed. Once that dialog is closed, the Caps Lock returns to its default behavior.

I haven't found anything on this with google so I'm asking for help here. Do you guys have any ideas on what might be going wrong?

Update:

I have been trying to figure this out and in my experiments, I copied my /usr/bin/xmodmap file to /usr/bin/xmodmap_ and replaced the /usr/bin/xmodmap file with the following bash script

#!/bin/bash

{
    echo '-------'
    date
    echo xmodmap "$@"
} >> ~/xmodmap-calls

exec /usr/bin/xmodmap_ "$@"

So, every time any damn script on the system runs xmodmap, I get to know it.

With this, I relogin and I only find one entry in my ~/xmodmap-calls file, which is the one running my ~/.Xmodmap, which is expected. So, I figured its not a xmodmap that is overwriting my changes.

Next, a bit of googling introduced me to the setxkbmap command, which apparently can also do the same thing. I replaced that executable also, similar to xmodmap above. And I got the culprit command!

setxkbmap -option terminate:ctrl_alt_bksp

I have absolutely no idea what that does, but after running xmodmap ~/.Xmodmap (which applied my settings correctly), if I run the above command, my changes are reset! Edit: This is turning out real funny. Just a setxkbmap command without any arguments, happily overwrites my changes by the xmodmap ~/.Xmodmap command.

Now I have two things to figure out, where is this setxkbmap being run from & why and how to fix this. I'm still investigation but could seriously use some help :)

Update 2

To hell with xmodmap. I can't figure out where the setxkbmap is being called from, but I figured a way to use setxkbmap command to make my Caps Lock behave as Ctrl.

setxkbmap -option ctrl:nocaps

Just before starting openbox. Works brilliant. The caps lock key stays acting as a ctrl key. xmodmap is never run.

I'll keep this question here open so someone who knows these things can provide some insight. Also, for people who face this after me :)

Update 3

Here's the contents of my .config/openbox/autostart, as requested by pedrosaurio.

#!/bin/bash

# Set the wallpaper.
feh --bg-scale /wall.png

# Set default brightness.
xbacklight -time 1 '=40'

# Compositing.
xcompmgr &

# The panel.
tint2 &

# Start a terminal too.
roxterm &

This doesn't have anything to do with the keyboard, as far as I can tell. Also, here's the script that starts my session: (Run by lightdm)

#!/bin/bash

setxkbmap -option ctrl:nocaps

exec openbox-session
share|improve this question
    
you are probably using some kind of keyboard configuration, e.g. choose the keyboard layout or something similar which reverts your applied changes –  Ulrich Dangel Jul 22 '12 at 1:46
    
The only other place I fiddled with keyboard configuration is the GUI keyboard layout preferences window, where I changed the caps lock key to behave as an additional ctrl. That works fine, in the cinnamon DE, my caps lock acts as a ctrl even after a relogin. I think that configuration was cinnamon-only, but I'm not sure. –  Shrikant Sharat Jul 22 '12 at 2:33
    
how are you adding the command in the autostart script? –  pedrosaurio Jul 23 '12 at 10:59
    
Can you post your autostart file? –  pedrosaurio Jul 23 '12 at 15:07
add comment

1 Answer

Without knowing your autostart script my bet is that you are not using the proper syntax by letting your commands run in the background using the ampersand (&).

Try editing your .config/openbox/autostart file so it looks like this:

# Run the system-wide support stuff
#. $GLOBALAUTOSTART
# Programs to launch at startup
# Programs that will run after Openbox has started
(sleep 1 && xmodmap ~/.Xmodmap ) &

If in doubt have a look in the openbox wiki and see how all the examples have & after each entry.

http://openbox.org/wiki/Help:Autostart

share|improve this answer
    
My autostart file is empty. At a point I did have xmodmap ~/.Xmodmap in that file (without an &, didn't seem necessary). I have been calling xmodmap (and now setxkbmap) in the script that start my openbox session. Just before running exec openbox-session, I run the setxkbmap command. –  Shrikant Sharat Jul 23 '12 at 14:32
    
Also, adding a sleep 1 delay so that xmodmap applies its changes after everything else loads is, while works most of the time, doesn't make me feel too confident about the solution. I'd prefer not to do it, if I have alternatives. –  Shrikant Sharat Jul 23 '12 at 14:34
    
You can avoid obviously all the comments and the sleep command, nevertheless the & is necessary after each entry, otherwise all the programs after the first entry will not run at all. –  pedrosaurio Jul 23 '12 at 15:01
    
Yes, if its a long running app/process, not adding a & will make it block. I used this behavior with the zenity command to find that my xmodmap changes are being overwritten after autostart finishes. My autostart is now growing in size and will paste it in the question in a moment. It doesn't have anything to do with the keyboard, though. –  Shrikant Sharat Jul 23 '12 at 16:45
    
And, without the sleep command, the changes made by xmodmap are overwritten as soon as the autostart file finishes. –  Shrikant Sharat Jul 23 '12 at 16:50
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.