Install notification timer with app

This commit is contained in:
2026-05-04 12:22:45 +02:00
parent a593cf6ad0
commit 118e10561c
2 changed files with 35 additions and 13 deletions

View File

@@ -1,5 +1,6 @@
BINARY := lazy-update-manager BINARY := lazy-update-manager
PREFIX ?= $(HOME)/.local PREFIX ?= $(HOME)/.local
APP_DIR := $(CURDIR)
# Versioning: try to use git describe, fall back to 'dev' # Versioning: try to use git describe, fall back to 'dev'
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev) VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
@@ -20,28 +21,47 @@ desktop-dist:
install: build install: build
@mkdir -p $(PREFIX)/bin @mkdir -p $(PREFIX)/bin
@mkdir -p $(PREFIX)/share/applications @mkdir -p $(PREFIX)/share/applications
@mkdir -p $(HOME)/.config/systemd/user
@echo "Installing $(BINARY) to $(PREFIX)/bin" @echo "Installing $(BINARY) to $(PREFIX)/bin"
@if [ -f "$(PREFIX)/bin/$(BINARY)" ]; then \ @if [ -f "$(PREFIX)/bin/$(BINARY)" ]; then \
if cmp -s bin/$(BINARY) "$(PREFIX)/bin/$(BINARY)"; then \ if cmp -s bin/$(BINARY) "$(PREFIX)/bin/$(BINARY)"; then \
echo "Existing binary is identical; skipping overwrite."; \ echo "Existing binary is identical; skipping overwrite."; \
exit 0; \
else \ else \
ts=$$(date +%Y%m%d%H%M%S); \ ts=$$(date +%Y%m%d%H%M%S); \
mv "$(PREFIX)/bin/$(BINARY)" "$(PREFIX)/bin/$(BINARY)-$$ts.bak"; \ mv "$(PREFIX)/bin/$(BINARY)" "$(PREFIX)/bin/$(BINARY)-$$ts.bak"; \
echo "Backed up previous binary to $(PREFIX)/bin/$(BINARY)-$$ts.bak"; \ echo "Backed up previous binary to $(PREFIX)/bin/$(BINARY)-$$ts.bak"; \
fi; \
fi; \
install -Dm755 bin/$(BINARY) $(PREFIX)/bin/$(BINARY); \ install -Dm755 bin/$(BINARY) $(PREFIX)/bin/$(BINARY); \
install -Dm644 systemd/lazy-update-manager.desktop $(PREFIX)/share/applications/lazy-update-manager.desktop; \ fi; \
else \
install -Dm755 bin/$(BINARY) $(PREFIX)/bin/$(BINARY); \
fi; \
{ \
echo "[Desktop Entry]"; \
echo "Type=Application"; \
echo "Name=LazyUpdateManager"; \
echo "Comment=Arch and Hyprland update helper"; \
echo "Exec=$(PREFIX)/bin/$(BINARY) gui"; \
echo "Path=$(APP_DIR)"; \
echo "Icon=system-software-update"; \
echo "Terminal=false"; \
echo "Categories=System;Utility;"; \
} > $(PREFIX)/share/applications/lazy-update-manager.desktop; \
install -Dm644 systemd/lazy-update-manager.service $(HOME)/.config/systemd/user/lazy-update-manager.service; \
install -Dm644 systemd/lazy-update-manager.timer $(HOME)/.config/systemd/user/lazy-update-manager.timer; \
if command -v systemctl >/dev/null 2>&1 && systemctl --user daemon-reload >/dev/null 2>&1; then \
systemctl --user enable --now lazy-update-manager.timer; \
echo "Enabled lazy-update-manager.timer for update notifications"; \
else \
echo "Installed user service files, but could not access the user systemd session."; \
echo "Run manually: systemctl --user daemon-reload && systemctl --user enable --now lazy-update-manager.timer"; \
fi; \
echo "Installed $(BINARY) to $(PREFIX)/bin" echo "Installed $(BINARY) to $(PREFIX)/bin"
install-user-service: install install-user-service: install
install -Dm644 systemd/lazy-update-manager.service $(HOME)/.config/systemd/user/lazy-update-manager.service @echo "User service installation is included in 'make install'."
install -Dm644 systemd/lazy-update-manager.timer $(HOME)/.config/systemd/user/lazy-update-manager.timer
systemctl --user daemon-reload
enable-user-service: install-user-service enable-user-service: install-user-service
systemctl --user enable --now lazy-update-manager.timer @echo "Timer activation is included in 'make install'."
test: test:
go test ./... go test ./...

View File

@@ -90,7 +90,13 @@ make desktop-dist
make install make install
``` ```
This installs the binary to `~/.local/bin/lazy-update-manager` and a desktop launcher to `~/.local/share/applications/lazy-update-manager.desktop`. This installs:
- the binary to `~/.local/bin/lazy-update-manager`
- the desktop launcher to `~/.local/share/applications/lazy-update-manager.desktop`
- the user service and timer to `~/.config/systemd/user/`
When a user systemd session is available, the timer is enabled immediately so update notifications work after install.
The install target now preserves the previous binary by backing it up when it differs, so installations are safe and reversible. The install target now preserves the previous binary by backing it up when it differs, so installations are safe and reversible.
@@ -116,11 +122,7 @@ If you prefer to test the local build without installing, run the bundled binary
./bin/lazy-update-manager gui ./bin/lazy-update-manager gui
``` ```
## Enable Weekly Reminder ## Weekly Reminder
```sh
make enable-user-service
```
The timer runs every two hours, but `lazy-update-manager notify` stores the last reminder timestamp in: The timer runs every two hours, but `lazy-update-manager notify` stores the last reminder timestamp in: