2022-09-14 14:28:51 +00:00
|
|
|
#!/bin/bash
|
2023-08-06 17:06:47 +00:00
|
|
|
|
|
|
|
# Set the directory path where icons are stored
|
2023-10-13 20:16:34 +00:00
|
|
|
declare -r icons_dir=/usr/share/tromjaro-theme-switcher/icons
|
2022-09-14 14:28:51 +00:00
|
|
|
|
2022-09-14 15:14:04 +00:00
|
|
|
set_icon_theme() {
|
2023-08-06 17:06:47 +00:00
|
|
|
# Change icon theme in XFCE
|
|
|
|
xfconf-query -c xsettings -p /Net/IconThemeName -n -t string -s "$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
enable_dark_panels() {
|
2023-10-13 20:16:34 +00:00
|
|
|
# Enable dark panels if not already enabled
|
|
|
|
[ "$(xfconf-query -c xfce4-panel -p /panels/dark-mode)" != 'true' ] &&
|
|
|
|
xfconf-query -c xfce4-panel -p /panels/dark-mode -n -t bool -s true &&
|
|
|
|
panel_notification=" with dark panels"
|
2023-08-06 17:06:47 +00:00
|
|
|
}
|
|
|
|
|
2022-09-14 15:14:04 +00:00
|
|
|
set_theme() {
|
2023-10-13 20:16:34 +00:00
|
|
|
local -r theme="$1"
|
|
|
|
unset panel_notification
|
2023-08-06 17:06:47 +00:00
|
|
|
|
2023-08-07 20:13:04 +00:00
|
|
|
# Set the icon theme and panel color according to the chosen theme
|
2023-08-06 17:06:47 +00:00
|
|
|
case "$theme" in
|
2023-10-16 10:57:07 +00:00
|
|
|
*'-Dark'|*'-Dark-Nord')
|
2023-08-06 17:06:47 +00:00
|
|
|
set_icon_theme 'zafiro-dark'
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
set_icon_theme 'zafiro'
|
|
|
|
enable_dark_panels
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
# Change the main theme to the chosen one
|
|
|
|
xfconf-query -c xsettings -p /Net/ThemeName -n -t string -s "$theme"
|
2023-08-07 20:13:04 +00:00
|
|
|
|
|
|
|
# Send notification about the theme change
|
2023-10-13 20:16:34 +00:00
|
|
|
notify-send 'Theme Switcher' "$theme theme$panel_notification was enabled"
|
2022-09-14 14:28:51 +00:00
|
|
|
}
|
|
|
|
|
2023-08-06 17:06:47 +00:00
|
|
|
# Export functions to make them available inside yad
|
2023-08-08 14:49:13 +00:00
|
|
|
export -f set_icon_theme enable_dark_panels set_theme
|
2023-08-06 17:06:47 +00:00
|
|
|
|
2023-10-13 20:16:34 +00:00
|
|
|
# A collection of tooltips that appear when you hover over a theme button
|
2023-10-16 10:57:07 +00:00
|
|
|
declare -r themes_tooltip=('Grey-Light' 'Grey-Nord' 'Grey-Dark' 'Grey-Dark-Nord' 'Pink-Light' 'Pink-Nord' 'Pink-Dark' 'Pink-Dark-Nord' 'Green-Light' 'Green-Nord' 'Green-Dark' 'Green-Dark-Nord' 'Orange-Light' 'Orange-Nord' 'Orange-Dark' 'Orange-Dark-Nord' 'Purple-Light' 'Purple-Nord' 'Purple-Dark' 'Purple-Dark-Nord' 'Yellow-Light' 'Yellow-Nord' 'Yellow-Dark' 'Yellow-Dark-Nord' 'Teal-Light' 'Teal-Nord' 'Teal-Dark' 'Teal-Dark-Nord (default)')
|
2023-10-13 20:16:34 +00:00
|
|
|
|
|
|
|
# Build the command line arguments we need to pass to yad to display the theme buttons
|
|
|
|
build_cmdline_args() {
|
|
|
|
for tooltip in "${themes_tooltip[@]}"; do
|
|
|
|
# Stripping the text after space gives you the theme name
|
|
|
|
local theme="Colloid-${tooltip% *}"
|
|
|
|
local theme_icon_path="$icons_dir/$theme.png"
|
|
|
|
printf '%s\n' "--field=!$theme_icon_path!$tooltip:BTN" "set_theme '$theme'"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
# Save those arguments to an array named cmdline_args
|
|
|
|
readarray -t cmdline_args < <(build_cmdline_args)
|
|
|
|
|
|
|
|
# Display the GUI interface using yad
|
|
|
|
yad --no-buttons --center --keep-icon-size --use-interp --title 'TROMjaro Theme Switcher' \
|
|
|
|
--text-align=center --text "A Theme Switcher for TROMjaro's default theme-set (Colloid) and icon-set (Zafiro)." \
|
|
|
|
--form --columns 7 --css='button:focus:not(:hover) { box-shadow: none; }' \
|
|
|
|
"${cmdline_args[@]}"
|