Subject: Bug#402: Numlock issues

From: [email-masked]
Date: Fri, 17 Jan 2014 12:01:11 +0100

Package: x2goserver
Version: 4.0.1.12-0x2go2+git20140108.809+wheezy.main.1

Hello, numlock does not behave correctly. It behaves like if it was
randomly and continuously toggling it state.

Happens when numlock key is pressed, and after some time, it seems to
stabilize in some state (on or off), but it can take some time.

Happens on Mate 1.6 desktop environment over Debian 6. No problem on same
host with a KDE session.

If numlock state is modified with numlockx binary, it works as expected,
only the key triggers this.

user@host:~$ while numlockx status; do sleep 0.1; done
Numlock is off
Numlock is off
Numlock is on
Numlock is on
Numlock is off
Numlock is on
Numlock is off
Numlock is on
Numlock is off
Numlock is on
Numlock is off
Numlock is off
Numlock is on
Numlock is on
Numlock is off
Numlock is on
Numlock is on
...

Standard output of xev, after typing on it "test" and numlock key:
http://paste.debian.net/76762/

---

From: [email-masked]
Date: Fri, 17 Jan 2014 12:56:16 +0100

> user@host:~$ while numlockx status; do sleep 0.1; done

Forgot to comment that same happens with pyhoca-gui.

Current workaround I'm using is executing "numlockx on" at user session
startup, because by default it is set to off and user presses numlock key
when starts to work.

---

From: [email-masked]
Date: Thu, 30 Jan 2014 09:46:04 +0100

> user@host:~$ while numlockx status; do sleep 0.1; done

Found that the Mate setting which makes numlock state change at a very
high rate can be disabled by:
  gsettings set org.mate.peripherals-keyboard remember-numlock-state false

Still, users notify me that numlock change randomly. I did monitor
numlock status with "numlockx status" command, and I can see it do
change but very intermitently.

I first monitored numlock status and actively changed it to on with a
script.

Lately, I added to the keyboard options, the equivalent to "setxkbmap -o
numpad:mac", which can be added to
/org/mate/desktop/peripherals/keyboard/kbd/options with
'compat\tnumpad:mac'

Here is a dirty script, which every user runs at session startup:

---------------%-----------------%------------------%------------------
#!/bin/bash
tab="$(printf "\t")"
cadena=( $(dconf read /org/mate/desktop/peripherals/keyboard/kbd/options |
sed -e 's/.*\[\|\]//g') )
for (( i=0;i<${#cadena[@]};i++ )); do
	# esborrar '[', ']' i ','
	cadena[$i]="$(printf "${cadena[$i]}" | sed -e 's/,//g')"
done
if ! echo ${cadena[@]} | grep -q 'compat\snumpad:mac'; then
	for (( i=0;i<${#cadena[@]};i++ )); do
		nova="$nova ${cadena[$i]},"
	done
	nova="$nova 'compat${tab}numpad:mac'"
	dconf write /org/mate/desktop/peripherals/keyboard/kbd/options "[ $nova ]"
fi
gsettings set org.mate.peripherals-keyboard numlock-state          'on'
---------------%-----------------%------------------%------------------

---

From: Mike Gabriel <[email-masked]>
Date: Fri, 31 Jan 2014 12:39:30 +0000

Control: reassign -1 x2gomatebindings
Control: found -1 0.0.1.1

On  Do 30 Jan 2014 09:46:04 CET, jordi wrote:

>> [...]
> [...]

We have to fix this in x2gomatebindings. So reassigning this bug.

Mike
-- 

DAS-NETZWERKTEAM
mike gabriel, herweg 7, 24357 fleckeby
fon: +49 (1520) 1976 148

GnuPG Key ID 0x25771B31
mail: [email-masked], http://das-netzwerkteam.de

freeBusy:
https://mail.das-netzwerkteam.de/freebusy/m.gabriel%40das-netzwerkteam.de.xfb

---

From: Mike Gabriel <[email-masked]>
Date: Wed, 02 Apr 2014 13:00:29 +0000

Control: tag -1 moreinfo

Hi Jordi,

> Here is a dirty script, which every user runs at session startup:

I would like to get this fixed before the next release of x2gomatebindings.

Do you think you could write a patch?

Here is an example for a possible approach:
http://code.x2go.org/gitweb?p=x2gomatebindings.git;a=blob;f=lib/x2go/extensions/pre-runcommand.d/005_MATE-monitors-xml-ignore;h=2f77bed691529e5cbbb45e569e196667b5b004d1;hb=a1a6a572d81a49c376eaab875de8343b2781d638

Simply use the extension concept of X2Go Server to hook into there and  
execute code that is necessary.

The goal of such code should be that the Numlock settings are changed  
for X2Go (on session startup e.g.), but that local logins (of the same  
user) are not affected. If that is at all possible...

Mike

-- 

DAS-NETZWERKTEAM

GnuPG Key ID 0x25771B31

freeBusy:

---

From: Mike Gabriel <[email-masked]>
Date: Thu, 10 Apr 2014 11:29:54 +0000

Hi Jordi,
(I am re-Cc:-ing #402 in our BTS, hope that's ok...)

On  Do 10 Apr 2014 12:03:02 CEST, jordi wrote:

>> Hi Jordi,
>>
>> On  Sa 05 Apr 2014 19:45:20 CEST, Jordi MarquÃ©s wrote:
>>
>>> Hello Mike, sorry for late answer.
>>>
>>> I have looked at it, so what you need is a simple bash script. I can
>>> do that. Could I write it and send it to you?
>>>
>>> If so, I think I can do it on monday.
>>>
>>> Jordi.
>>
>> Sure, send it to me.
>>
>> Make sure that X2Go session startup does not break local session
>> startup. So if you change something in pre-runcommand.d, make sure it
>> gets restored in post-runcommand.d.
>
> Hello Mike,
>
> sorry again for being late, I've got more work than I can handle.
>
> Please take a look at this post-runcommand.d http://paste.debian.net/92885/
> and this pre-runcommand.d: http://paste.debian.net/92886/ .
>
> I write to files to save the state of the two settings previous to being
> modified so I can restore it. I set a folder variable where I save those
> files. Would that be a correct way to work inside X2go? I set them to /tmp
> to test, please modify them accordingly to what would be the best value.
>
> Not directly related to this, I've played also with the reduced_resources
> variable, which set to true, disables completely windows animations, and
> makes window moving be done with a classic transparent line drawn box,
> instead of the real window image. I've applied to my users, if you find it
> interesting to try tell me to add it.

The approach is good. I have copied both scripts from paste.debian.net  
to my local working copy of x2gomatebindings. Thanks!

However, one thought:

With your proposed approach, the dconf/gsettings setup remains  
X2Go'ish for the duration of the X2Go Session.

It would be good, to make those settings and remove them immediately,  
after the session has successfully come up. I am not sure how MATE  
will behave if you launch the post-runcommand script 20 minutes after  
the session has come up.

And another thought...

Another approach actually is... Talking to MATE upstream and asking  
them to patch their code directly (i.e. ignore those settings / use  
pre-set value if MATE runs inside an X2Go session). I will talk to  
Stefano & co. about that (who is MATE upstream).

Greets,
Mike
-- 

DAS-NETZWERKTEAM

GnuPG Key ID 0x25771B31

freeBusy:

---

From: [email-masked]
Date: Thu, 10 Apr 2014 15:46:26 +0200

> Stefano & co. about that (who is MATE upstream).

I don't really know if these settings are session aware, but my impression
is that those are global settings for a user. If they are not and I can
modify the script please let me know!

---

From: Mike Gabriel <[email-masked]>
Date: Thu, 10 Apr 2014 16:57:45 +0000

Hi Jordi,

> modify the script please let me know!

My question is: if you run the pre-runcommand script just before  
session startup and then run the post-runcommand script right after  
session startup (not when the session is ended), are the settings then  
ok?

Mike
-- 

DAS-NETZWERKTEAM

GnuPG Key ID 0x25771B31

freeBusy:

---

From: [email-masked]
Date: Fri, 11 Apr 2014 08:51:32 +0200

Hi mike!

>>>> instead of the real window image. I've applied to my users, if you
>>>> find
>>>> it

Yes right, these scripts should be run at session start and at session end.

---

From: Mike Gabriel <[email-masked]>
Date: Fri, 11 Apr 2014 06:56:41 +0000

Hi Jordi,

> Yes right, these scripts should be run at session start and at session end.

Maybe we are misunderstanding each other.

My intention is: change the config for a minute or so, launch the X2Go  
session and then immediately switch back to the saved values.

My question is:

   o launch X2Go session including the pre-runcommand script
   o Wait for the session to come up
   o MANUALLY launch the post-runcommand script

Does that break the numlock state in the X2Go session immediately? Or  
do the related applications remember the settings they had during  
session startup.

I don't want X2Go to "break" user profiles while X2Go sessions are  
running. It is tolerable to tweak configuration files for 20secs  
during session startup, but not for longer.

The alternative approach would be making MATE (upstream) aware of X2Go  
sessions (vs. local X11 sessions).

Mike
-- 

DAS-NETZWERKTEAM

GnuPG Key ID 0x25771B31

freeBusy:

---

From: [email-masked]
Date: Fri, 11 Apr 2014 11:39:44 +0200

Hi Mike,

> sessions (vs. local X11 sessions).

Checked, these settings are global for the user, modifying them on a
session do alter another concurrent sessions, and gets saved for future
ones.

Jordi.