Is it possible and how to reliably gather the current keyboard language and/or layout via command-line in Ubuntu?
We've already tried different options:
localectl(status);cat /etc/default/locale;cat /etc/default/keyboard;setxkbmap -query;gsettings ...;setxkbmap -print | grep xkb_symbols(setxkbmap -v | awk -F "+" '/symbols/ {print $2}');- Tried to install
xkblayout-state, butmakefailed on fresh OS install - skipped.
All of these output the same per each command with keyboard layout change - us layout.
uname -a shows Linux x4 4.4.0-97-generic #120-Ubuntu SMP Tue Sep 19 17:28:18 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
The current distribution is KDE Neon 5.8 (based on Ubuntu) and window system is X11.
The outputs of the above commands:
$ localectl status:
System Locale: LANG=en_US.UTF-8
LC_NUMERIC=lt_LT.UTF-8
LC_TIME=lt_LT.UTF-8
LC_MONETARY=lt_LT.UTF-8
LC_PAPER=lt_LT.UTF-8
LC_NAME=lt_LT.UTF-8
LC_ADDRESS=lt_LT.UTF-8
LC_TELEPHONE=lt_LT.UTF-8
LC_MEASUREMENT=lt_LT.UTF-8
LC_IDENTIFICATION=lt_LT.UTF-8
VC Keymap: n/a
X11 Layout: us
X11 Model: pc105
$ cat /etc/default/locale:
# File generated by update-locale
LANG="en_US.UTF-8"
LC_NUMERIC="lt_LT.UTF-8"
LC_TIME="lt_LT.UTF-8"
LC_MONETARY="lt_LT.UTF-8"
LC_PAPER="lt_LT.UTF-8"
LC_NAME="lt_LT.UTF-8"
LC_ADDRESS="lt_LT.UTF-8"
LC_TELEPHONE="lt_LT.UTF-8"
LC_MEASUREMENT="lt_LT.UTF-8"
LC_IDENTIFICATION="lt_LT.UTF-8"
$ cat /etc/default/keyboard:
# KEYBOARD CONFIGURATION FILE
Consult the keyboard(5) manual page.
XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS=""
BACKSPACE="guess"
$ setxkbmap -query:
rules: evdev
model: pc101
layout: us,lt
options: grp:alt_shift_toggle
$ setxkbmap -print | grep xkb_symbols:
xkb_symbols { include "pc+us+lt:2+inet(evdev)+group(alt_shift_toggle)" };
$ setxkbmap -v | awk -F "+" '/symbols/ {print $2}':
us
$ cat ~/.config/kxkbrc:
[Layout]
DisplayNames=,
LayoutList=us,lt
LayoutLoopCount=-1
Model=pc101
Options=grp:alt_shift_toggle
ResetOldOptions=true
ShowFlag=false
ShowLabel=true
ShowLayoutIndicator=true
ShowSingle=false
SwitchMode=Global
Use=true
All of these commands were executed two times (before and after keyboard language/layout change) - no useful enough output.
However:
$ xset -q | grep -A 0 'LED' | cut -c59-67 (English language is enabled):
00000000
$ xset -q | grep -A 0 'LED' | cut -c59-67 (Lithuanian language is enabled):
00001000
Considering it's changing, is it a correct and reliable option?
gsettings get org.gnome.desktop.input-sources mru-sourcesgivesNo such key 'mru-sources'– Artfaith Nov 05 '17 at 22:57