Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)

Expand Down
3 changes: 2 additions & 1 deletion scripts/dracula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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")
Expand Down
15 changes: 13 additions & 2 deletions scripts/weather.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,33 @@ 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/tcp/wttr.in/443"; then
printf 'Weather Unavailable\n'
if "$_hide_errors"; then
printf ''
else
printf 'Weather Unavailable\n'
fi
return
fi

# BashFAQ/002: assignment of substitution does not effect status code.
local _resp
if ! _resp=$(fetch_weather_information "$_show_fahrenheit" "$_location"); then

if "$_hide_errors"; then
printf ''
return
fi

# e.g. "curl: (22) The requested URL returned error: 404"
case "${_resp##* }" in
404)
Expand Down
6 changes: 4 additions & 2 deletions scripts/weather_wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@ INTERVAL=1200
# 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 _current_dir _last _now
local _show_fahrenheit _show_location _hide_errors _location _current_dir _last _now
_show_fahrenheit="$1"
_show_location="$2"
_location="$3"
_hide_errors="$4"
_current_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
_last=$(cat "$LAST_EXEC_FILE" 2>/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

Expand Down