Use the Option type for oldConfigDir variable
This commit is contained in:
parent
85b0e75ff6
commit
11a1a7dc91
|
@ -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"],
|
||||
|
|
Loading…
Reference in New Issue
Block a user