-
Notifications
You must be signed in to change notification settings - Fork 17
/
weston.go
61 lines (49 loc) · 1.75 KB
/
weston.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package wallutils
import (
"errors"
"fmt"
"os"
"github.com/xyproto/env/v2"
)
// Weston windowmanager detector
type Weston struct {
mode string
verbose bool
}
// Name returns the name of this window manager or desktop environment
func (w *Weston) Name() string {
return "Weston"
}
// ExecutablesExists checks if executables associated with this backend exists in the PATH
func (w *Weston) ExecutablesExists() bool {
return which("weston") != ""
}
// Running examines environment variables to try to figure out if this backend is currently running
func (w *Weston) Running() bool {
return env.Contains("GDMSESSION", "weston") || env.Contains("XDG_SESSION_DESKTOP", "weston") || env.Contains("XDG_CURRENT_DESKTOP", "weston")
}
// SetMode will set the current way to display the wallpaper (stretched, tiled etc)
func (w *Weston) SetMode(mode string) {
w.mode = mode
}
// SetVerbose can be used for setting the verbose field to true or false.
// This will cause this backend to output information about what is is doing on stdout.
func (w *Weston) SetVerbose(verbose bool) {
w.verbose = verbose
}
// SetWallpaper sets the desktop wallpaper, given an image filename.
// The image must exist and be readable.
func (*Weston) SetWallpaper(imageFilename string) error {
if !exists(imageFilename) {
return fmt.Errorf("no such file: %s", imageFilename)
}
fmt.Println("WESTON CONFIG FILE: ", os.Getenv("WESTON_CONFIG_FILE"))
// TODO: Add the following to ~/.config/weston.ini
// (or whichever configuration file Weston uses)
// [shell]
// background-image=/home/user/somewhere/image.jpg
// background-type=scale
//
// Also use w.mode for setting the background type
return errors.New("Weston currently does not support changing the desktop wallpaper at runtime")
}