aboutsummaryrefslogtreecommitdiffstats
path: root/modules/system/system-monitor
diff options
context:
space:
mode:
Diffstat (limited to 'modules/system/system-monitor')
-rw-r--r--modules/system/system-monitor/assertions.nix19
-rw-r--r--modules/system/system-monitor/default.nix41
-rw-r--r--modules/system/system-monitor/system-monitor.sh26
3 files changed, 86 insertions, 0 deletions
diff --git a/modules/system/system-monitor/assertions.nix b/modules/system/system-monitor/assertions.nix
new file mode 100644
index 0000000..08b9f7c
--- /dev/null
+++ b/modules/system/system-monitor/assertions.nix
@@ -0,0 +1,19 @@
+{ config, ... }:
+[
+ {
+ assertion = !config.system.system-monitor.enable || config.system.bottom.enable;
+ message = "system.system-monitor is enabled but requires `system.bottom.enable`.";
+ }
+ {
+ assertion = !config.system.system-monitor.enable || config.system.nvtop.enable;
+ message = "system.system-monitor is enabled but requires `system.nvtop.enable`.";
+ }
+ {
+ assertion = !config.system.system-monitor.enable || config.terminal.tmux.enable;
+ message = "system.system-monitor is enabled but requires `terminal.tmux.enable`.";
+ }
+ {
+ assertion = !config.system.system-monitor.enable || config.terminal.kitty.enable;
+ message = "system.system-monitor is enabled but requires `terminal.kitty.enable`.";
+ }
+]
diff --git a/modules/system/system-monitor/default.nix b/modules/system/system-monitor/default.nix
new file mode 100644
index 0000000..e103ed3
--- /dev/null
+++ b/modules/system/system-monitor/default.nix
@@ -0,0 +1,41 @@
+# System monitor script using tmux to run bottom and nvtop side-by-side
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+let
+ inherit ((import ../../lib/script.nix { inherit lib pkgs; })) mkScriptModule;
+ script = mkScriptModule {
+ scope = [ "system" ];
+ name = "system-monitor";
+ path = ./system-monitor.sh;
+ description = "System monitor script using tmux to run bottom and nvtop side-by-side\nOpens a tmux session with:\n - Left pane: bottom (system/process monitor)\n - Right pane: nvtop (GPU monitor)";
+ deps = [
+ config.system.bottom.package
+ config.system.nvtop.package
+ config.terminal.tmux.package
+ config.terminal.kitty.package
+ pkgs.bash
+ ];
+ desktop = {
+ enable = true;
+ displayName = "System Monitor";
+ icon = "bottom-system-monitor";
+ };
+ inherit config;
+ };
+in
+{
+ options = script.options;
+ config = lib.mkMerge [
+ script.config
+ {
+ assertions = import ./assertions.nix { inherit config lib; };
+ home.file.".local/share/icons/hicolor/scalable/apps/bottom-system-monitor.svg" = {
+ source = ../../../assets/icons/bottom-system-monitor.svg;
+ };
+ }
+ ];
+}
diff --git a/modules/system/system-monitor/system-monitor.sh b/modules/system/system-monitor/system-monitor.sh
new file mode 100644
index 0000000..7a9e7ea
--- /dev/null
+++ b/modules/system/system-monitor/system-monitor.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+SESSION="system-monitor"
+
+kitty @ set-font-size -- -5
+
+cleanup() {
+ kitty @ set-font-size -- +5
+}
+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"