-
Notifications
You must be signed in to change notification settings - Fork 0
/
uninstall
executable file
·142 lines (133 loc) · 3.91 KB
/
uninstall
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/bin/bash
SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
have_real=$(type -p realpath)
[ "${have_real}" ] && SCRIPT_PATH="$(realpath "$SCRIPT_PATH")"
KITTCONF="${HOME}/.config/kitty"
KCDIR="${KITTCONF}/kitty-control"
DIFFCONF="${KITTCONF}/diff.conf"
DIRDCONF="${KITTY_CONFIG_DIRECTORY}/diff.conf"
KCKITTEN="kc_read_config.py"
rm -f ${HOME}/.local/bin/kitty-control
rm -f ${HOME}/.local/bin/ffetch
rm -f ${HOME}/.local/bin/nfetch
rm -rf ${KCDIR}
[ -d ${KITTCONF} ] && {
find ${KITTCONF} -name ${KCKITTEN} -print0 | xargs -0 rm -f
}
[ -f ${DIFFCONF} ] && {
grep kitty-control ${DIFFCONF} | grep example >/dev/null && {
rm -f ${DIFFCONF}
}
}
[ "${KITTY_CONFIG_DIRECTORY}" ] && {
[ "${KITTY_CONFIG_DIRECTORY}" == "${KITTCONF}" ] || {
[ -d "${KITTY_CONFIG_DIRECTORY}" ] && {
rm -rf ${KITTY_CONFIG_DIRECTORY}/kitty-control
find ${KITTY_CONFIG_DIRECTORY} -name ${KCKITTEN} -print0 | xargs -0 rm -f
[ -f ${DIRDCONF} ] && {
grep kitty-control ${DIRDCONF} | grep example >/dev/null && {
rm -f ${DIRDCONF}
}
}
}
}
}
rm -f ${HOME}/.local/share/man/man1/kitty-control.1
rm -f ${HOME}/.local/share/man/man1/nfetch.1
rm -f ${HOME}/.local/share/man/man1/ffetch.1
APP_TOP="${HOME}"/.local/share/applications/kitty-session.desktop
[ -f "${SCRIPT_PATH}"/kitty-session.desktop ] && {
[ -f "${APP_TOP}" ] && {
diff "${SCRIPT_PATH}"/kitty-session.desktop "${APP_TOP}" >/dev/null && {
rm -f "${APP_TOP}"
}
}
}
SES_DIR="${KITTCONF}/sessions"
for start in "${SES_DIR}"/*; do
[ "${start}" == "${SES_DIR}/*" ] && continue
b=$(basename "${start}")
[ -f "${SCRIPT_PATH}"/config/sessions/"$b" ] && {
diff "${SCRIPT_PATH}"/config/sessions/"$b" "${start}" >/dev/null && {
rm -f "${start}"
}
}
done
for kitty_icon in "${KITTCONF}"/kitty.app.png "${KITTCONF}"/kitty.app.icns
do
kc_icon="${SCRIPT_PATH}"/icons/kitty-128.png
echo "${kitty_icon}" | grep icns >/dev/null && {
kc_icon="${SCRIPT_PATH}"/icons/kitty.app.icns
}
[ -f "${kc_icon}" ] && [ -f "${kitty_icon}" ] && {
diff "${kc_icon}" "${kitty_icon}" >/dev/null && rm -f "${kitty_icon}"
}
done
FDEST="${HOME}/.local/share/figlet-fonts"
for ff in "${SCRIPT_PATH}"/figlet-fonts/*
do
[ "${ff}" == "${SCRIPT_PATH}/figlet-fonts/*" ] && continue
bn=$(basename "${ff}")
[ -f "${FDEST}/${bn}" ] || continue
diff "${ff}" "${FDEST}/${bn}" > /dev/null && {
rm -f "${FDEST}/${bn}"
}
done
empty=1
for i in "${FDEST}"/*
do
[ "$i" == "${FDEST}/*" ] && continue
empty=
done
[ "${empty}" ] && {
[ -d "${FDEST}" ] && rmdir "${FDEST}"
}
# Restore ugly Kitty icons
darwin=
platform=$(uname -s)
[ "${platform}" == "Darwin" ] && darwin=1
if [ "${darwin}" ]; then
APP="/Applications/kitty.app/Contents/Resources/kitty/logo"
icon="${APP}"/kitty.png
SUDO=
[ -w "${APP}" ] || SUDO="sudo"
[ -f ${icon}.bak ] && {
${SUDO} cp ${icon}.bak ${icon}
${SUDO} rm -f ${icon}.bak
}
icon="${APP}/kitty-128.png"
[ -f ${icon}.bak ] && {
${SUDO} cp ${icon}.bak ${icon}
${SUDO} rm -f ${icon}.bak
}
else
APP="${HOME}/.local/kitty.app"
for icon in ${APP}/lib/kitty/logo/kitty.png \
${APP}/share/icons/hicolor/256x256/apps/kitty.png
do
[ -f ${icon}.bak ] && {
cp ${icon}.bak ${icon}
rm -f ${icon}.bak
}
done
icon="${APP}/lib/kitty/logo/kitty-128.png"
[ -f ${icon}.bak ] && {
cp ${icon}.bak ${icon}
rm -f ${icon}.bak
}
fi
ICON_DIR="${HOME}/.local/share/icons/hicolor/512x512/apps"
for extra_icon in apple-logo.png tux.png
do
ex_icon="${ICON_DIR}/${extra_icon}"
kc_icon="${SCRIPT_PATH}"/icons/${extra_icon}
[ -f "${kc_icon}" ] && [ -f "${ex_icon}" ] && {
diff "${kc_icon}" "${ex_icon}" >/dev/null && rm -f "${ex_icon}"
}
done
ex_icon="${ICON_DIR}/kitty.png"
kc_icon="${SCRIPT_PATH}"/icons/kitty-512.png
[ -f "${kc_icon}" ] && [ -f "${ex_icon}" ] && {
diff "${kc_icon}" "${ex_icon}" >/dev/null && rm -f "${ex_icon}"
}
printf "Removal of kitty-control complete\n\n"