summary refs log tree commit diff
path: root/.config/waybar
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2020-07-21 13:13:12 +0200
committerRobert Günzler <r@gnzler.io>2020-07-21 13:13:12 +0200
commit763ca33ca082346ab8ef558efe0439304f8ef63c (patch)
treea9c67d6a1d98396d9e408cdf0a633d443b2858fb /.config/waybar
parent363cf5c64c83f29c0b218d44b9ae67572d0602c9 (diff)
waybar: Add weather module
Diffstat (limited to '.config/waybar')
-rw-r--r--.config/waybar/config62
-rwxr-xr-x.config/waybar/modules/weather.sh19
-rw-r--r--.config/waybar/style.css5
3 files changed, 85 insertions, 1 deletions
diff --git a/.config/waybar/config b/.config/waybar/config
index 09bb1e5..0a96687 100644
--- a/.config/waybar/config
+++ b/.config/waybar/config
@@ -5,7 +5,7 @@
     "height": 30,
 
     "modules-left": ["sway/mode", "sway/workspaces", "sway/window"],
-    "modules-center": ["custom/media", "custom/toggl", "clock#local", "clock#utc"],
+    "modules-center": ["custom/media", "custom/toggl", "custom/weather", "clock#local", "clock#utc"],
     "modules-right": ["tray", "cpu", "memory", "disk#root", "disk#home", "temperature", "idle_inhibitor", "backlight", "custom/redshift", "pulseaudio", "network#wg", "network", "battery"],
     "sway/workspaces": {
         "disable-scroll": true,
@@ -144,6 +144,66 @@
 	"on-click": "pkill -x -USR1 redshift",
 	"on-click-right": "pkill -x -HUP waybar-redshift"
     },
+    "custom/weather": {
+	"format": "{icon} {percentage}℃",
+	"format-icons": {
+            "113": "󰖙", // "Sunny",
+            "116": "󰖕", // "PartlyCloudy",
+            "119": "󰖐", // "Cloudy",
+            "122": "󰼯", // "VeryCloudy",
+            "143": "󰖑", // "Fog",
+            "176": "󰖗", // "LightShowers",
+            "179": "󰖒", // "LightSleetShowers",
+            "182": "󰖒", // "LightSleet",
+            "185": "󰖒", // "LightSleet",
+            "200": "󰖓", // "ThunderyShowers",
+            "227": "󰖘", // "LightSnow",
+            "230": "󰼶", // "HeavySnow",
+            "248": "󰖑", // "Fog",
+            "260": "󰖑", // "Fog",
+            "263": "󰖗", // "LightShowers",
+            "266": "󰖗", // "LightRain",
+            "281": "󰖒", // "LightSleet",
+            "284": "󰖒", // "LightSleet",
+            "293": "󰖗", // "LightRain",
+            "296": "󰖗", // "LightRain",
+            "299": "󰖖", // "HeavyShowers",
+            "302": "󰖖", // "HeavyRain",
+            "305": "󰖖", // "HeavyShowers",
+            "308": "󰖖", // "HeavyRain",
+            "311": "󰖒", // "LightSleet",
+            "314": "󰖒", // "LightSleet",
+            "317": "󰖒", // "LightSleet",
+            "320": "󰖘", // "LightSnow",
+            "323": "󰙿", // "LightSnowShowers",
+            "326": "󰙿", // "LightSnowShowers",
+            "329": "󰼶", // "HeavySnow",
+            "332": "󰼶", // "HeavySnow",
+            "335": "󰼶", //"HeavySnowShowers",
+            "338": "󰼶", //"HeavySnow",
+            "350": "󰖒", // "LightSleet",
+            "353": "󰖗", // "LightShowers",
+            "356": "󰖖", // "HeavyShowers",
+            "359": "󰖖", // "HeavyRain",
+            "362": "󰖒", // "LightSleetShowers",
+            "365": "󰖒", // "LightSleetShowers",
+            "368": "󰙿", // "LightSnowShowers",
+            "371": "󰼶", // "HeavySnowShowers",
+            "374": "󰖒", // "LightSleetShowers",
+            "377": "󰖒", // "LightSleet",
+            "386": "󰖓", // "ThunderyShowers",
+            "389": "󰖓", // "ThunderyHeavyRain",
+            "392": "󰖓", // "ThunderySnowShowers",
+            "395": "󰼶", // "HeavySnowShowers",
+        },
+	"exec": "$HOME/.config/waybar/modules/weather.sh Berlin",
+	"interval": 600,
+	"return-type": "json",
+	"tooltip": true,
+	"signal": 4,
+	"on-click-right": "pkill -SIGRTMIN+5 waybar",
+	"on-click": "swx -t env REPORT=1 $HOME/.config/waybar/modules/weather.sh Berlin"
+    },
     "mpd": {
         "format": "{stateIcon} {artist} - {title} ({elapsedTime:%M:%S}/{totalTime:%M:%S})",
         "format-disconnected": "",
diff --git a/.config/waybar/modules/weather.sh b/.config/waybar/modules/weather.sh
new file mode 100755
index 0000000..9f7780d
--- /dev/null
+++ b/.config/waybar/modules/weather.sh
@@ -0,0 +1,19 @@
+#!/bin/sh
+set -e
+[ -n "$DEBUG" ] && set -x
+
+loc=$1
+
+if [ -n "$REPORT" ]; then
+	curl -s v2.wttr.in/"${loc}"?F | less
+	exit 0
+fi
+
+curl -s wttr.in/"${loc}"?format=j1 \
+	| jq \
+	--raw-output \
+	--unbuffered \
+	--compact-output \
+	--arg tooltip "$(curl -s v2.wttr.in/"${loc}"?ATFQ | tail -n5)" \
+	'.current_condition[] | { text: .weatherDesc[0].value, percentage: (.temp_C | tonumber), class: .weatherCode, alt: .weatherCode, tooltip: ($tooltip) }'
+	
diff --git a/.config/waybar/style.css b/.config/waybar/style.css
index fb890ae..0a0b60b 100644
--- a/.config/waybar/style.css
+++ b/.config/waybar/style.css
@@ -27,6 +27,7 @@
 #custom-media,
 #custom-toggl,
 #custom-redshift,
+#custom-weather,
 #mpd,
 #tray,
 #idle_inhibitor {
@@ -207,6 +208,10 @@ label:focus {
   color: @dimmed;
 }
 
+#custom-weather {
+  color: @dimmed;
+}
+
 #mpd {
   color: @foreground;
   border-top: 2px solid #d75f00;