aboutsummaryrefslogtreecommitdiff
path: root/sway-de/install.sh
blob: b693941993c76a09565c24aec9d2656eafdb86e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
#
# Designed for Fedora Workstation
#
# Installs and configures sway and related tools to provide a richer
# "desktop environment" style session. Relies on systemd for running
# services as much as possible.

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
    --skip-packages)
      skip_packages=1
      shift
      ;;
    *)
      shift
      ;;
  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
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' ' | 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"
  fi

  # install packages
  sudo dnf install \
    sway waybar wob wofi foot lxpolkit mako cascadia-mono-pl-fonts \
    udiskie libappindicator-gtk3 duplicity python3-b2sdk pass passmenu \
    brightnessctl vlc unzip vim wget git zsh stow

fi

# use stow to install config files
$STOWCMD \
  --verbose \
  --dir /home/matt/.dotfiles/sway-de \
  --target /home/matt/.config \
  --stow config
$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