Discussion:
can not exec xmodmap at startup
(too old to reply)
Jameson Graef Rollins
2016-08-15 00:26:36 UTC
Permalink
Hey, folks. I realize this may be slightly off topic but I've been
trying for years to get this working and I'm at a loss, hoping maybe
others have run into the same problem:

I can not for the life of me figure out how to get xmodmap to execute at
login. I have tried putting it in my ~/.xsession:

servo:~ 0$ cat ~/.xsession
...
xmodmap ~/.xmodmap
...
exec i3
servo:~ 0$

I have tried adding it to i3/config:

servo:~ 0$ cat .config/i3/config
...
exec xmodmap ~/.xmodmap
...

I have even tried making a system Xsession script:

servo:~ 0$ cat /etc/X11/Xsession.d/80custom_load-xmodmap
USRMODMAP="$HOME/.xmodmap"
if [ -x /usr/bin/xmodmap ]; then
if [ -f "$USRMODMAP" ]; then
xmodmap "$USRMODMAP"
fi
fi
servo:~ 0$

None of it works. My keymap file is never executed at login. I always
have to execute it manually as the first thing I do when I get an i3
terminal window, at which point it runs fine and sets my keybindings
correctly.

Has anyone run into this problem before? I find references to this kind
of thing on stackexchange but the answers are always just "put it in
your .xession (or .xinitrc)", which is of course what's not working.
Presumably there's some error when it runs before the window manager is
running? But I have no idea where to find the errors messages. Nothing
is in my .xsession-errors.

Any help would be most appreciated.

jamie.
Tony Crisci
2016-08-15 03:38:32 UTC
Permalink
Hi,

I'll give you some debugging tips. First of all, make sure it is
actually being executed. Try replacing the call with `xmodmap ~/.xmodmap
&> ~/xmodmap.log` and view the contents of the file to see if you have
errors.

If it's not being executed, you will not see the file in your home
directory. If it is and there are errors, post what the errors are.

Here are some environment variables that can be used in place of the
call to xmodmap for common things you might find useful.

http://xkbcommon.org/doc/current/structxkb__rule__names.html

Also note that only `startx` will source `.xinitrc`. For lightdm, use
`.xsessionrc`. For other display managers, you need to figure out what
file they are sourcing. There are unfortunately not standards people
follow for an xsession file between all display managers.
Post by Jameson Graef Rollins
Hey, folks. I realize this may be slightly off topic but I've been
trying for years to get this working and I'm at a loss, hoping maybe
I can not for the life of me figure out how to get xmodmap to execute at
servo:~ 0$ cat ~/.xsession
...
xmodmap ~/.xmodmap
...
exec i3
servo:~ 0$
servo:~ 0$ cat .config/i3/config
...
exec xmodmap ~/.xmodmap
...
servo:~ 0$ cat /etc/X11/Xsession.d/80custom_load-xmodmap
USRMODMAP="$HOME/.xmodmap"
if [ -x /usr/bin/xmodmap ]; then
if [ -f "$USRMODMAP" ]; then
xmodmap "$USRMODMAP"
fi
fi
servo:~ 0$
None of it works. My keymap file is never executed at login. I always
have to execute it manually as the first thing I do when I get an i3
terminal window, at which point it runs fine and sets my keybindings
correctly.
Has anyone run into this problem before? I find references to this kind
of thing on stackexchange but the answers are always just "put it in
your .xession (or .xinitrc)", which is of course what's not working.
Presumably there's some error when it runs before the window manager is
running? But I have no idea where to find the errors messages. Nothing
is in my .xsession-errors.
Any help would be most appreciated.
jamie.
Michael Stapelberg
2016-08-15 06:51:37 UTC
Permalink
Also, try executing the file twice. I’ve seen xmodmap files which needed to
be executed twice (because they relied on state they change — the details
escape me).
Hi,
I'll give you some debugging tips. First of all, make sure it is actually
being executed. Try replacing the call with `xmodmap ~/.xmodmap &>
~/xmodmap.log` and view the contents of the file to see if you have errors.
If it's not being executed, you will not see the file in your home
directory. If it is and there are errors, post what the errors are.
Here are some environment variables that can be used in place of the call
to xmodmap for common things you might find useful.
http://xkbcommon.org/doc/current/structxkb__rule__names.html
Also note that only `startx` will source `.xinitrc`. For lightdm, use
`.xsessionrc`. For other display managers, you need to figure out what file
they are sourcing. There are unfortunately not standards people follow for
an xsession file between all display managers.
Post by Jameson Graef Rollins
Hey, folks. I realize this may be slightly off topic but I've been
trying for years to get this working and I'm at a loss, hoping maybe
I can not for the life of me figure out how to get xmodmap to execute at
servo:~ 0$ cat ~/.xsession
...
xmodmap ~/.xmodmap
...
exec i3
servo:~ 0$
servo:~ 0$ cat .config/i3/config
...
exec xmodmap ~/.xmodmap
...
servo:~ 0$ cat /etc/X11/Xsession.d/80custom_load-xmodmap
USRMODMAP="$HOME/.xmodmap"
if [ -x /usr/bin/xmodmap ]; then
if [ -f "$USRMODMAP" ]; then
xmodmap "$USRMODMAP"
fi
fi
servo:~ 0$
None of it works. My keymap file is never executed at login. I always
have to execute it manually as the first thing I do when I get an i3
terminal window, at which point it runs fine and sets my keybindings
correctly.
Has anyone run into this problem before? I find references to this kind
of thing on stackexchange but the answers are always just "put it in
your .xession (or .xinitrc)", which is of course what's not working.
Presumably there's some error when it runs before the window manager is
running? But I have no idea where to find the errors messages. Nothing
is in my .xsession-errors.
Any help would be most appreciated.
jamie.
--
Best regards,
Michael
Jameson Graef Rollins
2016-08-18 01:36:54 UTC
Permalink
Post by Tony Crisci
I'll give you some debugging tips. First of all, make sure it is
actually being executed. Try replacing the call with `xmodmap ~/.xmodmap
&> ~/xmodmap.log` and view the contents of the file to see if you have
errors.
Hi, Tony. Thanks for the debug tip. This was a good idea that hadn't
occurred to me, since I actually thought any errors would show up in my
.xsession-errors file, but which apparently they do not...

I tried both your and Michael's suggestions together:

servo:~ 0$ grep xmodmap .xsession
xmodmap "$HOME"/.xmodmap &>.xmodmap.log
xmodmap "$HOME"/.xmodmap &>>.xmodmap.log
xmodmap "$HOME"/.xmodmap &>>.xmodmap.log
servo:~ 0$

and got the following:

servo:~ 0$ cat .xmodmap.log
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 118 (X_SetModifierMapping)
Value in failed request: 0x17
Serial number of failed request: 16
Current serial number in output stream: 16
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 118 (X_SetModifierMapping)
Value in failed request: 0x17
Serial number of failed request: 16
Current serial number in output stream: 16
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 118 (X_SetModifierMapping)
Value in failed request: 0x17
Serial number of failed request: 16
Current serial number in output stream: 16
servo:~ 0$

I'm not sure what to make of this. One might assume I'm doing something
invalid in my .xmodmap, but given that it works fine at the command line
after login, could that be true?

Does i3 somehow modify the keymap itself, such that certain xmodmap
commands become valid only after login?
Post by Tony Crisci
Here are some environment variables that can be used in place of the
call to xmodmap for common things you might find useful.
http://xkbcommon.org/doc/current/structxkb__rule__names.html
This is very interesting. I guess I would just use this if I could get
the two things I'm looking for:

* CAPS_LOCK -> CTRL
* CTRL -> MOD4

I use MOD4 as my i3 WM command key.

Do you know if it's possible to do the later (CTRL->MOD4) with the xkb
infrastructure?
Post by Tony Crisci
Also note that only `startx` will source `.xinitrc`. For lightdm, use
`.xsessionrc`. For other display managers, you need to figure out what
file they are sourcing. There are unfortunately not standards people
follow for an xsession file between all display managers.
I actually don't use a display manager and just "exec startx" from a
console. So I don't use an .xinitrc. That part has been working fine,
although I acknowledge that it could be part of the problem I'm seeing.

jamie.
Michael Stapelberg
2016-08-18 06:23:10 UTC
Permalink
On Thu, Aug 18, 2016 at 3:36 AM, Jameson Graef Rollins <
Post by Jameson Graef Rollins
Post by Tony Crisci
I'll give you some debugging tips. First of all, make sure it is
actually being executed. Try replacing the call with `xmodmap ~/.xmodmap
&> ~/xmodmap.log` and view the contents of the file to see if you have
errors.
Hi, Tony. Thanks for the debug tip. This was a good idea that hadn't
occurred to me, since I actually thought any errors would show up in my
.xsession-errors file, but which apparently they do not...
servo:~ 0$ grep xmodmap .xsession
xmodmap "$HOME"/.xmodmap &>.xmodmap.log
xmodmap "$HOME"/.xmodmap &>>.xmodmap.log
xmodmap "$HOME"/.xmodmap &>>.xmodmap.log
servo:~ 0$
servo:~ 0$ cat .xmodmap.log
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 118 (X_SetModifierMapping)
Value in failed request: 0x17
Serial number of failed request: 16
Current serial number in output stream: 16
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 118 (X_SetModifierMapping)
Value in failed request: 0x17
Serial number of failed request: 16
Current serial number in output stream: 16
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 118 (X_SetModifierMapping)
Value in failed request: 0x17
Serial number of failed request: 16
Current serial number in output stream: 16
servo:~ 0$
I'm not sure what to make of this. One might assume I'm doing something
invalid in my .xmodmap, but given that it works fine at the command line
after login, could that be true?
Does i3 somehow modify the keymap itself, such that certain xmodmap
commands become valid only after login?
No, i3 does not modify any X settings (neither XKB nor RandR).
Post by Jameson Graef Rollins
Post by Tony Crisci
Here are some environment variables that can be used in place of the
call to xmodmap for common things you might find useful.
http://xkbcommon.org/doc/current/structxkb__rule__names.html
This is very interesting. I guess I would just use this if I could get
* CAPS_LOCK -> CTRL
* CTRL -> MOD4
I use MOD4 as my i3 WM command key.
Do you know if it's possible to do the later (CTRL->MOD4) with the xkb
infrastructure?
Post by Tony Crisci
Also note that only `startx` will source `.xinitrc`. For lightdm, use
`.xsessionrc`. For other display managers, you need to figure out what
file they are sourcing. There are unfortunately not standards people
follow for an xsession file between all display managers.
I actually don't use a display manager and just "exec startx" from a
console. So I don't use an .xinitrc. That part has been working fine,
although I acknowledge that it could be part of the problem I'm seeing.
jamie.
--
Best regards,
Michael
Layus
2016-08-18 06:35:32 UTC
Permalink
There is a big difference between .xsession and your terminal within i3.
They use a completely different environment.

within your terminal in i3, your shel sourced your .profile & such, but
within .xsession, no such variables exist.
Could it be that xmodmap requires some environment variables (like
locales) to accept your config ?

Also, http://askubuntu.com/a/211461 has nice information about xmodmap,
as well as fixes you could try.

Regards,

-- Layus.
Post by Jameson Graef Rollins
Post by Tony Crisci
I'll give you some debugging tips. First of all, make sure it is
actually being executed. Try replacing the call with `xmodmap ~/.xmodmap
&> ~/xmodmap.log` and view the contents of the file to see if you have
errors.
Hi, Tony. Thanks for the debug tip. This was a good idea that hadn't
occurred to me, since I actually thought any errors would show up in my
.xsession-errors file, but which apparently they do not...
servo:~ 0$ grep xmodmap .xsession
xmodmap "$HOME"/.xmodmap &>.xmodmap.log
xmodmap "$HOME"/.xmodmap &>>.xmodmap.log
xmodmap "$HOME"/.xmodmap &>>.xmodmap.log
servo:~ 0$
servo:~ 0$ cat .xmodmap.log
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 118 (X_SetModifierMapping)
Value in failed request: 0x17
Serial number of failed request: 16
Current serial number in output stream: 16
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 118 (X_SetModifierMapping)
Value in failed request: 0x17
Serial number of failed request: 16
Current serial number in output stream: 16
X Error of failed request: BadValue (integer parameter out of range for operation)
Major opcode of failed request: 118 (X_SetModifierMapping)
Value in failed request: 0x17
Serial number of failed request: 16
Current serial number in output stream: 16
servo:~ 0$
I'm not sure what to make of this. One might assume I'm doing something
invalid in my .xmodmap, but given that it works fine at the command line
after login, could that be true?
Does i3 somehow modify the keymap itself, such that certain xmodmap
commands become valid only after login?
Post by Tony Crisci
Here are some environment variables that can be used in place of the
call to xmodmap for common things you might find useful.
http://xkbcommon.org/doc/current/structxkb__rule__names.html
This is very interesting. I guess I would just use this if I could get
* CAPS_LOCK -> CTRL
* CTRL -> MOD4
I use MOD4 as my i3 WM command key.
Do you know if it's possible to do the later (CTRL->MOD4) with the xkb
infrastructure?
Post by Tony Crisci
Also note that only `startx` will source `.xinitrc`. For lightdm, use
`.xsessionrc`. For other display managers, you need to figure out what
file they are sourcing. There are unfortunately not standards people
follow for an xsession file between all display managers.
I actually don't use a display manager and just "exec startx" from a
console. So I don't use an .xinitrc. That part has been working fine,
although I acknowledge that it could be part of the problem I'm seeing.
jamie.
Loading...