diff options
| author | Robert Günzler <r@gnzler.io> | 2020-07-21 13:14:17 +0200 |
|---|---|---|
| committer | Robert Günzler <r@gnzler.io> | 2020-07-21 13:14:17 +0200 |
| commit | c66b664c987efd14ef256ed1a9b87f888f2defd2 (patch) | |
| tree | 4ceaa02578537dabb7b4739fea55f1ddfd314217 /.config | |
| parent | 763ca33ca082346ab8ef558efe0439304f8ef63c (diff) | |
waybar: rework redshift module
Diffstat (limited to '.config')
| -rw-r--r-- | .config/waybar/config | 5 | ||||
| -rw-r--r-- | .config/waybar/modules/redshift.go | 27 |
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") } } |