summaryrefslogtreecommitdiff
path: root/modules/10-i3/install.sh
blob: 17bc534addedc60bd481f90a626ddefe52b8683f (plain) (blame)
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
_script="$(realpath ${BASH_SOURCE[0]})"
_scriptname="$(basename $_script)"
_scriptdir="$(dirname $_script)"
_modulename="$(basename $_scriptdir)"
DOT_MODULE_NAME="i3"

function preinstall() {
	if ! [[ -x "$(command -v i3)" ]]; then
		PACKAGES+=("i3-gaps" "i3status")
	fi
	if ! [[ -x "$(command -v i3lock)" ]]; then
		PACKAGES+=("i3lock" "polkit")
	fi
	if ! [[ -x "$(command -v dmenu)" ]]; then
		PACKAGES+=("dmenu")
	fi
	if ! [[ -x "$(command -v startx)" ]]; then
		PACKAGES+=("xorg" "xorg-xinit")
	fi
	if ! [[ -x "$(command -v xss-lock)" ]]; then
		PACKAGES+=("xss-lock")
	fi
	if ! [[ -x "$(command -v scrot)" ]]; then
		PACKAGES+=("scrot")
	fi
	if ! [[ -x "$(command -v convert)" ]]; then
		PACKAGES+=("imagemagick")
	fi
}

function install() {
	# backup old file if it exists and we haven't backed it up before
	if ! [[ -f "$_scriptdir/.firstrun" ]]; then
		if [[ -d "$HOME/.config/i3" ]] && ! [[ -d "$HOME/.config/i3.bak" ]]; then
			log verbose "making backup of i3"
			cp -r "$HOME/.config/i3" "$HOME/.config/i3.bak"
		fi
		if [[ -d "$HOME/.config/i3status" ]] && ! [[ -d "$HOME/.config/i3status.bak" ]]; then
			log verbose "making backup of i3status"
			cp -r "$HOME/.config/i3status" "$HOME/.config/i3status.bak"
		fi
		touch "$_scriptdir/.firstrun"
	fi

	log info "linking i3 config"
	rm -rf "$HOME/.config/i3"
	ln -sf "$_scriptdir/i3" "$HOME/.config/i3"

	log info "linking i3status config"
	rm -rf "$HOME/.config/i3status"
	ln -sf "$_scriptdir/i3status/" "$HOME/.config/i3status"

	log info "linking xinitrc"
	ln -sf "$_scriptdir/xinitrc" "$HOME/.xinitrc"
}