-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathremove.sh
executable file
·98 lines (87 loc) · 3.14 KB
/
remove.sh
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/sh
# shellcheck disable=SC1091
if [ -z "${DOTFILES_ROOT}" ]; then
if command -v dirname >/dev/null 2>&1 && command -v realpath >/dev/null 2>&1; then
DOTFILES_ROOT="$(realpath "$(dirname "$0")")"
elif command -v dirname >/dev/null 2>&1; then
DOTFILES_ROOT="$(cd "$(dirname "$0")" || return; pwd)"
else
echo >&2 '[Error] cannot determine root (try running from working directory)'
exit 1
fi
fi
echo Removing dotfiles
# Load dependencies
. "${DOTFILES_ROOT}"/dotfiles/dependencies
# Figure out what we've got linked
# shellcheck disable=SC2154
for i in ${dotfiles}; do
dotfile="$(basename "${i}")"
file="${HOME}/.${dotfile}"
if [ -L "${file}" ]; then
echo Removing "${file}"
rm "${file}"
fi
BACKUP="${DOTFILES_ROOT}/backup/local-${dotfile}"
if [ -f "${BACKUP}" ]; then
echo Restoring "${file}" from backup
mv "${BACKUP}" "${file}"
fi
done
# shellcheck disable=SC2154
for dotfile in ${extra}; do
file="${dotfile}"
if [ -L "${file}" ]; then
echo Removing "${file}"
rm "${file}"
fi
BACKUP="${DOTFILES_ROOT}/backup/local-$(basename "${dotfile}" | xargs)"
if [ -f "${BACKUP}" ]; then
echo Restoring "${dotfile}" from backup
mv "${BACKUP}" "${file}"
fi
done
if [ -L "${USER_CHROME}" ]; then
echo Removing "${USER_CHROME}"
rm "${USER_CHROME}"
if [ -f "${DOTFILES_ROOT}/backup/local-userChrome.css" ]; then
echo Restoring "${USER_CHROME}" from backup
mv "${DOTFILES_ROOT}/backup/local-userChrome.css" "${USER_CHROME}"
elif [ -f "${DOTFILES_ROOT}/backup/userChrome.css" ]; then
echo Restoring "${USER_CHROME}" from backup
mv "${DOTFILES_ROOT}/backup/userChrome.css" "${USER_CHROME}"
fi
fi
if [ -L "${PIPEWIRE_CONFIG_ALSA_PATH}" ]; then
echo Removing "${PIPEWIRE_CONFIG_ALSA_PATH}"
rm "${PIPEWIRE_CONFIG_ALSA_PATH}"
if [ -f "${DOTFILES_ROOT}/backup/local-${PIPEWIRE_CONFIG_ALSA}" ]; then
echo Restoring "${PIPEWIRE_CONFIG_ALSA_PATH}" from backup
mv "${DOTFILES_ROOT}/backup/local-${PIPEWIRE_CONFIG_ALSA}" "${PIPEWIRE_CONFIG_ALSA_PATH}"
fi
fi
if [ -L "${PIPEWIRE_CONFIG_BLUEZ_PATH}" ]; then
echo Removing "${PIPEWIRE_CONFIG_BLUEZ_PATH}"
rm "${PIPEWIRE_CONFIG_BLUEZ_PATH}"
if [ -f "${DOTFILES_ROOT}/backup/local-${PIPEWIRE_CONFIG_BLUEZ}" ]; then
echo Restoring "${PIPEWIRE_CONFIG_BLUEZ_PATH}" from backup
mv "${DOTFILES_ROOT}/backup/local-${PIPEWIRE_CONFIG_BLUEZ}" "${PIPEWIRE_CONFIG_BLUEZ_PATH}"
fi
fi
if [ -L "${WIREPLUMBER_CONFIG_ALSA_PATH}" ]; then
echo Removing "${WIREPLUMBER_CONFIG_ALSA_PATH}"
rm "${WIREPLUMBER_CONFIG_ALSA_PATH}"
if [ -f "${DOTFILES_ROOT}/backup/local-${WIREPLUMBER_CONFIG_ALSA}" ]; then
echo Restoring "${WIREPLUMBER_CONFIG_ALSA_PATH}" from backup
mv "${DOTFILES_ROOT}/backup/local-${WIREPLUMBER_CONFIG_ALSA}" "${WIREPLUMBER_CONFIG_ALSA_PATH}"
fi
fi
if [ -L "${WIREPLUMBER_CONFIG_BLUETOOTH_PATH}" ]; then
echo Removing "${WIREPLUMBER_CONFIG_BLUETOOTH_PATH}"
rm "${WIREPLUMBER_CONFIG_BLUETOOTH_PATH}"
if [ -f "${DOTFILES_ROOT}/backup/local-${WIREPLUMBER_CONFIG_BLUETOOTH}" ]; then
echo Restoring "${WIREPLUMBER_CONFIG_BLUETOOTH_PATH}" from backup
mv "${DOTFILES_ROOT}/backup/local-${WIREPLUMBER_CONFIG_BLUETOOTH}" "${WIREPLUMBER_CONFIG_BLUETOOTH_PATH}"
fi
fi
echo Done