summary refs log tree commit diff
path: root/.config/waybar/modules/gamma.go
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2021-08-03 22:12:11 +0200
committerRobert Günzler <r@gnzler.io>2021-08-03 22:12:11 +0200
commit06eccec83a88b2af00b354bedc1a44713938a385 (patch)
treed7bd6fa7696fbee06befee2c79bf1d495d5b3d00 /.config/waybar/modules/gamma.go
parentc0b76fb561331af338ee382ce16492f1ff20cf5e (diff)
waybar: update
Diffstat (limited to '.config/waybar/modules/gamma.go')
-rwxr-xr-x[-rw-r--r--].config/waybar/modules/gamma.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/.config/waybar/modules/gamma.go b/.config/waybar/modules/gamma.go
index 2a91cdb..9813cc8 100644..100755
--- a/.config/waybar/modules/gamma.go
+++ b/.config/waybar/modules/gamma.go
@@ -1,5 +1,5 @@
-// usage:
-// go build -o waybar-gammastep gammastep.go
+#!/usr/bin/env yaegi
+
 package main
 
 import (
@@ -8,12 +8,14 @@ import (
 	"os"
 	"os/exec"
 	"os/signal"
+	"runtime"
 	"strings"
-
 	. "syscall"
 )
 
 func main() {
+	runtime.GOMAXPROCS(1)
+
 	var (
 		update = make(chan os.Signal, 1)
 		cancel = make(chan os.Signal, 1)
@@ -23,12 +25,11 @@ func main() {
 
 	// could use golang.org/x/sys/unix.Prctl here
 	// but I want to avoid the dependency
-	if _, _, e := Syscall6(SYS_PRCTL,
+	if _, _, e := Syscall6(uintptr(SYS_PRCTL),
 		uintptr(PR_SET_PDEATHSIG),
 		uintptr(SIGTERM),
 		0, 0, 0, 0); e != 0 {
-		log.Printf("error: %v", e)
-		os.Exit(1)
+		log.Fatalf("error: %v", e)
 	}
 
 	lookup()
@@ -38,8 +39,10 @@ func main() {
 			switch sig {
 			case SIGUSR1:
 				printJson("day")
+				// TODO(robert): toggle wlsunset off?
 			case SIGUSR2:
 				printJson("night")
+				// TODO(robert): toggle wlsunset on?
 			case SIGHUP:
 				lookup()
 			}
@@ -65,10 +68,9 @@ func lookup() {
 		printJson("unknown")
 		return
 	}
-	log.Println(cmdEnv)
 	b, err := exec.Command("bash", "-c", cmdEnv).Output()
 	if err != nil {
-		log.Printf("error: %v", err)
+		log.Fatalf("error: %v", err)
 		return
 	}
 	phase := strings.TrimSpace(string(b))