Swayscript: Silent on DND.
This commit is contained in:
parent
a2d1a3af88
commit
74609a80d8
|
@ -20,7 +20,7 @@ in {
|
||||||
margin = 32;
|
margin = 32;
|
||||||
max-history = max;
|
max-history = max;
|
||||||
max-visible = 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}";
|
text-color = "#${config.module.style.color.bg.dark}";
|
||||||
width = 480;
|
width = 480;
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,8 +16,8 @@
|
||||||
selection = "slurp -d -b ${color.bg.light}${opacity} -c ${color.fg.light} -w 0 -s 00000000";
|
selection = "slurp -d -b ${color.bg.light}${opacity} -c ${color.fg.light} -w 0 -s 00000000";
|
||||||
in {
|
in {
|
||||||
text = let
|
text = let
|
||||||
notifyStart = "${pkgs.pipewire}/bin/pw-cat -p ${<static/Short.ogg>} &";
|
notifyStart = ''swayscript notify_short'';
|
||||||
notifyEnd = "${pkgs.pipewire}/bin/pw-cat -p ${<static/Long.ogg>} &";
|
notifyEnd = ''swayscript notify_long'';
|
||||||
picEdit = ''swappy -f - -o -'';
|
picEdit = ''swappy -f - -o -'';
|
||||||
picFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -'';
|
picFull = ''-o $(swaymsg -t get_outputs | jq -r ".[] | select(.focused) | .name") -'';
|
||||||
picPrepFile = prepFile "\${XDG_PICTURES_DIR[0]}" "png";
|
picPrepFile = prepFile "\${XDG_PICTURES_DIR[0]}" "png";
|
||||||
|
|
|
@ -2,5 +2,4 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
util,
|
util,
|
||||||
...
|
...
|
||||||
} @args:
|
} @args: pkgs.writeShellScriptBin "swayscript" (util.catText (util.ls ./script) args + "\${@}")
|
||||||
pkgs.writeShellScriptBin "swayscript" (util.catText (util.ls ./script) args + "\${@}")
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{ ... }: {
|
{ ... }: {
|
||||||
text = ''
|
text = ''
|
||||||
function monitor() {
|
function monitor() {
|
||||||
_notify_short
|
notify_short
|
||||||
toggle() {
|
toggle() {
|
||||||
local output=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name')
|
local output=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name')
|
||||||
local state=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .power')
|
local state=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .power')
|
||||||
|
@ -23,7 +23,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function gaming() {
|
function gaming() {
|
||||||
_notify_short
|
notify_short
|
||||||
toggle() {
|
toggle() {
|
||||||
local output=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name')
|
local output=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .name')
|
||||||
local state=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .adaptive_sync_status')
|
local state=$(swaymsg -t get_outputs | jq -r '.[] | select(.focused) | .adaptive_sync_status')
|
||||||
|
@ -45,13 +45,14 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function dnd() {
|
function dnd() {
|
||||||
_notify_short
|
|
||||||
toggle() {
|
toggle() {
|
||||||
local state=$(makoctl mode)
|
local state=$(makoctl mode)
|
||||||
|
|
||||||
if [[ "''${state}" = "dnd" ]]; then
|
if [[ "''${state}" = "dnd" ]]; then
|
||||||
makoctl mode -s default
|
makoctl mode -s default
|
||||||
|
notify_short
|
||||||
else
|
else
|
||||||
|
notify_short
|
||||||
makoctl mode -s dnd
|
makoctl mode -s dnd
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
22
package/swayscript/script/Notify.nix
Normal file
22
package/swayscript/script/Notify.nix
Normal 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>} &
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
}
|
|
@ -2,6 +2,7 @@
|
||||||
text = ''
|
text = ''
|
||||||
# Kill all windows in Sway scratchpad.
|
# Kill all windows in Sway scratchpad.
|
||||||
function scratchpad_kill() {
|
function scratchpad_kill() {
|
||||||
|
notify_short
|
||||||
kill() {
|
kill() {
|
||||||
for window in $(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?) | select(.name == "__i3_scratch").floating_nodes[].id'); do
|
for window in $(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?) | select(.name == "__i3_scratch").floating_nodes[].id'); do
|
||||||
swaymsg [ con_id="$window" ] kill
|
swaymsg [ con_id="$window" ] kill
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{ ... }: {
|
{ ... }: {
|
||||||
text = ''
|
text = ''
|
||||||
function sound_output_cycle() {
|
function sound_output_cycle() {
|
||||||
_notify_short
|
notify_short
|
||||||
local IFS=$'\n'
|
local IFS=$'\n'
|
||||||
local current=$(pactl get-default-sink)
|
local current=$(pactl get-default-sink)
|
||||||
local all=($(pactl list short sinks | cut -f2))
|
local all=($(pactl list short sinks | cut -f2))
|
||||||
|
|
|
@ -15,13 +15,5 @@
|
||||||
SWAYSOCK="''${socket}" ''${1}
|
SWAYSOCK="''${socket}" ''${1}
|
||||||
done
|
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>} &
|
|
||||||
}
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
text = ''
|
text = ''
|
||||||
# Toggle vpn.
|
# Toggle vpn.
|
||||||
function vpn() {
|
function vpn() {
|
||||||
_notify_short
|
notify_short
|
||||||
if [[ "$(_vpn)" = "on" ]]; then
|
if [[ "$(_vpn)" = "on" ]]; then
|
||||||
nmcli connection down vpn
|
nmcli connection down vpn
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue