v-delete-sys-theme 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/bin/bash
  2. # info: removes a theme from the custom theme library
  3. # options: theme
  4. # labels: hestia
  5. #
  6. # example: v-delete-sys-theme dark
  7. #
  8. # The function removes a theme from the custom theme library.
  9. # Please note "default" theme can't be deleted due to dependencies for other themes
  10. #----------------------------------------------------------#
  11. # Variable&Function #
  12. #----------------------------------------------------------#
  13. # Argument definition
  14. theme=$1
  15. # Includes
  16. source $HESTIA/func/main.sh
  17. source $HESTIA/conf/hestia.conf
  18. #----------------------------------------------------------#
  19. # Action #
  20. #----------------------------------------------------------#
  21. if [ -z "$theme" ]; then
  22. # Theme not specified, throw an error.
  23. echo "ERROR: No theme specified."
  24. exit 1
  25. else
  26. if [ -e $HESTIA_THEMES/$theme.css ]; then
  27. # Protect system themes from deletion
  28. # Users can use the terminal to work around this if really desired.
  29. echo "ERROR: Unable to delete system theme: $theme."
  30. exit 1
  31. fi
  32. if [ -e $HESTIA_THEMES_CUSTOM/$theme.css ]; then
  33. # Remove theme if it exists.
  34. echo "Deleting $theme..."
  35. rm -f $HESTIA_THEMES_CUSTOM/$theme.css > /dev/null 2&>1
  36. else
  37. # Theme doesn't exist, throw an error.
  38. echo "ERROR: Theme $theme does not exist."
  39. fi
  40. fi
  41. # Set default theme in configuration file if deleted theme was active
  42. if [ "$THEME" = "$theme" ]; then
  43. rm -f $HESTIA/web/css/active-theme.css
  44. $BIN/v-change-sys-config-value 'THEME' default
  45. fi
  46. #----------------------------------------------------------#
  47. # Hestia #
  48. #----------------------------------------------------------#
  49. exit