darkine-kde/install.sh

103 lines
2.4 KiB
Bash
Raw Normal View History

2019-03-08 14:49:32 +01:00
#!/usr/bin/env bash
2019-05-13 15:08:36 +02:00
#
# @name : install.sh
# @version : 2.0.0
# @date : 12/05/2019
# @description : Install le last git version of XXXXX theme for KDE-Plasma.
# @website : https://github.com/Rokin05
#
##
2018-03-30 21:39:48 +02:00
set -e
2019-05-13 15:08:36 +02:00
name="darkine"
2018-03-30 21:39:48 +02:00
gh_repo="darkine-kde"
2019-05-13 15:08:36 +02:00
E='echo -e'
OUT="/dev/null"
2018-03-30 21:39:48 +02:00
2019-05-13 15:08:36 +02:00
: "${PREFIX:=/usr}"
: "${uninstall:=false}"
2018-03-30 21:39:48 +02:00
2019-05-13 15:08:36 +02:00
title() {
$E ; $E "[+]\e[1;33m ${1} \e[m"
$E "------------------------------------"
}
2018-03-30 21:39:48 +02:00
2019-05-13 15:08:36 +02:00
msg() {
$E " - ${1}"
}
2018-03-30 21:39:48 +02:00
_rm() {
# removes parent directories if empty
2019-05-13 15:08:36 +02:00
sudo rm -rf "${1}"
sudo rmdir -p "$(dirname "${1}")" 2>$OUT || true
2018-03-30 21:39:48 +02:00
}
_download() {
2019-05-13 15:08:36 +02:00
msg "Getting the latest version from GitHub ..."
msg "(https://github.com/Rokin05/${gh_repo}/archive/master.tar.gz)"
wget --quiet -O "${temp_file}" \
"https://github.com/Rokin05/${gh_repo}/archive/master.tar.gz"
msg "Unpacking archive ..."
tar -xzf "${temp_file}" -C "${temp_dir}"
2018-03-30 21:39:48 +02:00
}
_uninstall() {
2019-05-13 15:08:36 +02:00
msg "Deleting ${name^}"
_rm "${PREFIX}/share/plasma/look-and-feel/${name,,}"
_rm "${PREFIX}/share/plasma/desktoptheme/${name,,}"
_rm "${PREFIX}/share/color-schemes/${name^}.colors"
_rm "${PREFIX}/share/aurorae/themes/${name^}-classic"
_rm "${PREFIX}/share/aurorae/themes/${name^}-round"
_rm "${PREFIX}/share/Kvantum/${name^}"
_rm "${PREFIX}/share/icons/${name,,}"
_rm "${PREFIX}/share/sddm/themes/${name,,}"
_rm "${PREFIX}/share/wallpapers/${name^}"
_rm "${PREFIX}/share/konsole/Darkine.colorscheme"
2019-05-17 14:13:45 +02:00
_rm "${PREFIX}/share/themes/${name^}"
2018-03-30 21:39:48 +02:00
}
_install() {
2019-05-13 15:08:36 +02:00
msg "Installing"
2018-03-30 21:39:48 +02:00
sudo cp -R \
2019-05-13 15:08:36 +02:00
"${temp_dir}/${gh_repo}-master/plasma" \
"${temp_dir}/${gh_repo}-master/color-schemes" \
"${temp_dir}/${gh_repo}-master/aurorae" \
"${temp_dir}/${gh_repo}-master/Kvantum" \
"${temp_dir}/${gh_repo}-master/icons" \
"${temp_dir}/${gh_repo}-master/sddm" \
"${temp_dir}/${gh_repo}-master/wallpapers" \
"${temp_dir}/${gh_repo}-master/konsole" \
2019-05-17 14:13:45 +02:00
"${temp_dir}/${gh_repo}-master/themes" \
2019-05-13 15:08:36 +02:00
"${PREFIX}/share"
2018-03-30 21:39:48 +02:00
}
_cleanup() {
2019-05-13 15:08:36 +02:00
msg "Clearing cache"
rm -rf "${temp_file}" "${temp_dir}" \
~/.cache/plasma-svgelements-${name,,}* \
~/.cache/plasma_theme_${name,,}*.kcache \
~/.cache/icon-cache.kcache
2018-03-30 21:39:48 +02:00
}
temp_file="$(mktemp -u)"
temp_dir="$(mktemp -d)"
2019-05-13 15:08:36 +02:00
title "${name^}"
trap _cleanup EXIT HUP INT TERM
2018-03-30 21:39:48 +02:00
if [ "$uninstall" = "false" ]; then
_download
_uninstall
_install
else
_uninstall
2019-05-13 15:08:36 +02:00
fi