From 5d265a33f7f951a1e3dfcffebcdc084b23126951 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Mon, 7 Sep 2020 22:01:30 +0200 Subject: [PATCH] polybar: Add weather script Added script to show the forecast weather for the immediate future / right now in polybar. --- polybar/.config/polybar/config | 13 ++++++++++- polybar/.config/polybar/scripts/poly-weather | 23 ++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100755 polybar/.config/polybar/scripts/poly-weather diff --git a/polybar/.config/polybar/config b/polybar/.config/polybar/config index 41b5505..28070ae 100644 --- a/polybar/.config/polybar/config +++ b/polybar/.config/polybar/config @@ -59,7 +59,7 @@ module-margin-left = 2 modules-left = workspaces sxhkdmode pomo modules-center = music date papersdue -modules-right = networkspeed archupdates cpu temp backlight volume battery +modules-right = networkspeed weather archupdates cpu temp backlight volume battery ; do not use offsets for the bar, would only work with override-redirect ; and will mess up tray https://github.com/polybar/polybar/issues/1355 tray-position = right @@ -248,6 +248,17 @@ click-left = exist rofi-bib-due normal "opening due papers" && rofi-bib-due -p1 click-right = exist rofi-bib-due normal "opening due papers" && rofi-bib-due -p3 -u $(date --date='fri this week' +%Y-%m-%d) format-prefix = " " interval = 120 +format-underline = ${colors.primary} + +[module/weather] +type = custom/script +exec = $XDG_CONFIG_HOME/polybar/scripts/poly-weather '?format=%t+%C+(%p)' +exec-if = type $XDG_CONFIG_HOME/polybar/scripts/poly-weather +interval = 60.0 +format-padding = 5 +; format-background = ${colors.primary} +; format-foreground = ${colors.background} +format-underline = ${colors.primary} ; displays a small pomodoro timer [module/pomo] diff --git a/polybar/.config/polybar/scripts/poly-weather b/polybar/.config/polybar/scripts/poly-weather new file mode 100755 index 0000000..9604207 --- /dev/null +++ b/polybar/.config/polybar/scripts/poly-weather @@ -0,0 +1,23 @@ +#!/usr/bin/env sh + +wttr() { + # change Paris to your default location + request="wttr.in/${1-~Leipzig}" + curl -s -H "Accept-Language: ${LANG%_*}" --compressed "$request" +} + +wttr "$@" + +# while true; do +# all="$(bib-due -u 'fri this week' -p3 | wc -l)" +# required="$(bib-due -u 'fri this week' -p1 | wc -l)" + +# # add polybar formatting to color required readings red +# # https://github.com/polybar/polybar/wiki/Formatting#format-tags +# # TODO use xresources +# colorreq=$(xrdb -query | grep -e '\*color1:' | cut -f2) +# colorall=$(xrdb -query | grep -e '\*foreground:' | cut -f2) +# printf "%s%s%s(%s)\n" "%{F${colorall:-#000}}" "$all" "%{F${colorreq:-#d00}}" "$required" + +# sleep 120 +# done