Flake for my NixOS devices
1#!/usr/bin/env nu
2
3const SILENCED_APP_NAMES = [
4 "vesktop",
5 "discord",
6 "thunderbird",
7 "newsboat"
8]
9
10const APP_SOUNDS = {
11 "simplescreenrecorder": "camera-click",
12 "screengrab": "camera-click",
13 "battery-notif": "critical",
14 "kde connect": "pixel-notif",
15 "DEFAULT": "notif",
16}
17
18let name = $env.SWAYNC_APP_NAME? | default "" | str downcase
19
20# let LOG_FILE = $"($env.HOME)/.sawync-app-log.txt";
21
22# let log = if ($LOG_FILE | path exists) {
23# (open $LOG_FILE) | lines
24# } else {
25# []
26# };
27
28# $log | append $name | str join "\n" | save -f $LOG_FILE
29
30def main [sounds_path: string] {
31 let dnd = swaync-client -D | from json;
32 if (not $dnd) and ($name not-in $SILENCED_APP_NAMES) {
33 let sound = $APP_SOUNDS | get -o $name | default $APP_SOUNDS.DEFAULT;
34 aplay $"($sounds_path)/($sound).wav"
35 }
36}