You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+66-26Lines changed: 66 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,8 +23,9 @@ System Requirements:
23
23
1. NixOS operating system (based on the nature of the script)
24
24
2. A running Waybar instance (the script outputs JSON for Waybar integration)
25
25
3. Internet connectivity for performing update checks
26
+
4. Desktop notification system compatible with `notify-send`
26
27
27
-
## Privacy
28
+
## Privacy and Security Considerations
28
29
External Network Requests: The script uses `ping -c 1 -W 2 8.8.8.8` to check network connectivity and send packets to Google's DNS servers (8.8.8.8), which could potentially reveal:
29
30
- That your system is running and online
30
31
- The fact you're using this specific script
@@ -36,40 +37,66 @@ External Network Requests: The script uses `ping -c 1 -W 2 8.8.8.8` to check net
36
37
37
38
2.**File Initialization**: Creates necessary state files if they don't exist (tracks update count, last check time, and tooltip info).
38
39
39
-
3.**Network Check**: Verifies internet connectivity by pinging 8.8.8.8.
40
+
3.**Boot/Resume Detection**: Detects if the system has recently booted or resumed from suspension/hibernation to avoid unnecessary resource usage during these transition periods.
40
41
41
-
4.**System Update Status**: Checks if the system was recently rebuilt by looking for the rebuild flag.
42
+
4.**Grace Period Management**: Applies a configurable grace period after boot or resume before running update checks.
42
43
43
-
5.**Update Check Timing**: Determines if it's time to check for updates based on the last check timestamp.
44
+
5.**Network Check**: Verifies internet connectivity by pinging 8.8.8.8.
44
45
45
-
6.**Temporary Environment**: Creates a temporary directory for performing update checks without modifying the system.
46
+
6.**System Update Status**: Checks if the system was recently rebuilt by looking for the rebuild flag.
46
47
47
-
7.**Flake Update**: Runs `nix flake update` either in the config directory or temp directory based on settings.
48
+
7.**Update Check Timing**: Determines if it's time to check for updates based on the last check timestamp.
48
49
49
-
8.**System Build**: Builds the updated system configuration to compare with the current one.
50
+
8.**Temporary Environment**: Creates a temporary directory for performing update checks without modifying the system.
50
51
51
-
9.**Update Comparison**: Uses `nvd diff` to compare current system with the new build and count updates.
52
+
9.**Flake Update**: Runs `nix flake update` either in the config directory or temp directory based on settings.
52
53
53
-
10.**Result Storage**: Saves the number of updates and detailed update information to state files.
54
+
10.**System Build**: Builds the updated system configuration to compare with the current one.
54
55
55
-
11.**Notification**: Sends desktop notifications to inform the user about the update status.
56
+
11.**Update Comparison**: Uses `nvd diff` to compare current system with the new build and count updates.
56
57
57
-
12.**JSON Output**: Generates a JSON object with update count, status indicator, and tooltip for Waybar.
58
+
12.**Result Storage**: Saves the number of updates and detailed update information to state files.
58
59
59
-
13.**Flag Management**: Cleans up system update flags if a rebuild was detected.
60
+
13.**Notification**: Sends desktop notifications to inform the user about the update status.
60
61
61
-
14.**Error Handling**: Sets appropriate status messages if update checks fail or network is unavailable.
62
+
14.**JSON Output**: Generates a JSON object with update count, status indicator, and tooltip for Waybar.
62
63
63
-
15.**Tooltip Generation**: Creates detailed tooltips showing which packages have updates available.
64
+
15.**Flag Management**: Cleans up system update flags if a rebuild was detected.
64
65
65
-
16.**State Management**: Manages update state across multiple runs of the script.
66
+
16.**Error Handling**: Sets appropriate status messages if update checks fail or network is unavailable.
66
67
67
-
17.**Output Formatting**: Formats the final output to be compatible with Waybar's custom module format.
68
+
17.**Tooltip Generation**: Creates detailed tooltips showing which packages have updates available.
69
+
70
+
18.**State Management**: Manages update state across multiple runs of the script.
71
+
72
+
19.**Output Formatting**: Formats the final output to be compatible with Waybar's custom module format.
68
73
69
74
70
75
## How to Use
71
76
Download the `update-checker` script, put it in your [PATH](https://unix.stackexchange.com/a/26059) and make it executable (`chmod +x update-checker`).
72
77
78
+
### Configuration Options
79
+
80
+
You can modify these variables at the top of the script to customize behavior:
81
+
82
+
-`UPDATE_INTERVAL`: Time in seconds between update checks (default: 3599)
83
+
-`NIXOS_CONFIG_PATH`: Path to your NixOS configuration (default: ~/.config/nixos)
84
+
-`CACHE_DIR`: Directory for storing cache files (default: ~/.cache)
85
+
-`SKIP_AFTER_BOOT`: Whether to skip update checks right after boot/resume (default: true)
86
+
-`GRACE_PERIOD`: Time in seconds to wait after boot/resume before checking (default: 60)
87
+
-`UPDATE_LOCK_FILE`: Whether to update the lock file directly or use a temporary copy (default: false)
88
+
89
+
#### Cache Files
90
+
The script uses several cache files in your ~/.cache directory:
91
+
-`nix-update-state`: Stores the current number of available updates
92
+
-`nix-update-last-run`: Tracks when the last update check was performed
93
+
-`nix-update-tooltip`: Contains the tooltip text with update details
94
+
-`nix-update-boot-marker`: Used to detect system boot/resume events
95
+
-`nix-update-update-flag`: Signals that your lock file has been updated
96
+
-`nix-update-rebuild-flag`: Signals that your system has been rebuilt
97
+
98
+
### Waybar Integration
99
+
73
100
To configure, add the following to your Waybar config (`~/.config/waybar/config`).
74
101
75
102
In json:
@@ -111,30 +138,43 @@ In nix:
111
138
To style use the `#custom-nix-updates` ID in your Waybar styles file (`~/.config/waybar/styles.css`).
112
139
113
140
114
-
If you have you have UPDATE_LOCK_FILE set to "false", the UPDATE_FLAG file will signal that your lock file has been updated. Add the following to your update script, used to update your lock file (i.e. "nix flake update" script), so that the output of nvd diff is piped in:
141
+
If you have UPDATE_LOCK_FILE set to "false", the UPDATE_FLAG file will signal that your lock file has been updated. Add the following to your update script, used to update your lock file (i.e. "nix flake update" script), so that the output of nvd diff is piped in:
115
142
`| tee >(if grep -qe '\\[U'; then touch \"$HOME/.cache/nix-update-update-flag\"; else rm -f \"$HOME/.cache/nix-update-update-flag\"; fi) &&`
nvd diff /run/current-system ./result | tee >(if grep -qe '\\[U'; then touch \"$HOME/.cache/nix-update-update-flag\"; else rm -f \"$HOME/.cache/nix-update-update-flag\"; fi) &&
151
+
popd";
125
152
```
126
153
127
154
The REBUILD_FLAG signals this script to run after your system has been rebuilt. Add this to your update script to create the REBUILD_FLAG and send a signal to waybar to refresh after updating:
0 commit comments