From 03bd9b6ad5335aff65d9cb6fb1d117b5cb4b7919 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Sat, 18 Jul 2026 14:55:21 +0530 Subject: refactor(scripts): split monolithic module into per-script submodules Extract shared `mkScript` and `mkScriptModule` helpers into `lib.nix` Split each script into `modules/scripts//` with its own `default.nix`, `script.sh`, and `assertions.nix` Remove `conditions` parameter from `mkScriptModule`; move condition assertions into per-script `assertions.nix` files with inline checks and error messages Simplify `mkScriptModule` to return `{ options, moduleConfig }` instead of a module function, taking `config` as a direct parameter Add `description` field to `mkScript` that inserts the description as a `# ` comment between the shebang and env vars Thread `description` through `mkScriptModule` to each `default.nix` Move top comment lines from each `script.sh` into the `description` field and remove from sources to avoid duplication Remove old flat `.sh` files from `modules/scripts/` root --- modules/scripts/system-monitor/script.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 modules/scripts/system-monitor/script.sh (limited to 'modules/scripts/system-monitor/script.sh') diff --git a/modules/scripts/system-monitor/script.sh b/modules/scripts/system-monitor/script.sh new file mode 100644 index 0000000..951428c --- /dev/null +++ b/modules/scripts/system-monitor/script.sh @@ -0,0 +1,25 @@ +SESSION="system-monitor" + +kitty @ set-font-size -- -4 + +cleanup() { + kitty @ set-font-size -- +4 +} +trap cleanup EXIT INT TERM + +# Kill any existing session +tmux kill-session -t "$SESSION" 2>/dev/null + +# Start new tmux session with btm wrapped to kill session on exit +tmux new-session -d -s "$SESSION" -c "$HOME" "bash -c 'btm; tmux kill-session -t $SESSION'" + +# Split horizontally: right pane runs nvtop wrapped similarly +tmux split-window -h -t "$SESSION:0" -c "$HOME" "bash -c 'nvtop; tmux kill-session -t $SESSION'" + +tmux set -g status off +tmux set -g mouse on +tmux set -g focus-events on + +# Select main pane and attach +tmux select-pane -t "$SESSION:0.0" +tmux attach-session -t "$SESSION" -- cgit v1.2.3