Discussion:
[X2Go-User] execute xmodmap on resume
richard lucassen
2018-07-25 15:03:37 UTC
Permalink
Hello list,

Not an x2go problem, but maybe someone might be able to guess what is
happening here. I made a chmod 755 shell script:

$ cat /usr/lib/x2go/extensions/post-resume.d/010-xmodmap
#!/bin/dash
test -f ~/.Xmodmap || exit 0
/usr/bin/xmodmap -display $DISPLAY ~/.Xmodmap

When resuming an x2go session, the script is executed, but x2go session
starts but does not show up. The problem is that in one or another way,
the xmodmap executable is waiting for something, but I have no idea
what. Putting the xmodmap line to the background using an "&" makes the
x2go session start, but the xmodmap mappings are not set. I still have
to set the key mappings manually by invoking "xmodmap ~/.Xmodmap".

Anyone a hint on what's going on here?

R.
--
richard lucassen
http://contact.xaq.nl/
richard lucassen
2018-07-25 15:15:36 UTC
Permalink
On Wed, 25 Jul 2018 17:03:37 +0200
Post by richard lucassen
$ cat /usr/lib/x2go/extensions/post-resume.d/010-xmodmap
Oops, s/010-xmodmap/010_xmodmap/
--
richard lucassen
http://contact.xaq.nl/
John Stoffel
2018-07-27 14:57:48 UTC
Permalink
richard> Hello list,
richard> Not an x2go problem, but maybe someone might be able to guess what is
richard> happening here. I made a chmod 755 shell script:

richard> $ cat /usr/lib/x2go/extensions/post-resume.d/010-xmodmap
richard> #!/bin/dash
richard> test -f ~/.Xmodmap || exit 0
richard> /usr/bin/xmodmap -display $DISPLAY ~/.Xmodmap

richard> When resuming an x2go session, the script is executed, but x2go session
richard> starts but does not show up. The problem is that in one or another way,
richard> the xmodmap executable is waiting for something, but I have no idea
richard> what. Putting the xmodmap line to the background using an "&" makes the
richard> x2go session start, but the xmodmap mappings are not set. I still have
richard> to set the key mappings manually by invoking "xmodmap ~/.Xmodmap".

It sounds like when the script runs, the Xserver isn't quite ready,
and xmodmap is waiting for that. Maybe you can start debugging by
putting:

xmodmap -verbose -pm

before your call, to see what it prints out. And make sure the
$DISPLAY is set correctly too!

You can also do an 'strace xmodmap ...' call in there, to see where
it's going and what it's calling to.

John
richard lucassen
2018-07-29 22:26:22 UTC
Permalink
On Fri, 27 Jul 2018 10:57:48 -0400
Post by John Stoffel
It sounds like when the script runs, the Xserver isn't quite ready,
and xmodmap is waiting for that.
Hmm, it is called "post-resume", that suggests that everything is up an
running...
Post by John Stoffel
Maybe you can start debugging by
xmodmap -verbose -pm
before your call, to see what it prints out. And make sure the
$DISPLAY is set correctly too!
You can also do an 'strace xmodmap ...' call in there, to see where
it's going and what it's calling to.
I tried an "&", the session is starting, but xmodmap has no result,
even with an extra "sleep 5" in a separate script. I'll try the
"-verbose -pm" tomorrow.

Thnx for your answer,

R.
--
richard lucassen
http://contact.xaq.nl/
Ulrich Sibiller
2018-07-29 23:21:48 UTC
Permalink
Have a look at /usr/bin/x2goserver-run-extensions, this is the place
where the extensions are called.

The call is

find "$X2GO_LIB_PATH/extensions/$X2GO_MODALITY.d/" -maxdepth 1
-mindepth 1 | egrep "/[0-9]{3}_[[:alnum:]]+" | sort | while read
x2go_extension; do

which indicates that the script name has to start with _three_ digits
followed by _ and an alphanumeric name. Your script does not match, so
I guess that's the reason it is not executed.

Uli




Maybe remove

On Mon, Jul 30, 2018 at 12:26 AM, richard lucassen
Post by richard lucassen
On Fri, 27 Jul 2018 10:57:48 -0400
Post by John Stoffel
It sounds like when the script runs, the Xserver isn't quite ready,
and xmodmap is waiting for that.
Hmm, it is called "post-resume", that suggests that everything is up an
running...
Post by John Stoffel
Maybe you can start debugging by
xmodmap -verbose -pm
before your call, to see what it prints out. And make sure the
$DISPLAY is set correctly too!
You can also do an 'strace xmodmap ...' call in there, to see where
it's going and what it's calling to.
I tried an "&", the session is starting, but xmodmap has no result,
even with an extra "sleep 5" in a separate script. I'll try the
"-verbose -pm" tomorrow.
Thnx for your answer,
R.
--
richard lucassen
http://contact.xaq.nl/
_______________________________________________
x2go-user mailing list
https://lists.x2go.org/listinfo/x2go-user
richard lucassen
2018-07-30 09:05:44 UTC
Permalink
On Mon, 30 Jul 2018 01:21:48 +0200
Post by Ulrich Sibiller
Have a look at /usr/bin/x2goserver-run-extensions, this is the place
where the extensions are called.
The call is
find "$X2GO_LIB_PATH/extensions/$X2GO_MODALITY.d/" -maxdepth 1
-mindepth 1 | egrep "/[0-9]{3}_[[:alnum:]]+" | sort | while read
x2go_extension; do
which indicates that the script name has to start with _three_ digits
followed by _ and an alphanumeric name. Your script does not match, so
I guess that's the reason it is not executed.
No, the syntax is ok, the script is executed as stated in the OP...
--
richard lucassen
http://contact.xaq.nl/
Ulrich Sibiller
2018-07-30 10:33:39 UTC
Permalink
On Mon, Jul 30, 2018 at 11:05 AM, richard lucassen
Post by richard lucassen
On Mon, 30 Jul 2018 01:21:48 +0200
Post by Ulrich Sibiller
Have a look at /usr/bin/x2goserver-run-extensions, this is the place
where the extensions are called.
The call is
find "$X2GO_LIB_PATH/extensions/$X2GO_MODALITY.d/" -maxdepth 1
-mindepth 1 | egrep "/[0-9]{3}_[[:alnum:]]+" | sort | while read
x2go_extension; do
which indicates that the script name has to start with _three_ digits
followed by _ and an alphanumeric name. Your script does not match, so
I guess that's the reason it is not executed.
No, the syntax is ok, the script is executed as stated in the OP...
The egrep above clearly rules out any non-matching file. So maybe this
script is run by some other mechanism?

Uli
richard lucassen
2018-07-31 11:40:59 UTC
Permalink
On Mon, 30 Jul 2018 12:33:39 +0200
Post by Ulrich Sibiller
Post by richard lucassen
No, the syntax is ok, the script is executed as stated in the OP...
The egrep above clearly rules out any non-matching file. So maybe this
script is run by some other mechanism?
No, there is only one instance, in the right directory:

$ find /usr/lib/x2go/extensions/ -maxdepth 2 -mindepth 1 \
| egrep "/[0-9] {3}_[[:alnum:]]+"
/usr/lib/x2go/extensions/post-resume.d/010_xmodmap

R.
--
richard lucassen
http://contact.xaq.nl/
Ulrich Sibiller
2018-07-31 12:07:06 UTC
Permalink
On Tue, Jul 31, 2018 at 1:40 PM, richard lucassen
Post by richard lucassen
On Mon, 30 Jul 2018 12:33:39 +0200
Post by Ulrich Sibiller
Post by richard lucassen
No, the syntax is ok, the script is executed as stated in the OP...
The egrep above clearly rules out any non-matching file. So maybe this
script is run by some other mechanism?
$ find /usr/lib/x2go/extensions/ -maxdepth 2 -mindepth 1 \
| egrep "/[0-9] {3}_[[:alnum:]]+"
/usr/lib/x2go/extensions/post-resume.d/010_xmodmap
Alright, but I was refferring to your first mail where you wrote
"010-xmodmap" which does NOT match. ;-)

Uli
richard lucassen
2018-07-31 13:21:29 UTC
Permalink
On Tue, 31 Jul 2018 14:07:06 +0200
Post by Ulrich Sibiller
"010-xmodmap" which does NOT match. ;-)
I think you missed the first reply to my own post in which I wrote:

"Oops, s/010-xmodmap/010_xmodmap/"

:)
--
richard lucassen
http://contact.xaq.nl/
Stefan Baur
2018-07-31 12:18:00 UTC
Permalink
Post by richard lucassen
Post by John Stoffel
It sounds like when the script runs, the Xserver isn't quite ready,
and xmodmap is waiting for that.
Hmm, it is called "post-resume", that suggests that everything is up an
running...
Not necessarily.
"We're done resuming on the X2Go side of things" might not be the same
as "We're up and running on the X-Server side of things". It MAY
coincide, but I don't see a hard MUST for that.

-Stefan
--
BAUR-ITCS UG (haftungsbeschränkt)
Geschäftsführer: Stefan Baur
Eichenäckerweg 10, 89081 Ulm | Registergericht Ulm, HRB 724364
Fon/Fax 0731 40 34 66-36/-35 | USt-IdNr.: DE268653243
richard lucassen
2018-07-31 13:22:27 UTC
Permalink
On Tue, 31 Jul 2018 14:18:00 +0200
Post by Stefan Baur
Post by richard lucassen
Hmm, it is called "post-resume", that suggests that everything is
up an running...
Not necessarily.
"We're done resuming on the X2Go side of things" might not be the same
as "We're up and running on the X-Server side of things". It MAY
coincide, but I don't see a hard MUST for that.
Ok, then I will keep the 10 seconds sleep time, it's a workable
solution :)

R.
--
richard lucassen
http://contact.xaq.nl/
richard lucassen
2018-07-30 09:27:42 UTC
Permalink
On Fri, 27 Jul 2018 10:57:48 -0400
Post by John Stoffel
It sounds like when the script runs, the Xserver isn't quite ready,
and xmodmap is waiting for that. Maybe you can start debugging by
xmodmap -verbose -pm
before your call, to see what it prints out. And make sure the
$DISPLAY is set correctly too!
$DISPLAY is set correctly. The "xmodmap -verbose -pm" in a session works
fine. Writing the output to /tmp/test.txt doesn't change anything.
Post by John Stoffel
You can also do an 'strace xmodmap ...' call in there, to see where
it's going and what it's calling to.
[..]
access("/home/richard/.Xauthority", R_OK) = 0
openat(AT_FDCWD, "/home/richard/.Xauthority", O_RDONLY) = 4
fstat(4, {st_mode=S_IFREG|0600, st_size=100, ...}) = 0
read(4, "\1\0\0\4x2go\0\00250\0\22MIT-MAGIC-COOKIE-1"..., 4096) = 100
read(4, "", 4096) = 0
close(4) = 0
getsockname(3, {sa_family=AF_UNIX}, [124->2]) = 0
fcntl(3, F_GETFL) = 0x2 (flags O_RDWR)
fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
fcntl(3, F_SETFD, FD_CLOEXEC) = 0
poll([{fd=3, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=3, revents=POLLOUT}])
writev(3, [{iov_base="l\0\v\0\0\0\22\0\20\0\0\0", iov_len=12}, {iov_base="", iov_len=0}, {iov_base="MIT-MAGIC-COOKIE-1", iov_len=18}, {iov_base="\0\0", iov_len=2}, {iov_base="\360R\364\23\360\261\331\215\t\275\241en#`3", iov_len=16}, {iov_base="", iov_len=0}], 6) = 48
recvfrom(3, 0x558d1d8c28a0, 8, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)

That's where ist stops. The complete strace is here:

http://tmp.xaq.nl/strace.txt

R.
--
richard lucassen
http://contact.xaq.nl/
richard lucassen
2018-07-30 09:56:00 UTC
Permalink
On Fri, 27 Jul 2018 10:57:48 -0400
Post by John Stoffel
It sounds like when the script runs, the Xserver isn't quite ready,
and xmodmap is waiting for that. Maybe you can start debugging by
Hmm, this is a Q&D workaround:

$ cat /usr/lib/x2go/extensions/post-resume.d/010_xmodmap
#!/bin/dash
test -f ~/.Xmodmap || exit 0
/usr/local/scripts/xmodmap.sh &

$ cat /usr/local/scripts/xmodmap.sh
#!/bin/dash
sleep 10
exec /usr/bin/xmodmap ${HOME}/.Xmodmap

After 10 seconds the xmodmap is executed, 5 seconds apparently is not
enough. I'm not an x2go guru, but in fact it would mean IMHO that
"post-resume.d" is executed before the session has really finished
resuming. After resuming the session I get this when typing "'" + "e",
when the 10 seconds have ended the "dead key" which is in ~/.Xmodmap
is starting to work:

$ 'e'e'e'eééé

R.
--
richard lucassen
http://contact.xaq.nl/
Stefan Baur
2018-07-31 13:49:53 UTC
Permalink
Post by richard lucassen
On Fri, 27 Jul 2018 10:57:48 -0400
Post by John Stoffel
It sounds like when the script runs, the Xserver isn't quite ready,
and xmodmap is waiting for that. Maybe you can start debugging by
$ cat /usr/lib/x2go/extensions/post-resume.d/010_xmodmap
#!/bin/dash
test -f ~/.Xmodmap || exit 0
/usr/local/scripts/xmodmap.sh &
$ cat /usr/local/scripts/xmodmap.sh
#!/bin/dash
sleep 10
exec /usr/bin/xmodmap ${HOME}/.Xmodmap
You should be able to simplify that into one script, assuming dash
understands the syntax bash uses for this (haven't tried it):

$ cat /usr/lib/x2go/extensions/post-resume.d/010_xmodmap
#!/bin/dash
test -f ~/.Xmodmap || exit 0
(sleep 10; exec /usr/bin/xmodmap ${HOME}/.Xmodmap) &

Not sure why you'd need the "exec", even.

Instead of blindly sleeping 10 seconds, you could also check if xmodmap
returns an error when it's called too early in the process.
Maybe something like
(while ! /usr/bin/xmodmap ${HOME}/.Xmodmap ; do sleep 1 ; done) &

Also, is there a particular reason why you need to run xmodmap
manually/scripted, rather than using the keyboard settings option inside
X2GoClient? Are you a macOS X2GoClient user, and the autodetection we
need to use on the Mac is failing for you?

Kind Regards,
Stefan Baur
--
BAUR-ITCS UG (haftungsbeschränkt)
Geschäftsführer: Stefan Baur
Eichenäckerweg 10, 89081 Ulm | Registergericht Ulm, HRB 724364
Fon/Fax 0731 40 34 66-36/-35 | USt-IdNr.: DE268653243
richard lucassen
2018-07-31 14:18:25 UTC
Permalink
On Tue, 31 Jul 2018 15:49:53 +0200
Post by Stefan Baur
Post by richard lucassen
$ cat /usr/lib/x2go/extensions/post-resume.d/010_xmodmap
#!/bin/dash
test -f ~/.Xmodmap || exit 0
/usr/local/scripts/xmodmap.sh &
$ cat /usr/local/scripts/xmodmap.sh
#!/bin/dash
sleep 10
exec /usr/bin/xmodmap ${HOME}/.Xmodmap
You should be able to simplify that into one script, assuming dash
As I said: "this is a Q&D workaround" Q&D means Quick and Dirty ;-)
Post by Stefan Baur
$ cat /usr/lib/x2go/extensions/post-resume.d/010_xmodmap
#!/bin/dash
test -f ~/.Xmodmap || exit 0
(sleep 10; exec /usr/bin/xmodmap ${HOME}/.Xmodmap) &
Not sure why you'd need the "exec", even.
There's no need "exec" for it indeed
Post by Stefan Baur
Instead of blindly sleeping 10 seconds, you could also check if
xmodmap returns an error when it's called too early in the process.
Maybe something like
(while ! /usr/bin/xmodmap ${HOME}/.Xmodmap ; do sleep 1 ; done) &
That would be a better option indeed
Post by Stefan Baur
Also, is there a particular reason why you need to run xmodmap
manually/scripted, rather than using the keyboard settings option
inside X2GoClient? Are you a macOS X2GoClient user, and the
autodetection we need to use on the Mac is failing for you?
It's all Linux. I use a script to start WindowMaker as windowmanager
("Custom desktop") and I noticed that xmodmap keymapping is reset
after a suspend/resume cycle. I needed to run "xmodmap ~/.Xmodmap" each
time after a suspend/resume cycle. That's why I was trying to script it.

I use the x2go-server from various devices with sometimes some weird
keyboards. On some devices I mapped certain keys to functions like PgUp
and PgDn because otherwise these keys need "Fn + key" combination and
I'd like to keep these setting in the x2go session.

BTW, as stated in the OP, I don't think it's an x2go issue. Maybe I
have to play with the keyboard settings, I never did actually.

R.
--
richard lucassen
http://contact.xaq.nl/
Loading...