Skip to content

Instantly share code, notes, and snippets.

@luminoso
Created May 15, 2024 10:56
Show Gist options
  • Save luminoso/1ecce7cabfdd815c170a72d264b2fe9c to your computer and use it in GitHub Desktop.
Save luminoso/1ecce7cabfdd815c170a72d264b2fe9c to your computer and use it in GitHub Desktop.
Sets KDE plasma 6 Inhibited (do not disturb) state by command. Useful for fokus
#!/bin/bash
# Sets KDE plasma 6 Inhibited (do not disturb) state by command
toogle() {
qdbus-qt6 org.kde.kglobalaccel /component/plasmashell invokeShortcut "toggle do not disturb"
}
on_off() {
current_state=$(qdbus-qt6 org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.Inhibited)
if [[ $current_state != "$1" ]]; then
# echo "Switching..."
toogle
else
:
# echo "did nothing"
fi
}
validate_args() {
if [[ $1 -ne 1 || ("$2" != "true" && "$2" != "false") ]]; then
>&2 echo "Wrong arguments provided. Use 'false' or 'true' to set the Inhibited state"
exit 1
fi
}
validate_args $# "$1"
on_off "$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment