summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.config/waybar/config5
-rw-r--r--.config/waybar/modules/redshift.go27
2 files changed, 17 insertions, 15 deletions
diff --git a/.config/waybar/config b/.config/waybar/config
index 0a96687..0edd528 100644
--- a/.config/waybar/config
+++ b/.config/waybar/config
@@ -138,6 +138,11 @@
         "interval": 30
     },
     "custom/redshift": {
+	"format": "{icon}",
+	"format-icons": {
+            "day": "󰱌",
+	    "night": "󰱊"
+        },
         "exec-if": "pgrep redshift",
         "exec": "$HOME/.config/waybar/modules/waybar-redshift",
 	"return-type": "json",
diff --git a/.config/waybar/modules/redshift.go b/.config/waybar/modules/redshift.go
index 43b623c..b336748 100644
--- a/.config/waybar/modules/redshift.go
+++ b/.config/waybar/modules/redshift.go
@@ -13,10 +13,6 @@ import (
 	. "syscall"
 )
 
-const (
-	ICON = ""
-)
-
 func main() {
 	var (
 		update = make(chan os.Signal, 1)
@@ -47,25 +43,26 @@ func main() {
 			switch sig {
 			case SIGUSR1:
 				// redshift off
-				printJson("day", "day", ICON)
+				printJson("day", "day")
 			case SIGUSR2:
 				// redshift on
-				printJson("night", "night", ICON)
+				printJson("night", "night")
 			case SIGHUP:
 				lookup()
 			}
 		case <-cancel:
-			fmt.Fprintln(os.Stderr, "bye")
+			fmt.Fprintf(os.Stderr, "%v exiting\n", os.Args[0])
 			os.Exit(0)
 		}
 	}
 }
 
-func printJson(class, tooltip, text string) {
-	_ = json.NewEncoder(os.Stdout).Encode(map[string]string{
-		"class":   class,
+func printJson(state, tooltip string) {
+	_ = json.NewEncoder(os.Stdout).Encode(map[string]interface{}{
+		"class":   state,
+		"alt":     state,
 		"tooltip": "redshift: " + tooltip,
-		"text":    text,
+		"text":    state,
 	})
 }
 
@@ -83,10 +80,10 @@ func lookup() {
 	}
 	switch fds[0] {
 	case "Night":
-		printJson("night", "night", ICON)
+		printJson("night", "night")
 	case "Transition":
-		printJson("night", "transition", ICON)
-	case "Day":
-		printJson("day", "day", ICON)
+		printJson("night", "transition")
+	case "Daytime":
+		printJson("day", "day")
 	}
 }