Compare commits

...

15 Commits

2 changed files with 57 additions and 54 deletions

@ -1,14 +1,14 @@
# Maintainer: TROM <contact@tromsite.com>
pkgname=tromjaro-theme-switcher
pkgver=1.2.0
pkgver=1.4
pkgrel=1
pkgdesc="TROMjaro Theme switcher application"
arch=(any)
url=""
license=(unknown)
depends=('yad'
'zafiro-icon-theme'
'skeuos-gtk')
'colloid-gtk-theme-git'
'zafiro-icon-theme')
provides=('tromjaro-theme-switcher')
backup=()
options=(!strip)

@ -1,60 +1,63 @@
#!/bin/bash
icons=/usr/share/tromjaro-theme-switcher/icons
# Set the directory path where icons are stored
declare -r icons_dir=/usr/share/tromjaro-theme-switcher/icons
set_icon_theme() {
# Change icon theme in XFCE
xfconf-query -c xsettings -p /Net/IconThemeName -n -t string -s "$1"
# Change icon theme in XFCE
xfconf-query -c xsettings -p /Net/IconThemeName -n -t string -s "$1"
}
enable_dark_panels() {
# 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"
}
set_theme() {
if [ "${1##*-}" = 'Light' ]; then
yad --image "dialog-question" --title '' --buttons-layout=center --text-align=center --button='DARK':1 --button='LIGHT':0 --text "Select the panels theme\n\nNote: dark panels may result in light icons over a light theme"
case $? in
1)
# Enable dark panels
xfconf-query -c xfce4-panel -p /panels/dark-mode -n -t bool -s true
# Use the dark icon theme
set_icon_theme zafiro-dark
;;
0)
# Disable dark panels
xfconf-query -c xfce4-panel -p /panels/dark-mode -n -t bool -s false
# Use the light icon theme
set_icon_theme zafiro
;;
*) exit ;;
esac
else
# Use the dark icon theme
set_icon_theme zafiro-dark
fi
# Change the main theme to the chosen one
xfconf-query -c xsettings -p /Net/ThemeName -n -t string -s "Skeuos-$1"
xfconf-query -c xfwm4 -p /general/theme -n -t string -s "Skeuos-$1-XFWM"
gsettings set org.gnome.desktop.interface gtk-theme "Skeuos-$1"
notify-send "Skeuos-$1 theme was enabled"
local -r theme="$1"
unset panel_notification
# Set the icon theme and panel color according to the chosen theme
case "$theme" in
*'-Dark-Gruvbox'|*'-Dark'|*'-Dark-Nord')
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"
# Send notification about the theme change
notify-send 'Theme Switcher' "$theme theme$panel_notification was enabled"
}
export -f set_icon_theme set_theme
# Export functions to make them available inside yad
export -f set_icon_theme enable_dark_panels set_theme
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 (Skeuos) and icon-set (Zafiro)." --form --columns 5 \
--field=!"$icons/Blue-Dark.png"!'Blue-Dark':FBTN "set_theme 'Blue-Dark'" \
--field=!"$icons/Violet-Dark.png"!'Violet-Dark':FBTN "set_theme 'Violet-Dark'" \
--field=!"$icons/Blue-Light.png"!'Blue-Light':FBTN "set_theme 'Blue-Light'" \
--field=!"$icons/Violet-Light.png"!'Violet-Light':FBTN "set_theme 'Violet-Light'" \
--field=!"$icons/Teal-Dark.png"!'Teal-Dark':FBTN "set_theme 'Teal-Dark'" \
--field=!"$icons/Orange-Dark.png"!'Orange-Dark':FBTN "set_theme 'Orange-Dark'" \
--field=!"$icons/Teal-Light.png"!'Teal-Light':FBTN "set_theme 'Teal-Light'" \
--field=!"$icons/Orange-Light.png"!'Orange-Light':FBTN "set_theme 'Orange-Light'" \
--field=!"$icons/Green-Dark.png"!'Green-Dark (default)':FBTN "set_theme 'Green-Dark'" \
--field=!"$icons/Brown-Dark.png"!'Brown-Dark':FBTN "set_theme 'Brown-Dark'" \
--field=!"$icons/Green-Light.png"!'Green-Light':FBTN "set_theme 'Green-Light'" \
--field=!"$icons/Brown-Light.png"!'Brown-Light':FBTN "set_theme 'Brown-Light'" \
--field=!"$icons/Magenta-Dark.png"!'Magenta-Dark':FBTN "set_theme 'Magenta-Dark'" \
--field=!"$icons/Yellow-Dark.png"!'Yellow-Dark':FBTN "set_theme 'Yellow-Dark'" \
--field=!"$icons/Magenta-Light.png"!'Magenta-Light':FBTN "set_theme 'Magenta-Light'" \
--field=!"$icons/Yellow-Light.png"!'Yellow-Light':FBTN "set_theme 'Yellow-Light'" \
--field=!"$icons/Red-Dark.png"!'Red-Dark':FBTN "set_theme 'Red-Dark'" \
--field=!"$icons/Grey-Dark.png"!'Grey-Dark':FBTN "set_theme 'Grey-Dark'" \
--field=!"$icons/Red-Light.png"!'Red-Light':FBTN "set_theme 'Red-Light'" \
--field=!"$icons/Grey-Light.png"!'Grey-Light':FBTN "set_theme 'Grey-Light'"
# A collection of tooltips that appear when you hover over a theme button
declare -r themes_tooltip=('Grey-Light' 'Grey' 'Grey-Nord' 'Grey-Dark' 'Grey-Dark-Nord' 'Grey-Dark-Gruvbox' 'Pink-Light' 'Pink' 'Pink-Nord' 'Pink-Dark' 'Pink-Dark-Nord' 'Pink-Dark-Gruvbox' 'Green-Light' 'Green' 'Green-Nord' 'Green-Dark' 'Green-Dark-Nord' 'Dark-Gruvbox' 'Orange-Light' 'Orange' 'Orange-Nord' 'Orange-Dark' 'Orange-Dark-Nord' 'Orange-Dark-Gruvbox' 'Purple-Light' 'Purple' 'Purple-Nord' 'Purple-Dark' 'Purple-Dark-Nord' 'Purple-Dark-Gruvbox' 'Yellow-Light' 'Yellow' 'Yellow-Nord' 'Yellow-Dark' 'Yellow-Dark-Nord' 'Yellow-Dark-Gruvbox' 'Teal-Light' 'Teal' 'Teal-Nord' 'Teal-Dark' 'Teal-Dark-Nord (default)' 'Dark-Nord')
# 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[@]}"