Create a shortcut for specific settings

I could be crazy but I seem to recall a recent post about Plasma 6.7 allowing shortcuts to be created for any option in system settings but now I can’t find the post anywhere.

I know there’s a command for opening a page in system settings, but is there a way to toggle a particular setting, in this case middle mouse scrolling (Hold down middle button and move mouse to scroll)?

You could use this script:

What this script does: It creates a bash script file in ~/.local/bin/toggle-middle-scroll loops through all devices then finds the ones that support scrollOnButtonDown option then it toggles that option for each device to true or false (on or off) lastly it makes the bash script executable.

cat > ~/.local/bin/toggle-middle-scroll << 'EOF'
#!/usr/bin/env bash
SERVICE="org.kde.KWin"
IFACE="org.kde.KWin.InputDevice"
METHOD_GET="org.freedesktop.DBus.Properties.Get"
METHOD_SET="org.freedesktop.DBus.Properties.Set"
DBUS_PATH="/org/kde/KWin/InputDevice"

for device in $(qdbus6 $SERVICE $DBUS_PATH $METHOD_GET org.kde.KWin.InputDeviceManager devicesSysNames); do
  path="$DBUS_PATH/$device"
  current=$(qdbus6 $SERVICE "$path" $METHOD_GET "$IFACE" scrollOnButtonDown 2>/dev/null)
  [ -z "$current" ] && continue
  if [ "$current" = "true" ]; then
    qdbus6 $SERVICE "$path" $METHOD_SET "$IFACE" scrollOnButtonDown false
  else
    qdbus6 $SERVICE "$path" $METHOD_SET "$IFACE" scrollOnButtonDown true
  fi
done
EOF

chmod +x ~/.local/bin/toggle-middle-scroll

After running this command you can set a keyboard shortcut by adding a new option in System Settings > Keyboard > Shortcuts and pointing the option to ~/.local/bin/toggle-middle-scroll then you can set the keyboard shortcut you want

Thanks. Is there a way to identify the mouse first instead of looping through all of them? I added a notify-send command and every device is returning that property.
I know the mouse is currently event2 in devicesSysNames but I don’t know if that changes on reboot.

eventN could change, yeah, but the name property shouldn’t :

  1. use this script to get the name properties for all devices then find your event2 name:
qdbus6 org.kde.KWin /org/kde/KWin/InputDevice \
  org.freedesktop.DBus.Properties.Get org.kde.KWin.InputDeviceManager devicesSysNames |
tr -d '[]",' | tr ' ' '\n' |
while read -r dev; do
  name=$(qdbus6 org.kde.KWin /org/kde/KWin/InputDevice/$dev \
    org.freedesktop.DBus.Properties.Get org.kde.KWin.InputDevice name 2>/dev/null)
  echo "$dev -> $name"
done
  1. Replace the executable script from earlier with this one and use that name you found for event2 in the TARGET_NAME variable, for example my mouse is named 2.4G Mouse:
#!/usr/bin/env bash
SERVICE="org.kde.KWin"
IFACE="org.kde.KWin.InputDevice"
METHOD_GET="org.freedesktop.DBus.Properties.Get"
METHOD_SET="org.freedesktop.DBus.Properties.Set"
DBUS_PATH="/org/kde/KWin/InputDevice"

TARGET_NAME="2.4G Mouse"

for device in $(qdbus6 $SERVICE $DBUS_PATH $METHOD_GET org.kde.KWin.InputDeviceManager devicesSysNames); do
  path="$DBUS_PATH/$device"

  name=$(qdbus6 $SERVICE "$path" $METHOD_GET "$IFACE" name 2>/dev/null)
  name=${name//\"/}

  if [[ "$name" != "$TARGET_NAME" ]]; then
    continue
  fi

  current=$(qdbus6 $SERVICE "$path" $METHOD_GET "$IFACE" scrollOnButtonDown 2>/dev/null)
  [ -z "$current" ] && continue

  if [ "$current" = "true" ]; then
    qdbus6 $SERVICE "$path" $METHOD_SET "$IFACE" scrollOnButtonDown false
  else
    qdbus6 $SERVICE "$path" $METHOD_SET "$IFACE" scrollOnButtonDown true
  fi
done

This script will: loop through all the devices > find the device that has the specified name > toggle scrollOnButtonDown only for that device. We still need to loop through the devices cause either there is no “getDeviceByName()” call or I couldn’t find it