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)
This commit is contained in:
@@ -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
|
||||
|
||||
+6
-14
@@ -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
|
||||
|
||||
+15
-4
@@ -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"
|
||||
|
||||
@@ -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..."
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user