# Xmodmap and setxkbmap

**URL:** <https://forums.suse.com/t/xmodmap-and-setxkbmap/27037>\
**Category:** SLED Hardware\
**Created:** [May 14, 2015, 7:18pm UTC](https://forums.suse.com/t/xmodmap-and-setxkbmap/27037 "2015-05-14T19:18:00Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![prussell](https://avatars.discourse-cdn.com/v4/letter/p/ac8455/32.png) [@prussell](https://forums.suse.com/u/prussell)\
**Post date:** [May 14, 2015, 7:18pm UTC](https://forums.suse.com/t/xmodmap-and-setxkbmap/27037/1 "2015-05-14T19:18:00Z")

</div>

Hi Forums!  
I mistakenly posted this on the OpenSUSE forums, so I’ll attempt to reproduce the thread flow here:

I have bought a new keyboard to help my RSI, it’s like an ergonomic keyboard and I need to swap Left arrow cursor with Delete to get normal usage.

Running xmodmap queries yields:

[CODE]:~\> xmodmap -pke | grep Del  
keycode 91 = KP\_Delete KP\_Decimal KP\_Delete KP\_Decimal  
keycode 119 = Delete NoSymbol Delete

~\> xmodmap -pke | grep Left  
keycode 23 = Tab ISO\_Left\_Tab Tab ISO\_Left\_Tab  
keycode 83 = KP\_Left KP\_4 KP\_Left KP\_4  
keycode 113 = Left NoSymbol Left  
[/CODE]

I found that by adding to a new file ~/.Xmodmap

`
keycode 113=Delete
keycode 119=Left`

The problem was fixed. However, it’s not persistent, so to try to sort this, I added to my ~/.bashrc

`
xmodmap /user/prussell/.Xmodmap`

This is a partial fix, because I have to open a terminal session to activate it! More to the point, I know now, xmodmap is deprecated. In short, can anyone tell me where and how to achieve the sample simple bindings for SUSE Enterprise desktop, using the more modern setxkbmap on X11?

My version of Linux is : SUSE Linux Enterprise Desktop, x86 & x86-64  
I use a UK keyboard layout, and this is the 104 key version.

Thanks!

---

<div class="post-metadata">

**Author:** ![mikewillis](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@mikewillis](https://forums.suse.com/u/mikewillis)\
**Post date:** [May 14, 2015, 8:48pm UTC](https://forums.suse.com/t/xmodmap-and-setxkbmap/27037/2 "2015-05-14T20:48:51Z")

</div>

> [@prussell;27878](#):
>
> My version of Linux is : SUSE Linux Enterprise Desktop, x86 & x86-64

Which version of SUSE Linux Enterprise Desktop? If you’re not sure

```auto
$ cat /etc/*release*
```

---

<div class="post-metadata">

**Author:** ![prussell](https://avatars.discourse-cdn.com/v4/letter/p/ac8455/32.png) [@prussell](https://forums.suse.com/u/prussell)\
**Post date:** [May 14, 2015, 10:18pm UTC](https://forums.suse.com/t/xmodmap-and-setxkbmap/27037/3 "2015-05-14T22:18:19Z")

</div>

Hi Mike

Thanks for your reply.

```auto
NAME="SLED"
VERSION="12"
VERSION_ID="12"
PRETTY_NAME="SUSE Linux Enterprise Desktop 12"
ID="sled"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sled:12"
SUSE Linux Enterprise Desktop 12 (x86_64)
VERSION = 12
PATCHLEVEL = 0
```

I hope that helps!

---

<div class="post-metadata">

**Author:** ![prussell](https://avatars.discourse-cdn.com/v4/letter/p/ac8455/32.png) [@prussell](https://forums.suse.com/u/prussell)\
**Post date:** [May 14, 2015, 11:19pm UTC](https://forums.suse.com/t/xmodmap-and-setxkbmap/27037/4 "2015-05-14T23:19:24Z")

</div>

Following this

[http://unix.stackexchange.com/questions/65507/use-setxkbmap-to-swap-the-left-shift-and-left-control](http://unix.stackexchange.com/questions/65507/use-setxkbmap-to-swap-the-left-shift-and-left-control)

Pablo;s entry. I tried this

`
Partial modifier_keys
xkb_symbols "swap_del_left" {
    replace key <DELE> { [Left] };
    replace key <LEFT> { [Delete] };
};`

Ran it from here:

```auto
setxkbmap -I/home/prussell/.xkb/keymap/mykbd $DISPLAY
```

No luck though!

---

<div class="post-metadata">

**Author:** ![mikewillis](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@mikewillis](https://forums.suse.com/u/mikewillis)\
**Post date:** [May 15, 2015, 12:30am UTC](https://forums.suse.com/t/xmodmap-and-setxkbmap/27037/5 "2015-05-15T00:30:42Z")

</div>

[QUOTE=prussell;27886]Following this

[http://unix.stackexchange.com/questions/65507/use-setxkbmap-to-swap-the-left-shift-and-left-control](http://unix.stackexchange.com/questions/65507/use-setxkbmap-to-swap-the-left-shift-and-left-control)

Pablo;s entry. I tried this

`
Partial modifier_keys
xkb_symbols "swap_del_left" {
    replace key <DELE> { [Left] };
    replace key <LEFT> { [Delete] };
};`

Ran it from here:

```auto
setxkbmap -I/home/prussell/.xkb/keymap/mykbd $DISPLAY
```

No luck though![/QUOTE]

That setxkbmap command for loading the map doesn’t appear in the page you link to. What’s in that page you link to works fine for me if I use xkbcomp to load the map.

`
mike@Unknown:~> cat ~/.xkb/keymap/mykbd
xkb_keymap {
	xkb_keycodes { include "evdev+aliases(qwerty)"	};
	xkb_types { include "complete"	};
	xkb_compat { include "complete"	};
	xkb_symbols { include "pc+gb+us:2+inet(evdev)+terminate(ctrl_alt_bksp)+terminate(ctrl_alt_bksp)+myswap(swap_del_left)"	};
	xkb_geometry { include "pc(pc105)"	};
mike@Unknown:~> cat ~/.xkb/symbols/myswap 
Partial modifier_keys
xkb_symbols "swap_del_left" {
    replace key <DELE> { [Left] };
    replace key <LEFT> { [Delete] };
};
mike@Unknown:~> xkbcomp -I${HOME}/.xkb ${HOME}/.xkb/keymap/mykbd $DISPLAY`

Can’t just figure out how to (effectively) run it automatically at login. Calling it from a .desktop file in ~/.config/autostart/ doesnÂt work, nor does putting the command in to a script preceded by ‘sleep 10’ then calling that from a .desktop file in ~/.config/autostart/

---

<div class="post-metadata">

**Author:** ![prussell](https://avatars.discourse-cdn.com/v4/letter/p/ac8455/32.png) [@prussell](https://forums.suse.com/u/prussell)\
**Post date:** [May 15, 2015, 1:31pm UTC](https://forums.suse.com/t/xmodmap-and-setxkbmap/27037/6 "2015-05-15T13:31:48Z")

</div>

Thanks, Mike!

I’ll try that a bit later today, and will let you know my results. Ref, firing this thing up at start-up: is there not some kind of start-up package in Suse?

Best, Paul

---

<div class="post-metadata">

**Author:** ![prussell](https://avatars.discourse-cdn.com/v4/letter/p/ac8455/32.png) [@prussell](https://forums.suse.com/u/prussell)\
**Post date:** [May 15, 2015, 2:02pm UTC](https://forums.suse.com/t/xmodmap-and-setxkbmap/27037/7 "2015-05-15T14:02:43Z")

</div>

[QUOTE=prussell;27897]Thanks, Mike!

I’ll try that a bit later today, and will let you know my results. Ref, firing this thing up at start-up: is there not some kind of start-up package in Suse?

Best, Paul[/QUOTE]

That works! Thanks! Now all that remains is how to make it fire on login!

---

<div class="post-metadata">

**Author:** ![mikewillis](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@mikewillis](https://forums.suse.com/u/mikewillis)\
**Post date:** [May 15, 2015, 3:21pm UTC](https://forums.suse.com/t/xmodmap-and-setxkbmap/27037/8 "2015-05-15T15:21:25Z")

</div>

> [@prussell;27897](#):
>
> Ref, firing this thing up at start-up: is there not some kind of start-up package in Suse?

Well GNOME has the facility to start applications at log in\* and what it does behind the scenes is put a copy of the relevant application’s .desktop file in ~/.config/autostart/ But like I said, calling the xkbcomp command from a .desktop file in there has no effect. It gets run, just doesn’t have an effect.

- On SLED 12 run gnome-tweak-tool\*\* and look in ‘Startup Applications’. Clicking the + sign gets you a list of applications you can add unhelpfully listed in no apparent order with no apparent way to search the list. There’s no way to manually specify something to run, like was provided in GNOME 2, you can only select from the list.

\*\* Run it from command line or pressing Alt-F2, or find ‘Tweak Tool’ in GNOME Control Centre. You won’t find it in the Applications menu or the Activities Overview search because SUSE have deliberately made it not show up there in SLED 12. You will find something called ‘GNOME Configuration Tool’ though, SUSE didn’t hide that even though it’s gconf-editor which is of almost zero use given that in GNOME 3 almost everything uses dconf. SUSE have also deliberately hidden dconf-editor in the same way as gnome-tweak-tool despite that being vastly more useful than gconf-editor.

---

<div class="post-metadata">

**Author:** ![malcolmlewis](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/malcolmlewis/32/11375_2.png) [@malcolmlewis](https://forums.suse.com/u/malcolmlewis)\
**Post date:** [May 15, 2015, 4:32pm UTC](https://forums.suse.com/t/xmodmap-and-setxkbmap/27037/9 "2015-05-15T16:32:08Z")

</div>

> [@](#):
>
> On Fri 15 May 2015 12:24:02 PM CDT, mikewillis wrote:
> 
> prussell;27897 Wrote:[color=blue]
> 
> > Ref, firing this thing up at start-up: is there not some kind of  
> > start-up package in Suse?  
> > [/color]
> 
> Well GNOME has the facility to start applications at log in\* and what it  
> does behind the scenes is put a copy of the relevant application’s  
> …desktop file in ~/.config/autostart/ But like I said, calling the  
> xkbcomp command from a .desktop file in there has no effect. It gets  
> run, just doesn’t have an effect.
> 
> - On SLED 12 run gnome-tweak-tool\*\* and look in ‘Startup Applications’.  
> Clicking the + sign gets you a list of applications you can add  
> unhelpfully listed in no apparent order with no apparent way to search  
> the list. There’s no way to manually specify something to run, like was  
> provided in GNOME 2, you can only select from the list.
> 
> \*\* Run it from command line or pressing Alt-F2, or find ‘Tweak Tool’ in  
> GNOME Control Centre. You won’t find it in the Applications menu or the  
> Activities Overview search because SUSE have deliberately made it not  
> show up there in SLED 12. You will find something called ‘GNOME  
> Configuration Tool’ though, SUSE didn’t hide that even though it’s  
> gconf-editor which is of almost zero use given that in GNOME 3 almost  
> everything uses dconf. SUSE have also deliberately hidden dconf-editor  
> in the same way as gnome-tweak-tool despite that being vastly more  
> useful than gconf-editor.

Hi  
Create a systemd service file and run it systemwide…

–  
Cheers Malcolm Â°Â¿Â° LFCS, SUSE Knowledge Partner (Linux Counter #276890)  
SUSE Linux Enterprise Desktop 12 GNOME 3.10.1 Kernel 3.12.39-47-default  
If you find this post helpful and are logged into the web interface,  
please show your appreciation and click on the star below… Thanks!

---

<div class="post-metadata">

**Author:** ![prussell](https://avatars.discourse-cdn.com/v4/letter/p/ac8455/32.png) [@prussell](https://forums.suse.com/u/prussell)\
**Post date:** [May 16, 2015, 8:08pm UTC](https://forums.suse.com/t/xmodmap-and-setxkbmap/27037/10 "2015-05-16T20:08:01Z")

</div>

Well, thanks for trying for me, Mike 🙂 I sure appreciate it!

I’ve bodged a temporary solution with a few desktop shortcuts which run xmodmaps. This is working, and I;ve other fish to fry right now.

Regards the way Linux seems to be going-- during scouting for a solution to my problem, I’m surprised that xmodmap is deprecated, as I found that easy to use. Though i’m sure there’s a reason for this, it;s replacement is difficult to fathom out.

I tried all manner of things, I put scripts inside my init.d folders, but couldn’t get this to work. Did I read somewhere that init.d after.local doesn’t work anymore?  
The point I’d make is this: I,m new to Linux, and am a Java programmer from a Windows background. The only Linux skills I have I gleaned years ago during my college days. Deprecating parts of the system and then hiding others makes life tough for newbs like me. I love the product though:=unlike Open Suse and about five other distros, it installed on my Nofen silent PC without hitch. Everything works, including the VGA, Bluetooth, wifi, twin monitors. I can tell you, it’s very different story from when I last tried to install Linux! Happy bunny, but wish Suse hadn’t hidden so much.

---

<div class="post-metadata">

**Author:** ![mikewillis](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@mikewillis](https://forums.suse.com/u/mikewillis)\
**Post date:** [May 16, 2015, 11:36pm UTC](https://forums.suse.com/t/xmodmap-and-setxkbmap/27037/11 "2015-05-16T23:36:56Z")

</div>

Depreciation is not unique to the Linux world.

Simply dropping scripts in to init.d isn’t going to achieve anything. You’d need to write them as services and enable them. In any case SLED 12 uses systemd for the init system to the way to get stuff running at boot is to create a unit file and put it in /etc/systemd/system/

Dropping the line

```auto
echo "i ran" > /dev/shm/$(basename $0)
```

in to /etc/init.d/after.local shows it does get called during boot. I don’t know exactly when in the boot process it get called. The comments in it are unhelpfully vague even in the context of sysvinit and I suspect whatever their meaning is supposed to be is no longer true with systemd. (I know for a fact that systemd makes the comments in boot.local about when it gets run false.)

It seems like it would be possible to get xkbcomp to work when run from the init system by calling a suitable script. The script would need more than just the xkbcomp command in it. E.g If I log in as root via ssh I can set the keyboard map with

```auto
$ XAUTHORITY=$(ps --no-headers $(pidof Xorg) | awk '{print $11}') xkbcomp -I/home/mike/.xkb /home/mike/.xkb/keymap/mykbd :0
```

You’d have to make craft the dependencies in the systemd unit file to ensure the script didn’t run until after X was up and running.

Amusing you only want the mod for your own user it’s easier to do it within the context of your own user though.

[CODE]

mike@Unknown:~\> cat .config/autostart/modkeybdmap.desktop  
[Desktop Entry]  
Name=My keyboard map mod  
Exec=/home/mike/bin/modkeyboardmap  
Type=Application  
mike@Unknown:~\> cat /home/mike/bin/modkeyboardmap  
#!/bin/bash  
sleep 10  
xkbcomp -I${HOME}/.xkb ${HOME}/.xkb/keymap/mykbd $DISPLAY  
mike@Unknown-:~\>[/CODE]  
You need to make modkeyboardmap executable

```auto
mike@Unknown-:~> chmod u+x~/bin/modkeyboardmap
```

I could have sworn I tried this the other day and it didn’t work. But it’s consistently working for me now.
