From 538028fdd2e03f78562f1f6e85a38cd3ca442803 Mon Sep 17 00:00:00 2001 From: Andinus Date: Sun, 5 Apr 2020 20:56:24 +0530 Subject: Unveil gsettings & pcmanfm Previous versions will fail to set background on systems that support gsettings & pcmanfm & if it is running on OpenBSD. --- cmd/cetus/main_openbsd.go | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) (limited to 'cmd') 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 -- cgit 1.4.1-2-gfad0