diff --git a/themeSwitcher.nim b/themeSwitcher.nim index e12c88b..30f638a 100644 --- a/themeSwitcher.nim +++ b/themeSwitcher.nim @@ -1,6 +1,7 @@ from std/osproc import execProcess, ProcessOption, startProcess, waitForExit, close from std/envvars import existsEnv, getEnv, delEnv, putEnv from std/os import symlinkExists, getConfigDir, `/` +from std/options import Option, some, get, isNone from std/strutils import split, endsWith from std/strformat import fmt import owlkettle @@ -56,16 +57,13 @@ proc setTheme(themeName: string) = var - oldConfigDir: string - oldConfigDirUnset: bool + 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 = getEnv("XDG_CONFIG_HOME") - else: - oldConfigDirUnset = true + oldConfigDir = some(getEnv("XDG_CONFIG_HOME")) putEnv("XDG_CONFIG_HOME", "/dev/null") configDirChanged = true @@ -76,10 +74,10 @@ viewable App: build: # Reset the user's XDG_CONFIG_HOME variable back to what it was before if configDirChanged == true: - if oldConfigDirUnset: + if oldConfigDir.isNone(): delEnv("XDG_CONFIG_HOME") else: - putEnv("XDG_CONFIG_HOME", oldConfigDir) + putEnv("XDG_CONFIG_HOME", get(oldConfigDir)) let currentTheme: string = execProcess("/usr/bin/xfconf-query", args=["--channel=xsettings", "--property=/Net/ThemeName"],