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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Please update your custom themes and segments now. [#489](https://github.com/eri
- `now_playing.sh`: removed Spotify though wine. Not likely this is used anymore. If someone still uses, shout at me and I'll add it back :-). [#473](https://github.com/erikw/tmux-powerline/pull/473)
- `weather.sh`: Removed GNU Grep dependency [#468](https://github.com/erikw/tmux-powerline/pull/468)
- `cpu.sh`: Removed GNU Grep dependency [#472](https://github.com/erikw/tmux-powerline/pull/472)
### Fixed
- Set custom User Agent for weather segment's met.no API call. [#500](https://github.com/erikw/tmux-powerline/pull/500)


## [3.1.0] - 2025-03-03
Expand Down
5 changes: 5 additions & 0 deletions lib/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,8 @@ tp_round() {
env printf "%.${digits}f" "$(echo "scale=${digits};(((10^${digits})*${number})+0.5)/(10^${digits})" | bc)"
};


# Get tmux-powerline version.
tp_version() {
grep release: "$TMUX_POWERLINE_DIR_HOME/.semver.yaml" | cut -d' ' -f2
}
6 changes: 5 additions & 1 deletion segments/weather.sh
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ __yrno() {
return 1
fi

if weather_data=$(curl --max-time 4 -s "https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=${TMUX_POWERLINE_SEG_WEATHER_LAT}&lon=${TMUX_POWERLINE_SEG_WEATHER_LON}"); then
# Ref: https://api.met.no/doc/TermsOfService
local user_agent
user_agent="tmux-powerline/$(tp_version) (https://github.com/erikw/tmux-powerline)"

if weather_data=$(curl --max-time 4 -A "$user_agent" -s "https://api.met.no/weatherapi/locationforecast/2.0/compact?lat=${TMUX_POWERLINE_SEG_WEATHER_LAT}&lon=${TMUX_POWERLINE_SEG_WEATHER_LON}"); then
error=$(echo "$weather_data" | grep -i "error")
if [ -n "$error" ]; then
tp_err_seg "Err: yr.no err: error in api return"
Expand Down