-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
62 lines (54 loc) · 878 Bytes
/
main.go
File metadata and controls
62 lines (54 loc) · 878 Bytes
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
package main
import (
"flag"
"fmt"
"os"
"os/exec"
"strings"
"github.com/wouterbeets/cyclist"
)
func main() {
flag.Parse()
args := flag.Args()
if len(args) != 1 {
fmt.Println("error: no id")
os.Exit(1)
}
c, err := cyclist.New(
map[string]cyclist.Cycle{
"0": cyclist.Cycle{
Entries: []string{
"xrandr --auto",
},
},
},
os.Getenv("HOME")+"/.screens",
)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
nbScreens := args[0]
if err != nil {
fmt.Println(err)
os.Exit(1)
}
cmd, err := c.Cycle(nbScreens)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
comm := exec.Command("notify-send", cmd)
err = comm.Run()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
cmdArgs := strings.Split(cmd, " ")
comm = exec.Command(cmdArgs[0], cmdArgs[1:]...)
err = comm.Run()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}