Created
May 15, 2024 10:56
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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