mirror of
https://github.com/szymon-jozef/amazing-dotfiles.git
synced 2026-09-07 20:20:43 +02:00
nicer scripting
This commit is contained in:
@@ -6,41 +6,7 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
|
||||||
mako-dnd-script = pkgs.writeShellScriptBin "ashell-mako-dnd" ''
|
|
||||||
case $1 in
|
|
||||||
listen)
|
|
||||||
print_state() {
|
|
||||||
if makoctl mode | grep -q do-not-disturb; then
|
|
||||||
echo '{"alt":"dnd"}'
|
|
||||||
else
|
|
||||||
echo '{"alt":"none"}'
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
trap print_state USR1
|
|
||||||
|
|
||||||
print_state
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
sleep infinity & wait $!
|
|
||||||
done
|
|
||||||
;;
|
|
||||||
|
|
||||||
toggle)
|
|
||||||
if makoctl mode | grep -q do-not-disturb; then
|
|
||||||
makoctl mode -r do-not-disturb > /dev/null
|
|
||||||
else
|
|
||||||
makoctl mode -a do-not-disturb > /dev/null
|
|
||||||
fi
|
|
||||||
|
|
||||||
pkill -USR1 -f "ashell-mako-dnd listen"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
|
|
||||||
programs.ashell = {
|
programs.ashell = {
|
||||||
enable = true;
|
enable = true;
|
||||||
package = lib.mkIf (!isNixOS) null;
|
package = lib.mkIf (!isNixOS) null;
|
||||||
@@ -72,8 +38,31 @@ in
|
|||||||
{
|
{
|
||||||
name = "CustomNotifications";
|
name = "CustomNotifications";
|
||||||
icon = "";
|
icon = "";
|
||||||
command = "${mako-dnd-script}/bin/ashell-mako-dnd toggle";
|
command = "${pkgs.writeShellScript "dnd-toggle" ''
|
||||||
listen_cmd = "${mako-dnd-script}/bin/ashell-mako-dnd listen";
|
if makoctl mode | grep -q do-not-disturb; then
|
||||||
|
makoctl mode -r do-not-disturb > /dev/null
|
||||||
|
else
|
||||||
|
makoctl mode -a do-not-disturb > /dev/null
|
||||||
|
fi
|
||||||
|
pkill -USR1 -f dnd-check
|
||||||
|
''}";
|
||||||
|
listen_cmd = "${pkgs.writeShellScript "dnd-check" ''
|
||||||
|
print_state() {
|
||||||
|
if makoctl mode | grep -q do-not-disturb; then
|
||||||
|
echo '{"alt":"dnd"}'
|
||||||
|
else
|
||||||
|
echo '{"alt":"none"}'
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
trap print_state USR1
|
||||||
|
|
||||||
|
print_state
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
sleep infinity & wait $!
|
||||||
|
done
|
||||||
|
''}";
|
||||||
icons.dnd = "";
|
icons.dnd = "";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user