3

My old laptop's keyboard has a dead Space key.

I have found that with the commands:

xmodmap -e "keysym Alt_L = Space"
xmodmap -e "keysym Super_L = Alt_L"

I can do the job,as I have to map the space to it's nearest key, thus to Alt, and then to remap the Alt key.

My question is, how can I run it on every boot? Also, I created a .sh file with these two commands, to execute in my desktop but it does nothing.

Oli
  • 293,335

2 Answers2

2

You have to create .desktop file

[Desktop Entry]
Type=Application
Exec="</path/to/script>"
Hidden=true
NoDisplay=true
X-GNOME-Autostart-enabled=true
Name=Modify keyboard map

and place it to $HOME/.config/autostart

imraro
  • 172
  • Thanks for answering. I managed to do the job by putting the line

    Exec=xmodmap -e "keysym Alt_L = space" but if i place the second Exec like Exec=xmodmap -e "keysym Super_L = Alt_L" then in some way it cancels the first. Should I place it in another file or what?

    – Aggelos Mhsenoiazei Apr 28 '15 at 06:35
  • This line should work: Exec=sh -c "xmodmap -e 'keysym Alt_L = space' && xmodmap -e 'keysym Super_L = Alt_L'" , but I recommend you to use this commands in shell script and place this script in /usr/local/bin/ – imraro Apr 28 '15 at 08:22
2

With this solution, your new Space is Left Alt and your old Space is Left Super

  1. Search for the right keycodes with:

    xmodmap -pke | grep Alt_L
    

    Sample output

    keycode  64 = Alt_L Meta_L Alt_L Meta_L Alt_L Meta_L
    keycode 204 = NoSymbol Alt_L NoSymbol Alt_L NoSymbol Alt_L
    

    and

    xmodmap -pke | grep Super_L
    

    Sample output

    keycode 133 = Super_L NoSymbol Super_L NoSymbol Super_L
    keycode 206 = NoSymbol Super_L NoSymbol Super_L NoSymbol Super_L
    
  2. Open the file ~/.Xmodmap

    nano ~/.Xmodmap
    
  3. Place your mappings, eg.:

    keycode  64 = space
    keycode 133 = Alt_L
    

    in this file and test it with

     xmodmap ~/.Xmodmap
    
  4. Then open the file ~/.xinitrc

    nano ~/.xinitrc
    

    and add this lines

    if [ -s ~/.Xmodmap ]; then
        xmodmap ~/.Xmodmap
    fi
    

    If ~/.xinitrc does not work then use ~/.profile

  5. Log out and log in again.

A.B.
  • 90,397