wallswitch 0.64.2

randomly selects wallpapers for multiple monitors
Documentation
# Makefile to automate compilation, installation and systemd configuration
# Adopting defensive coding practices

# Define default secure shell properties
SHELL := /bin/bash
.SHELLFLAGS := -euo pipefail -c

# User-configurable parameters with safe defaults
INTERVAL ?= 300

# Locate binaries dynamically
CARGO := $(shell command -v cargo 2>/dev/null)
PYTHON3 := $(shell command -v python3 2>/dev/null)
SYSTEMCTL := $(shell command -v systemctl 2>/dev/null)

.PHONY: all build install setup-systemd uninstall check-requirements

all: build

check-requirements:
ifndef CARGO
	$(error "cargo binary was not found in PATH. Please install the Rust toolchain.")
endif
ifndef PYTHON3
	$(error "python3 binary was not found in PATH. Please install Python 3.")
endif

build: check-requirements
	"$(CARGO)" b -r

install: check-requirements
	"$(CARGO)" install --path=.
	"$(PYTHON3)" setup_systemd.py --seconds "$(INTERVAL)"

setup-systemd: check-requirements
	"$(PYTHON3)" setup_systemd.py --seconds "$(INTERVAL)"

uninstall: check-requirements
	@echo "Deactivating systemd configuration..."
	-if [ -n "$(SYSTEMCTL)" ]; then \
		"$(SYSTEMCTL)" --user disable --now wallswitch.timer 2>/dev/null || true; \
	fi
	@echo "Removing generated unit files..."
	-rm -f "$(HOME)/.config/systemd/user/wallswitch.service"
	-rm -f "$(HOME)/.config/systemd/user/wallswitch.timer"
	-if [ -n "$(SYSTEMCTL)" ]; then \
		"$(SYSTEMCTL)" --user daemon-reload 2>/dev/null || true; \
	fi
	@echo "Uninstalling cargo binary..."
	-"$(CARGO)" uninstall wallswitch 2>/dev/null || true
	@echo "Uninstallation finished."