XFCE - The keyboard layout changes automatically

Non release banter
Kulle
Warlord
Warlord
Posts: 594
Joined: 28 Jan 2017, 10:39
Distribution: v4.0 64bit Xfce
Location: Berlin

XFCE - The keyboard layout changes automatically

Post#16 by Kulle » 27 Jan 2023, 17:17

I used Rava's script.
After "Suspend" the time is also adjusted,
from January 27th to January 30th

Code: Select all

guest@porteus:~$ date
Fr 27. Jan 18:02:54 CET 2023
guest@porteus:~$ date
Mo 30. Jan 14:03:49 CET 2023

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

XFCE - The keyboard layout changes automatically

Post#17 by Rava » 27 Jan 2023, 19:55

Kulle wrote:
27 Jan 2023, 17:17
I used Rava's script.
After "Suspend" the time is also adjusted,
from January 27th to January 30th

Code: Select all

guest@porteus:~$ date
Fr 27. Jan 18:02:54 CET 2023
guest@porteus:~$ date
Mo 30. Jan 14:03:49 CET 2023
Can you please post the script how you used it?

My script has no part that tweaks anything of the system date/time.

And when you go into suspend using your DE way, that also only calls

Code: Select all

loginctl suspend
to go into suspend.

To debug a script, I always insert "echo INFO" lines, e.g. echo with the info what part of the script that echo is from.

In the phase of debugging I recommend using a better readable code, in this case, the one with if else fi and not the one with && and ||
I would also add info into there like so:

Code: Select all

echo debug - A ## DEBUG
date ## DEBUG
echo setxkbmap de
setxkbmap de
returnval=$?
echo debug - B ## DEBUG
echo '$returnval'=$returnval ## DEBUG
if [ $returnval -eq 0 ]; then
	notify-send -i info -t 5000 "Keyboard set" "to DE"
else
	notify-send -i error -t 0 "Keyboard setting to" "DE failed"
fi
echo debug - C ## DEBUG
date ## DEBUG
Set the number of the echo debug - X accordingly, and only use unique numbers so that one echo debug output will only be printed by one specific place in the script - and never by any other place in the script.
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

XFCE - The keyboard layout changes automatically

Post#18 by Ed_P » 27 Jan 2023, 20:17

Rava wrote:
27 Jan 2023, 19:55
To debug a script, I always insert "echo INFO" lines, e.g. echo with the info what part of the script that echo is from.
I add a "set -x;" command near the top to help debug scripts I have problems with.
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

XFCE - The keyboard layout changes automatically

Post#19 by Rava » 28 Jan 2023, 00:20

Ed_P wrote:
27 Jan 2023, 20:17
I add a "set -x;" command near the top to help debug scripts I have problems with.
What he said. :D
Cheers!
Yours Rava

Kulle
Warlord
Warlord
Posts: 594
Joined: 28 Jan 2017, 10:39
Distribution: v4.0 64bit Xfce
Location: Berlin

XFCE - The keyboard layout changes automatically

Post#20 by Kulle » 28 Jan 2023, 16:03

Hi Rava,
1. Test
"suspend" by clicking on the Suspend button

Code: Select all

guest@porteus:~$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     de
options:    grp:alt_shift_toggle,terminate:ctrl_alt_bksp
guest@porteus:~$ date
Sa 28. Jan 16:33:03 CET 2023
After suspend:

Code: Select all

guest@porteus:~$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     us
options:    grp:alt_shift_toggle,terminate:ctrl_alt_bksp
guest@porteus:~$ date
Di 31. Jan 12:35:34 CET 2023
2. Test
"suspend" via the console command loginctl suspend

Code: Select all

guest@porteus:~$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     de
options:    grp:alt_shift_toggle,terminate:ctrl_alt_bksp
guest@porteus:~$ date
Sa 28. Jan 16:38:01 CET 2023
guest@porteus:~$ loginctl suspend
guest@porteus:~$ setxkbmap -query
rules:      evdev
model:      pc105
layout:     us
options:    grp:alt_shift_toggle,terminate:ctrl_alt_bksp
guest@porteus:~$ date
Di 31. Jan 12:38:45 CET 2023
3. Test
"suspend" via Rava's Script ==> the same thing.

Kbmap and time are always changed !

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

XFCE - The keyboard layout changes automatically

Post#21 by Rava » 28 Jan 2023, 16:33

Kulle wrote:
28 Jan 2023, 16:03
Hi Rava,
1. Test
"suspend" by clicking on the Suspend button
[…]
2. Test
"suspend" via the console command loginctl suspend
[…]
3. Test
"suspend" via Rava's Script ==> the same thing.

Kbmap and time are always "suspend" via Rava's Script ==> the same thing.
changed !
As I suspected, since all 3 variants did the same erroneous change of date/time, it has nothing to do with my script nor with calling loginctl suspend via a terminal.

My suggestion:
Post what gets written into /var/log/messages.

You can facilitate that by creating a script now owned and executed by root that does these things:

suspend-debug.sh (must be run as root!)

Code: Select all

#!/bin/sh
MYNAME=$0
function seconds2time () 
{
    local T=$1;
    local D=$((T/60/60/24));
    local H=$((T/60/60%24));
    local M=$((T/60%60));
    local S=$((T%60));
    if [[ ${D} != 0 ]]; then
        if [[ ${D} = 1 ]]; then
            printf '%d day %02d:%02d:%02d' $D $H $M $S;
        else
            printf '%d days %02d:%02d:%02d' $D $H $M $S;
        fi;
    else
        printf '%02d:%02d:%02d' $H $M $S;
    fi
}
function mydate () {
	echo $(date +%d.%m.%Y\ %H:%M:%S) ____________________________________________________________
}
# we use the function mydate to more easily find the date/time info in /var/log/messages

declare -i startepoch=$(date +%s)
echo "●●●●● before $MYNAME ●●●●●●●●●●●●●●●" >>/var/log/messages
mydate  >>/var/log/messages
echo loginctl suspend >>/var/log/messages
loginctl suspend >>/var/log/messages
echo '●● sleeping 10 seconds for loginctl suspend to background-suspend. ●●' |tee -a /var/log/messages
# now suspend should happen
sleep 10s
echo '●●●●● loginctl suspend took '$(seconds2time $(date +%s)-$startepoch)' … ●●●●●●●●●●●●●●●'|tee -a /var/log/messages
echo "●●●●● after $MYNAME ●●●●●●●●●●●●●●●" >>/var/log/messages
mydate  >>/var/log/messages
Run suspend-debug.sh as root.

Post here what is printed in the terminal that ran suspend-debug.sh

Also post here all the info from /var/log/messages
- starting with

Code: Select all

●●●●● before $MYNAME ●●●●●●●●●●●●●●●
and ending with

Code: Select all

●●●●● after $MYNAME ●●●●●●●●●●●●●●●
and the following date/time info as created by the mydate function.
$MYNAME gets replaced by the name you gave the script.

Unless the date/time change as recorded in /var/log/messages happens later than the

Code: Select all

●●●●● after $MYNAME ●●●●●●●●●●●●●●●
line and the date/time info as created by the mydate function - then post all beginning from

Code: Select all

●●●●● before $MYNAME ●●●●●●●●●●●●●●●
to the end of /var/log/messages

Hopefully then we do know more.


Why must the script be executed by root?

Because only root has read/write permission into /var/log/messages
HTH!
Cheers!
Yours Rava

User avatar
Ed_P
Contributor
Contributor
Posts: 8341
Joined: 06 Feb 2013, 22:12
Distribution: Cinnamon 5.01 ISO
Location: Western NY, USA

XFCE - The keyboard layout changes automatically

Post#22 by Ed_P » 28 Jan 2023, 17:00

Kulle wrote:
28 Jan 2023, 16:03
3. Test
"suspend" via Rava's Script ==> the same thing.

:o The "setxkbmap de" at the end of Rava's script didn't work?? :crazy:

Added in 7 minutes 8 seconds:
Rava wrote:
28 Jan 2023, 16:33
Why must the script be executed by root?

Because only root has read/write permission into /var/log/messages
You can't prefix the script's writes with "echo toor | sudo -S" ? If so guest can run the script.
Ed

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

XFCE - The keyboard layout changes automatically

Post#23 by Rava » 28 Jan 2023, 17:13

Ed_P wrote:
28 Jan 2023, 17:07
:o The "setxkbmap de" at the end of Rava's script didn't work?? :crazy:
It's not about that, currently it is about the strange change of system time/date in his system when
● suspend is done via the menu in XFCE
● manually via loginctl suspend
● or via my script (that also uses loginctl suspend).
Ed_P wrote:
28 Jan 2023, 17:07
You can't prefix the script's writes with "echo toor | sudo -S" ? If so guest can run the script.
Only when the user did not change the root's password to a more secure one. Like is recommended. :)
Cheers!
Yours Rava

beny
Full of knowledge
Full of knowledge
Posts: 2086
Joined: 02 Jan 2011, 11:33
Location: italy

XFCE - The keyboard layout changes automatically

Post#24 by beny » 28 Jan 2023, 20:33

hi

Code: Select all

guest@porteus:~$ setxkbmap -print -verbose 10
Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /etc/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules:      evdev
model:      pc105
layout:     it,us
variant:    ,
options:    terminate:ctrl_alt_bksp
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwerty)
types:      complete
compat:     complete
symbols:    pc+it+us:2+inet(evdev)+terminate(ctrl_alt_bksp)
geometry:   pc(pc105)
xkb_keymap {
	xkb_keycodes  { include "evdev+aliases(qwerty)"	};
	xkb_types     { include "complete"	};
	xkb_compat    { include "complete"	};
	xkb_symbols   { include "pc+it+us:2+inet(evdev)+terminate(ctrl_alt_bksp)"	};
	xkb_geometry  { include "pc(pc105)"	};
};

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

XFCE - The keyboard layout changes automatically

Post#25 by Rava » 28 Jan 2023, 20:44

This is my setxkbmap -print -verbose 10 using probably the same setup as Kulle:

Code: Select all

Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /etc/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules:      evdev
model:      pc105
layout:     de
variant:    nodeadkeys
options:    terminate:ctrl_alt_bksp
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwertz)
types:      complete
compat:     complete
symbols:    pc+de(nodeadkeys)+inet(evdev)+terminate(ctrl_alt_bksp)
geometry:   pc(pc105)
xkb_keymap {
	xkb_keycodes  { include "evdev+aliases(qwertz)"	};
	xkb_types     { include "complete"	};
	xkb_compat    { include "complete"	};
	xkb_symbols   { include "pc+de(nodeadkeys)+inet(evdev)+terminate(ctrl_alt_bksp)"	};
	xkb_geometry  { include "pc(pc105)"	};
};
as you can see, in contrast to beny's output mine only shows one layout:

Code: Select all

layout:     de
variant:    nodeadkeys
Cheers!
Yours Rava

Kulle
Warlord
Warlord
Posts: 594
Joined: 28 Jan 2017, 10:39
Distribution: v4.0 64bit Xfce
Location: Berlin

XFCE - The keyboard layout changes automatically

Post#26 by Kulle » 29 Jan 2023, 09:29

Another new test:
Rava wrote
"You can also set that via its settings menu Settings ▷ Keyboard ..."
I did that.

Result after "suspend" : keyboard map is preserved, time/date is also preserved
This solves the problem

Rava wrote "Post what gets written into /var/log/messages"
I'll do that soon, as soon as I have time

Kulle
Warlord
Warlord
Posts: 594
Joined: 28 Jan 2017, 10:39
Distribution: v4.0 64bit Xfce
Location: Berlin

XFCE - The keyboard layout changes automatically

Post#27 by Kulle » 29 Jan 2023, 12:42

I wrote hastily.
Also now was after a longer "suspend" date/time changed:

Code: Select all

guest@porteus:~$ date
Mi 1. Feb 09:31:45 CET 2023
(keyboard map has been retained)
It may be, so this effect occurs sometimes
or after a longer "suspend".
I will keep watching

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

XFCE - The keyboard layout changes automatically

Post#28 by Rava » 29 Jan 2023, 15:13

Kulle wrote:
29 Jan 2023, 09:29
"You can also set that via its settings menu Settings ▷ Keyboard ..."
I did that.

Result after "suspend" : keyboard map is preserved, time/date is also preserved
This solves the problem
:good:
Yay! :Yahoo!: And when I recall correctly it was my first suggestion to boot.

Good to know it helped.

Kulle wrote:
29 Jan 2023, 12:42
It may be, so this effect occurs sometimes
or after a longer "suspend".
I will keep watching
I am 99% sure that the date/time offset is unrelated to the setting of the keymap.
Cheers!
Yours Rava

Rapha_
Shogun
Shogun
Posts: 238
Joined: 12 Jun 2021, 21:59
Distribution: Xfce 4.12 - 5.rc3 - x86_64
Location: France

XFCE - The keyboard layout changes automatically

Post#29 by Rapha_ » 29 Jan 2023, 17:02

Kulle wrote:
25 Jan 2023, 18:03
in porteus-v5.0-x86_64.cfg file I have: kmap=de lang=de
I dont see any lang= in Porteus cheatcodes.txt :(

User avatar
Rava
Contributor
Contributor
Posts: 5401
Joined: 11 Jan 2011, 02:46
Distribution: XFCE 5.01 x86_64 + 4.0 i586
Location: Forests of Germany

XFCE - The keyboard layout changes automatically

Post#30 by Rava » 29 Jan 2023, 17:05

Rapha_ wrote:
29 Jan 2023, 17:02
I dont see any lang= in Porteus cheatcodes.txt :(
There are also more generic cheat codes that apply to most Linux kernels, not just the Porteus one. Many of those are not listed in cheatcodes.txt :)
I presume lang= is one of the generic cheat codes.
Cheers!
Yours Rava

Post Reply