mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-13 10:34:28 +05:00
script: mainsail theme installer overhaul
This commit is contained in:
@@ -1,6 +1,64 @@
|
|||||||
### base variables
|
### base variables
|
||||||
SYSTEMDDIR="/etc/systemd/system"
|
SYSTEMDDIR="/etc/systemd/system"
|
||||||
|
|
||||||
|
get_theme_list(){
|
||||||
|
theme_csv_url="https://raw.githubusercontent.com/meteyou/mainsail/cb874c1918f47f79441bd80decaa272fe8bae40f/docs/_data/themes.csv"
|
||||||
|
theme_csv=$(curl -s -L $theme_csv_url)
|
||||||
|
unset t_name
|
||||||
|
unset t_note
|
||||||
|
unset t_auth
|
||||||
|
unset t_url
|
||||||
|
i=0
|
||||||
|
while IFS="," read -r col1 col2 col3 col4; do
|
||||||
|
t_name+=("$col1")
|
||||||
|
t_note+=("$col2")
|
||||||
|
t_auth+=("$col3")
|
||||||
|
t_url+=("$col4")
|
||||||
|
if [ ! "$col1" == "name" ]; then
|
||||||
|
printf "| $i) %-50s|\n" "[$col1]"
|
||||||
|
fi
|
||||||
|
let i++
|
||||||
|
done <<< $theme_csv
|
||||||
|
}
|
||||||
|
|
||||||
|
ms_theme_ui(){
|
||||||
|
top_border
|
||||||
|
echo -e "| ${red}~~~~~~~~ [ Mainsail Theme Installer ] ~~~~~~~${default} | "
|
||||||
|
hr
|
||||||
|
echo -e "| ${green}A preview of each Mainsail theme can be found here:${default} | "
|
||||||
|
echo -e "| https://docs.mainsail.xyz/theming/themes | "
|
||||||
|
blank_line
|
||||||
|
echo -e "| ${yellow}Important note:${default} | "
|
||||||
|
echo -e "| Installing a theme from this menu will overwrite an | "
|
||||||
|
echo -e "| already installed theme or modified custom.css file! | "
|
||||||
|
hr
|
||||||
|
#echo -e "| Theme: | "
|
||||||
|
# dynamically generate the themelist from a csv file
|
||||||
|
get_theme_list
|
||||||
|
echo -e "| | "
|
||||||
|
echo -e "| R) [Remove Theme] | "
|
||||||
|
#echo -e "| | "
|
||||||
|
quit_footer
|
||||||
|
}
|
||||||
|
|
||||||
|
ms_theme_menu(){
|
||||||
|
ms_theme_ui
|
||||||
|
while true; do
|
||||||
|
read -p "${cyan}Install theme:${default} " a; echo
|
||||||
|
if [ $a = "q" ] || [ $a = "Q" ]; then
|
||||||
|
clear && advanced_menu && break
|
||||||
|
elif [ $a -le ${#t_url[@]} ]; then
|
||||||
|
ms_theme_install "${t_auth[$a]}" "${t_url[$a]}" "${t_name[$a]}" "${t_note[$a]}"
|
||||||
|
ms_theme_menu
|
||||||
|
else
|
||||||
|
clear && print_header
|
||||||
|
ERROR_MSG="Invalid command!" && print_msg && clear_msg
|
||||||
|
ms_theme_menu
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
ms_theme_menu
|
||||||
|
}
|
||||||
|
|
||||||
check_select_printer(){
|
check_select_printer(){
|
||||||
unset printer_num
|
unset printer_num
|
||||||
|
|
||||||
@@ -27,6 +85,24 @@ check_select_printer(){
|
|||||||
[ ! -d $THEME_PATH ] && mkdir -p $THEME_PATH
|
[ ! -d $THEME_PATH ] && mkdir -p $THEME_PATH
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ms_theme_install(){
|
||||||
|
THEME_URL="https://github.com/$1/$2"
|
||||||
|
|
||||||
|
### check and select printer if there is more than 1
|
||||||
|
check_select_printer
|
||||||
|
|
||||||
|
### download all files
|
||||||
|
status_msg "Installing $3 ..."
|
||||||
|
status_msg "Please wait ..."
|
||||||
|
|
||||||
|
[ -d "$THEME_PATH/.theme" ] && rm -rf "$THEME_PATH/.theme"
|
||||||
|
cd $THEME_PATH && git clone "$THEME_URL" ".theme"
|
||||||
|
|
||||||
|
ok_msg "Theme installation complete!"
|
||||||
|
[ ! -z "$4" ] && echo "${yellow}###### Theme Info: $4${default}"
|
||||||
|
ok_msg "Please remember to delete your browser cache!\n"
|
||||||
|
}
|
||||||
|
|
||||||
ms_theme_delete(){
|
ms_theme_delete(){
|
||||||
### check and select printer if there is more than 1
|
### check and select printer if there is more than 1
|
||||||
check_select_printer
|
check_select_printer
|
||||||
@@ -38,55 +114,4 @@ ms_theme_delete(){
|
|||||||
else
|
else
|
||||||
status_msg "No Theme installed!\n"
|
status_msg "No Theme installed!\n"
|
||||||
fi
|
fi
|
||||||
}
|
|
||||||
|
|
||||||
ms_theme_dracula(){
|
|
||||||
THEME_URL="https://github.com/steadyjaw/dracula-mainsail-theme"
|
|
||||||
|
|
||||||
### check and select printer if there is more than 1
|
|
||||||
check_select_printer
|
|
||||||
|
|
||||||
### download all files
|
|
||||||
status_msg "Installing Dracula theme ..."
|
|
||||||
status_msg "Please wait ..."
|
|
||||||
|
|
||||||
[ -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"
|
|
||||||
}
|
|
||||||
|
|
||||||
ms_theme_cyberpunk(){
|
|
||||||
THEME_URL="https://github.com/Dario-Ciceri/cp2077-mainsail-theme"
|
|
||||||
|
|
||||||
### check and select printer if there is more than 1
|
|
||||||
check_select_printer
|
|
||||||
|
|
||||||
### download all files
|
|
||||||
status_msg "Installing Cyberpunk theme ..."
|
|
||||||
status_msg "Please wait ..."
|
|
||||||
|
|
||||||
[ -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"
|
|
||||||
}
|
|
||||||
|
|
||||||
ms_theme_voron_toolhead(){
|
|
||||||
THEME_URL="https://github.com/eriroh/Mainsail-x-Voron-Toolhead-Theme"
|
|
||||||
|
|
||||||
### check and select printer if there is more than 1
|
|
||||||
check_select_printer
|
|
||||||
|
|
||||||
### download all files
|
|
||||||
status_msg "Installing Mainsail x Voron Toolhead theme ..."
|
|
||||||
status_msg "Please wait ..."
|
|
||||||
|
|
||||||
[ -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"
|
|
||||||
}
|
}
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
ms_theme_ui(){
|
|
||||||
top_border
|
|
||||||
echo -e "| ${red}~~~~~~~~ [ Mainsail Theme Installer ] ~~~~~~~${default} | "
|
|
||||||
hr
|
|
||||||
echo -e "| Please note: | "
|
|
||||||
echo -e "| Installing a theme from this menu will overwrite an | "
|
|
||||||
echo -e "| already installed theme or modified custom.css file! | "
|
|
||||||
hr
|
|
||||||
echo -e "| Theme: | "
|
|
||||||
echo -e "| 1) [Dracula] | "
|
|
||||||
echo -e "| 2) [Cyberpunk] | "
|
|
||||||
echo -e "| 3) [Voron Toolhead] | "
|
|
||||||
echo -e "| | "
|
|
||||||
echo -e "| R) [Remove Theme] | "
|
|
||||||
echo -e "| | "
|
|
||||||
quit_footer
|
|
||||||
}
|
|
||||||
|
|
||||||
ms_theme_menu(){
|
|
||||||
do_action "" "ms_theme_ui"
|
|
||||||
while true; do
|
|
||||||
read -p "${cyan}Perform action:${default} " action; echo
|
|
||||||
case "$action" in
|
|
||||||
1) do_action "ms_theme_dracula" "ms_theme_ui";;
|
|
||||||
2) do_action "ms_theme_cyberpunk" "ms_theme_ui";;
|
|
||||||
3) do_action "ms_theme_voron_toolhead" "ms_theme_ui";;
|
|
||||||
R|r) do_action "ms_theme_delete" "ms_theme_ui";;
|
|
||||||
Q|q) clear; advanced_menu; break;;
|
|
||||||
*) deny_action "ms_theme_ui";;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
ms_theme_menu
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user