diff options
author | Andinus <andinus@nand.sh> | 2020-04-05 20:56:24 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-04-05 20:56:24 +0530 |
commit | 538028fdd2e03f78562f1f6e85a38cd3ca442803 (patch) | |
tree | 653cf875b8e09e56717ea8ee64b3a5a2d2d56ebd /cmd | |
parent | 0ba76c22e48ca028c8247b990c86297795352085 (diff) | |
download | cetus-538028fdd2e03f78562f1f6e85a38cd3ca442803.tar.gz |
Unveil gsettings & pcmanfm
Previous versions will fail to set background on systems that support gsettings & pcmanfm & if it is running on OpenBSD.
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/cetus/main_openbsd.go | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/cmd/cetus/main_openbsd.go b/cmd/cetus/main_openbsd.go index 24da43f..b978e7c 100644 --- a/cmd/cetus/main_openbsd.go +++ b/cmd/cetus/main_openbsd.go @@ -46,12 +46,12 @@ func unveil() { } } - err = unveilCmd("feh") - if err != nil { - log.Fatal(err) - } - - err = unveilCmd("notify-send") + err = unveilCmds([]string{ + "feh", + "gsettings", + "pcmanfm", + "notify-send", + }) if err != nil { log.Fatal(err) } @@ -63,14 +63,19 @@ func unveil() { } } -// unveilCmd will unveil commands. -func unveilCmd(cmd string) error { +// unveilCmds will unveil commands. +func unveilCmds(cmds []string) error { pathList := strings.Split(getEnv("PATH", ""), ":") - for _, path := range pathList { - err = unix.Unveil(fmt.Sprintf("%s/%s", path, cmd), "rx") + // Unveil each command. + for _, cmd := range cmds { + for _, path := range pathList { + err = unix.Unveil(fmt.Sprintf("%s/%s", path, cmd), "rx") - if err != nil && err.Error() != "no such file or directory" { - return err + if err != nil && err.Error() != "no such file or directory" { + return fmt.Errorf("%s\n%s", + cmd, + err.Error()) + } } } return nil |