Swayscript: Silent on DND.

This commit is contained in:
Dmitry Voronin 2024-11-22 18:44:10 +03:00
parent a2d1a3af88
commit 74609a80d8
Signed by: voronind
SSH key fingerprint: SHA256:3kBb4iV2ahufEBNq+vFbUe4QYfHt98DHQjN7QaptY9k
9 changed files with 33 additions and 18 deletions

View file

@ -20,7 +20,7 @@ in {
margin = 32;
max-history = max;
max-visible = max;
on-notify = "exec ${pkgs.pipewire}/bin/pw-cat -p ${<static/Notification.ogg>}";
on-notify = "exec swayscript notify";
text-color = "#${config.module.style.color.bg.dark}";
width = 480;
};

View file

@ -16,8 +16,8 @@
selection = "slurp -d -b ${color.bg.light}${opacity} -c ${color.fg.light} -w 0 -s 00000000";
in {
text = let
notifyStart = "${pkgs.pipewire}/bin/pw-cat -p ${<static/Short.ogg>} &";
notifyEnd = "${pkgs.pipewire}/bin/pw-cat -p ${<static/Long.ogg>} &";
notifyStart = ''swayscript notify_short'';
notifyEnd = ''swayscript notify_long'';
picEdit = ''swappy -f - -o -'';
picFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -'';
picPrepFile = prepFile "\${XDG_PICTURES_DIR[0]}" "png";

View file

@ -2,5 +2,4 @@
pkgs,
util,
...
} @args:
pkgs.writeShellScriptBin "swayscript" (util.catText (util.ls ./script) args + "\${@}")
} @args: pkgs.writeShellScriptBin "swayscript" (util.catText (util.ls ./script) args + "\${@}")

View file

@ -1,7 +1,7 @@
{ ... }: {
text = ''
function monitor() {
_notify_short
notify_short
toggle() {
local output=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name')
local state=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .power')
@ -23,7 +23,7 @@
}
function gaming() {
_notify_short
notify_short
toggle() {
local output=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name')
local state=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .adaptive_sync_status')
@ -45,13 +45,14 @@
}
function dnd() {
_notify_short
toggle() {
local state=$(makoctl mode)
if [[ "''${state}" = "dnd" ]]; then
makoctl mode -s default
notify_short
else
notify_short
makoctl mode -s dnd
fi

View file

@ -0,0 +1,22 @@
{
__findFile,
pkgs,
...
}: {
text = ''
function notify() {
[[ "''$(dndstate)" = "Y" ]] && return
${pkgs.pipewire}/bin/pw-cat -p ${<static/Notification.ogg>} &
}
function notify_short() {
[[ "''$(dndstate)" = "Y" ]] && return
${pkgs.pipewire}/bin/pw-cat -p ${<static/Short.ogg>} &
}
function notify_long() {
[[ "''$(dndstate)" = "Y" ]] && return
${pkgs.pipewire}/bin/pw-cat -p ${<static/Long.ogg>} &
}
'';
}

View file

@ -2,6 +2,7 @@
text = ''
# Kill all windows in Sway scratchpad.
function scratchpad_kill() {
notify_short
kill() {
for window in $(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?) | select(.name == "__i3_scratch").floating_nodes[].id'); do
swaymsg [ con_id="$window" ] kill

View file

@ -1,7 +1,7 @@
{ ... }: {
text = ''
function sound_output_cycle() {
_notify_short
notify_short
local IFS=$'\n'
local current=$(pactl get-default-sink)
local all=($(pactl list short sinks | cut -f2))

View file

@ -15,13 +15,5 @@
SWAYSOCK="''${socket}" ''${1}
done
}
function _notify_short() {
${pkgs.pipewire}/bin/pw-cat -p ${<static/Short.ogg>} &
}
function _notify_long() {
${pkgs.pipewire}/bin/pw-cat -p ${<static/Long.ogg>} &
}
'';
}

View file

@ -2,7 +2,7 @@
text = ''
# Toggle vpn.
function vpn() {
_notify_short
notify_short
if [[ "$(_vpn)" = "on" ]]; then
nmcli connection down vpn
else