aboutsummaryrefslogtreecommitdiffstats
path: root/modules/scripts
diff options
context:
space:
mode:
authorArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2025-11-29 00:27:09 +0530
committerArpit Chakladar <54011232+arpitchakladar@users.noreply.github.com>2025-11-29 00:27:09 +0530
commit012f5fc45afc81e18b4ae564ab8207b8c4e02d2a (patch)
treec0319a82c986d117ecccf58e9e6a54fad1236cd8 /modules/scripts
parent170461002890d55718618bec64feaa8856c3a6d4 (diff)
downloadhome-manager-config-012f5fc45afc81e18b4ae564ab8207b8c4e02d2a.tar.gz
home-manager-config-012f5fc45afc81e18b4ae564ab8207b8c4e02d2a.zip
Added a convenience script system-monitor that runs both bottom (for cpu + cpu temps + network monitoring) and nvtop for graphics card mintoring with tmux.
Diffstat (limited to 'modules/scripts')
-rw-r--r--modules/scripts/default.nix10
-rw-r--r--modules/scripts/system-monitor.sh34
2 files changed, 44 insertions, 0 deletions
diff --git a/modules/scripts/default.nix b/modules/scripts/default.nix
index f421543..62769c2 100644
--- a/modules/scripts/default.nix
+++ b/modules/scripts/default.nix
@@ -14,5 +14,15 @@
source = ./restart-network.sh;
executable = true;
};
+ home.file."scripts/system-monitor" =
+ lib.mkIf
+ (config.tools.bottom.enable &&
+ config.tools.nvtop.enable &&
+ config.tools.tmux.enable &&
+ config.tools.kitty.enable)
+ {
+ source = ./system-monitor.sh;
+ executable = true;
+ };
};
}
diff --git a/modules/scripts/system-monitor.sh b/modules/scripts/system-monitor.sh
new file mode 100644
index 0000000..0364a14
--- /dev/null
+++ b/modules/scripts/system-monitor.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+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
+
+# Hover over pane = instant focus
+tmux bind -n MouseDown1Pane select-pane -t= \; send-keys -M
+tmux bind -n MouseDrag1Pane select-pane -t= \; send-keys -M
+
+# Wheel always works in focused pane
+tmux bind -n WheelUpPane select-pane -t= \; send-keys -M
+tmux bind -n WheelDownPane select-pane -t= \; send-keys -M
+
+# Select main pane and attach
+tmux select-pane -t "$SESSION:0.0"
+tmux attach-session -t "$SESSION"