Merge pull request #44 from avivbintangaringga/nix-monitor
feat(nix-monitor): update version 1.2.0
This commit is contained in:
@@ -13,7 +13,7 @@ NixOS generations, store size, closure size, and update status from the bar.
|
|||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
This plugin is intended for NixOS. It uses `nix`, `nixos-version`,
|
This plugin is intended for NixOS. It uses `nix`, `nixos-version`,
|
||||||
`nixos-rebuild`, and `git`, plus the standard commands `du`, `cat`, `awk`,
|
`nixos-rebuild`, `nix-store`, and `git`, plus the standard commands `du`, `cat`, `read`, `echo`, `awk`,
|
||||||
`grep`, `tail`, `wc`, `kill`, and `pkill`. Home Manager generation information
|
`grep`, `tail`, `wc`, `kill`, and `pkill`. Home Manager generation information
|
||||||
is shown when `home-manager` is available.
|
is shown when `home-manager` is available.
|
||||||
|
|
||||||
@@ -29,8 +29,8 @@ Open the panel directly with:
|
|||||||
noctalia msg panel-toggle avivbintangaringga/nix-monitor:panel
|
noctalia msg panel-toggle avivbintangaringga/nix-monitor:panel
|
||||||
```
|
```
|
||||||
|
|
||||||
Set `update_command` before using **Update**. **Clean** runs the configured
|
Set `update_command` before using **Update**. **Optimize** runs the configured command `nix-store --optimise -vv`. **Clean** runs the configured
|
||||||
cleanup command, which defaults to `nix-collect-garbage -d`. Both commands open
|
cleanup command, which defaults to `nix-collect-garbage -d`. All commands open
|
||||||
in a terminal so you can review their output.
|
in a terminal so you can review their output.
|
||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
@@ -47,7 +47,8 @@ Update behavior:
|
|||||||
| `show_update_available_notification` | `true` | Notifies when a newer revision is available. |
|
| `show_update_available_notification` | `true` | Notifies when a newer revision is available. |
|
||||||
| `branch` | `nixos-unstable` | Nixpkgs branch compared by the service. |
|
| `branch` | `nixos-unstable` | Nixpkgs branch compared by the service. |
|
||||||
| `update_command` | *(empty)* | Command launched by the panel's **Update** button. |
|
| `update_command` | *(empty)* | Command launched by the panel's **Update** button. |
|
||||||
| `clean_command` | `nix-collect-garbage -d` | Command launched by **Clean**. |
|
| `optimize_command` | `nix-store --optimize -vv` | Command launched by the panel's **Optimize** button. |
|
||||||
|
| `clean_command` | `nix-collect-garbage -d` | Command launched by the panel's **Clean** button. |
|
||||||
| `close_on_enter` | `true` | Keeps the command terminal open until Enter is pressed. |
|
| `close_on_enter` | `true` | Keeps the command terminal open until Enter is pressed. |
|
||||||
|
|
||||||
Widget appearance:
|
Widget appearance:
|
||||||
|
|||||||
@@ -23,7 +23,8 @@ end
|
|||||||
|
|
||||||
function killWithPidFile(file)
|
function killWithPidFile(file)
|
||||||
if noctalia.fileExists(file) then
|
if noctalia.fileExists(file) then
|
||||||
local pid = noctalia.string.trim(noctalia.readFile(file))
|
local content = noctalia.readFile(file) or ""
|
||||||
|
local pid = noctalia.string.trim(content)
|
||||||
|
|
||||||
if type(pid) == "string" and pid ~= "" then
|
if type(pid) == "string" and pid ~= "" then
|
||||||
noctalia.runAsync(`pkill -9 -P {pid} && kill -9 {pid}`)
|
noctalia.runAsync(`pkill -9 -P {pid} && kill -9 {pid}`)
|
||||||
@@ -38,7 +39,7 @@ local updateCheckInterval = cfg("update_check_interval")
|
|||||||
local updateCheckDurationThreshold = cfg("update_check_duration_threshold")
|
local updateCheckDurationThreshold = cfg("update_check_duration_threshold")
|
||||||
local systemStatsCheckInterval = cfg("system_stats_check_interval")
|
local systemStatsCheckInterval = cfg("system_stats_check_interval")
|
||||||
local systemStatsCheckDurationThreshold = cfg("system_stats_check_duration_threshold")
|
local systemStatsCheckDurationThreshold = cfg("system_stats_check_duration_threshold")
|
||||||
local stateDir = "/tmp/nix-monitor"
|
local stateDir = noctalia.pluginDataDir() or "/tmp/nix-monitor"
|
||||||
local remoteHashFile = stateDir .. "/remoteHash"
|
local remoteHashFile = stateDir .. "/remoteHash"
|
||||||
local storeSizeFile = stateDir .. "/storeSize"
|
local storeSizeFile = stateDir .. "/storeSize"
|
||||||
local closureSizeFile = stateDir .. "/closureSize"
|
local closureSizeFile = stateDir .. "/closureSize"
|
||||||
@@ -95,7 +96,7 @@ end
|
|||||||
-- Currently it is writing to a file because when I use the runAsync with
|
-- Currently it is writing to a file because when I use the runAsync with
|
||||||
-- the callback, it is timed out
|
-- the callback, it is timed out
|
||||||
function checkRemoteHash(delay: number?)
|
function checkRemoteHash(delay: number?)
|
||||||
local delay = delay or 0
|
local _delay = delay or 0
|
||||||
|
|
||||||
if getState("isRemoteCheckRunning") then
|
if getState("isRemoteCheckRunning") then
|
||||||
return
|
return
|
||||||
@@ -109,12 +110,13 @@ function checkRemoteHash(delay: number?)
|
|||||||
end
|
end
|
||||||
|
|
||||||
noctalia.writeFile(remoteHashFile, "")
|
noctalia.writeFile(remoteHashFile, "")
|
||||||
noctalia.runAsync(`sleep {delay} && {remoteHashCmd} > {remoteHashFile} & echo $! > {remotePidFile}`)
|
noctalia.runAsync(`sleep {_delay} && {remoteHashCmd} > {remoteHashFile} & echo $! > {remotePidFile}`)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if the remoteHash check command is finished by reading the file
|
-- Check if the remoteHash check command is finished by reading the file
|
||||||
function checkRemoteStatus()
|
function checkRemoteStatus()
|
||||||
local remoteHash = noctalia.string.trim(noctalia.readFile(remoteHashFile))
|
local remoteHashFileContent = noctalia.readFile(remoteHashFile) or ""
|
||||||
|
local remoteHash = noctalia.string.trim(remoteHashFileContent)
|
||||||
|
|
||||||
if type(remoteHash) == "string" and remoteHash ~= "" then
|
if type(remoteHash) == "string" and remoteHash ~= "" then
|
||||||
setState("isRemoteCheckRunning", false)
|
setState("isRemoteCheckRunning", false)
|
||||||
@@ -179,8 +181,10 @@ function checkSystemStats()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function checkSystemStatsFile()
|
function checkSystemStatsFile()
|
||||||
local storeSize = noctalia.string.trim(noctalia.readFile(storeSizeFile))
|
local storeSizeFileContent = noctalia.readFile(storeSizeFile) or ""
|
||||||
local closureSize = noctalia.string.trim(noctalia.readFile(closureSizeFile))
|
local storeSize = noctalia.string.trim(storeSizeFileContent)
|
||||||
|
local closureSizeFileContent = noctalia.readFile(closureSizeFile) or ""
|
||||||
|
local closureSize = noctalia.string.trim(closureSizeFileContent)
|
||||||
|
|
||||||
if typeof(storeSize) == "string" and storeSize ~= "" then
|
if typeof(storeSize) == "string" and storeSize ~= "" then
|
||||||
setState("storeSize", storeSize)
|
setState("storeSize", storeSize)
|
||||||
|
|||||||
@@ -119,6 +119,19 @@ local function render()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not cfg("hide_optimize_button") then
|
||||||
|
table.insert(
|
||||||
|
buttons,
|
||||||
|
ui.button({
|
||||||
|
text = tr("panel.optimize"),
|
||||||
|
glyph = "database-cog",
|
||||||
|
flexGrow = 1,
|
||||||
|
variant = "primary",
|
||||||
|
onClick = "onOptimizeClicked",
|
||||||
|
})
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
if not cfg("hide_clean_button") then
|
if not cfg("hide_clean_button") then
|
||||||
table.insert(
|
table.insert(
|
||||||
buttons,
|
buttons,
|
||||||
@@ -273,3 +286,18 @@ function onCleanClicked()
|
|||||||
panel.close()
|
panel.close()
|
||||||
noctalia.runInTerminal(command)
|
noctalia.runInTerminal(command)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function onOptimizeClicked()
|
||||||
|
local command = cfg("optimize_command")
|
||||||
|
if command == "" then
|
||||||
|
noctalia.notifyError(tr("notification.optimize_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)
|
||||||
|
end
|
||||||
|
|||||||
+16
-2
@@ -1,12 +1,12 @@
|
|||||||
id = "avivbintangaringga/nix-monitor"
|
id = "avivbintangaringga/nix-monitor"
|
||||||
name = "Nix Monitor"
|
name = "Nix Monitor"
|
||||||
version = "1.1.1"
|
version = "1.2.0"
|
||||||
plugin_api = 3
|
plugin_api = 3
|
||||||
icon = "package"
|
icon = "package"
|
||||||
author = "avivbintangaringga"
|
author = "avivbintangaringga"
|
||||||
description = "Nixpkgs update monitor"
|
description = "Nixpkgs update monitor"
|
||||||
tags = [ "nixos", "utility" ]
|
tags = [ "nixos", "utility" ]
|
||||||
dependencies = [ "nix", "nixos-version", "nixos-rebuild", "git", "du", "cat", "awk", "grep", "tail", "wc", "kill", "pkill" ]
|
dependencies = [ "nix", "nixos-version", "nixos-rebuild", "nix-store", "git", "du", "cat", "echo", "read", "awk", "grep", "tail", "wc", "kill", "pkill" ]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
[[widget]]
|
[[widget]]
|
||||||
@@ -180,6 +180,13 @@ label_key = "setting.update_command.label"
|
|||||||
description_key = "setting.update_command.description"
|
description_key = "setting.update_command.description"
|
||||||
default = ""
|
default = ""
|
||||||
|
|
||||||
|
[[setting]]
|
||||||
|
key = "optimize_command"
|
||||||
|
type = "string"
|
||||||
|
label_key = "setting.optimize_command.label"
|
||||||
|
description_key = "setting.optimize_command.description"
|
||||||
|
default = "nix-store --optimise -vv"
|
||||||
|
|
||||||
[[setting]]
|
[[setting]]
|
||||||
key = "clean_command"
|
key = "clean_command"
|
||||||
type = "string"
|
type = "string"
|
||||||
@@ -194,6 +201,13 @@ label_key = "setting.hide_update_button.label"
|
|||||||
description_key = "setting.hide_update_button.description"
|
description_key = "setting.hide_update_button.description"
|
||||||
default = false
|
default = false
|
||||||
|
|
||||||
|
[[setting]]
|
||||||
|
key = "hide_optimize_button"
|
||||||
|
type = "bool"
|
||||||
|
label_key = "setting.hide_optimize_button.label"
|
||||||
|
description_key = "setting.hide_optimize_button.description"
|
||||||
|
default = false
|
||||||
|
|
||||||
[[setting]]
|
[[setting]]
|
||||||
key = "hide_clean_button"
|
key = "hide_clean_button"
|
||||||
type = "bool"
|
type = "bool"
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 53 KiB After Width: | Height: | Size: 54 KiB |
@@ -8,6 +8,7 @@
|
|||||||
"notification": {
|
"notification": {
|
||||||
"checking_update": "Checking NixOS update...",
|
"checking_update": "Checking NixOS update...",
|
||||||
"clean_command_is_empty": "Clean command is empty!",
|
"clean_command_is_empty": "Clean command is empty!",
|
||||||
|
"optimize_command_is_empty": "Optimize command is empty!",
|
||||||
"update_check_completed": "NixOS update check completed!",
|
"update_check_completed": "NixOS update check completed!",
|
||||||
"update_command_is_empty": "Update command is empty!",
|
"update_command_is_empty": "Update command is empty!",
|
||||||
"update_is_available": "NixOS update is available!"
|
"update_is_available": "NixOS update is available!"
|
||||||
@@ -15,6 +16,7 @@
|
|||||||
"panel": {
|
"panel": {
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
"check": "Check",
|
"check": "Check",
|
||||||
|
"optimize": "Optimize",
|
||||||
"clean": "Clean",
|
"clean": "Clean",
|
||||||
"closure_size": "Closure size",
|
"closure_size": "Closure size",
|
||||||
"current": "Current",
|
"current": "Current",
|
||||||
@@ -30,6 +32,14 @@
|
|||||||
"description": "Which nixpkgs branch to use",
|
"description": "Which nixpkgs branch to use",
|
||||||
"label": "Branch"
|
"label": "Branch"
|
||||||
},
|
},
|
||||||
|
"update_command": {
|
||||||
|
"description": "Command to run when clicking Update button",
|
||||||
|
"label": "Update command"
|
||||||
|
},
|
||||||
|
"optimize_command": {
|
||||||
|
"label": "Optimize command",
|
||||||
|
"description": "Command to run when clicking Optimize button"
|
||||||
|
},
|
||||||
"clean_command": {
|
"clean_command": {
|
||||||
"description": "Command to run when clicking Clean button",
|
"description": "Command to run when clicking Clean button",
|
||||||
"label": "Clean command"
|
"label": "Clean command"
|
||||||
@@ -38,14 +48,18 @@
|
|||||||
"description": "Add 'Press enter to exit' on the terminal window",
|
"description": "Add 'Press enter to exit' on the terminal window",
|
||||||
"label": "Close on press Enter"
|
"label": "Close on press Enter"
|
||||||
},
|
},
|
||||||
"hide_clean_button": {
|
|
||||||
"description": "Whether to hide the clean button on the panel",
|
|
||||||
"label": "Hide clean button"
|
|
||||||
},
|
|
||||||
"hide_update_button": {
|
"hide_update_button": {
|
||||||
"description": "Whether to hide the update button on the panel",
|
"description": "Whether to hide the update button on the panel",
|
||||||
"label": "Hide update button"
|
"label": "Hide update button"
|
||||||
},
|
},
|
||||||
|
"hide_optimize_button": {
|
||||||
|
"label": "Hide optimize button",
|
||||||
|
"description": "Whether to hide the optimize button on the panel"
|
||||||
|
},
|
||||||
|
"hide_clean_button": {
|
||||||
|
"description": "Whether to hide the clean button on the panel",
|
||||||
|
"label": "Hide clean button"
|
||||||
|
},
|
||||||
"option": {
|
"option": {
|
||||||
"branch": {
|
"branch": {
|
||||||
"master": "Master",
|
"master": "Master",
|
||||||
@@ -91,10 +105,6 @@
|
|||||||
"description": "How often to check for updates (in minutes)",
|
"description": "How often to check for updates (in minutes)",
|
||||||
"label": "Update check interval"
|
"label": "Update check interval"
|
||||||
},
|
},
|
||||||
"update_command": {
|
|
||||||
"description": "Command to run when clicking Update button",
|
|
||||||
"label": "Update command"
|
|
||||||
},
|
|
||||||
"widget": {
|
"widget": {
|
||||||
"checking_color": {
|
"checking_color": {
|
||||||
"label": "Checking color"
|
"label": "Checking color"
|
||||||
|
|||||||
Reference in New Issue
Block a user