Skip to content

Commit

Permalink
Merge pull request #56 from DavidCatalano/main
Browse files Browse the repository at this point in the history
  • Loading branch information
fabioluciano authored Nov 29, 2024
2 parents c6251d7 + 8f2421a commit e84e1e6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Hit <kbd>prefix</kbd> + <kbd>I</kbd> to fetch the plugin and source it. You can
| Configuration | Description | Avaliable Options | Default |
| ------------------------------------------ | ----------- | ----------------- | ------- |
| `@theme_plugin_datetime_icon` | | | |
| `@theme_plugin_datetime_icon` | | Any character 📅 | Nerd Font 'Calendar' icon |
| `@theme_plugin_datetime_accent_color` | | | |
| `@theme_plugin_datetime_accent_color_icon` | | | |
| `@theme_plugin_datetime_format` | | | |
Expand All @@ -80,10 +80,16 @@ Hit <kbd>prefix</kbd> + <kbd>I</kbd> to fetch the plugin and source it. You can
| Configuration | Description | Avaliable Options | Default |
| ----------------------------------------- | ----------- | ----------------- | ------- |
| `@theme_plugin_weather_icon` | | | |
| `@theme_plugin_weather_icon` | | Any character 🌡️ | Font Awesome 'Cloud' icon |
| `@theme_plugin_weather_accent_color` | | | |
| `@theme_plugin_weather_accent_color_icon` | | | |
| `@theme_plugin_weather_format` | | | |
| `@theme_plugin_weather_format` | Format for displaying weather information | `%t`, `%c`, `%h`, `%w` (temperature, condition, humidity, wind) | `%t+H:%h` |
| `@theme_plugin_weather_location` | Location for weather (city/country) | `"City, Country"` | IP-based location detection |

#### Example
```
set -g @theme_plugin_weather_location 'Blacksburg, United States'
```

### Playerctl

Expand Down
10 changes: 8 additions & 2 deletions src/plugin/weather.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
plugin_weather_icon=$(get_tmux_option "@theme_plugin_weather_icon" "")
plugin_weather_accent_color=$(get_tmux_option "@theme_plugin_weather_accent_color" "blue7")
plugin_weather_accent_color_icon=$(get_tmux_option "@theme_plugin_weather_accent_color_icon" "blue0")
plugin_weather_location=$(get_tmux_option "@theme_plugin_weather_location" "")

export plugin_weather_icon plugin_weather_accent_color plugin_weather_accent_color_icon

Expand All @@ -18,8 +19,13 @@ function load_plugin() {
exit 1
fi

LOCATION=$(curl -s http://ip-api.com/json | jq -r '"\(.city), \(.country)"' 2>/dev/null)
WEATHER=$(curl -sL wttr.in/"${LOCATION// /%20}"\?format="${plugin_weather_format_string}" 2>/dev/null)
if [[ -n "$plugin_weather_location" ]]; then
LOCATION="$plugin_weather_location"
else
LOCATION=$(curl -s http://ip-api.com/json | jq -r '"\(.city), \(.country)"' 2>/dev/null)
fi

WEATHER=$(curl -sL wttr.in/"${LOCATION// /%20}"\?format="${plugin_weather_format_string}" 2>/dev/null)

echo "${WEATHER}"
}
Expand Down

0 comments on commit e84e1e6

Please sign in to comment.