diff --git a/docs/CONFIG.md b/docs/CONFIG.md index eb7c9475..aa031601 100644 --- a/docs/CONFIG.md +++ b/docs/CONFIG.md @@ -218,8 +218,6 @@ these settings will introduce the following icons: - we were able to determine that the battery is charging/ discharging, but something about the percentage went wrong: `󰂃` - we don't know the status of the battery: `` - - if you have no battery and would like the widget to hide in that case, set the following: ```bash @@ -541,7 +539,6 @@ set -g @dracula-kubernetes-eks-extract-account true This script retrieves and displays continuous glucose monitoring (CGM) data from the LibreView API. It caches the data to minimize API requests and displays the latest glucose level along with a trend indicator in a Tmux status bar. - ### mac-player - [up](#table-of-contents) This widget and script displays music information provided by the native macOS players. @@ -737,7 +734,6 @@ To limit the maximum length (0 means unlimited length): set -g @dracula-spotify-tui-max-len 30 ``` - `set -g @dracula-refresh-rate 5` affects this widget ### spr - [up](#table-of-contents) @@ -777,7 +773,6 @@ set -g @dracula-spr-remote-next "N" `set -g @dracula-refresh-rate 5` affects this widget - ### ssh-session - [up](#table-of-contents) This widget displays the current username@host combination, both of the local machine as well as when connected via ssh. @@ -922,6 +917,12 @@ Hide your location ```bash set -g @dracula-show-location false ``` +Hide the weather plugin output when an error occurs (prints an empty string instead of "Weather Unavailable" / "Unknown Location"). +This is especially useful together with `set -g @dracula-show-empty-plugins false`. + +```bash +set -g @dracula-weather-hide-errors true +``` ### custom:script-name - [up](#table-of-contents) diff --git a/scripts/dracula.sh b/scripts/dracula.sh index 2fa9abca..c7e53031 100755 --- a/scripts/dracula.sh +++ b/scripts/dracula.sh @@ -18,6 +18,7 @@ main() { show_fahrenheit=$(get_tmux_option "@dracula-show-fahrenheit" true) show_location=$(get_tmux_option "@dracula-show-location" true) fixed_location=$(get_tmux_option "@dracula-fixed-location") + weather_hide_errors=$(get_tmux_option "@dracula-weather-hide-errors" false) show_powerline=$(get_tmux_option "@dracula-show-powerline" false) transparent_powerline_bg=$(get_tmux_option "@dracula-transparent-powerline-bg" false) show_flags=$(get_tmux_option "@dracula-show-flags" false) @@ -310,7 +311,7 @@ main() { elif [ $plugin = "weather" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-weather-colors" "orange dark_gray") - script="#($current_dir/weather_wrapper.sh $show_fahrenheit $show_location '$fixed_location')" + script="#($current_dir/weather_wrapper.sh $show_fahrenheit $show_location '$fixed_location' $weather_hide_errors)" elif [ $plugin = "time" ]; then IFS=' ' read -r -a colors <<< $(get_tmux_option "@dracula-time-colors" "dark_purple white") diff --git a/scripts/weather.sh b/scripts/weather.sh index 89e8055d..ec7b066c 100755 --- a/scripts/weather.sh +++ b/scripts/weather.sh @@ -94,15 +94,21 @@ function format_weather_info() { # show fahrenheit, either "true" (default) or "false" # show location, either "true" (default) or "false" # optional fixed location to query data about, e.g. "Houston, Texas" +# hide errors, either "true" or "false" (default) function main() { - local _show_fahrenheit _show_location _location + local _show_fahrenheit _show_location _location _hide_errors _show_fahrenheit="${1:-true}" _show_location="${2:-true}" _location="$3" + _hide_errors="${4:-false}" # process should be cancelled when session is killed if ! timeout 1 bash -c "/dev/null || echo 0) _now=$(date +%s) if (((_now - _last) > INTERVAL)); then # Run weather script here - "${_current_dir}/weather.sh" "$_show_fahrenheit" "$_show_location" "$_location" >"${DATAFILE}" + "${_current_dir}/weather.sh" "$_show_fahrenheit" "$_show_location" "$_location" "$_hide_errors" >"${DATAFILE}" printf '%s' "$_now" >"${LAST_EXEC_FILE}" fi