summary refs log tree commit diff
path: root/.config/waybar/modules
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2021-05-31 16:40:10 +0200
committerRobert Günzler <r@gnzler.io>2021-05-31 16:43:35 +0200
commitf9a2f1f9b6bb223dd1f52cf78392c2dd640730f3 (patch)
tree3faf261fe5ae95e5dead6ee01936b201291319ba /.config/waybar/modules
parentae795bd39751b6c385193c1fc99a0f88e399e2d6 (diff)
waybar: various updates
* add extension to config file
* covid: use tail vs head for historical data
* remove network.vpn
* gamma: change name from gammastep
Diffstat (limited to '.config/waybar/modules')
-rwxr-xr-x.config/waybar/modules/covid.sh2
-rw-r--r--.config/waybar/modules/gamma.go (renamed from .config/waybar/modules/gammastep.go)50
-rwxr-xr-x.config/waybar/modules/weather.sh3
3 files changed, 19 insertions, 36 deletions
diff --git a/.config/waybar/modules/covid.sh b/.config/waybar/modules/covid.sh
index 558c2c5..9f1860c 100755
--- a/.config/waybar/modules/covid.sh
+++ b/.config/waybar/modules/covid.sh
@@ -71,7 +71,7 @@ tooltip="
 last update: ${last_update}
 
 history (${trend_arrow}):
-$(awk -F, '{print $1 " " $2}' ${HISTFILE} | head -n10)
+$(awk -F, '{print $1 " " $2}' ${HISTFILE} | tail -n10)
 "
 
 jq -nr \
diff --git a/.config/waybar/modules/gammastep.go b/.config/waybar/modules/gamma.go
index c855e1b..2a91cdb 100644
--- a/.config/waybar/modules/gammastep.go
+++ b/.config/waybar/modules/gamma.go
@@ -30,12 +30,6 @@ func main() {
 		log.Printf("error: %v", e)
 		os.Exit(1)
 	}
-	// if err := Prctl(PR_SET_PDEATHSIG,
-	// 		SIGTERM,
-	// 		0, 0, 0); err != nil {
-	// 	fmt.Fprintln(os.Stderr, err)
-	// 	os.Exit(1)
-	// }
 
 	lookup()
 	for {
@@ -43,11 +37,9 @@ func main() {
 		case sig := <-update:
 			switch sig {
 			case SIGUSR1:
-				// redshift off
-				printJson("day", "day")
+				printJson("day")
 			case SIGUSR2:
-				// redshift on
-				printJson("night", "night")
+				printJson("night")
 			case SIGHUP:
 				lookup()
 			}
@@ -58,37 +50,27 @@ func main() {
 	}
 }
 
-func printJson(state, tooltip string) {
+func printJson(phase string) {
 	_ = json.NewEncoder(os.Stdout).Encode(map[string]interface{}{
-		"class":   state,
-		"alt":     state,
-		"tooltip": "gammastep: " + tooltip,
-		"text":    state,
+		"class":   phase,
+		"alt":     phase,
+		"tooltip": "gamma: " + phase,
+		"text":    phase,
 	})
 }
 
 func lookup() {
-	b, err := exec.Command("gammastep", "-p").CombinedOutput()
+	cmdEnv, ok := os.LookupEnv("GAMMA_COMMAND")
+	if !ok {
+		printJson("unknown")
+		return
+	}
+	log.Println(cmdEnv)
+	b, err := exec.Command("bash", "-c", cmdEnv).Output()
 	if err != nil {
 		log.Printf("error: %v", err)
 		return
 	}
-	var period string
-	var fds = strings.Fields(string(b))
-	for idx, f := range fds {
-		if f == "Period:" {
-			period = fds[idx+1]
-			break
-		}
-	}
-	switch period {
-	case "Night":
-		printJson("night", "night")
-	case "Transition":
-		printJson("night", "transition")
-	case "Daytime":
-		printJson("day", "day")
-	default:
-		printJson("unknown", "unknown")
-	}
+	phase := strings.TrimSpace(string(b))
+	printJson(phase)
 }
diff --git a/.config/waybar/modules/weather.sh b/.config/waybar/modules/weather.sh
index 0b83de1..929732b 100755
--- a/.config/waybar/modules/weather.sh
+++ b/.config/waybar/modules/weather.sh
@@ -5,7 +5,8 @@ set -e
 loc=$1
 if [ -z "${loc}" ]; then
 	# use /etc/localtime
-	loc=$(basename "$(readlink -f /etc/localtime)")
+	# loc=$(basename "$(readlink -f /etc/localtime)")
+	loc="${HOME_LAT},${HOME_LON}"
 fi
 
 if [ -n "$REPORT" ]; then