forked from xyproto/wallutils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
feh.go
39 lines (31 loc) · 836 Bytes
/
feh.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package wallutils
// This is the fallback if no specific windowmanager has been detected
import (
"errors"
)
type Feh struct {
verbose bool
}
func (f *Feh) Name() string {
return "Feh"
}
func (f *Feh) ExecutablesExists() bool {
return which("feh") != ""
}
func (f *Feh) Running() bool {
return true
}
func (f *Feh) SetVerbose(verbose bool) {
f.verbose = verbose
}
// SetWallpaper sets the desktop wallpaper, given an image filename.
// The image must exist and be readable.
// `feh` is used for setting the desktop background, and must be in the PATH.
func (f *Feh) SetWallpaper(imageFilename string) error {
// bg-fill | bg-center | bg-max | bg-scale | bg-tile
command := "feh --bg-fill " + imageFilename
if err := run(command, f.verbose); err != nil {
return errors.New(command + " failed to run")
}
return nil
}