Discussion:
xmodmap
Jorge Almeida
2011-10-01 09:49:46 UTC
Permalink
I have a very annoying problem with xmodmap:

Inside X, in an xterm:

$ echo $DISPLAY
:1

In console (agetty1):

$ echo $DISPLAY

$ xmodmap .Xmodmap
xmodmap: unable to open display ''

$ xmodmap -display :2 .Xmodmap
xmodmap: unable to open display ':2'

Until now, everything as expected. The problem is:

$ xmodmap -display :1 .Xmodmap
$ echo $?
0

So, everything seems fine, but switching to the vt where X is I find
that xmodmap didn't load anything. Note that if running "xmodmap
.Xmodmap" from X it works. In console, I tried also setting the env
variable DISPLAY (the only one relevant to xmodmap, according to the
manual), to no avail.

You might wonder why is this a problem, since it works from X. I have
a xmodmap command in the startup file of the window manager (openbox).
Other X related commands work, only xmodmap fails. It seems that
xmodmap requires being run from an emulator inside an X session, which
it's not supposed to.

Any help about this essentially undocumented piece of software would
be appreciated. Alternatively, anyone knows whether there is some
alternative to xmodmap? xkb doesn't seem to be able to replace it,
judging by what poor documentation there is out there.

TIA

Jorge Almeida
XeCycle
2011-10-01 12:50:42 UTC
Permalink
Jorge Almeida <***@gmail.com> writes:

[...]
It seems that xmodmap requires being run from an emulator inside an X
session, which it's not supposed to.
I'm afraid not. For me, I'm running it like this:

.xinitrc:
#!/bin/sh
metacity & wmpid=$!
sleep 2
xmodmap ~/.xmodmaps &
# other commands
wait $wmpid

It works for me.
--
Carl Lei (XeCycle)
Department of Physics, Shanghai Jiao Tong University
OpenPGP public key: 7795E591
Fingerprint: 1FB6 7F1F D45D F681 C845 27F7 8D71 8EC4 7795 E591
Jorge Almeida
2011-10-01 13:05:54 UTC
Permalink
Post by XeCycle
[...]
It seems that xmodmap requires being run from an emulator inside an X
session, which it's not supposed to.
#!/bin/sh
metacity & wmpid=$!
sleep 2
xmodmap ~/.xmodmaps &
# other commands
wait $wmpid
It works for me.
Thanks. It may be an openbox thing, but then you started your wm
before other stuff. Any special reason for that? Why not exec into
metacity in the end, rather than keeping .xinitrc waiting? And why
backgrounding xmodmap? I suppose I should try all possibilities, but
it remains the mystery: why running from the console doesn't work?

Jorge Almeida
r***@aol.com
2011-10-01 13:19:42 UTC
Permalink
Post by Jorge Almeida
Post by XeCycle
[...]
It seems that xmodmap requires being run from an emulator inside an X
session, which it's not supposed to.
#!/bin/sh
metacity & wmpid=$!
sleep 2
xmodmap ~/.xmodmaps &
# other commands
wait $wmpid
It works for me.
Thanks. It may be an openbox thing, but then you started your wm
before other stuff. Any special reason for that? Why not exec into
metacity in the end, rather than keeping .xinitrc waiting? And why
backgrounding xmodmap? I suppose I should try all possibilities, but
it remains the mystery: why running from the console doesn't work?
Jorge Almeida
FWIW, icewmbg, which is supposed to be run before icewm (according to the
documentation); or which is supposed to be run by icewm-session; fails for
similar reasons ($DISPLAY is not set and X is not running) unless I first
run icewm, open a terminal window and then run icewmbg. For me this is not
a big deal because I run icewm in order to run lean and clean and if I
really want to see that background photo, I can run xfwm4.

T.
Jorge Almeida
2011-10-01 13:43:56 UTC
Permalink
Post by r***@aol.com
FWIW, icewmbg, which is supposed to be run before icewm (according to the
documentation); or which is supposed to be run by icewm-session; fails for
similar reasons ($DISPLAY is not set and X is not running) unless I first
run icewm, open a terminal window and then run icewmbg.  For me this is not
a big deal because I run icewm in order to run lean and clean and if I
really want to see that background photo, I can run xfwm4.
I suppose that is a quirk of icewm. I set my background in the same
script that is supposed to run xmodmap, and the background is really
set. On the other hand, I put an "echo $DISPLAY" in the same script,
just to check that the display is set, and it gives the expected
output. As for X, the script is the client of xinit, and besides the
other X-related tasks get done, only xmodmap fails.

J.A.
Jorge Almeida
2011-10-01 17:29:58 UTC
Permalink
On Sat, Oct 1, 2011 at 4:15 PM, marshall
Hopefully this time I'll make the list.
My enviroment file.
setxkbmap gb
xmodmap /home/marshall/.Xmodmap
I used run xmodmap from ~/.config/openbox/autostart
but that ceased to work after the openbox 3.5 upgrade. I then tried to
run it from my .xinitrc file, this also fails to work as expected.
OK, I found it. The problem was "setxkbmap -option
terminate:ctrl_alt_bksp" _after_ xmodmap! As I use setxkbmap just to
recover the traditional Ctrl-Alt-Backspace behavior that Xorg
developers decided to drop, it didn't occur to me that it might
interact with xmodmap. I changed the places of both commands and it
works now. It works regardless of whether it is run before the openbox
binary (via environment file, or equivalent) or after openbox (via
--startup flag). It is also independent of the fact that I'm using a
non-standard setup.

Thanks

Jorge

Loading...