Search multiple locations for profiles

This commit is contained in:
Martin 2021-10-16 12:58:11 +02:00
parent 0bffb6ad35
commit 1634321bd2
Signed by: mawalu
GPG Key ID: BF556F989760A7C8
2 changed files with 13 additions and 13 deletions

View File

@ -1,10 +0,0 @@
{
"mount": [],
"romount": ["/etc", "/var", "/usr", "/opt", ".oh-my-zsh", ".zsh", ".zshrc"],
"symlinks": [
{"src": "usr/lib", "dst": "/lib"},
{"src": "usr/lib64", "dst": "/lib64"},
{"src": "usr/bin", "dst": "/bin"},
{"src": "usr/sbin", "dst": "/sbin"}
]
}

View File

@ -15,9 +15,19 @@ proc checkRelativePath*(p: string): string =
getHomeDir().joinPath(p) getHomeDir().joinPath(p)
proc getProfilePath*(profile: string): string = proc getProfilePath*(profile: string): string =
getConfigDir() let pid = getCurrentProcessId()
.joinPath(APP_NAME)
.joinPath(profile) for path in [
getConfigDir().joinPath(APP_NAME),
&"/usr/share/{APP_NAME}",
parentDir(expandSymlink(&"/proc/{pid}/exe")).joinPath("configs")
]:
let file = path.joinPath(profile)
if fileExists(file):
return file
raise newException(IOError, "Profile not found")
proc getProfilePath*(args: Args): string = proc getProfilePath*(args: Args): string =
getProfilePath(args.getProfile()) getProfilePath(args.getProfile())