From dc67ffba604bfb559ab1531009f967a35a849096 Mon Sep 17 00:00:00 2001 From: Matt Singleton Date: Sun, 2 Apr 2023 14:44:20 -0500 Subject: enable systemd service --- sway-de/install.sh | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'sway-de') diff --git a/sway-de/install.sh b/sway-de/install.sh index 62ab544..b693941 100755 --- a/sway-de/install.sh +++ b/sway-de/install.sh @@ -6,7 +6,15 @@ # "desktop environment" style session. Relies on systemd for running # services as much as possible. -set -euo pipefail +set -eo pipefail + +if command -v stow > /dev/null; then + STOWCMD="stow" +fi +if [ -z "$STOWCMD" ]; then + echo "requires 'stow'. run without '--skip-packages' to install." + exit 1 +fi while [[ $# -gt 0 ]]; do case $1 in @@ -20,6 +28,8 @@ while [[ $# -gt 0 ]]; do esac done +set -u + if ! command -v dnf > /dev/null !! [ ! -f /etc/fedora-release ]; then echo "doesn't seem to be fedora workstation" exit 1 @@ -28,11 +38,11 @@ fi if [ -z "$skip_packages" ]; then # install rpmfusion if it's not already installed - repos_installed=$(dnf --cacheonly repolist | tail -n+2 | cut -f1 -d' ' | egrep -x 'rpmfusion-free|rpmfusion-nonfree' | wc -l) + repos_installed=$(dnf --cacheonly repolist | tail -n+2 | cut -f1 -d' ' | grep -Exc 'rpmfusion-free|rpmfusion-nonfree') if [ "$repos_installed" -lt "2" ]; then sudo dnf install \ - https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm \ - https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm + "https://mirrors.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm" \ + "https://mirrors.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm" fi # install packages @@ -44,13 +54,23 @@ if [ -z "$skip_packages" ]; then fi # use stow to install config files -stow \ +$STOWCMD \ --verbose \ --dir /home/matt/.dotfiles/sway-de \ --target /home/matt/.config \ --stow config -stow \ +$STOWCMD \ --verbose \ --dir /home/matt/.dotfiles/sway-de \ --target /home/matt/.local \ --stow local + +# enable new systemd units and start them if sway is running and +sway_active=$(systemctl --user is-active sway-session.target) +for unit in /home/matt/.dotfiles/sway-de/local/share/systemd/user/*; do + if [ "active" = "$sway_active" ]; then + systemctl --user enable --now "$(basename "$unit")" + else + systemctl --user enable "$(basename "$unit")" + fi +done -- cgit v1.2.3