Compare commits
1 Commits
b417fdebe3
...
tio-patch-
Author | SHA1 | Date | |
---|---|---|---|
1cd60b163e |
43
PKGBUILD
43
PKGBUILD
@@ -1,47 +1,25 @@
|
|||||||
# Maintainer: TROM <contact@tromsite.com>
|
# Maintainer: TROM <contact@tromsite.com>
|
||||||
pkgname=tromjaro-theme-switcher
|
pkgname=tromjaro-theme-switcher
|
||||||
pkgver=1.4
|
pkgver=1.2.0
|
||||||
pkgrel=3
|
pkgrel=1
|
||||||
pkgdesc="TROMjaro Theme switcher application"
|
pkgdesc="TROMjaro Theme switcher application"
|
||||||
arch=('x86_64')
|
arch=(any)
|
||||||
url="https://git.trom.tf/TROMjaro/theme-switcher-package"
|
url=""
|
||||||
license=(unknown)
|
license=(unknown)
|
||||||
depends=('tromjaro-fixes'
|
depends=('yad'
|
||||||
'xfconf'
|
'zafiro-icon-theme'
|
||||||
'gtk4'
|
'skeuos-gtk')
|
||||||
'colloid-gtk-theme-git'
|
|
||||||
'zafiro-icon-theme')
|
|
||||||
makedepends=('choosenim')
|
|
||||||
provides=('tromjaro-theme-switcher')
|
provides=('tromjaro-theme-switcher')
|
||||||
backup=()
|
backup=()
|
||||||
options=(!strip)
|
options=(!strip)
|
||||||
source=("themeSwitcher.nim"
|
source=("theme-switcher"
|
||||||
"tromjaro-theme-switcher.desktop"
|
"tromjaro-theme-switcher.desktop"
|
||||||
"tromjaro-theme-switcher.svg"
|
"tromjaro-theme-switcher.svg"
|
||||||
"icons.zip::https://www.drive.tromsite.com/s/zFtCp3SkZ4NpKix/download")
|
"https://www.drive.tromsite.com/s/zFtCp3SkZ4NpKix/download")
|
||||||
sha256sums=('SKIP'
|
sha256sums=('SKIP'
|
||||||
'SKIP'
|
'SKIP'
|
||||||
'SKIP'
|
'SKIP'
|
||||||
'SKIP')
|
'SKIP')
|
||||||
prepare() {
|
|
||||||
# Disable telemetry in choosenim if user is running it for the first time
|
|
||||||
[ -f "$HOME"/.choosenim/analytics ] || {
|
|
||||||
mkdir -p "$HOME"/.choosenim
|
|
||||||
touch "$HOME"/.choosenim/analytics
|
|
||||||
}
|
|
||||||
echo 'Install Nim if not already installed:'
|
|
||||||
choosenim stable
|
|
||||||
echo 'Update Nim to the latest stable release:'
|
|
||||||
choosenim update stable
|
|
||||||
echo 'Refresh nimble package list:'
|
|
||||||
"$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@#head
|
|
||||||
}
|
|
||||||
build(){
|
|
||||||
echo 'Compile themeSwitcher.nim for release build:'
|
|
||||||
"$HOME"/.nimble/bin/nim c -d:release --out:${srcdir}/themeSwitcher ${srcdir}/themeSwitcher.nim
|
|
||||||
}
|
|
||||||
package() {
|
package() {
|
||||||
# copy icons
|
# copy icons
|
||||||
install -d ${pkgdir}/usr/share/tromjaro-theme-switcher/icons
|
install -d ${pkgdir}/usr/share/tromjaro-theme-switcher/icons
|
||||||
@@ -49,9 +27,10 @@ package() {
|
|||||||
|
|
||||||
# copy executables
|
# copy executables
|
||||||
install -Dm644 ${srcdir}/tromjaro-theme-switcher.desktop ${pkgdir}/usr/share/applications/tromjaro-theme-switcher.desktop
|
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
|
install -Dm755 ${srcdir}/theme-switcher ${pkgdir}/usr/bin/tromjaro-theme-switcher
|
||||||
|
|
||||||
# copy the icon
|
# copy the icon
|
||||||
install -d ${pkgdir}/usr/share/icons/hicolor/scalable/apps
|
install -d ${pkgdir}/usr/share/icons/hicolor/scalable/apps
|
||||||
install -Dm644 ${srcdir}/tromjaro-theme-switcher.svg ${pkgdir}/usr/share/icons/hicolor/scalable/apps
|
install -Dm644 ${srcdir}/tromjaro-theme-switcher.svg ${pkgdir}/usr/share/icons/hicolor/scalable/apps
|
||||||
|
|
||||||
}
|
}
|
||||||
|
95
theme-switcher
Normal file
95
theme-switcher
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
#!/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'"
|
@@ -1,128 +0,0 @@
|
|||||||
from std/osproc import execProcess, ProcessOption, startProcess, waitForExit, close
|
|
||||||
from std/os import symlinkExists, getConfigDir, putEnv, `/`
|
|
||||||
from std/strutils import split, endsWith, strip
|
|
||||||
from std/algorithm import fill
|
|
||||||
from std/strformat import fmt
|
|
||||||
import owlkettle
|
|
||||||
|
|
||||||
const
|
|
||||||
# Set the directory path where icons are stored
|
|
||||||
iconsDir = "/usr/share/tromjaro-theme-switcher/icons"
|
|
||||||
# GTK CSS for overriding the default icon size of buttons
|
|
||||||
gtkCSS = "button { -gtk-icon-size: 22mm; }"
|
|
||||||
themeColors = ["Grey", "Pink", "Green", "Orange", "Purple", "Yellow", "Teal"]
|
|
||||||
themeStyles = ["Light", "Nord", "Dark", "Dark-Nord"]
|
|
||||||
|
|
||||||
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.endsWith("-Dark-Nord"):
|
|
||||||
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("com.tromjaro.ThemeSwitcher", "Theme Switcher", fmt"{themeName} theme{panelNotification} is enabled",
|
|
||||||
icon=fmt"{iconsDir}/{themeName}.svg")
|
|
||||||
|
|
||||||
|
|
||||||
# Prevent loading GTK theme from ~/.config/gtk-4.0 directory when it is a symlink
|
|
||||||
if symlinkExists(getConfigDir() / "gtk-4.0"):
|
|
||||||
putEnv("XDG_CONFIG_HOME", "/dev/null")
|
|
||||||
|
|
||||||
var
|
|
||||||
lastClickedButton: array[2, int]
|
|
||||||
|
|
||||||
# Display the GTK-4 GUI using owlkettle
|
|
||||||
viewable App:
|
|
||||||
# 2D array storing the style for each button
|
|
||||||
buttonStyles: array[themeStyles.len(),array[themeColors.len(), StyleClass]]
|
|
||||||
hooks:
|
|
||||||
build:
|
|
||||||
# Make all buttons flat by default
|
|
||||||
for index in 0..state.buttonStyles.high():
|
|
||||||
fill(state.buttonStyles[index], ButtonFlat)
|
|
||||||
|
|
||||||
let currentTheme: string = execProcess("/usr/bin/xfconf-query",
|
|
||||||
args=["--channel=xsettings", "--property=/Net/ThemeName"],
|
|
||||||
options={}).strip(leading=false, trailing=true, chars={'\n'})
|
|
||||||
|
|
||||||
let currentThemeSplit: seq[string] = currentTheme.split('-', 2)
|
|
||||||
|
|
||||||
if currentThemeSplit.len() < 3 or currentThemeSplit[0] != "Colloid":
|
|
||||||
return
|
|
||||||
|
|
||||||
let currentThemeColorIndex = find(themeColors, currentThemeSplit[1])
|
|
||||||
let currentThemeStyleIndex = find(themeStyles, currentThemeSplit[2])
|
|
||||||
|
|
||||||
if -1 in [currentThemeColorIndex, currentThemeStyleIndex]:
|
|
||||||
return
|
|
||||||
|
|
||||||
# Highlight current theme button
|
|
||||||
state.buttonStyles[currentThemeStyleIndex][currentThemeColorIndex] = ButtonSuggested
|
|
||||||
lastClickedButton = [currentThemeStyleIndex, currentThemeColorIndex]
|
|
||||||
|
|
||||||
method view(app: AppState): Widget =
|
|
||||||
result = gui:
|
|
||||||
Window:
|
|
||||||
title = "TROMjaro Theme Switcher"
|
|
||||||
# Shrink window to the smallest size
|
|
||||||
defaultSize = (0, 0)
|
|
||||||
# Vertical box
|
|
||||||
Box(orient = OrientY, margin = 7, spacing = 5):
|
|
||||||
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>"
|
|
||||||
for y, themeStyle in themeStyles:
|
|
||||||
# Horizontal box
|
|
||||||
Box(orient = OrientX, spacing = 5):
|
|
||||||
for x, themeColor in themeColors:
|
|
||||||
Button {.vAlign: AlignCenter, hAlign: AlignCenter.}:
|
|
||||||
icon = fmt"Colloid-{themeColor}-{themeStyle}"
|
|
||||||
# Teal-Dark-Nord theme will have "(default)" added to its tooltip
|
|
||||||
tooltip = if (themeColor, themeStyle) == ("Teal", "Dark-Nord"):
|
|
||||||
fmt"{themeColor}-{themeStyle} (default)"
|
|
||||||
else:
|
|
||||||
fmt"{themeColor}-{themeStyle}"
|
|
||||||
style = app.buttonStyles[y][x]
|
|
||||||
proc clicked() =
|
|
||||||
var thisButton = [y, x]
|
|
||||||
setTheme(fmt"Colloid-{themeColor}-{themeStyle}")
|
|
||||||
# Highlight this button
|
|
||||||
app.buttonStyles[y][x] = ButtonSuggested
|
|
||||||
if lastClickedButton != thisButton:
|
|
||||||
# Remove highlight from lastClickedButton
|
|
||||||
app.buttonStyles[lastClickedButton[0]][lastClickedButton[1]] = ButtonFlat
|
|
||||||
lastClickedButton = thisButton
|
|
||||||
|
|
||||||
brew("com.tromjaro.ThemeSwitcher", gui(App()), icons=[iconsDir], stylesheets=[newStylesheet(gtkCSS)])
|
|
Reference in New Issue
Block a user