Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weather, add padding and padding defaults to custom overrides, add more override tags #6520

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 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
6 changes: 6 additions & 0 deletions weather@mockturtl/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 3.6.5

- Add more tags for overrides, including forecasts when available, details in README
- Add left/right padding options and a pad fill option for tags in overrides
- Add ability to programatically set overridable default padding options for tags in overrides, added some defaults

## 3.6.4

- Add attribution to nominatim
Expand Down
93 changes: 70 additions & 23 deletions weather@mockturtl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,31 +164,68 @@ Alerts are an US only feature as of May 2024.

### Usage of "Override label on panel", "Override location label" and "Override tooltip on panel" setting

The setting allows you to make the applet display basically anything in the form of text in the panel (and other places). In addition, it exposes a number of values for you to use as you like, these will be replaced with actual data values. The full text-to-value mapping can be found below.

| Text to enter | Mapped value |
| ----------------- | --------------------------------------------------------- |
| `{t}` | Temperature value |
| `{u}` | Temperature unit |
| `{c}` | Short condition text |
| `{c_long}` | Long condition text (same as short if not available) |
| `{dew_point}` | Dew point value |
| `{humidity}` | Humidity value (always as percent) |
| `{pressure}` | Pressure value |
| `{pressure_unit}` | Pressure unit |
| `{extra_value}` | API specific value (usually "Feels Like" or "Cloudiness") |
| `{extra_name}` | API specific value's name |
| `{wind_speed}` | Wind speed with unit |
| `{wind_dir}` | Wind direction in text format (NW, etc) |
| `{city}` | City name shown in the popup |
| `{country}` | Country name shown in the popup |
| `{search_entry}` | Search entry text in manual location (or location store) |
| `{last_updated}` | Formatted last updated time |
| `{br}` | Line Break |
The setting allows you to make the applet display basically anything in the form of text in the panel (and other places). In addition, it exposes a number of values for you to use as you like, these will be replaced with actual data values. The full text-to-value mapping can be found below. Left-pad values with up to 3 zeros using `{humidity,3.0}`. Right-pad values with up to 4 spaces using `{t.4}` (or `{t.4. }`). Some values have an overridable default padding.

| Text to enter | Mapped value | Padding | Pad Right | Pad Char |
| ----------------- | --------------------------------------------------------- |---------|-----------|----------|
| `{t}` | Temperature value | 3 | true | |
| `{u}` | Temperature unit | | | |
| `{c}` | Short condition text | | | |
| `{c_long}` | Long condition text (same as short if not available) | | | |
| `{dew_point}` | Dew point value | | | |
| `{humidity}` | Humidity value (always as percent) | 3 | true | |
| `{pressure}` | Pressure value | 6 | true | |
| `{pressure_unit}` | Pressure unit | | | |
| `{extra_value}` | API specific value (usually "Feels Like" or "Cloudiness") | 3 | true | |
| `{extra_name}` | API specific value's name | | | |
| `{city}` | City name shown in the popup | | | |
| `{country}` | Country name shown in the popup | | | |
| `{search_entry}` | Search entry text in manual location (or location store) | | | |
| `{last_updated}` | Formatted last updated time | | | |
| `{wind_speed}` | Wind speed | | | |
| `{wind_unit}` | Wind speed unit | | | |
| `{wind_dir}` | Wind direction in text format (NW, etc) | | | |
| `{wind_arrow}` | Wind direction as text arrow (↘, etc) | | | |
| `{wind_deg}` | Wind direction as degree value | | | |
| `{sunrise}` | Sunrise time | | | |
| `{sunset}` | Sunset time | | | |
| `{day_length}` | Daylight length in hours and minutes | | | |
| `{day_remain}` | Daylight remaining in hours and minutes ("" after dark) | | | |
| `{day_rem_pct}` | Daylight remaining as percentage ("0" after dark) | | | |
| `{day_len_rem}` | Day length and daylight remaining (or day length) | | | |
| `{min}` | Minimum temperature | | | |
| `{max}` | Maximum temperature | | | |
| `{tmr_min}` | Tomorrow's min temperature | | | |
| `{tmr_max}` | Tomorrow's max temperature | | | |
| `{tmr_min_diff}` | Tomorrow's min temperature difference from today | | | |
| `{tmr_max_diff}` | Tomorrow's max temperature difference from today | | | |
| `{tmr_t}` | Tomorrow's min and max temperatures | | | |
| `{tmr_td}` | Tomorrow's min and max temperatures with differences | | | |
| `{tmr_c}` | Tomorrow's short condition text | | | |
| `{t_h}` | Temperature in next 1-2 hours | | | |
| `{t_h_diff}` | Temperature change in next 1-2 hours with arrow indicator | | | |
| `{br}` | Line Break | | | |

1-Line Examples:

Current Temp, Condition: `{t}{u}, {c}`
Daylight & Extremes: `{day_len_rem} ({day_rem_pct}%), Min: {min}{u}, Max: {max}{u}`
Full Current Weather: `{t}{u}{t_h_diff}, {c_long}, {humidity}%, {wind_speed}{wind_unit} {wind_dir} ({wind_deg}°), {pressure}{pressure_unit}`
Location & Weather: `{city} {country}: {t}{u}, {c}, Wind: {wind_speed}{wind_unit}`
Pressure, Humidity, & Wind: `{pressure}{pressure_unit}, {humidity}%, {wind_speed}{wind_unit} {wind_dir}`
Tomorrow's Full Forecast: `Tomorrow: {tmr_min}{u} - {tmr_max}{u}, {tmr_c}`

2-Line Examples:

Comprehensive Weather & Daylight: `{c} {t}{t_h_diff}{br}{wind_speed}{wind_arrow} {humidity}% {pressure} {day_remain}`
Feels Like with Full Wind Info: `{t}{u}{t_h_diff} Feels: {extra_value}{u}{br}Wind: {wind_speed}{wind_unit}, {wind_dir} ({wind_deg}°)`
Full Daylight & Timing: `{sunrise} - {sunset}{br}{day_len_rem} ({day_rem_pct}%)`
Location, Weather, & Wind Details: `{city}, {country}: {t}{u}{t_h_diff}{br}{c}, {wind_speed}{wind_unit} {wind_dir}, {humidity}%`
Today and Tomorrow: `{min} / {max} {u} {c} {t}{u}{br}{tmr_t} {tmr_c}`

## Run script when the weather data changes

"Run a script when the weather info changes" field will run the command you provide every time the weather data is updated. The command will be interpolated with the same values with the same format you can get in any of the overrides, in addition you get `{full_data}` which is the full current weather data. Interpolation with single brackets `{xxx}` will not be escaped, with double brackets `{{xxxx}}` they are wrapped in single quotes `'` and all other single quotes are escaped inside. You can use this to integrate the weather data with other parts of your system.
"Run a script when the weather info changes" field will run the command you provide every time the weather data is updated. The command will be interpolated with the same values with the same format you can get in any of the overrides, in addition you get `{full_data}` which is the full current weather data. Interpolation with single brackets `{xxx}` will not be escaped, with double brackets `{{xxxx}}` they are wrapped in single quotes `'` and all other single quotes are escaped inside. Padding and padding defaults can be included with triple brackets `{{{xxx}}}`. You can use this to integrate the weather data with other parts of your system.

### Examples

Expand All @@ -200,7 +237,17 @@ The setting allows you to make the applet display basically anything in the form

## Future Plans

* Add special formatting options (like padded temperature) for values in panel in the "Override label on panel" setting
# Custom Overrides

* Add presets.

* Add more tags for changes in values.

* Add support for minutely forecasts.

* Add ability to specify number of decimal places in values, e.g., `{t_h_diff,4. .1}` for 1 decimal place, left-padded with spaces to width of 4. (This might be achievable by extracting float values then applying a default or specified precision to all numerical values.)

* Make tags that (or a way to) default to '' when no upcoming forecast changes in value to save panel space.

## Language Translations

Expand Down
2 changes: 1 addition & 1 deletion weather@mockturtl/build_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Visual Studio Code has the best Typescript support, although you can use other T

## Build for 3.8

Run `build.sh`, it will build for 3.8.
Run `build.sh`, it will build for 3.8. Alternatively, run `install.sh` to build and install.

## Build for 3.0

Expand Down
Loading