Skip to content

Commit c0434e3

Browse files
author
guttermonk
committed
Update-checker v2.0 release.
1 parent e3a8d7a commit c0434e3

File tree

4 files changed

+554
-358
lines changed

4 files changed

+554
-358
lines changed

README.md

Lines changed: 52 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
1-
PRs Welcome! Things left to fix:
2-
- [x] Improve error Handling
3-
- [x] Show an "updating" icon while updating
4-
- [x] Add notification icons
5-
- [x] Create a nix flake
6-
- [x] Failed updates populate a detailed error message in the tooltip
7-
- [x] Remove the additional space at the bottom of the tooltip
8-
- [ ] Make an optional animated spinner while updating
9-
- [ ] Look at the fork's way of handling the temp build using a flag vs temp dir
10-
- [ ] Replace ping with an offline and more private network connection checker
11-
- [ ] Add an optional on/off toggle
12-
13-
14-
# waybar-nixos-updates
15-
A Waybar update checking script for NixOS that checks for available updates and displays them in your Waybar.
1+
# 🔄 waybar-nixos-updates
2+
[![License: GPL-3.0](https://img.shields.io/badge/license-GPLv3-blue.svg?style=for-the-badge)](https://opensource.org/licenses/MIT)
3+
[![GitHub stars](https://img.shields.io/github/stars/guttermonk/waybar-nixos-updates?style=for-the-badge)](https://github.com/guttermonk/waybar-nixos-updates/stargazers)
4+
5+
A [Waybar](https://github.com/Alexays/Waybar) update checking script for NixOS that checks for available updates and displays them in your Waybar.
166

177
Here's how the module looks in Waybar with and without updates:
188

@@ -24,33 +14,33 @@ Here's how the module's tooltip looks when updates are available:
2414

2515
Credit goes to [this project](https://github.com/J-Carder/waybar-apt-updates) for the idea and starting point.
2616

27-
## Dependencies
17+
## 📦 Dependencies
2818

2919
When using the flake, all dependencies are automatically handled. The script requires:
3020

31-
### Commands/Programs:
21+
### 🔧 Commands/Programs:
3222
1. `nix` - Used for `nix flake update` and `nix build` commands
3323
2. `nvd` - Used for comparing system versions (`nvd diff`)
3424
3. `notify-send` - For desktop notifications
35-
4. Standard utilities: `bash`, `grep`, `awk`, `sed`, `ping`
25+
4. Standard utilities: `bash`, `grep`, `awk`, `sed`, `iproute2` (for `ip` command)
3626

37-
### System Requirements:
27+
### 💻 System Requirements:
3828
1. NixOS operating system
3929
2. A running Waybar instance (the script outputs JSON for Waybar integration)
4030
3. Internet connectivity for performing update checks
4131
4. Desktop notification system compatible with `notify-send`
4232

43-
### Configuration Assumptions:
33+
### 📋 Configuration Assumptions:
4434
- Your flake is in `~/.config/nixos` (configurable via Home Manager module)
4535
- Your flake's nixosConfigurations is named the same as your `$hostname`
4636

47-
## How to Use
37+
## 🚀 How to Use
4838

49-
### Installation Methods
39+
### 💿 Installation Methods
5040

5141
This project provides multiple installation methods through its Nix flake:
5242

53-
#### 1. Using the Flake as a Package
43+
#### 1. 📦 Using the Flake as a Package
5444

5545
Add to your flake inputs:
5646
```nix
@@ -64,7 +54,7 @@ Add to your flake inputs:
6454
}
6555
```
6656

67-
#### 2. Using Home Manager Module (Recommended)
57+
#### 2. 🏠 Using Home Manager Module (Recommended)
6858

6959
This provides the most flexibility for configuration:
7060

@@ -90,7 +80,7 @@ This provides the most flexibility for configuration:
9080
}
9181
```
9282

93-
#### 3. Using NixOS Module
83+
#### 3. ⚙️ Using NixOS Module
9484

9585
For system-wide installation:
9686
```nix
@@ -101,18 +91,18 @@ For system-wide installation:
10191
}
10292
```
10393

104-
#### 4. Using the Legacy default.nix
94+
#### 4. 🔄 Using the Legacy default.nix
10595

10696
You can still use the included `default.nix` file with Home Manager:
10797
```nix
10898
imports = [ ./path-to-waybar-nixos-updates/default.nix ];
10999
```
110100

111-
#### 5. Manual Installation
101+
#### 5. 🔨 Manual Installation
112102

113103
For a manual installation, download the `update-checker` script, put it in your [PATH](https://unix.stackexchange.com/a/26059) and make it executable (`chmod +x update-checker`). Add the icons to your ~/.icons folder.
114104

115-
### Configuration Options
105+
### ⚙️ Configuration Options
116106
You can modify these variables at the top of the script to customize behavior:
117107

118108
- `UPDATE_INTERVAL`: Time in seconds between update checks (default: 3599)
@@ -122,7 +112,13 @@ You can modify these variables at the top of the script to customize behavior:
122112
- `GRACE_PERIOD`: Time in seconds to wait after boot/resume before checking (default: 60)
123113
- `UPDATE_LOCK_FILE`: Whether to update the lock file directly or use a temporary copy (default: false)
124114

125-
### Waybar Integration
115+
### 🔄 Toggle Functionality
116+
The script supports toggling update checks on/off. When disabled, it will show the last known state without performing new checks:
117+
- To toggle: Run `update-checker toggle`
118+
- The toggle state is preserved across restarts
119+
- When disabled, the module shows "disabled" state with the last check timestamp
120+
121+
### 🎨 Waybar Integration
126122

127123
If you're using the Home Manager module, the waybar configuration is automatically provided through `config.programs.waybar-nixos-updates.waybarConfig`. Otherwise, configure manually:
128124

@@ -133,7 +129,7 @@ In json (if adding directly to the config file):
133129
"custom/nix-updates": {
134130
"exec": "$HOME/bin/update-checker", // <--- path to script
135131
"signal": 12,
136-
"on-click": "", // refresh on click
132+
"on-click": "$HOME/bin/update-checker toggle", // toggle update checking
137133
"on-click-right": "rm ~/.cache/nix-update-last-run", // force an update
138134
"interval": 3600, // refresh every hour
139135
"tooltip": true,
@@ -143,6 +139,7 @@ In json (if adding directly to the config file):
143139
"has-updates": "󰚰", // icon when updates needed
144140
"updating": "", // icon when updating
145141
"updated": "", // icon when all packages updated
142+
"disabled": "󰚰", // icon when update checking is disabled
146143
"error": "" // icon when errot occurs
147144
},
148145
},
@@ -153,7 +150,7 @@ In nix (if adding it "the nix way" through home-manager):
153150
"custom/nix-updates" = {
154151
exec = "$HOME/bin/update-checker"; # Or "${pkgs.waybar-nixos-updates}/bin/update-checker" if using the flake
155152
signal = 12;
156-
on-click = "";
153+
on-click = "$HOME/bin/update-checker toggle"; # Toggle update checking
157154
on-click-right = "rm ~/.cache/nix-update-last-run";
158155
interval = 3600;
159156
tooltip = true;
@@ -163,6 +160,7 @@ In nix (if adding it "the nix way" through home-manager):
163160
has-updates = "󰚰";
164161
updating = "";
165162
updated = "";
163+
disabled = "󰚰";
166164
error = "";
167165
};
168166
};
@@ -176,7 +174,7 @@ programs.waybar.settings.mainBar."custom/nix-updates" =
176174

177175
To style use the `#custom-nix-updates` ID in your Waybar styles file (`~/.config/waybar/styles.css`). For more information see the [Waybar wiki](https://github.com/Alexays/Waybar/wiki).
178176

179-
### Complete Configuration Example
177+
### 💡 Complete Configuration Example
180178

181179
Here's a complete example of using waybar-nixos-updates with Home Manager:
182180

@@ -227,6 +225,10 @@ Here's a complete example of using waybar-nixos-updates with Home Manager:
227225
#custom-nix-updates.updating {
228226
color: #f9e2af;
229227
}
228+
#custom-nix-updates.disabled {
229+
color: #6c7086;
230+
opacity: 0.7;
231+
}
230232
#custom-nix-updates.error {
231233
color: #eba0ac;
232234
}
@@ -240,7 +242,7 @@ Here's a complete example of using waybar-nixos-updates with Home Manager:
240242
}
241243
```
242244

243-
### Flake Outputs
245+
### 📤 Flake Outputs
244246

245247
The flake provides the following outputs:
246248

@@ -249,9 +251,9 @@ The flake provides the following outputs:
249251
- **nixosModules.default**: NixOS module for system-level installation
250252
- **apps.default**: Direct execution of the update-checker script
251253

252-
### Troubleshooting
254+
### 🔍 Troubleshooting
253255

254-
#### Common Issues and Solutions
256+
#### 🐛 Common Issues and Solutions
255257

256258
1. **Script not finding NixOS configuration**
257259
- Ensure your configuration is at `~/.config/nixos` or update the `nixosConfigPath` option
@@ -279,10 +281,10 @@ The flake provides the following outputs:
279281
- When using the wrapper script, restart waybar after rebuilding
280282
- Verify the correct script is being executed: check waybar config `exec` path
281283

282-
### System Integration
284+
### System Integration
283285
You can integrate the updater with your system by modifying your flake update script and your rebuild script to pass the UPDATE_FLAG variable and the REBUILD_FLAG variable, respectively.
284286

285-
#### Your Flake Update Script and the UPDATE_FLAG
287+
#### 🔄 Your Flake Update Script and the UPDATE_FLAG
286288
You can integrate your system to control the UPDATE_FLAG, which is saved in the "nix-update-update-flag" cache file. If you have UPDATE_LOCK_FILE set to "true", no further action is required. The program will detect if your lock file has been updated. If you have UPDATE_LOCK_FILE set to "false", the "nix-update-update-flag" file will signal that your lock file has been updated.
287289

288290
To integrate the update checker with your system, add the following to the update script you use to update your system's lock file (i.e. your "nix flake update" script), so that the output of nvd diff is piped in:
@@ -298,7 +300,7 @@ checkup =
298300
popd";
299301
```
300302

301-
#### Your Rebuild Script and the REBUILD_FLAG
303+
#### 🏗️ Your Rebuild Script and the REBUILD_FLAG
302304
The REBUILD_FLAG, which is saved in the "nix-update-rebuild-flag" cache file, 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:
303305
`if [ -f \"$HOME/.cache/nix-update-update-flag\" ]; then touch \"$HOME/.cache/nix-update-rebuild-flag\" && pkill -x -RTMIN+12 .waybar-wrapped; fi &&`
304306

@@ -315,10 +317,10 @@ nixup =
315317
popd";
316318
```
317319

318-
## Additional Information
320+
## ℹ️ Additional Information
319321
Some additional things to expect in regards to 1) what notifications you'll receive, 2) what files will be written, 3) and how the script uses your network connection.
320322

321-
### Notifications
323+
### 🔔 Notifications
322324
These notifications require `notify-send` to be installed on your system. The script sends desktop notifications to keep you informed:
323325
- When starting an update check: "Checking for Updates - Please be patient"
324326
- When throttled due to recent checks: "Please Wait" with time until next check
@@ -327,28 +329,28 @@ These notifications require `notify-send` to be installed on your system. The sc
327329
- When connectivity fails: "Update Check Failed - Not connected to the internet"
328330
- When an update fails: "Update Check Failed - Check tooltip for detailed error message"
329331

330-
### Cache Files
332+
### 💾 Cache Files
331333
The script uses several cache files in your ~/.cache directory:
332334
- `nix-update-state`: Stores the current number of available updates
333335
- `nix-update-last-run`: Tracks when the last update check was performed
334336
- `nix-update-tooltip`: Contains the tooltip text with update details
335337
- `nix-update-boot-marker`: Used to detect system boot/resume events
338+
- `nix-update-toggle`: Stores the enabled/disabled state for update checking
336339
- `nix-update-update-flag`: Signals that your lock file has been updated
337340
- `nix-update-rebuild-flag`: Signals that your system has been rebuilt
338341
- `nix-update-updating-flag`: Signals that an update process is currently performing
339342

340-
### Privacy and Security Considerations
341-
Aside from checking repos for updates, this script uses external network requests to check for internet connectivity.
342-
343-
In regards to external network requests, the script uses `ping -c 1 -W 2 8.8.8.8` to check network connectivity and sends packets to Google's DNS servers (8.8.8.8), which could potentially reveal:
344-
- That your system is running and online
345-
- The fact you're using this specific script
346-
- Your IP address to Google's DNS infrastructure
343+
### 🔒 Privacy and Security Considerations
344+
The script checks network connectivity locally using the `ip` command to verify network interfaces and routing tables. This approach:
345+
- Does not send any external network requests for connectivity checking
346+
- Only checks local network configuration (interfaces and routes)
347+
- Performs actual network requests only when fetching updates from configured Nix repositories
348+
- Provides better privacy as no external connectivity checks are performed
347349

348-
## Contributing
350+
## 🤝 Contributing
349351

350352
PRs are welcome! Please test your changes and ensure they work with both the flake installation methods and manual installation.
351353

352-
## License
354+
## 📜 License
353355

354356
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)