Map systemsettings5 to a devd event

driesm

Developer
Hi all,

I'm running kde5 and would like to map the function key "settings" on my laptop to opening the GUI window of systemsettings5 in KDE Plasma.
For this I know what button press I must map, but I can't seem to wrap my head around what command I must run so that it gets attached to my session and the window opens. When I'm logged in and simply run "systemsettings5" it works fine. But when run from a devd script it doesn't. Any help would be appreciated. Below you can find my devd mapping script, which I known functionally works :)
I have tried using Xauthority, and the naked command as such but now I'm stuck. The action I'm trying to get to work is under "Ox1d) # Settings" in the script.

Code:
#!/bin/sh
case $1 in
        0x1b) # Microphone mute
                LEVEL=`sysctl -n dev.acpi_ibm.0.mic_led`
                if [ "$LEVEL" = "1" ]
                then
                        sysctl dev.acpi_ibm.0.mic_led=0
                else
                        sysctl dev.acpi_ibm.0.mic_led=1
                fi
                ;;
        Ox07) # Switch screen
                ;;
        Ox05) # WIFI
                LEVEL=`sysctl -n dev.acpi_ibm.0.wlan`
                if [ "$LEVEL" = "1" ]
                then
                        sysctl dev.acpi_ibm.0.wlan=0
                else
                        sysctl dev.acpi_ibm.0.wlan=1
                fi
                ;;
        Ox1d) # Settings
                /usr/bin/su dries -c 'env XAUTHORITY=/home/dries/.Xauthority DISPLAY=:0 /usr/local/bin/systemsettings5'
                ;;
        0x14) # Bluetooth
                LEVEL=`sysctl -n dev.acpi_ibm.0.bluetooth`
                if [ "$LEVEL" = "1" ]
                then
                        sysctl dev.acpi_ibm.0.bluetooth=0
                else
                        sysctl dev.acpi_ibm.0.bluetooth=1
                fi
                ;;
        0x15) # Keyboard
                ;;
        0x11) # Favorites
                ;;
        *)
esac
exit 0
 
I think you have to test that yourself since it varies depending on the device. I also have never tested the function keys and my current keyboard dont have any one.

Edit: While looking at /usr/bin/su dries -c 'env XAUTHORITY=/home/dries/.Xauthority DISPLAY=:0 /usr/local/bin/systemsettings5'

Does systemsettings5 gets executed as normal user? Because you can not run KDE apps as root.
 
I have tried through system settings but KDE does not "see" my function keys when pressed which means I can not use it as a trigger for a custom shortcut for example.
To answer your question, yes it is being executed as a normal user, dries (hence the su dries -c "command here").
Configuring this in systemsettings would have been ideal but my function keys aren't recognized in there, sadge.
 
Back
Top