Remove weather and update temperature module
This commit is contained in:
parent
504c15dc3b
commit
2cce5603d1
@ -80,7 +80,7 @@
|
||||
|
||||
modules-left = i3 bspwm xwindow
|
||||
modules-center =
|
||||
modules-right = pulseaudio mpd xbacklight redshift nordvpn lockscreen dunst packages unread_mail cpu battery temperature date
|
||||
modules-right = pulseaudio xbacklight redshift nordvpn lockscreen dunst packages unread_mail cpu battery temperature date
|
||||
|
||||
wm-restack = i3
|
||||
|
||||
@ -346,38 +346,34 @@
|
||||
#+END_SRC
|
||||
|
||||
* Temperature
|
||||
#+BEGIN_SRC conf
|
||||
#+begin_src conf
|
||||
[module/temperature]
|
||||
type = internal/temperature
|
||||
|
||||
interval = 5
|
||||
interval = 2
|
||||
thermal-zone = 0
|
||||
warn-temperature = 70
|
||||
hwmon-path = /sys/devices/platform/coretemp.0/hwmon/hwmon2/temp1_input
|
||||
|
||||
format = %{A1:$TERMINAL -e "watch sensors" &:}<ramp> <label>%{A}
|
||||
format-underline = ${colors.bg}
|
||||
units = false
|
||||
format = %{A1:$TERMINAL --class="Floating" -e "watch sensors" &:}<ramp> <label>%{A}
|
||||
format-warn = <ramp> <label-warn>
|
||||
label = %temperature-c%°C
|
||||
label-warn = %temperature-c%°C
|
||||
label-warn-foreground = ${colors.fg}
|
||||
format-warn-underline = ${colors.red}
|
||||
|
||||
label = %temperature-c%
|
||||
label-warn = %temperature-c%
|
||||
label-warn-foreground = ${colors.red}
|
||||
|
||||
ramp-0 =
|
||||
ramp-1 =
|
||||
ramp-2 =
|
||||
ramp-3 =
|
||||
ramp-4 =
|
||||
ramp-foreground = ${color.fg}
|
||||
#+END_SRC
|
||||
ramp-foreground = ${colors.fg}
|
||||
#+end_src
|
||||
|
||||
* Unread Mails
|
||||
#+BEGIN_SRC conf
|
||||
[module/unread_mail]
|
||||
type = custom/script
|
||||
|
||||
:format-underline = ${colors.bg}
|
||||
format-underline = ${colors.bg}
|
||||
click-left = ~/.config/polybar/scripts/mail-open.sh
|
||||
format = <label>
|
||||
exec = ~/.config/polybar/scripts/mail-status.sh
|
||||
@ -415,7 +411,6 @@
|
||||
[module/redshift]
|
||||
type = custom/script
|
||||
|
||||
label-font = 2
|
||||
format-underline = ${colors.bg}
|
||||
click-left = ~/.config/polybar/scripts/redshift-toggle.sh
|
||||
format = <label>
|
||||
@ -463,14 +458,13 @@
|
||||
interval = 2
|
||||
#+END_SRC
|
||||
|
||||
** TODO Nordvpn Status script
|
||||
** Nordvpn Status script
|
||||
:PROPERTIES:
|
||||
:header-args: :tangle ~/.config/polybar/scripts/nordvpn-status.sh
|
||||
:header-args+: :comments both :mkdirp yes
|
||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||
:END:
|
||||
|
||||
- [ ] Should check if there is a tmpfile, if there is not, run nordvpn status and create the tmpfile accordindly
|
||||
#+BEGIN_SRC bash
|
||||
tmpfile="/tmp/vpnstatus";
|
||||
|
||||
@ -637,144 +631,6 @@
|
||||
fi
|
||||
#+end_src
|
||||
|
||||
* Weather
|
||||
https://github.com/x70b1/polybar-scripts/tree/master/polybar-scripts/openweathermap-fullfeatured
|
||||
|
||||
#+begin_src conf
|
||||
[module/weather]
|
||||
type = custom/script
|
||||
|
||||
exec = ~/.config/polybar/scripts/weather-status.sh
|
||||
click-left = ~/.config/polybar/scripts/weather-open.sh
|
||||
|
||||
interval = 600
|
||||
label-font = 3
|
||||
#+end_src
|
||||
|
||||
** Script to retrieve the weather
|
||||
:PROPERTIES:
|
||||
:header-args: :tangle ~/.config/polybar/scripts/weather-status.sh
|
||||
:header-args+: :comments both :mkdirp yes
|
||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||
:END:
|
||||
|
||||
#+BEGIN_SRC bash
|
||||
get_icon() {
|
||||
case $1 in
|
||||
01d) icon="";;
|
||||
01n) icon="";;
|
||||
02d) icon="";;
|
||||
02n) icon="";;
|
||||
03*) icon="";;
|
||||
04*) icon="";;
|
||||
09d) icon="";;
|
||||
09n) icon="";;
|
||||
10d) icon="";;
|
||||
10n) icon="";;
|
||||
11d) icon="";;
|
||||
11n) icon="";;
|
||||
13d) icon="";;
|
||||
13n) icon="";;
|
||||
50d) icon="";;
|
||||
50n) icon="";;
|
||||
,*) icon="";
|
||||
esac
|
||||
|
||||
echo $icon
|
||||
}
|
||||
|
||||
get_duration() {
|
||||
|
||||
osname=$(uname -s)
|
||||
|
||||
case $osname in
|
||||
,*BSD) date -r "$1" -u +%H:%M;;
|
||||
,*) date --date="@$1" -u +%H:%M;;
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
KEY="a705adc4ce0e271801051b9460ecb1cd"
|
||||
CITY=""
|
||||
UNITS="metric"
|
||||
SYMBOL="°"
|
||||
|
||||
API="https://api.openweathermap.org/data/2.5"
|
||||
|
||||
if [ -n "$CITY" ]; then
|
||||
if [ "$CITY" -eq "$CITY" ] 2>/dev/null; then
|
||||
CITY_PARAM="id=$CITY"
|
||||
else
|
||||
CITY_PARAM="q=$CITY"
|
||||
fi
|
||||
|
||||
current=$(curl -sf "$API/weather?appid=$KEY&$CITY_PARAM&units=$UNITS")
|
||||
forecast=$(curl -sf "$API/forecast?appid=$KEY&$CITY_PARAM&units=$UNITS&cnt=1")
|
||||
else
|
||||
location=$(curl -sf https://location.services.mozilla.com/v1/geolocate?key=geoclue)
|
||||
|
||||
if [ -n "$location" ]; then
|
||||
location_lat="$(echo "$location" | jq '.location.lat')"
|
||||
location_lon="$(echo "$location" | jq '.location.lng')"
|
||||
|
||||
current=$(curl -sf "$API/weather?appid=$KEY&lat=$location_lat&lon=$location_lon&units=$UNITS")
|
||||
forecast=$(curl -sf "$API/forecast?appid=$KEY&lat=$location_lat&lon=$location_lon&units=$UNITS&cnt=1")
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "$current" ] && [ -n "$forecast" ]; then
|
||||
current_temp=$(echo "$current" | jq ".main.temp" | cut -d "." -f 1)
|
||||
current_icon=$(echo "$current" | jq -r ".weather[0].icon")
|
||||
|
||||
forecast_temp=$(echo "$forecast" | jq ".list[].main.temp" | cut -d "." -f 1)
|
||||
forecast_icon=$(echo "$forecast" | jq -r ".list[].weather[0].icon")
|
||||
|
||||
|
||||
if [ "$current_temp" -gt "$forecast_temp" ]; then
|
||||
trend="" #
|
||||
elif [ "$forecast_temp" -gt "$current_temp" ]; then
|
||||
trend="" #
|
||||
else
|
||||
trend="" #
|
||||
fi
|
||||
|
||||
|
||||
sun_rise=$(echo "$current" | jq ".sys.sunrise")
|
||||
sun_set=$(echo "$current" | jq ".sys.sunset")
|
||||
now=$(date +%s)
|
||||
|
||||
if [ "$sun_rise" -gt "$now" ]; then
|
||||
daytime=" $(get_duration "$((sun_rise-now))")"
|
||||
elif [ "$sun_set" -gt "$now" ]; then
|
||||
daytime=" $(get_duration "$((sun_set-now))")"
|
||||
else
|
||||
daytime=" $(get_duration "$((sun_rise-now))")"
|
||||
fi
|
||||
|
||||
echo "$(get_icon "$current_icon") $current_temp$SYMBOL $trend $(get_icon "$forecast_icon") $forecast_temp$SYMBOL $daytime"
|
||||
fi
|
||||
#+END_SRC
|
||||
|
||||
** TODO Open Weather Webpage
|
||||
:PROPERTIES:
|
||||
:header-args: :tangle ~/.config/polybar/scripts/weather-open.sh
|
||||
:header-args+: :comments both :mkdirp yes
|
||||
:header-args+: :shebang "#!/usr/bin/env bash"
|
||||
:END:
|
||||
- [ ] Find a way to open a web page with detailed forecast with the current location
|
||||
|
||||
#+BEGIN_SRC bash
|
||||
# location=$(curl -sf https://location.services.mozilla.com/v1/geolocate?key=geoclue)
|
||||
|
||||
# if [ -n "$location" ]; then
|
||||
# location_lat="$(echo "$location" | jq '.location.lat')"
|
||||
# location_lon="$(echo "$location" | jq '.location.lng')"
|
||||
# else
|
||||
|
||||
# fi
|
||||
$BROWSER https://www.yahoo.com/news/weather/france/grenoble/grenoble-593720
|
||||
#+END_SRC
|
||||
|
||||
* Network
|
||||
#+begin_src conf
|
||||
[module/wired-network]
|
||||
|
Loading…
Reference in New Issue
Block a user