#!/usr/bin/env bash

# Enable system services.

dry_run="0"
while [[ $# -gt 0 ]]; do
	echo "ARG: \"$1\""

	# Handle a --dry or --dry-run argument
	if [[ "$1" =~ ^--dry ]]; then
		dry_run="1"
	fi
	shift
done

log() {
	if [[ $dry_run == "1" ]]; then
		echo "[DRY_RUN]: $1"
	else
		echo "$1"
	fi
}

log_and_run() {
	log "Running: \"$*\""

	if [[ $dry_run == "0" ]]; then
		eval "$1"
	fi
}

log_and_run "sudo chsh --shell $(which zsh)"
log_and_run "systemctl --user daemon-reload"
log_and_run "systemctl --user enable --now hyprpaper.service"
log_and_run "systemctl --user enable --now hypridle.service"
log_and_run "espanso service register"
log_and_run "sudo setcap "cap_dac_override+p" $(which espanso)"

log_and_run "systemctl --user enable --now logout-task.service"
log_and_run "systemctl --user enable --now battery-monitor.timer"
log_and_run "systemctl --user enable --now tmux-kill-sessions.timer"
log_and_run "sudo systemctl enable --now pcscd.service"
log_and_run "sudo systemctl enable --now firewalld.service"
