From e0f8006b74bb150a346fc57471a05caa138c92c9 Mon Sep 17 00:00:00 2001 From: Aviv Bintang Aringga <53284815+avivbintangaringga@users.noreply.github.com> Date: Wed, 29 Jul 2026 19:49:09 +0700 Subject: [PATCH] feat(nix-monitor): update version 1.3.0 (#144) * feat(nix-monitor): add system stats check mode * fix(nix-monitor): prevent terminal closing on non-zero exit * fix(nix-monitor): force system stats check when clicking the Check button (if not off) --- nix-monitor/nix_monitor_service.luau | 23 ++++++++++++++++++++--- nix-monitor/panel.luau | 20 ++++++-------------- nix-monitor/plugin.toml | 19 +++++++++++++++---- nix-monitor/translations/en.json | 12 +++++++++++- 4 files changed, 52 insertions(+), 22 deletions(-) diff --git a/nix-monitor/nix_monitor_service.luau b/nix-monitor/nix_monitor_service.luau index 8252cc8..6ae9c47 100644 --- a/nix-monitor/nix_monitor_service.luau +++ b/nix-monitor/nix_monitor_service.luau @@ -68,6 +68,7 @@ setState("isRemoteCheckRunning", false) setState("isUpdateAvailable", false) setState("lastGenerationsCheckTime", 0) setState("isSystemStatsCheckRunning", false) +setState("systemStatsCheckHasBeenPerformed", false) setState("lastSystemStatsCheckTime", os.time()) setState("lastSystemStatsCheckRunTime", os.time()) setState("hasHomeManager", noctalia.commandExists("home-manager")) @@ -167,11 +168,22 @@ function checkGenerations() end -- System stats check -function checkSystemStats() +function checkSystemStats(force) if getState("isSystemStatsCheckRunning") then return end + if cfg("system_stats_check_mode") == "off" then + return + end + + if cfg("system_stats_check_mode") == "on_start" and getState("systemStatsCheckHasBeenPerformed") and not force then + return + end + + setState("storeSize", "•••") + setState("closureSize", "•••") + setState("systemStatsCheckHasBeenPerformed", true) setState("isSystemStatsCheckRunning", true) setState("lastSystemStatsCheckRunTime", os.time()) @@ -216,7 +228,12 @@ end -- Init checkLocalHash() checkRemoteHash(10) -checkSystemStats() +if cfg("system_stats_check_mode") ~= "off" then + checkSystemStats() +else + setState("storeSize", "n/a") + setState("closureSize", "n/a") +end -- Command watcher watchState("command", function(command) @@ -225,7 +242,7 @@ watchState("command", function(command) cancelRemoteCheck() checkRemoteHash() checkGenerations() - checkSystemStats() + checkSystemStats(true) end if command == "cancel" then diff --git a/nix-monitor/panel.luau b/nix-monitor/panel.luau index 2868b48..6a0fe9a 100644 --- a/nix-monitor/panel.luau +++ b/nix-monitor/panel.luau @@ -263,13 +263,7 @@ function onUpdateClicked() noctalia.notifyError(tr("notification.update_command_is_empty")) return end - - if cfg("close_on_enter") then - command = `{command} && echo && read -p "{tr("terminal.press_enter_to_exit")}"` - end - - panel.close() - noctalia.runInTerminal(command) + runCommandInTerminal(command) end function onCleanClicked() @@ -278,13 +272,7 @@ function onCleanClicked() noctalia.notifyError(tr("notification.clean_command_is_empty")) return end - - if cfg("close_on_enter") then - command = `{command} && echo && read -p "{tr("terminal.press_enter_to_exit")}"` - end - - panel.close() - noctalia.runInTerminal(command) + runCommandInTerminal(command) end function onOptimizeClicked() @@ -293,11 +281,15 @@ function onOptimizeClicked() noctalia.notifyError(tr("notification.optimize_command_is_empty")) return end + runCommandInTerminal(command) +end +function runCommandInTerminal(command) if cfg("close_on_enter") then command = `{command} && echo && read -p "{tr("terminal.press_enter_to_exit")}"` end + command = `{command} || (echo && read -p "{tr("terminal.command_exits_non_zero")}")` panel.close() noctalia.runInTerminal(command) end diff --git a/nix-monitor/plugin.toml b/nix-monitor/plugin.toml index d65b9d8..46adb52 100644 --- a/nix-monitor/plugin.toml +++ b/nix-monitor/plugin.toml @@ -1,6 +1,6 @@ id = "avivbintangaringga/nix-monitor" name = "Nix Monitor" -version = "1.2.0" +version = "1.3.0" plugin_api = 3 icon = "package" author = "avivbintangaringga" @@ -128,12 +128,24 @@ default = 5 min = 1 max = 30 +[[setting]] +key = "system_stats_check_mode" +type = "select" +label_key = "setting.system_stats_check_mode.label" +description_key = "setting.system_stats_check_mode.description" +options = [ + { value = "off", label_key="setting.option.system_stats_check_mode.off" }, + { value = "on_interval", label_key="setting.option.system_stats_check_mode.on_interval" }, + { value = "on_start", label_key="setting.option.system_stats_check_mode.on_start" }, +] +default = "on_interval" + [[setting]] key = "system_stats_check_interval" type = "int" label_key = "setting.system_stats_check_interval.label" description_key = "setting.system_stats_check_interval.description" -default = 10 +default = 60 min = 5 [[setting]] @@ -141,9 +153,8 @@ key = "system_stats_check_duration_threshold" type = "int" label_key = "setting.system_stats_check_duration_threshold.label" description_key = "setting.system_stats_check_duration_threshold.description" -default = 5 +default = 15 min = 1 -max = 30 [[setting]] key = "panel_card_color" diff --git a/nix-monitor/translations/en.json b/nix-monitor/translations/en.json index 9b7894e..48820fd 100644 --- a/nix-monitor/translations/en.json +++ b/nix-monitor/translations/en.json @@ -75,6 +75,11 @@ "nixos_26_05_small": "NixOS 26.05 Small", "nixos_unstable": "NixOS Unstable", "nixos_unstable_small": "NixOS Unstable Small" + }, + "system_stats_check_mode": { + "off": "Off", + "on_interval": "On interval", + "on_start": "On start" } }, "show_update_available_notification": { @@ -89,6 +94,10 @@ "description": "Cancel system stats check if it took too long (in minutes)", "label": "System stats check duration threshold" }, + "system_stats_check_mode": { + "description": "Select how system stats checking is performed (off, on interval, on start)", + "label": "System stats check mode" + }, "system_stats_check_interval": { "description": "How often to check for system stats (in minutes)", "label": "System stats check interval" @@ -151,6 +160,7 @@ } }, "terminal": { - "press_enter_to_exit": "Press enter to exit..." + "press_enter_to_exit": "Press enter to exit...", + "command_exits_non_zero": "WARNING: Command exits in a non-zero status!\nPress enter to exit..." } }