From 118e10561c2219e13613f4b4efbc76e4dac6d539 Mon Sep 17 00:00:00 2001 From: Pepe44DEV Date: Mon, 4 May 2026 12:22:45 +0200 Subject: [PATCH] Install notification timer with app --- Makefile | 34 +++++++++++++++++++++++++++------- README.md | 14 ++++++++------ 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 5f2eea9..d38e5d9 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ BINARY := lazy-update-manager PREFIX ?= $(HOME)/.local +APP_DIR := $(CURDIR) # Versioning: try to use git describe, fall back to 'dev' VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev) @@ -20,28 +21,47 @@ desktop-dist: install: build @mkdir -p $(PREFIX)/bin @mkdir -p $(PREFIX)/share/applications + @mkdir -p $(HOME)/.config/systemd/user @echo "Installing $(BINARY) to $(PREFIX)/bin" @if [ -f "$(PREFIX)/bin/$(BINARY)" ]; then \ if cmp -s bin/$(BINARY) "$(PREFIX)/bin/$(BINARY)"; then \ echo "Existing binary is identical; skipping overwrite."; \ - exit 0; \ else \ ts=$$(date +%Y%m%d%H%M%S); \ mv "$(PREFIX)/bin/$(BINARY)" "$(PREFIX)/bin/$(BINARY)-$$ts.bak"; \ echo "Backed up previous binary to $(PREFIX)/bin/$(BINARY)-$$ts.bak"; \ + install -Dm755 bin/$(BINARY) $(PREFIX)/bin/$(BINARY); \ 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; \ - install -Dm755 bin/$(BINARY) $(PREFIX)/bin/$(BINARY); \ - install -Dm644 systemd/lazy-update-manager.desktop $(PREFIX)/share/applications/lazy-update-manager.desktop; \ echo "Installed $(BINARY) to $(PREFIX)/bin" install-user-service: install - 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 - systemctl --user daemon-reload + @echo "User service installation is included in 'make install'." enable-user-service: install-user-service - systemctl --user enable --now lazy-update-manager.timer + @echo "Timer activation is included in 'make install'." test: go test ./... diff --git a/README.md b/README.md index 752cf36..f72d48a 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,13 @@ make desktop-dist 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. @@ -116,11 +122,7 @@ If you prefer to test the local build without installing, run the bundled binary ./bin/lazy-update-manager gui ``` -## Enable Weekly Reminder - -```sh -make enable-user-service -``` +## Weekly Reminder The timer runs every two hours, but `lazy-update-manager notify` stores the last reminder timestamp in: