refactor: nixify / clean remaining dots scripts

This commit is contained in:
hektor committed 2026-11-06 21:00:20 +01:00
1 parent 9030f33842
commit 9110789527
53 files changed
+265 -655

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
# Anki review percentage for statusbar
num_to_review=200
# Get current card count from Anki
count=$(curl -s 127.0.0.1:8765 -X POST -d '{"action": "getNumCardsReviewedToday", "version": 6}' | jq '.result') || count=
if [ -n "$count" ]; then
echo "$count" > "$ANKI_REVIEWS"
elif [ ! -s "$ANKI_REVIEWS" ]; then
echo "-1" > "$ANKI_REVIEWS"
fi
num_reviews=$(cat "$ANKI_REVIEWS")
echo -n " Reviews: $(awk -v n="$num_reviews" -v t="$num_to_review" 'BEGIN { printf "%.2f%%", 100 * n / t }') "
+2
View File
@@ -0,0 +1,2 @@
pomo="${XDG_DATA_HOME:-$HOME/.local/share}/pomo"
if [ -f "$pomo" ]; then cat "$pomo"; fi
+2
View File
@@ -0,0 +1,2 @@
# Render contents of $HOME/.project if present
if [ -f "$HOME/.project" ]; then cat "$HOME/.project"; fi
+5
View File
@@ -0,0 +1,5 @@
num_done="$(task end.after:today status:completed count)"
num_pending="$(($(task count status:pending) + num_done))"
num_waiting="$(task count status:waiting)"
echo "Tasks: $num_done/$num_pending+$num_waiting"
+110 -54
View File
@@ -1,59 +1,115 @@
{
config,
lib,
pkgs,
...
}:
let
status =
name: args:
lib.getExe (
pkgs.writeShellApplication (
{
inherit name;
text = builtins.readFile ./scripts/${name};
}
// args
)
);
in
{
programs.waybar.settings = [
{
height = 16;
spacing = 4;
modules-left = [ "niri/workspaces" ];
modules-right = [
"pulseaudio"
"memory"
"cpu"
"network"
"clock"
"battery"
];
clock = {
format = "W{:%V %d %b %H:%M}";
tooltip-format = "{calendar}";
format-alt = "{:%Y-%m-%d %H:%M:%S}";
};
battery = {
bat = "BAT0";
adapter = "ADP1";
interval = 5;
full-at = 99;
states = {
good = 80;
warning = 20;
critical = 10;
(
{
height = 16;
spacing = 4;
modules-left = [ "niri/workspaces" ];
modules-right = [
"custom/project"
"custom/pomo"
]
++ lib.optional config.taskwarrior.enable "custom/tasks"
++ lib.optional config.anki.enable "custom/anki"
++ [
"pulseaudio"
"memory"
"cpu"
"network"
"clock"
"battery"
];
clock = {
format = "W{:%V %d %b %H:%M}";
tooltip-format = "{calendar}";
format-alt = "{:%Y-%m-%d %H:%M:%S}";
};
format = "{capacity}%--";
format-charging = "{capacity}%++";
format-plugged = "{capacity}%";
format-alt = "{time} {power}W";
};
pulseaudio = {
format = "VOL {volume}%";
format-muted = "muted";
on-click = "pavucontrol";
};
memory = {
interval = 2;
format = "RAM {percentage}%";
format-alt = "RAM {used:0.1f}G/{total:0.1f}G";
};
cpu = {
interval = 2;
format = "CPU {usage}%";
format-alt = "CPU {avg_frequency}GHz";
};
network = {
interval = 5;
format-wifi = "{ifname} {ipaddr} {essid}";
format-ethernet = "{ifname} {ipaddr}";
format-disconnected = "{ifname} disconnected";
tooltip-format = "{ifname}: {ipaddr}/{cidr}";
};
}
battery = {
bat = "BAT0";
adapter = "ADP1";
interval = 5;
full-at = 99;
states = {
good = 80;
warning = 20;
critical = 10;
};
format = "{capacity}%--";
format-charging = "{capacity}%++";
format-plugged = "{capacity}%";
format-alt = "{time} {power}W";
};
pulseaudio = {
format = "VOL {volume}%";
format-muted = "muted";
on-click = "pavucontrol";
};
memory = {
interval = 2;
format = "RAM {percentage}%";
format-alt = "RAM {used:0.1f}G/{total:0.1f}G";
};
cpu = {
interval = 2;
format = "CPU {usage}%";
format-alt = "CPU {avg_frequency}GHz";
};
network = {
interval = 5;
format-wifi = "{ifname} {ipaddr} {essid}";
format-ethernet = "{ifname} {ipaddr}";
format-disconnected = "{ifname} disconnected";
tooltip-format = "{ifname}: {ipaddr}/{cidr}";
};
"custom/project" = {
exec = status "sb-project" { runtimeInputs = [ pkgs.coreutils ]; };
interval = 30;
};
"custom/pomo" = {
exec = status "sb-pomo" { runtimeInputs = [ pkgs.coreutils ]; };
interval = 1;
};
}
// lib.optionalAttrs config.taskwarrior.enable {
"custom/tasks" = {
exec = status "sb-tasks" { runtimeInputs = [ config.programs.taskwarrior.package ]; };
interval = 60;
};
}
// lib.optionalAttrs config.anki.enable {
"custom/anki" = {
exec = status "sb-anki" {
runtimeInputs = with pkgs; [
coreutils
curl
gawk
jq
];
runtimeEnv.ANKI_REVIEWS = config.anki.reviewsCache;
};
interval = 300;
};
}
)
];
}