diff --git a/README.md b/README.md index 2bfa44b..5de6365 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ Post your setup here: [Config flex 💪](https://github.com/ErikReider/SwayNotif - A panel to view previous notifications - Show album art for notifications like Spotify - Do not disturb +- Inhibiting notifications through DBUS or client - Restores previous Do not disturb value after restart - Click notification to execute default action - Show alternative notification actions @@ -278,7 +279,11 @@ Waybar config "notification": "", "none": "", "dnd-notification": "", - "dnd-none": "" + "dnd-none": "", + "inhibited-notification": "", + "inhibited-none": "", + "dnd-inhibited-notification": "", + "dnd-inhibited-none": "" }, "return-type": "json", "exec-if": "which swaync-client", diff --git a/completions/bash/swaync-client b/completions/bash/swaync-client index d6ac6f5..35ea571 100644 --- a/completions/bash/swaync-client +++ b/completions/bash/swaync-client @@ -14,6 +14,11 @@ _swaync-client() { -D -dn -df + -I + -In + -Ia + -Ir + -Ic -c -C -sw @@ -33,6 +38,11 @@ _swaync-client() { --get-dnd --dnd-on --dnd-off + --get-inhibited + --get-num-inhibitors + --inhibitor-add + --inhibitor-remove + --inhibitors-clear --count --hide-latest --close-latest diff --git a/completions/fish/swaync-client.fish b/completions/fish/swaync-client.fish index 065d956..e2ff10f 100644 --- a/completions/fish/swaync-client.fish +++ b/completions/fish/swaync-client.fish @@ -10,6 +10,11 @@ complete -c swaync-client -s d -l toggle-dnd --description "Toggle and print the complete -c swaync-client -s D -l get-dnd --description "Print the current dnd state" -r complete -c swaync-client -s dn -l dnd-on --description "Turn dnd on and print the new dnd state" -r complete -c swaync-client -s df -l dnd-off --description "Turn dnd off and print the new dnd state" -r +complete -c swaync-client -s I -l get-inhibited --description "Print if currently inhibited or not" -r +complete -c swaync-client -s In -l get-num-inhibitors --description "Print number of inhibitors" -r +complete -c swaync-client -s Ia -l inhibitor-add --description "Add an inhibitor" -r +complete -c swaync-client -s Ir -l inhibitor-remove --description "Remove an inhibitor" -r +complete -c swaync-client -s Ic -l inhibitors-clear --description "Clears all inhibitors" -r complete -c swaync-client -s c -l count --description "Print the current notificaion count" -r complete -c swaync-client -l hide-latest --description "Hides latest notification. Still shown in Control Center" -r complete -c swaync-client -l close-latest --description "Closes latest notification" -r diff --git a/completions/zsh/_swaync-client b/completions/zsh/_swaync-client index 758c214..b18a84a 100644 --- a/completions/zsh/_swaync-client +++ b/completions/zsh/_swaync-client @@ -12,6 +12,11 @@ _arguments -s \ '(-D --get-dnd)'{-D,--get-dnd}'[Print the current dnd state]' \ '(-dn --dnd-on)'{-dn,--dnd-on}'[Turn dnd on and print the new dnd state]' \ '(-df --dnd-off)'{-df,--dnd-off}'[Turn dnd off and print the new dnd state]' \ + '(-I --get-inhibited)'{-I,--get-inhibited}'[Print if currently inhibited or not]' \ + '(-In --get-num-inhibitors)'{-In,--get-num-inhibitors}'[Print number of inhibitors]' \ + '(-Ia --inhibitor-add)'{-Ia,--inhibitor-add}'[Add an inhibitor]' \ + '(-Ir --inhibitor-remove)'{-Ir,--inhibitor-remove}'[Remove an inhibitor]' \ + '(-Ic --inhibitors-clear)'{-Ic,--inhibitors-clear}'[Clears all inhibitors]' \ '(-c --count)'{-c,--count}'[Print the current notificaion count]' \ '(--hide-latest)'--hide-latest'[Closes all notifications]' \ '(--close-latest)'--close-latest'[Hides latest notification. Still shown in Control Center]' \ diff --git a/man/swaync-client.1.scd b/man/swaync-client.1.scd index af71613..8c7596d 100644 --- a/man/swaync-client.1.scd +++ b/man/swaync-client.1.scd @@ -43,6 +43,21 @@ swaync-client - Client executable *-df, --dnd-off* Turn dnd off and print the new dnd state +*-I, --get-inhibited* + Print if currently inhibited or not + +*-In, --get-num-inhibitors* + Print number of inhibitors + +*-Ia, --inhibitor-add [APP_ID]* + Add an inhibitor + +*-Ir, --inhibitor-remove [APP_ID]* + Remove an inhibitor + +*-Ic, --inhibitors-clear* + Clears all inhibitors + *-c, --count* Print the current notificaion count diff --git a/man/swaync.1.scd b/man/swaync.1.scd index d4a0541..a5140de 100644 --- a/man/swaync.1.scd +++ b/man/swaync.1.scd @@ -129,7 +129,11 @@ Waybar config "notification": "", "none": "", "dnd-notification": "", - "dnd-none": "" + "dnd-none": "", + "inhibited-notification": "", + "inhibited-none": "", + "dnd-inhibited-notification": "", + "dnd-inhibited-none": "" }, "return-type": "json", "exec-if": "which swaync-client", diff --git a/man/swaync.5.scd b/man/swaync.5.scd index 369136e..ba83f55 100644 --- a/man/swaync.5.scd +++ b/man/swaync.5.scd @@ -199,6 +199,8 @@ config file to be able to detect config errors optional: true ++ *buttons-grid*++ optional: true ++ + *inhibitors*++ + optional: true ++ description: ++ Which order and which widgets to display. ++ If the \"notifications\" widget isn't specified, it ++ @@ -211,6 +213,7 @@ config file to be able to detect config errors ``` { "widgets": [ + "inhibitors", "title", "dnd", "notifications" @@ -407,7 +410,27 @@ config file to be able to detect config errors optional: true ++ default: 0 ++ description: Lowest possible value for brightness ++ - description: Slider to control screen brightness ++ + description: Slider to control screen brightness ++ + *inhibitors*++ + type: object ++ + css class: widget-inhibitors ++ + properties: ++ + text: ++ + type: string ++ + optional: true ++ + default: "Inhibitors" ++ + description: The title of the widget ++ + clear-all-button: ++ + type: bool ++ + optional: true ++ + default: true ++ + description: Whether to display a "Clear All" button ++ + button-text: ++ + type: string ++ + optional: true ++ + default: "Clear All" ++ + description: "Clear All" button text ++ + description: Displayed if notifications are inhibited. example: ``` diff --git a/src/client.vala b/src/client.vala index ddf06b7..f9c6837 100644 --- a/src/client.vala +++ b/src/client.vala @@ -2,6 +2,7 @@ public struct SwayncDaemonData { public bool dnd; public bool cc_open; public uint count; + public bool inhibited; } [DBus (name = "org.erikreider.swaync.cc")] @@ -32,54 +33,67 @@ interface CcDaemon : Object { [DBus (name = "GetSubscribeData")] public abstract SwayncDaemonData get_subscribe_data () throws Error; - public signal void subscribe (uint count, bool dnd, bool cc_open); + public signal void subscribe_v2 (uint count, bool dnd, bool cc_open, bool inhibited); + + public abstract bool add_inhibitor (string application_id) throws DBusError, IOError; + public abstract bool remove_inhibitor (string application_id) throws DBusError, IOError; + public abstract uint number_of_inhibitors () throws DBusError, IOError; + public abstract bool is_inhibited () throws DBusError, IOError; + public abstract bool clear_inhibitors () throws DBusError, IOError; } private CcDaemon cc_daemon = null; private void print_help (string[] args) { print ("Usage:\n"); - print ("\t %s