Compare commits
57 Commits
tio-patch-
...
main
Author | SHA1 | Date | |
---|---|---|---|
485056263d | |||
286faba203 | |||
53a4777985 | |||
f7a680587d | |||
8828398707 | |||
12dfb42215 | |||
f0f4214fa4 | |||
6eead68790 | |||
52c15867df | |||
25fed8663b | |||
cfcb07ab77 | |||
ae9fcce069 | |||
339d4113d6 | |||
c79c2ed7e8 | |||
696fc180c8 | |||
f97cecf89c | |||
300dd23942 | |||
7f58471475 | |||
dd101c50b5 | |||
a575fb583e | |||
f3e1c0a14c | |||
54c1c74878 | |||
11a1a7dc91 | |||
85b0e75ff6 | |||
acf400bd54 | |||
4c5a39a77c | |||
d3c1054ec0 | |||
9056b40bc4 | |||
4d6446d47d | |||
859fe8c2fa | |||
19e75fc5c0 | |||
8fe0c425f7 | |||
e50903aab7 | |||
b417fdebe3 | |||
30aa304b4a | |||
79a22a493c | |||
69867e2af9 | |||
45ebde24a2 | |||
da34f2087f | |||
8fa15242e6 | |||
7125866bb8 | |||
b342545738 | |||
992c201eed | |||
f1a643cb34 | |||
146f416bc4 | |||
0b6549ccc6 | |||
dc00830e31 | |||
703f23f3f8 | |||
6536b3cb21 | |||
e0255d4763 | |||
3dca8cb2a0 | |||
ee1c98250b | |||
2803bf44f4 | |||
d8accac823 | |||
d6757d36c8 | |||
092b572cf3 | |||
ca5367307c |
10
Makefile
10
Makefile
|
@ -1,12 +1,12 @@
|
||||||
# makefile for theme-switcher
|
# makefile for tromjaro-theme-switcher
|
||||||
build:
|
build:
|
||||||
makepkg
|
makepkg -s
|
||||||
|
|
||||||
install:
|
install:
|
||||||
pamac-installer theme-switcher-*.tar.xz
|
pamac-installer tromjaro-theme-switcher-*.tar.zst
|
||||||
|
|
||||||
remove:
|
remove:
|
||||||
pamac-installer --remove theme-switcher
|
pamac-installer --remove tromjaro-theme-switcher
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) -rf src/ pkg/ *.tar.xz
|
$(RM) -rf src/ pkg/ icons.tar.gz *.tar.zst
|
||||||
|
|
76
PKGBUILD
76
PKGBUILD
|
@ -1,36 +1,68 @@
|
||||||
# Maintainer: TROM <contact@tromsite.com>
|
# Maintainer: TROM <contact@tromsite.com>
|
||||||
pkgname=tromjaro-theme-switcher
|
pkgname=tromjaro-theme-switcher
|
||||||
pkgver=1.2.0
|
pkgver=3
|
||||||
pkgrel=1
|
pkgrel=4
|
||||||
pkgdesc="TROMjaro Theme switcher application"
|
pkgdesc="TROMjaro Theme switcher application"
|
||||||
arch=(any)
|
arch=('x86_64')
|
||||||
url=""
|
url="https://git.trom.tf/TROMjaro/theme-switcher-package"
|
||||||
license=(unknown)
|
license=(unknown)
|
||||||
depends=('yad'
|
depends=('tromjaro-fixes'
|
||||||
'zafiro-icon-theme'
|
'xfconf'
|
||||||
'skeuos-gtk')
|
'gtk4'
|
||||||
|
'colloid-gtk-theme-git'
|
||||||
|
'colloid-dracula-gtk-theme-git'
|
||||||
|
'colloid-gruvbox-gtk-theme-git'
|
||||||
|
'colloid-nord-gtk-theme-git'
|
||||||
|
'colloid-everforest-gtk-theme-git'
|
||||||
|
'colloid-catppuccin-gtk-theme-git'
|
||||||
|
'zafiro-icon-theme')
|
||||||
|
makedepends=('choosenim')
|
||||||
provides=('tromjaro-theme-switcher')
|
provides=('tromjaro-theme-switcher')
|
||||||
backup=()
|
backup=()
|
||||||
options=(!strip)
|
options=(!strip)
|
||||||
source=("theme-switcher"
|
source=("themeSwitcher.nim"
|
||||||
"tromjaro-theme-switcher.desktop"
|
"tromjaro-theme-switcher.desktop"
|
||||||
"tromjaro-theme-switcher.svg"
|
"tromjaro-theme-switcher.svg"
|
||||||
"https://www.drive.tromsite.com/s/zFtCp3SkZ4NpKix/download")
|
"icons.tar.gz::https://www.drive.tromsite.com/s/ysM33nJAkpro85b/download/icons.tar.gz")
|
||||||
sha256sums=('SKIP'
|
sha256sums=('SKIP'
|
||||||
'SKIP'
|
'SKIP'
|
||||||
'SKIP'
|
'SKIP'
|
||||||
'SKIP')
|
'SKIP')
|
||||||
package() {
|
prepare() {
|
||||||
# copy icons
|
# Disable telemetry in choosenim if user is running it for the first time
|
||||||
install -d ${pkgdir}/usr/share/tromjaro-theme-switcher/icons
|
[ -f "$HOME"/.choosenim/analytics ] || {
|
||||||
install -Dm644 ${srcdir}/icons/* ${pkgdir}/usr/share/tromjaro-theme-switcher/icons
|
mkdir -p "$HOME"/.choosenim
|
||||||
|
touch "$HOME"/.choosenim/analytics
|
||||||
# copy executables
|
}
|
||||||
install -Dm644 ${srcdir}/tromjaro-theme-switcher.desktop ${pkgdir}/usr/share/applications/tromjaro-theme-switcher.desktop
|
echo 'Install Nim if not already installed:'
|
||||||
install -Dm755 ${srcdir}/theme-switcher ${pkgdir}/usr/bin/tromjaro-theme-switcher
|
choosenim stable
|
||||||
|
echo 'Update Nim to the latest stable release:'
|
||||||
# copy the icon
|
choosenim update stable
|
||||||
install -d ${pkgdir}/usr/share/icons/hicolor/scalable/apps
|
echo 'Refresh nimble package list:'
|
||||||
install -Dm644 ${srcdir}/tromjaro-theme-switcher.svg ${pkgdir}/usr/share/icons/hicolor/scalable/apps
|
"$HOME"/.nimble/bin/nimble --nim:"$HOME"/.nimble/bin/nim refresh
|
||||||
|
echo 'Install owlkettle from the latest git commit:'
|
||||||
|
"$HOME"/.nimble/bin/nimble --nim:"$HOME"/.nimble/bin/nim install owlkettle
|
||||||
|
}
|
||||||
|
build(){
|
||||||
|
echo 'Compile themeSwitcher.nim for release build:'
|
||||||
|
"$HOME"/.nimble/bin/nim c -d:release --out:${srcdir}/themeSwitcher ${srcdir}/themeSwitcher.nim
|
||||||
|
}
|
||||||
|
package() {
|
||||||
|
# copy icons
|
||||||
|
install -d ${pkgdir}/usr/share/tromjaro-theme-switcher/icons/Styles
|
||||||
|
install -Dm644 ${srcdir}/icons/Styles/* ${pkgdir}/usr/share/tromjaro-theme-switcher/icons/Styles
|
||||||
|
|
||||||
|
for source_dir in "${srcdir}/icons/Accent Colors"/*; do
|
||||||
|
dest_dir="${pkgdir}/usr/share/tromjaro-theme-switcher/icons/Accent Colors/${source_dir##*/}"
|
||||||
|
install -d "$dest_dir"
|
||||||
|
install -Dm644 "$source_dir"/* "$dest_dir"
|
||||||
|
done
|
||||||
|
|
||||||
|
# copy executables
|
||||||
|
install -Dm644 ${srcdir}/tromjaro-theme-switcher.desktop ${pkgdir}/usr/share/applications/tromjaro-theme-switcher.desktop
|
||||||
|
install -Dm755 ${srcdir}/themeSwitcher ${pkgdir}/usr/bin/tromjaro-theme-switcher
|
||||||
|
|
||||||
|
# copy the icon
|
||||||
|
install -d ${pkgdir}/usr/share/icons/hicolor/scalable/apps
|
||||||
|
install -Dm644 ${srcdir}/tromjaro-theme-switcher.svg ${pkgdir}/usr/share/icons/hicolor/scalable/apps
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
# TROMjaro Theme switcher package
|
# TROMjaro Theme switcher
|
||||||
|
|
||||||
TROMjaro Theme switcher application
|
A Theme Switcher app for TROMjaro's default theme-set ([Colloid](https://github.com/vinceliuice/Colloid-gtk-theme)) and icon-set ([Zafiro](https://github.com/zayronxio/Zafiro-icons)). It gives you a nice and easy interface to try out different themes quickly.
|
||||||
|
|
||||||
|
<video width="720" height="480" controls autoplay title="Screen recording of the app in action" src="https://git.trom.tf/TROMjaro/theme-switcher-package/raw/branch/main/screenRecord.mp4" type="video/mp4"></video>
|
||||||
|
|
||||||
## Building the package
|
## Building the package
|
||||||
|
|
||||||
|
@ -16,6 +18,6 @@ To remove just installed package, use:
|
||||||
|
|
||||||
`make remove`
|
`make remove`
|
||||||
|
|
||||||
To cleanup the project, use:
|
To cleanup the project folder, use:
|
||||||
|
|
||||||
`make clean`
|
`make clean`
|
||||||
|
|
BIN
screenRecord.mp4
Normal file
BIN
screenRecord.mp4
Normal file
Binary file not shown.
|
@ -1,95 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
icons=/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"
|
|
||||||
}
|
|
||||||
|
|
||||||
enable_dark_panels() {
|
|
||||||
# Enable dark panels
|
|
||||||
xfconf-query -c xfce4-panel -p /panels/dark-mode -n -t bool -s true
|
|
||||||
}
|
|
||||||
|
|
||||||
disable_dark_panels() {
|
|
||||||
# Disable dark panels
|
|
||||||
xfconf-query -c xfce4-panel -p /panels/dark-mode -n -t bool -s false
|
|
||||||
}
|
|
||||||
|
|
||||||
show_icon_dialog() {
|
|
||||||
local icon_path=$1
|
|
||||||
yad --image "$icon_path" --title "Theme Icon" --window-icon=gtk-dialog-info --no-buttons --timeout=2
|
|
||||||
}
|
|
||||||
|
|
||||||
set_theme() {
|
|
||||||
local theme=$1
|
|
||||||
local icon_theme
|
|
||||||
local enable_dark
|
|
||||||
|
|
||||||
case "$theme" in
|
|
||||||
Colloid-Grey-Dark-Nord | Colloid-Grey | Colloid-Pink | Colloid-Green | Colloid-Orange | Colloid-Purple | Colloid-Teal | Colloid-Yellow | Colloid-Pink-Dark-Nord | Colloid-Green-Dark-Nord | Colloid-Orange-Dark-Nord | Colloid-Purple-Dark-Nord | Colloid-Teal-Dark-Nord | Colloid-Yellow-Dark-Nord | Colloid-Dark-Nord)
|
|
||||||
icon_theme='zafiro-dark'
|
|
||||||
enable_dark=true
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
icon_theme='zafiro'
|
|
||||||
enable_dark=false
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ "$enable_dark" = true ]; then
|
|
||||||
enable_dark_panels
|
|
||||||
set_icon_theme "$icon_theme"
|
|
||||||
else
|
|
||||||
disable_dark_panels
|
|
||||||
set_icon_theme "$icon_theme"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Change the main theme to the chosen one
|
|
||||||
xfconf-query -c xsettings -p /Net/ThemeName -n -t string -s "$theme"
|
|
||||||
xfconf-query -c xfwm4 -p /general/theme -n -t string -s "$theme"
|
|
||||||
notify-send "$theme theme was enabled"
|
|
||||||
}
|
|
||||||
|
|
||||||
export -f set_icon_theme set_theme enable_dark_panels disable_dark_panels show_icon_dialog
|
|
||||||
|
|
||||||
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 8 --width=1000 --height=400 \
|
|
||||||
--field=!"$icons/Colloid-Grey.png"!'Colloid-Grey':FBTN "set_theme 'Colloid-Grey'" \
|
|
||||||
--field=!"$icons/Colloid-Grey-Light.png"!'Colloid-Grey-Light':FBTN "set_theme 'Colloid-Grey-Light'" \
|
|
||||||
--field=!"$icons/Colloid-Grey-Dark-Nord.png"!'Colloid-Grey-Dark-Nord':FBTN "set_theme 'Colloid-Grey-Dark-Nord'" \
|
|
||||||
--field=!"$icons/Colloid-Grey-Dark-Gruvbox.png"!'Colloid-Grey-Dark-Gruvbox':FBTN "set_theme 'Colloid-Grey-Dark-Gruvbox'" \
|
|
||||||
\
|
|
||||||
--field=!"$icons/Colloid-Pink.png"!'Colloid-Pink':FBTN "set_theme 'Colloid-Pink'" \
|
|
||||||
--field=!"$icons/Colloid-Pink-Light.png"!'Colloid-Pink-Light':FBTN "set_theme 'Colloid-Pink-Light'" \
|
|
||||||
--field=!"$icons/Colloid-Pink-Dark-Nord.png"!'Colloid-Pink-Dark-Nord':FBTN "set_theme 'Colloid-Pink-Dark-Nord'" \
|
|
||||||
--field=!"$icons/Colloid-Pink-Dark-Gruvbox.png"!'Colloid-Pink-Dark-Gruvbox':FBTN "set_theme 'Colloid-Pink-Dark-Gruvbox'" \
|
|
||||||
\
|
|
||||||
--field=!"$icons/Colloid-Green.png"!'Colloid-Green':FBTN "set_theme 'Colloid-Green'" \
|
|
||||||
--field=!"$icons/Colloid-Green-Light.png"!'Colloid-Green-Light':FBTN "set_theme 'Colloid-Green-Light'" \
|
|
||||||
--field=!"$icons/Colloid-Green-Dark-Nord.png"!'Colloid-Green-Dark-Nord':FBTN "set_theme 'Colloid-Green-Dark-Nord'" \
|
|
||||||
\
|
|
||||||
--field=!"$icons/Colloid-Orange.png"!'Colloid-Orange':FBTN "set_theme 'Colloid-Orange'" \
|
|
||||||
--field=!"$icons/Colloid-Orange-Light.png"!'Colloid-Orange-Light':FBTN "set_theme 'Colloid-Orange-Light'" \
|
|
||||||
--field=!"$icons/Colloid-Orange-Dark-Nord.png"!'Colloid-Orange-Dark-Nord':FBTN "set_theme 'Colloid-Orange-Dark-Nord'" \
|
|
||||||
\
|
|
||||||
--field=!"$icons/Colloid-Purple.png"!'Colloid-Purple':FBTN "set_theme 'Colloid-Purple'" \
|
|
||||||
--field=!"$icons/Colloid-Purple-Light.png"!'Colloid-Purple-Light':FBTN "set_theme 'Colloid-Purple-Light'" \
|
|
||||||
--field=!"$icons/Colloid-Purple-Dark-Nord.png"!'Colloid-Purple-Dark-Nord':FBTN "set_theme 'Colloid-Purple-Dark-Nord'" \
|
|
||||||
\
|
|
||||||
--field=!"$icons/Colloid-Teal.png"!'Colloid-Teal':FBTN "set_theme 'Colloid-Teal'" \
|
|
||||||
--field=!"$icons/Colloid-Teal-Light.png"!'Colloid-Teal-Light':FBTN "set_theme 'Colloid-Teal-Light'" \
|
|
||||||
--field=!"$icons/Colloid-Teal-Dark-Nord.png"!'Colloid-Teal-Dark-Nord':FBTN "set_theme 'Colloid-Teal-Dark-Nord'" \
|
|
||||||
\
|
|
||||||
--field=!"$icons/Colloid-Yellow.png"!'Colloid-Yellow':FBTN "set_theme 'Colloid-Yellow'" \
|
|
||||||
--field=!"$icons/Colloid-Yellow-Light.png"!'Colloid-Yellow-Light':FBTN "set_theme 'Colloid-Yellow-Light'" \
|
|
||||||
--field=!"$icons/Colloid-Yellow-Dark-Nord.png"!'Colloid-Yellow-Dark-Nord':FBTN "set_theme 'Colloid-Yellow-Dark-Nord'" \
|
|
||||||
--field=!"$icons/Colloid-Yellow-Dark-Gruvbox.png"!'Colloid-Yellow-Dark-Gruvbox':FBTN "set_theme 'Colloid-Yellow-Dark-Gruvbox'" \
|
|
||||||
\
|
|
||||||
--field=!"$icons/Colloid-Dark-Nord.png"!'Colloid-Dark-Nord':FBTN "set_theme 'Colloid-Dark-Nord'" \
|
|
||||||
--field=!"$icons/Colloid-Pink-Dark-Nord.png"!'Colloid-Pink-Dark-Nord':FBTN "set_theme 'Colloid-Pink-Dark-Nord'" \
|
|
||||||
--field=!"$icons/Colloid-Green-Dark-Nord.png"!'Colloid-Green-Dark-Nord':FBTN "set_theme 'Colloid-Green-Dark-Nord'" \
|
|
||||||
--field=!"$icons/Colloid-Orange-Dark-Nord.png"!'Colloid-Orange-Dark-Nord':FBTN "set_theme 'Colloid-Orange-Dark-Nord'" \
|
|
||||||
--field=!"$icons/Colloid-Purple-Dark-Nord.png"!'Colloid-Purple-Dark-Nord':FBTN "set_theme 'Colloid-Purple-Dark-Nord'" \
|
|
||||||
--field=!"$icons/Colloid-Teal-Dark-Nord.png"!'Colloid-Teal-Dark-Nord':FBTN "set_theme 'Colloid-Teal-Dark-Nord'" \
|
|
||||||
--field=!"$icons/Colloid-Yellow-Dark-Nord.png"!'Colloid-Yellow-Dark-Nord':FBTN "set_theme 'Colloid-Yellow-Dark-Nord'" \
|
|
||||||
--field=!"$icons/Colloid-Dark-Nord.png"!'Colloid-Dark-Nord':FBTN "set_theme 'Colloid-Dark-Nord'"
|
|
262
themeSwitcher.nim
Normal file
262
themeSwitcher.nim
Normal file
|
@ -0,0 +1,262 @@
|
||||||
|
from std/osproc import execProcess, ProcessOption, startProcess, waitForExit, close
|
||||||
|
from std/os import symlinkExists, getConfigDir, walkDirs, `/`
|
||||||
|
from std/envvars import existsEnv, getEnv, delEnv, putEnv
|
||||||
|
from std/strutils import split, endsWith, contains
|
||||||
|
from std/options import Option, some, get, isNone
|
||||||
|
from std/strformat import fmt
|
||||||
|
import owlkettle
|
||||||
|
|
||||||
|
const
|
||||||
|
# Set the directory path where icons are stored
|
||||||
|
iconsDir = "/usr/share/tromjaro-theme-switcher/icons"
|
||||||
|
styleIconsDir = iconsDir / "Styles"
|
||||||
|
accentIconsDir = iconsDir / "Accent Colors"
|
||||||
|
# GTK CSS for overriding the default icon size of buttons
|
||||||
|
gtkCSS = """
|
||||||
|
.style-button {
|
||||||
|
min-width: 5.5em;
|
||||||
|
min-height: 5em;
|
||||||
|
padding: 0.3em;
|
||||||
|
border-radius: 14%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.accent-button {
|
||||||
|
-gtk-icon-size: 1.65em;
|
||||||
|
padding: 0.4em;
|
||||||
|
border-radius: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#.accent-button.suggested-action {
|
||||||
|
# outline-color: black;
|
||||||
|
# outline-width: 0.05em;
|
||||||
|
# outline-offset: -0.45em;
|
||||||
|
}"""
|
||||||
|
appID = "com.tromjaro.ThemeSwitcher"
|
||||||
|
appLogo = "tromjaro-theme-switcher"
|
||||||
|
themeShades = ["Light", "", "Dark"]
|
||||||
|
themeStyles = ["Default", "Nord", "Dracula", "Catppuccin", "Everforest", "Gruvbox"]
|
||||||
|
accentColors = ["Blue", "Red", "Purple", "Pink", "Teal", "Green", "Yellow", "Orange", "Grey"]
|
||||||
|
|
||||||
|
var iconsDirs: seq[string]
|
||||||
|
|
||||||
|
for dir in walkDirs(accentIconsDir / "*"):
|
||||||
|
iconsDirs.add(dir)
|
||||||
|
|
||||||
|
type Theme = tuple[shade: string, style: string, color: string]
|
||||||
|
|
||||||
|
# Function prototypes
|
||||||
|
proc getCurrentTheme(): Theme
|
||||||
|
proc makeThemeButton(shadeName: string, styleName: string): Widget
|
||||||
|
proc makeAccentButton(accentColor: string): Widget
|
||||||
|
proc runCommand(command: string, args: openArray[string]): bool
|
||||||
|
proc setIconTheme(iconName: string)
|
||||||
|
proc enableDarkPanels(): bool
|
||||||
|
proc setTheme(themeName: string)
|
||||||
|
|
||||||
|
# Highlight current theme button
|
||||||
|
var currentTheme = getCurrentTheme()
|
||||||
|
|
||||||
|
var
|
||||||
|
oldConfigDir: Option[string]
|
||||||
|
configDirChanged: bool
|
||||||
|
|
||||||
|
# Prevent loading GTK theme from ~/.config/gtk-4.0 directory when it is a symlink
|
||||||
|
if symlinkExists(getConfigDir() / "gtk-4.0"):
|
||||||
|
if existsEnv("XDG_CONFIG_HOME"):
|
||||||
|
oldConfigDir = some(getEnv("XDG_CONFIG_HOME"))
|
||||||
|
putEnv("XDG_CONFIG_HOME", "/dev/null")
|
||||||
|
configDirChanged = true
|
||||||
|
|
||||||
|
# Display the GTK-4 GUI using owlkettle
|
||||||
|
viewable App:
|
||||||
|
hooks:
|
||||||
|
build:
|
||||||
|
# Reset the user's XDG_CONFIG_HOME variable back to what it was before
|
||||||
|
if configDirChanged == true:
|
||||||
|
if oldConfigDir.isNone():
|
||||||
|
delEnv("XDG_CONFIG_HOME")
|
||||||
|
else:
|
||||||
|
putEnv("XDG_CONFIG_HOME", get(oldConfigDir))
|
||||||
|
|
||||||
|
method view(app: AppState): Widget =
|
||||||
|
result = gui:
|
||||||
|
Window:
|
||||||
|
title = "TROMjaro Theme Switcher"
|
||||||
|
# Shrink window to the smallest size
|
||||||
|
defaultSize = (1, 1)
|
||||||
|
iconName = appLogo
|
||||||
|
# Vertical box
|
||||||
|
Box(orient = OrientY, margin = 13, spacing = 10):
|
||||||
|
Label:
|
||||||
|
useMarkup=true
|
||||||
|
text="<span size='large'>STYLE</span>"
|
||||||
|
# Vertical box
|
||||||
|
Box(orient = OrientY, spacing = 5):
|
||||||
|
for shadeName in themeShades:
|
||||||
|
# Horizontal box
|
||||||
|
Box(orient = OrientX, spacing = 5):
|
||||||
|
for styleName in themeStyles:
|
||||||
|
insert(makeThemeButton(shadeName, styleName)) {.vAlign: AlignCenter, hAlign: AlignCenter.}
|
||||||
|
Separator(margin = Margin(top: 5)) {.vAlign: AlignCenter.}
|
||||||
|
Label:
|
||||||
|
useMarkup=true
|
||||||
|
text="<span size='large'>ACCENT COLOR</span>"
|
||||||
|
# Horizontal box
|
||||||
|
Box(orient = OrientX, spacing = 3):
|
||||||
|
for accentColor in accentColors:
|
||||||
|
insert(makeAccentButton(accentColor)) {.vAlign: AlignCenter, hAlign: AlignCenter.}
|
||||||
|
Separator(margin = Margin(top: 12)) {.vAlign: AlignCenter.}
|
||||||
|
# Vertical box
|
||||||
|
Box(orient = OrientY):
|
||||||
|
Label:
|
||||||
|
text="A Theme Switcher for TROMjaro's default theme-set (Colloid) and icon-set (Zafiro)."
|
||||||
|
Label {.vAlign: AlignStart.}:
|
||||||
|
useMarkup = true
|
||||||
|
text="<span size='small'>NOTE: Some apps need to be reopened for the theme to be applied.</span>"
|
||||||
|
|
||||||
|
brew(appID, gui(App()), icons=iconsDirs, stylesheets=[newStylesheet(gtkCSS)])
|
||||||
|
|
||||||
|
|
||||||
|
# Function declarations
|
||||||
|
|
||||||
|
proc getCurrentTheme(): Theme =
|
||||||
|
let currentThemeString = execProcess("/usr/bin/xfconf-query",
|
||||||
|
args=["--channel=xsettings", "--property=/Net/ThemeName"],
|
||||||
|
options={})[0 .. ^2]
|
||||||
|
|
||||||
|
let words = currentThemeString.split('-')
|
||||||
|
if words[0] != "Colloid":
|
||||||
|
return
|
||||||
|
var currentTheme: Theme = ("", "Default", "Blue")
|
||||||
|
|
||||||
|
case len(words):
|
||||||
|
of 1: discard
|
||||||
|
|
||||||
|
of 2:
|
||||||
|
let word1 = words[1]
|
||||||
|
if word1 in accentColors:
|
||||||
|
currentTheme.color = word1
|
||||||
|
elif word1 in themeShades:
|
||||||
|
currentTheme.shade = word1
|
||||||
|
elif word1 in themeStyles:
|
||||||
|
currentTheme.style = word1
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
of 3:
|
||||||
|
let
|
||||||
|
word1 = words[1]
|
||||||
|
word2 = words[2]
|
||||||
|
if (word1 in accentColors) and (word2 in themeShades):
|
||||||
|
currentTheme.color = word1
|
||||||
|
currentTheme.shade = word2
|
||||||
|
elif (word1 in themeShades) and (word2 in themeStyles):
|
||||||
|
currentTheme.shade = word1
|
||||||
|
currentTheme.style = word2
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
of 4:
|
||||||
|
let
|
||||||
|
word1 = words[1]
|
||||||
|
word2 = words[2]
|
||||||
|
word3 = words[3]
|
||||||
|
if (word1 in accentColors) and (word2 in themeShades) and (word3 in themeStyles):
|
||||||
|
currentTheme.color = word1
|
||||||
|
currentTheme.shade = word2
|
||||||
|
currentTheme.style = word3
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
|
||||||
|
result = currentTheme
|
||||||
|
|
||||||
|
proc makeThemeButton(shadeName: string, styleName: string): Widget =
|
||||||
|
let
|
||||||
|
shade = if shadeName == "": "" else: fmt"-{shadeName}"
|
||||||
|
style = if styleName == "Default": "" else: fmt"-{styleName}"
|
||||||
|
color = if currentTheme.color in ["Blue", ""]: "" else: fmt"-{currentTheme.color}"
|
||||||
|
theme = fmt"Colloid{color}{shade}{style}"
|
||||||
|
|
||||||
|
result = gui:
|
||||||
|
Button:
|
||||||
|
Picture:
|
||||||
|
pixbuf = loadPixbuf(fmt"{styleIconsDir}/Colloid{shade}{style}.svg")
|
||||||
|
tooltip = if shadeName == "": styleName else: fmt"{shadeName}-{styleName}"
|
||||||
|
style = if (shadeName, styleName) == (currentTheme.shade, currentTheme.style):
|
||||||
|
[StyleClass("style-button"), ButtonSuggested]
|
||||||
|
else:
|
||||||
|
[StyleClass("style-button"), ButtonFlat]
|
||||||
|
|
||||||
|
proc clicked() =
|
||||||
|
setTheme(theme)
|
||||||
|
# Highlight this button
|
||||||
|
currentTheme.shade = shadeName
|
||||||
|
currentTheme.style = styleName
|
||||||
|
if currentTheme.color == "":
|
||||||
|
currentTheme.color = "Blue"
|
||||||
|
|
||||||
|
proc makeAccentButton(accentColor: string): Widget =
|
||||||
|
let
|
||||||
|
shade = if currentTheme.shade == "": "" else: fmt"-{currentTheme.shade}"
|
||||||
|
style = if currentTheme.style in ["Default", ""]: "" else: fmt"-{currentTheme.style}"
|
||||||
|
color = if accentColor == "Blue": "" else: fmt"-{accentColor}"
|
||||||
|
theme = fmt"Colloid{color}{shade}{style}"
|
||||||
|
|
||||||
|
result = gui:
|
||||||
|
Button:
|
||||||
|
icon = fmt"{accentColor}{style}{shade}"
|
||||||
|
tooltip = accentColor
|
||||||
|
style = if accentColor == currentTheme.color:
|
||||||
|
[StyleClass("accent-button"), ButtonSuggested]
|
||||||
|
else:
|
||||||
|
[StyleClass("accent-button"), ButtonFlat]
|
||||||
|
|
||||||
|
proc clicked() =
|
||||||
|
setTheme(theme)
|
||||||
|
# Highlight this button
|
||||||
|
currentTheme.color = accentColor
|
||||||
|
if currentTheme.style == "":
|
||||||
|
currentTheme.style = "Default"
|
||||||
|
|
||||||
|
proc runCommand(command: string, args: openArray[string]): bool =
|
||||||
|
## This will run a command with the given args and return true upon success
|
||||||
|
let process = startProcess(command, args=args, options={poParentStreams})
|
||||||
|
result = process.waitForExit() == 0
|
||||||
|
process.close()
|
||||||
|
|
||||||
|
proc setIconTheme(iconName: string) =
|
||||||
|
# Change icon theme in XFCE
|
||||||
|
discard runCommand("/usr/bin/xfconf-query",
|
||||||
|
args=["--channel=xsettings", "--property=/Net/IconThemeName", "--create", "--type=string", "--set", iconName])
|
||||||
|
|
||||||
|
proc enableDarkPanels(): bool =
|
||||||
|
# Return if dark panels is already enabled
|
||||||
|
if execProcess("/usr/bin/xfconf-query",
|
||||||
|
args=["--channel=xfce4-panel", "--property=/panels/dark-mode"], options={}) == "true\n":
|
||||||
|
return
|
||||||
|
# Try to enable it and return true upon success
|
||||||
|
result = runCommand("/usr/bin/xfconf-query",
|
||||||
|
args=["--channel=xfce4-panel", "--property=/panels/dark-mode", "--create", "--type=bool", "--set=true"])
|
||||||
|
|
||||||
|
proc setTheme(themeName: string) =
|
||||||
|
|
||||||
|
var panelNotification: string
|
||||||
|
|
||||||
|
# Set the icon theme and panel color according to the chosen theme
|
||||||
|
if themeName.endsWith("-Dark") or themeName.contains("-Dark-"):
|
||||||
|
setIconTheme("zafiro-dark")
|
||||||
|
else:
|
||||||
|
setIconTheme("zafiro")
|
||||||
|
if enableDarkPanels():
|
||||||
|
panelNotification = " with dark panels"
|
||||||
|
|
||||||
|
# Change the main theme to the chosen one
|
||||||
|
discard runCommand("/usr/bin/xfconf-query",
|
||||||
|
args=["--channel=xsettings", "--property=/Net/ThemeName", "--create", "--type=string", "--set", themeName])
|
||||||
|
|
||||||
|
# Send notification about the theme change
|
||||||
|
sendNotification(appID, "Theme Switcher", fmt"{themeName} theme{panelNotification} is enabled",
|
||||||
|
icon=appLogo)
|
Loading…
Reference in New Issue
Block a user