From 60675a1710953914c2750ac6de1c9eacf88fac67 Mon Sep 17 00:00:00 2001 From: Dane Williams Date: Wed, 29 Apr 2020 11:33:51 -0700 Subject: [PATCH] celsius option --- data/weather.txt | 2 +- dracula.tmux | 3 --- scripts/battery.sh | 4 ---- scripts/dracula.sh | 9 +++------ scripts/network.sh | 4 ---- scripts/sleep_weather.sh | 4 +++- scripts/weather.sh | 15 ++++++++------- 7 files changed, 15 insertions(+), 26 deletions(-) diff --git a/data/weather.txt b/data/weather.txt index 00d39e1..0536cf7 100644 --- a/data/weather.txt +++ b/data/weather.txt @@ -1 +1 @@ -Loading Weather... +☀ 18° Pleasanton, CA diff --git a/dracula.tmux b/dracula.tmux index a98fb3c..e230713 100755 --- a/dracula.tmux +++ b/dracula.tmux @@ -1,8 +1,5 @@ #!/usr/bin/env bash -# Author: Dane Williams -# a theme for tmux inspired by dracula - # source and run dracula theme current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" diff --git a/scripts/battery.sh b/scripts/battery.sh index 7e4bb24..21c01ff 100755 --- a/scripts/battery.sh +++ b/scripts/battery.sh @@ -1,9 +1,5 @@ #!/usr/bin/env bash -#author: Dane Williams -#scipt for gathering battery percentage and A/C status -#script is called in dracula.tmux program - battery_percent() { # Check OS diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 2e1f14b..a5e6f79 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -1,8 +1,5 @@ #!/usr/bin/env bash -# a tmux color scheme inspired by dracula -# author: Dane Williams - get_tmux_option() { local option=$1 local default_value=$2 @@ -23,7 +20,7 @@ main() show_battery=$(get_tmux_option "@dracula-show-battery" true) show_network=$(get_tmux_option "@dracula-show-network" true) show_weather=$(get_tmux_option "@dracula-show-weather" true) - fahrenheit=$(get_tmux_option "@dracula-fahrenheit" true) + show_fahrenheit=$(get_tmux_option "@dracula-show-fahrenheit" true) # Dracula Color Pallette white='#f8f8f2' @@ -40,7 +37,7 @@ main() # start weather script in background if $show_weather; then - $current_dir/sleep_weather.sh & + $current_dir/sleep_weather.sh $show_fahrenheit & fi # set refresh interval @@ -76,7 +73,7 @@ main() fi if $show_weather; then - tmux set-option -ga status-right "#[fg=${dark_gray},bg=${orange}] #(cat $current_dir/../data/weather.txt) " + tmux set-option -ga status-right "#[fg=${dark_gray},bg=${orange}] #(cat $current_dir/../data/weather.txt) " fi tmux set-option -ga status-right "#[fg=${white},bg=${dark_purple}] %a %m/%d %I:%M %p #(date +%Z) " diff --git a/scripts/network.sh b/scripts/network.sh index 87c9156..045445c 100755 --- a/scripts/network.sh +++ b/scripts/network.sh @@ -1,9 +1,5 @@ #!/usr/bin/env bash -#author: Dane Williams -#script for gathering internet connectivity info -#script is called in dracula.tmux program - HOSTS="google.com github.com example.com" get_ssid() diff --git a/scripts/sleep_weather.sh b/scripts/sleep_weather.sh index f1f93d3..393f771 100755 --- a/scripts/sleep_weather.sh +++ b/scripts/sleep_weather.sh @@ -2,6 +2,8 @@ #wrapper script for running weather on interval +fahrenheit=$1 + main() { current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -10,7 +12,7 @@ main() while tmux has-session &> /dev/null do - $current_dir/weather.sh > $current_dir/../data/weather.txt + $current_dir/weather.sh $fahrenheit > $current_dir/../data/weather.txt if tmux has-session &> /dev/null then sleep 1200 diff --git a/scripts/weather.sh b/scripts/weather.sh index 066f516..cef059b 100755 --- a/scripts/weather.sh +++ b/scripts/weather.sh @@ -1,11 +1,8 @@ #!/usr/bin/env bash -#author: Dane Williams -#script for gathering current location and weather at location -#script is then called in the dracula.tmux program -# test if rate limit hit -# only testing last request because of redundancy +fahrenheit=$1 + load_request_params() { @@ -33,7 +30,11 @@ weather_information() } get_temp() { - weather_information | grep 'deg;F' | cut -d '&' -f 1 + if $fahrenheit; then + echo $(weather_information | grep 'deg;F' | cut -d '&' -f 1) + else + echo $(( ($(weather_information | grep 'deg;F' | cut -d '&' -f 1) - 32) * 5 / 9 )) + fi } forecast_unicode() { @@ -57,7 +58,7 @@ forecast_unicode() display_weather() { if [ $country = 'US' ]; then - echo "$(forecast_unicode)$(get_temp)°F" + echo "$(forecast_unicode)$(get_temp)°" else echo '' fi