Bug 1023211

Summary: systemd: Wrong behaviour in localectl set-keymap MAP
Product: [openSUSE] openSUSE Distribution Reporter: Stefan Dirsch <sndirsch>
Component: BasesystemAssignee: systemd maintainers <systemd-maintainers>
Status: RESOLVED WONTFIX QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: fbui
Version: Leap 42.2   
Target Milestone: ---   
Hardware: Other   
OS: Other   
See Also: https://bugzilla.suse.com/show_bug.cgi?id=1023774
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---

Description Stefan Dirsch 2017-02-02 14:23:41 UTC
localectl set-keymap <MAP> 

doesn't change "XkbLayout" to "<MAP>" in /etc/X11/xorg.conf.d/00-keyboard.conf, if <MAP> is already set in /etc/vconsole.conf
(KEYMAP=<MAP>). It does work if KEYMAP is set to a different value in etc/vconsole.conf. I consider this a bug.

Example:

# localectl set-keymap us
# cat /etc/X11/xorg.conf.d/00-keyboard.conf
[...]
        Option "XkbLayout" "us"
[...]

<change KEYMAP in /etc/vconsole.conf from "us" to "de".

# localectl set-keymap de
# cat /etc/X11/xorg.conf.d/00-keyboard.conf
[...]
        Option "XkbLayout" "us"
[...]

<change KEYMAP in /etc/vconsole.conf from "de" back to "us".

 localectl set-keymap de
# cat /etc/X11/xorg.conf.d/00-keyboard.conf
[...]
        Option "XkbLayout" "de"
[...]
Comment 1 Franck Bui 2017-02-06 09:29:05 UTC
According to upstream that's expected if you edit manually vconsole.conf:

https://github.com/systemd/systemd/issues/5221

So I'm closing this one, if you don't agree please discuss with upstream directly.

Thanks.
Comment 2 Stefan Dirsch 2017-02-06 11:01:45 UTC
Thanks for reporting the issue to github! I've promised to you some time ago to file a bug for this issue, so I did this in the end. I don't think it's worth discussing this with upstream. This guy won't listen to me and won't accept a fix for that issue either. I'm pretty sure.
Comment 3 Franck Bui 2017-02-06 11:15:21 UTC
Well it depends on how good your arguments are ;)
Comment 4 Stefan Dirsch 2017-02-06 12:04:23 UTC
(In reply to Franck Bui from comment #3)
> Well it depends on how good your arguments are ;)

I seriously doubt this. I thought about workarounding the issue, but failed miserably.

 . $vconsole_conf_file
 if [ ! -z $KEYMAP ]; then
   echo "KEYMAP: $KEYMAP"
   options="$KEYMAP $KEYMAP_TOGGLE"
   ### Linux console and X11 keymap isn't set, if $KEYMAP option for
   ### "localectl set-keymap" is the same as specified in 
   ### vconsole.conf; so # make sure this cannot happen by setting it
  ### to some bogus value first (bnc#1023211)
   # sed -i 's/KEYMAP=.*/KEYMAP=replace_me/g' $vconsole_conf_file
   setkeyboard "$options"
 fi

Issue seems to be, that the value of $KEYMAP inside of localed and in /etc/vconsole.conf are not in sync, i.e. localed is caching this somehow regularly. :-(
Comment 5 Stefan Dirsch 2017-02-06 12:50:46 UTC
(In reply to Stefan Dirsch from comment #4)
> (In reply to Franck Bui from comment #3)
> > Well it depends on how good your arguments are ;)
> 
> I seriously doubt this. I thought about workarounding the issue, but failed
> miserably.
> 
>  . $vconsole_conf_file
>  if [ ! -z $KEYMAP ]; then
>    echo "KEYMAP: $KEYMAP"
>    options="$KEYMAP $KEYMAP_TOGGLE"
>    ### Linux console and X11 keymap isn't set, if $KEYMAP option for
>    ### "localectl set-keymap" is the same as specified in 
>    ### vconsole.conf; so # make sure this cannot happen by setting it
>   ### to some bogus value first (bnc#1023211)
>    # sed -i 's/KEYMAP=.*/KEYMAP=replace_me/g' $vconsole_conf_file
>    setkeyboard "$options"
>  fi
> 
> Issue seems to be, that the value of $KEYMAP inside of localed and in
> /etc/vconsole.conf are not in sync, i.e. localed is caching this somehow
> regularly. :-(

The sed command was the key here. I commented it out afterwards. 

The issue was, that localed apparently thought the previous keymap before the bogus value was still set in vconsole.conf, so it did just nothing, i.e. it also did not overwrite the bogus value in /etc/vconsole.conf. Oh well. So no reliable way to set Linux console and X11 keymap originated from the value
in /etc/vconsole.conf.
Comment 6 Franck Bui 2017-02-06 12:57:47 UTC
Apparently localed expects modifications in vconsole.conf are done by localectl ony.

Why can't this assumption be met in your case ?
Comment 7 Stefan Dirsch 2017-02-06 13:14:32 UTC
Well, previously Linux console and X11 default keymaps were set during displaymanger startup according to the configuration in /etc/sysconfig/keyboard. 
/etc/vconsole.conf looked like the successor to me. Meanwhile it turned out to be
something different, not very useful to me.

Anyway, I'll let the YaST guys to no longer to write /etc/vconsole.conf directly - in case they (still) do - and run "localectl set-x11-keymap <keymap> [...]" instead. And I'll remove this keymap configuration script completely.
Comment 8 Franck Bui 2017-02-06 13:37:46 UTC
Sounds better indeed, thanks Stefan.
Comment 9 Bernhard Wiedemann 2017-02-06 15:01:28 UTC
This is an autogenerated message for OBS integration:
This bug (1023211) was mentioned in
https://build.opensuse.org/request/show/454992 Factory / xdm
Comment 10 Stefan Dirsch 2017-02-07 14:48:40 UTC
*** Bug 1023775 has been marked as a duplicate of this bug. ***