summary refs log tree commit diff stats
path: root/background/set_darwin.go
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2020-03-24 18:35:27 +0530
committerAndinus <andinus@nand.sh>2020-03-24 18:35:27 +0530
commitbf040f6d1c8c7bc33d5268db42bc2ac9016e2198 (patch)
tree76006187821bd925a1509af614e4cecbef449133 /background/set_darwin.go
parent842bc9065905e8fcbd0e801526306407ac6793c4 (diff)
downloadcetus-bf040f6d1c8c7bc33d5268db42bc2ac9016e2198.tar.gz
Add background package
This rewrite has better comments and returns better error messages.
Diffstat (limited to 'background/set_darwin.go')
-rw-r--r--background/set_darwin.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/background/set_darwin.go b/background/set_darwin.go
new file mode 100644
index 0000000..43e86b7
--- /dev/null
+++ b/background/set_darwin.go
@@ -0,0 +1,25 @@
+// +build darwin
+
+package background
+
+import (
+	"fmt"
+	"os/exec"
+	"strconv"
+)
+
+// SetFromFile takes a string as an input, it must be absolute path to
+// the background. Checks are not made to check if the path exists or
+// it is actually an image, that must be verified before passing it to
+// SetFromFile. SetFromFile will exit returning in error if there is
+// any.
+func SetFromFile(path string) error {
+	err := exec.Command("osascript", "-e",
+		`tell application "System Events" to tell every desktop to set picture to `+strconv.Quote(path)).Run()
+	if err != nil {
+		err = fmt.Errorf("%s\n%s",
+			"set_darwin.go: failed to set background",
+			err.Error())
+	}
+	return err
+}
ames Booth <boothj5@gmail.com> 2012-06-19 01:02:18 +0100 committer James Booth <boothj5@gmail.com> 2012-06-19 01:02:18 +0100 Updated README' href='/danisanti/profani-tty/commit/README?id=073612779000458fe7312d2dce6dfd75aff5d5c6'>07361277 ^
711448e8 ^

07361277 ^



711448e8 ^



fa176ad0 ^



07361277 ^


7c793de3 ^

07361277 ^
7c793de3 ^





07361277 ^
7c793de3 ^

07361277 ^





a97a4f51 ^
07361277 ^






16ad65d4 ^
07361277 ^














81901ebd ^
07361277 ^
81901ebd ^

16ad65d4 ^
07361277 ^

81901ebd ^

07361277 ^
81901ebd ^
07361277 ^


81901ebd ^
07361277 ^



81901ebd ^
07361277 ^
81901ebd ^
07361277 ^

5709f5a2 ^




4484c2b0 ^
5709f5a2 ^
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112