feat: followup to 7c7dd4e

This commit is contained in:
th33xitus
2021-03-22 13:34:52 +01:00
parent 7c7dd4ec3c
commit b46457328f

View File

@@ -4,9 +4,9 @@ SYSTEMDDIR="/etc/systemd/system"
check_select_printer(){
unset printer_num
### get klipper cfg loc and set default theme loc
### get klipper cfg loc and set default .theme folder loc
check_klipper_cfg_path
THEME_PATH="$klipper_cfg_loc/.theme"
THEME_PATH="$klipper_cfg_loc"
### check if there is more than one moonraker instance and if yes
### ask the user to select the printer he wants to install/remove the theme
@@ -19,9 +19,12 @@ check_select_printer(){
bottom_border
read -p "${cyan}Select printer:${default} " printer_num
### rewrite the theme path matching the selected printer
THEME_PATH="$klipper_cfg_loc/printer_$printer_num/.theme"
### rewrite the .theme path matching the selected printer
THEME_PATH="$klipper_cfg_loc/printer_$printer_num"
fi
### create the cfg folder if there is none yet
[ ! -d $THEME_PATH ] && mkdir -p $THEME_PATH
}
ms_theme_delete(){
@@ -29,50 +32,27 @@ ms_theme_delete(){
check_select_printer
### remove .theme folder
if [ -d $THEME_PATH ]; then
if [ -d "$THEME_PATH/.theme" ]; then
status_msg "Removing Theme ..."
rm -rf $THEME_PATH && ok_msg "Theme removed!\n"
rm -rf "$THEME_PATH/.theme" && ok_msg "Theme removed!\n"
else
status_msg "No Theme installed!\n"
fi
}
ms_theme_dracula(){
THEME_RAW_URL="https://raw.githubusercontent.com/steadyjaw/dracula-mainsail-theme/master/config/.theme/"
THEME_URL="https://github.com/steadyjaw/dracula-mainsail-theme"
### check and select printer if there is more than 1
check_select_printer
### list filenames we need to download
files=(
custom.css
favicon-32x32.png
favicon-64x64.png
sidebar-background.png
sidebar-logo.svg
)
### check for .theme folder
[ ! -d $THEME_PATH ] && mkdir -p $THEME_PATH
cd $THEME_PATH
### download all files
status_msg "Installing Dracula theme ..."
status_msg "Please wait ..."
for file in ${files[@]}
do
status_msg "Downloading $file ..."
wget -q "$THEME_RAW_URL$file" -O $file
ok_msg "Done!"
done
### check if all files got downloaded
if [ $(ls | wc -l) = ${#files[@]} ]; then
echo
ok_msg "Theme installation complete!"
ok_msg "Please remember to delete your browser cache!\n"
else
echo
warn_msg "Some files are missing! Please try again!\n"
fi
[ -d "$THEME_PATH/.theme" ] && rm -rf "$THEME_PATH/.theme"
cd $THEME_PATH && git clone "$THEME_URL" ".theme"
ok_msg "Theme installation complete!"
ok_msg "Please remember to delete your browser cache!\n"
}