Skip to content

Commit

Permalink
Weather, add padding options, more tags, add new build_and_install sc…
Browse files Browse the repository at this point in the history
…ript
  • Loading branch information
aperkins81 committed Oct 21, 2024
1 parent 0e8845f commit cbec771
Show file tree
Hide file tree
Showing 44 changed files with 82,997 additions and 83,589 deletions.
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 3 defaults

## 3.6.4

- Add attribution to nominatim
Expand Down
46 changes: 41 additions & 5 deletions weather@mockturtl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,17 +178,43 @@ The setting allows you to make the applet display basically anything in the form
| `{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 |
| `{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 |

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 (t: 4 padded left, humidity: 3 padded left, pressure: 7 padded left; all using spaces).

Multiline example for panel: `{c} {t}{u}{t_h_diff}{br}{wind_speed}{wind_arrow} {humidity}% {pressure} {day_remain}`

Multiline example for tooltip - extra spaces fix rounded tooltips: ` {city} {country}, Last updated {last_updated} {br}Min / Max: {min} / {max} {u}{br}Tomorrow: {tmr_t} {br}Day Length: {day_length} ({day_rem_pct}%)`

## 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 +226,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

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

## Language Translations

Expand Down
62 changes: 62 additions & 0 deletions weather@mockturtl/build_and_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash
# Check for lint errors, webpack errors, then installs applet and restarts cinnamon
# REQUIREMENTS:
# - typescript installed
VERSION='3.8'

# Check for upstream changes and exit with code if detected
git fetch origin && [ "$(git rev-parse @)" = "$(git rev-parse @{u})" ] || { echo "Upstream changes detected. A git pull is required."; exit -3; }

# Resolve Symlinks
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null && pwd )"

echo 'Checking with Lint...'
# Run the npm lint command and capture its output
lint_output=$(npm run lint 2>&1)

# Use awk and sed to extract and clean the number of errors and warnings
errors=$(echo "$lint_output" | awk '/problems/ {print $4}' | sed 's/[()]//g')
warnings=$(echo "$lint_output" | awk '/problems/ {print $6}' | sed 's/[()]//g')

echo "Lint Errors: $errors"
echo "Lint Warnings: $warnings"

# Check if there are zero errors
if [ "$errors" -eq 0 ]; then

# Run the npx webpack command and capture its output
echo 'Running webpack....'
webpack_output=$(npx webpack 2>&1)
echo "Webpack: $webpack_output"

# Check if the word 'successfully' is in the output
if echo "$webpack_output" | grep -q "compiled successfully in"; then
# Save current dir for convenience then run translations
path=${PWD}
cd ..
echo "Creating translations..."
./cinnamon-spices-makepot weather@mockturtl
cd $path
echo "Installing applet..."
cp --verbose files/weather@mockturtl/${VERSION}/weather-applet.js ~/.local/share/cinnamon/applets/weather\@mockturtl/${VERSION}/weather-applet.js
echo "Restarting Cinnamon..."
# Restart Cinnamon in the background without terminating the script
nohup bash -c "export DISPLAY=:0; cinnamon --replace" > /dev/null 2>&1 &
#cinnamon-looking-glass --logs & #TODO create command line parameter in Looking Glass to open logs tab
cinnamon-looking-glass &
echo "Build and installation successful."
exit 0 # Exit the script
else
echo "Webpack Errors prevented compiling"
exit -2
fi
else
echo "Lint Errors prevented compiling: $lint_output"
exit -1
fi
Loading

0 comments on commit cbec771

Please sign in to comment.