This forum has been archived. All content is frozen. Please use KDE Discuss instead.

How to fake a System Settings change via shell script.

Tags: None
(comma "," separated)
User avatar
dotancohen
Registered Member
Posts
59
Karma
0
OS
Due to a bug in Ubuntu [1], I must set then remove the "Swap CapsLock and Escape" feature in System Settings [2] often. Is there a way that I can script this rather than opening the window and playing with the mouse? I just need this option to be, sleep 1, then unset as a workaround for the Ubuntu bug.

Thanks.


[1] https://bugs.launchpad.net/ubuntu/+sour ... ug/1510501
[2] System Settings -> Input Devices -> Keyboard -> Advanced -> CapsLock Key Behavior -> Swap CapsLock and Escape


dotancohen, proud to be a member of KDE forums since 2008-Oct.
User avatar
einar
Administrator
Posts
3402
Karma
7
OS
I wonder if using dbus (if possible) would help, but I am not sure what's in charge of handling that.


"Violence is the last refuge of the incompetent."
Image
Plasma FAQ maintainer - Plasma programming with Python
luebking
Karma
0
The keyboard is re-added "cleanly" (but according to X11 configs) on attaching it, KDE basically simply calls setxkb on login/keyboard layout change.

Run
Code: Select all
setxkbmap -device $ID -option caps:swapescape


Notice that $ID can be obtained by calling "xinput" (prints a list of all devices) and is NOT static.

The imo better approach to handle this is to configure keyboards

/etc/X11/xorg.conf.d/11-keyboard.conf
Code: Select all
Section "InputClass"
    Identifier          "Keyboard Defaults"
    MatchIsKeyboard     "yes" # this is relevant
    # MatchProduct "Microsoft Comfort Curve Keyboard 2000" # you can treat them differently
    Option              "XkbLayout" "de,fr" # comma separated list of layouts
    Option              "XkbVariant" "deadgraveacute" # variants to your preference
    # Option              "XkbModel" "microsofccurve2k" # you can even specify the preferred model over pc104
    Option              "XkbOptions" "terminate:ctrl_alt_bksp,compose:caps" # the relevant line, but i prefer it as compose key ;-)
    # Option              "XkbRules" "xorg" # enforce rules
    # Option              "XkbKeycodes" "evdev" # enforce driver
EndSection


Those rules will be auto-applied on adding keyboards (same is possible for mice)
User avatar
dotancohen
Registered Member
Posts
59
Karma
0
OS
luebking wrote:The keyboard is re-added "cleanly" (but according to X11 configs) on attaching it, KDE basically simply calls setxkb on login/keyboard layout change.

Run
Code: Select all
setxkbmap -device $ID -option caps:swapescape


Notice that $ID can be obtained by calling "xinput" (prints a list of all devices) and is NOT static.


Thank you, the below code works perfectly:

Code: Select all
$ setxkbmap -device $(xinput | grep keyboard | grep Microsoft | awk '{print $7}' | awk -F'=' '{print $2}') -option caps:swapescape







luebking wrote:The imo better approach to handle this is to configure keyboards

/etc/X11/xorg.conf.d/11-keyboard.conf
Code: Select all
Section "InputClass"
    Identifier          "Keyboard Defaults"
    MatchIsKeyboard     "yes" # this is relevant
    # MatchProduct "Microsoft Comfort Curve Keyboard 2000" # you can treat them differently
    Option              "XkbLayout" "de,fr" # comma separated list of layouts
    Option              "XkbVariant" "deadgraveacute" # variants to your preference
    # Option              "XkbModel" "microsofccurve2k" # you can even specify the preferred model over pc104
    Option              "XkbOptions" "terminate:ctrl_alt_bksp,compose:caps" # the relevant line, but i prefer it as compose key ;-)
    # Option              "XkbRules" "xorg" # enforce rules
    # Option              "XkbKeycodes" "evdev" # enforce driver
EndSection


Those rules will be auto-applied on adding keyboards (same is possible for mice)



I will experiment with this, as in fact I do want this behaviour for all keyboards.

Thank you very much!


dotancohen, proud to be a member of KDE forums since 2008-Oct.


Bookmarks



Who is online

Registered users: Bing [Bot], Evergrowing, Google [Bot]