Compare commits

...

40 Commits

Author SHA1 Message Date
6a6c81ee5a Code refactoring 2024-12-30 00:43:26 +05:30
485056263d Update PKGBUILD 2024-10-19 23:22:55 +00:00
286faba203 Fix large window bug on small resolution screens 2024-10-19 20:46:27 +05:30
53a4777985 Update PKGBUILD 2024-10-19 13:31:54 +00:00
f7a680587d Make style buttons resizable 2024-10-19 17:22:53 +05:30
8828398707 Use relative units in GTK CSS 2024-10-18 23:21:41 +05:30
12dfb42215 commented out the outline for accent color buttons 2024-09-03 23:00:12 +00:00
f0f4214fa4 Add outline for the current accent color button 2024-09-04 01:34:16 +05:30
6eead68790 Tweak GTK CSS to make the buttons look better 2024-09-03 13:12:21 +05:30
52c15867df Update PKGBUILD 2024-08-20 15:12:34 +00:00
25fed8663b New improved Theme Switcher with more options 2024-08-20 19:12:00 +05:30
cfcb07ab77 added the catppuccin theme as dependency 2024-08-16 23:43:01 +00:00
ae9fcce069 colloid split into different packages 2024-04-13 23:43:50 +00:00
339d4113d6 Merge pull request 'Add required colloid packages as dependencies' () from rokosun-patch-1 into main
Reviewed-on: 
2024-04-13 23:42:39 +00:00
c79c2ed7e8 Add required colloid packages as dependencies
Colloid theme packages are now split into different variants.
2024-04-13 18:05:32 +00:00
696fc180c8 Update command for installing owlkettle 2024-03-28 17:13:19 +00:00
f97cecf89c Fix video not loading
Also add title for the video (appears as tooltip on hover)
2023-11-22 17:09:56 +01:00
300dd23942 Use better HTML tags for the video 2023-11-22 16:55:33 +01:00
7f58471475 Update readme to show the screen recording 2023-11-22 16:32:08 +01:00
dd101c50b5 Add screen record of the app in action 2023-11-22 16:17:18 +01:00
a575fb583e Update PKGBUILD 2023-11-05 15:46:58 +01:00
f3e1c0a14c Set icon name for the window
Now the app icon will show up on the XFCE workspace window.
2023-11-05 10:51:43 +01:00
54c1c74878 Update PKGBUILD 2023-11-04 16:38:30 +01:00
11a1a7dc91 Use the Option type for oldConfigDir variable 2023-11-03 13:34:30 +01:00
85b0e75ff6 Add build hook to revert the $XDG_CONFIG_HOME variable
Also created the applicationID variable
2023-11-01 19:13:17 +01:00
acf400bd54 Update PKGBUILD 2023-10-29 12:27:20 +01:00
4c5a39a77c Merge pull request 'Simplify code, remove unnecessary 2D array' () from rokosun-patch-1 into main
Reviewed-on: 
2023-10-29 12:26:56 +01:00
d3c1054ec0 No need to use strip here, just remove the last character 2023-10-29 08:41:17 +01:00
9056b40bc4 Update PKGBUILD 2023-10-28 23:24:17 +02:00
4d6446d47d Simplify code, remove unnecessary 2D array 2023-10-28 23:04:56 +02:00
859fe8c2fa Update PKGBUILD 2023-10-28 22:37:29 +02:00
19e75fc5c0 Better description in README 2023-10-28 14:34:00 +02:00
8fe0c425f7 Fix issues with Makefile
Fixes these problems:

* The `make` command for building the package simply called `makepkg` instead of `makepkg -s` which could also install missing dependencies with pacman

* The name of the package has been changed to tromjaro-theme-switcher but Makefile still used the old name theme-switcher, also the extension for Arch linux package is now `.tar.zst` instead of the previous `.tar.xz` - all of this meant that the `make install` command was not working properly

* `make clean` command didn't remove icons.zip and the proper linux package file which now ends in `.tar.zst` instead of the previous `.tar.xz`
2023-10-28 14:19:35 +02:00
e50903aab7 Use the px unit for setting icon size 2023-10-28 08:30:04 +02:00
b417fdebe3 Merge pull request 'Improve PKGBUILD' () from rokosun-patch-1 into main
Reviewed-on: 
2023-10-28 02:32:36 +02:00
30aa304b4a Improve PKGBUILD 2023-10-27 21:14:25 +02:00
79a22a493c Add note saying some apps need to be reopened 2023-10-27 16:43:56 +02:00
69867e2af9 Merge pull request 'Rewrite Theme Switcher in Nim' () from nim-rewrite into main
Reviewed-on: 
2023-10-27 15:30:14 +02:00
45ebde24a2 Update PKGBUILD for the new code in Nim
Also improved a bunch of other things like the missing URL and architecture information.
2023-10-27 15:07:17 +02:00
da34f2087f Rewrite Theme Switcher in Nim 2023-10-27 15:02:14 +02:00
7 changed files with 342 additions and 91 deletions

@ -1,12 +1,12 @@
# makefile for theme-switcher
# makefile for tromjaro-theme-switcher
build:
makepkg
makepkg -s
install:
pamac-installer theme-switcher-*.tar.xz
pamac-installer tromjaro-theme-switcher-*.tar.zst
remove:
pamac-installer --remove theme-switcher
pamac-installer --remove tromjaro-theme-switcher
clean:
$(RM) -rf src/ pkg/ *.tar.xz
$(RM) -rf src/ pkg/ icons.tar.gz *.tar.zst

@ -1,36 +1,68 @@
# Maintainer: TROM <contact@tromsite.com>
pkgname=tromjaro-theme-switcher
pkgver=1.4
pkgrel=3
pkgver=3
pkgrel=4
pkgdesc="TROMjaro Theme switcher application"
arch=(any)
url=""
arch=('x86_64')
url="https://git.trom.tf/TROMjaro/theme-switcher-package"
license=(unknown)
depends=('yad'
depends=('tromjaro-fixes'
'xfconf'
'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')
backup=()
options=(!strip)
source=("theme-switcher"
source=("themeSwitcher.nim"
"tromjaro-theme-switcher.desktop"
"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'
'SKIP'
'SKIP'
'SKIP')
package() {
# copy icons
install -d ${pkgdir}/usr/share/tromjaro-theme-switcher/icons
install -Dm644 ${srcdir}/icons/* ${pkgdir}/usr/share/tromjaro-theme-switcher/icons
# copy executables
install -Dm644 ${srcdir}/tromjaro-theme-switcher.desktop ${pkgdir}/usr/share/applications/tromjaro-theme-switcher.desktop
install -Dm755 ${srcdir}/theme-switcher ${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
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
}
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
@ -16,6 +18,6 @@ To remove just installed package, use:
`make remove`
To cleanup the project, use:
To cleanup the project folder, use:
`make clean`

BIN
screenRecord.mp4 Normal file

Binary file not shown.

@ -1,63 +0,0 @@
#!/bin/bash
# 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"
}
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() {
local -r theme="$1"
unset panel_notification
# Set the icon theme and panel color according to the chosen theme
case "$theme" in
*'-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 functions to make them available inside yad
export -f set_icon_theme enable_dark_panels set_theme
# A collection of tooltips that appear when you hover over a theme button
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)')
# 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[@]}"

169
themeSwitcher.nim Normal file

@ -0,0 +1,169 @@
from std/os import symlinkExists, getConfigDir, walkDirs, `/`
from std/envvars import existsEnv, getEnv, delEnv, putEnv
from std/options import Option, some, get, isNone
from std/strformat import fmt
import pkg/owlkettle
import ./themes
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%;
}
"""
var iconsDirs: seq[string]
for dir in walkDirs(accentIconsDir / "*"):
iconsDirs.add(dir)
# Function prototypes
proc makeThemeButton(shadeName: string, styleName: string): Widget
proc makeAccentButton(accentColor: string): Widget
proc accentButtons(): Widget
proc themeButtons(): Widget
proc mainGUI(): Widget
# Keep track of 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 = mainGUI()
brew(appID, gui(App()), icons=iconsDirs, stylesheets=[newStylesheet(gtkCSS)])
# Function declarations
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}"
themeString = 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(themeString)
# 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}"
themeString = 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(themeString)
# Highlight this button
currentTheme.color = accentColor
if currentTheme.style == "":
currentTheme.style = "Default"
proc themeButtons(): Widget =
gui:
# Vertical box
Box(orient = OrientY, spacing = 5):
for shadeName in themeShades:
# Horizontal box
Box(orient = OrientX, spacing = 5):
for styleName in themeStyles:
let themeButton = makeThemeButton(shadeName, styleName)
insert(themeButton) {.vAlign: AlignCenter, hAlign: AlignCenter.}
proc accentButtons(): Widget =
gui:
# Horizontal box
Box(orient = OrientX, spacing = 3):
for accentColor in accentColors:
let accentButton = makeAccentButton(accentColor)
insert(accentButton) {.vAlign: AlignCenter, hAlign: AlignCenter.}
proc mainGUI(): Widget =
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>"
# Theme buttons
insert(themeButtons())
Separator(margin = Margin(top: 5)) {.vAlign: AlignCenter.}
Label:
useMarkup=true
text="<span size='large'>ACCENT COLOR</span>"
# Accent buttons
insert(accentButtons())
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>"

111
themes.nim Normal file

@ -0,0 +1,111 @@
from std/osproc import execProcess, ProcessOption, startProcess, waitForExit, close
from std/strutils import split, endsWith, contains
from std/strformat import fmt
import pkg/owlkettle
type Theme = tuple[color, shade, style: string]
const
themeShades* = ["Light", "", "Dark"]
themeStyles* = ["Default", "Nord", "Dracula", "Catppuccin", "Everforest", "Gruvbox"]
accentColors* = ["Blue", "Red", "Purple", "Pink", "Teal", "Green", "Yellow", "Orange", "Grey"]
appID* = "com.tromjaro.ThemeSwitcher"
appLogo* = "tromjaro-theme-switcher"
proc getCurrentTheme*(): Theme =
let currentThemeString = execProcess("/usr/bin/xfconf-query",
args=["--channel=xsettings", "--property=/Net/ThemeName"],
options={})[0 .. ^2]
# Split the theme string into words
let words = currentThemeString.split('-')
if words[0] != "Colloid":
return
var currentTheme: Theme = (color: "Blue", shade: "", style: "Default")
case len(words):
of 1: discard
# Match against Colloid-Color, Colloid-Shade, Colloid-Style
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
# Match against Colloid-Color-Shade, Colloid-Shade-Style
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
# Match against Colloid-Color-Shade-Style
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
return currentTheme
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)