From 06eccec83a88b2af00b354bedc1a44713938a385 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Tue, 3 Aug 2021 22:12:11 +0200 Subject: waybar: update --- .config/waybar/modules/gamma.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) mode change 100644 => 100755 .config/waybar/modules/gamma.go (limited to '.config/waybar/modules/gamma.go') diff --git a/.config/waybar/modules/gamma.go b/.config/waybar/modules/gamma.go old mode 100644 new mode 100755 index 2a91cdb..9813cc8 --- 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)) -- cgit 1.4.1