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("isUpdateAvailable", false)
|
||||||
setState("lastGenerationsCheckTime", 0)
|
setState("lastGenerationsCheckTime", 0)
|
||||||
setState("isSystemStatsCheckRunning", false)
|
setState("isSystemStatsCheckRunning", false)
|
||||||
|
setState("systemStatsCheckHasBeenPerformed", false)
|
||||||
setState("lastSystemStatsCheckTime", os.time())
|
setState("lastSystemStatsCheckTime", os.time())
|
||||||
setState("lastSystemStatsCheckRunTime", os.time())
|
setState("lastSystemStatsCheckRunTime", os.time())
|
||||||
setState("hasHomeManager", noctalia.commandExists("home-manager"))
|
setState("hasHomeManager", noctalia.commandExists("home-manager"))
|
||||||
@@ -167,11 +168,22 @@ function checkGenerations()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- System stats check
|
-- System stats check
|
||||||
function checkSystemStats()
|
function checkSystemStats(force)
|
||||||
if getState("isSystemStatsCheckRunning") then
|
if getState("isSystemStatsCheckRunning") then
|
||||||
return
|
return
|
||||||
end
|
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("isSystemStatsCheckRunning", true)
|
||||||
setState("lastSystemStatsCheckRunTime", os.time())
|
setState("lastSystemStatsCheckRunTime", os.time())
|
||||||
|
|
||||||
@@ -216,7 +228,12 @@ end
|
|||||||
-- Init
|
-- Init
|
||||||
checkLocalHash()
|
checkLocalHash()
|
||||||
checkRemoteHash(10)
|
checkRemoteHash(10)
|
||||||
checkSystemStats()
|
if cfg("system_stats_check_mode") ~= "off" then
|
||||||
|
checkSystemStats()
|
||||||
|
else
|
||||||
|
setState("storeSize", "n/a")
|
||||||
|
setState("closureSize", "n/a")
|
||||||
|
end
|
||||||
|
|
||||||
-- Command watcher
|
-- Command watcher
|
||||||
watchState("command", function(command)
|
watchState("command", function(command)
|
||||||
@@ -225,7 +242,7 @@ watchState("command", function(command)
|
|||||||
cancelRemoteCheck()
|
cancelRemoteCheck()
|
||||||
checkRemoteHash()
|
checkRemoteHash()
|
||||||
checkGenerations()
|
checkGenerations()
|
||||||
checkSystemStats()
|
checkSystemStats(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
if command == "cancel" then
|
if command == "cancel" then
|
||||||
|
|||||||
+6
-14
@@ -263,13 +263,7 @@ function onUpdateClicked()
|
|||||||
noctalia.notifyError(tr("notification.update_command_is_empty"))
|
noctalia.notifyError(tr("notification.update_command_is_empty"))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
runCommandInTerminal(command)
|
||||||
if cfg("close_on_enter") then
|
|
||||||
command = `{command} && echo && read -p "{tr("terminal.press_enter_to_exit")}"`
|
|
||||||
end
|
|
||||||
|
|
||||||
panel.close()
|
|
||||||
noctalia.runInTerminal(command)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function onCleanClicked()
|
function onCleanClicked()
|
||||||
@@ -278,13 +272,7 @@ function onCleanClicked()
|
|||||||
noctalia.notifyError(tr("notification.clean_command_is_empty"))
|
noctalia.notifyError(tr("notification.clean_command_is_empty"))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
runCommandInTerminal(command)
|
||||||
if cfg("close_on_enter") then
|
|
||||||
command = `{command} && echo && read -p "{tr("terminal.press_enter_to_exit")}"`
|
|
||||||
end
|
|
||||||
|
|
||||||
panel.close()
|
|
||||||
noctalia.runInTerminal(command)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function onOptimizeClicked()
|
function onOptimizeClicked()
|
||||||
@@ -293,11 +281,15 @@ function onOptimizeClicked()
|
|||||||
noctalia.notifyError(tr("notification.optimize_command_is_empty"))
|
noctalia.notifyError(tr("notification.optimize_command_is_empty"))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
runCommandInTerminal(command)
|
||||||
|
end
|
||||||
|
|
||||||
|
function runCommandInTerminal(command)
|
||||||
if cfg("close_on_enter") then
|
if cfg("close_on_enter") then
|
||||||
command = `{command} && echo && read -p "{tr("terminal.press_enter_to_exit")}"`
|
command = `{command} && echo && read -p "{tr("terminal.press_enter_to_exit")}"`
|
||||||
end
|
end
|
||||||
|
|
||||||
|
command = `{command} || (echo && read -p "{tr("terminal.command_exits_non_zero")}")`
|
||||||
panel.close()
|
panel.close()
|
||||||
noctalia.runInTerminal(command)
|
noctalia.runInTerminal(command)
|
||||||
end
|
end
|
||||||
|
|||||||
+15
-4
@@ -1,6 +1,6 @@
|
|||||||
id = "avivbintangaringga/nix-monitor"
|
id = "avivbintangaringga/nix-monitor"
|
||||||
name = "Nix Monitor"
|
name = "Nix Monitor"
|
||||||
version = "1.2.0"
|
version = "1.3.0"
|
||||||
plugin_api = 3
|
plugin_api = 3
|
||||||
icon = "package"
|
icon = "package"
|
||||||
author = "avivbintangaringga"
|
author = "avivbintangaringga"
|
||||||
@@ -128,12 +128,24 @@ default = 5
|
|||||||
min = 1
|
min = 1
|
||||||
max = 30
|
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]]
|
[[setting]]
|
||||||
key = "system_stats_check_interval"
|
key = "system_stats_check_interval"
|
||||||
type = "int"
|
type = "int"
|
||||||
label_key = "setting.system_stats_check_interval.label"
|
label_key = "setting.system_stats_check_interval.label"
|
||||||
description_key = "setting.system_stats_check_interval.description"
|
description_key = "setting.system_stats_check_interval.description"
|
||||||
default = 10
|
default = 60
|
||||||
min = 5
|
min = 5
|
||||||
|
|
||||||
[[setting]]
|
[[setting]]
|
||||||
@@ -141,9 +153,8 @@ key = "system_stats_check_duration_threshold"
|
|||||||
type = "int"
|
type = "int"
|
||||||
label_key = "setting.system_stats_check_duration_threshold.label"
|
label_key = "setting.system_stats_check_duration_threshold.label"
|
||||||
description_key = "setting.system_stats_check_duration_threshold.description"
|
description_key = "setting.system_stats_check_duration_threshold.description"
|
||||||
default = 5
|
default = 15
|
||||||
min = 1
|
min = 1
|
||||||
max = 30
|
|
||||||
|
|
||||||
[[setting]]
|
[[setting]]
|
||||||
key = "panel_card_color"
|
key = "panel_card_color"
|
||||||
|
|||||||
@@ -75,6 +75,11 @@
|
|||||||
"nixos_26_05_small": "NixOS 26.05 Small",
|
"nixos_26_05_small": "NixOS 26.05 Small",
|
||||||
"nixos_unstable": "NixOS Unstable",
|
"nixos_unstable": "NixOS Unstable",
|
||||||
"nixos_unstable_small": "NixOS Unstable Small"
|
"nixos_unstable_small": "NixOS Unstable Small"
|
||||||
|
},
|
||||||
|
"system_stats_check_mode": {
|
||||||
|
"off": "Off",
|
||||||
|
"on_interval": "On interval",
|
||||||
|
"on_start": "On start"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"show_update_available_notification": {
|
"show_update_available_notification": {
|
||||||
@@ -89,6 +94,10 @@
|
|||||||
"description": "Cancel system stats check if it took too long (in minutes)",
|
"description": "Cancel system stats check if it took too long (in minutes)",
|
||||||
"label": "System stats check duration threshold"
|
"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": {
|
"system_stats_check_interval": {
|
||||||
"description": "How often to check for system stats (in minutes)",
|
"description": "How often to check for system stats (in minutes)",
|
||||||
"label": "System stats check interval"
|
"label": "System stats check interval"
|
||||||
@@ -151,6 +160,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"terminal": {
|
"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