-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rofi-wttr: Weather display with forecast popup (#451)
rofi-wttr: Weather display with forecast popup A minimal weather line with forecast pop up on click. Using rofi for the pop up and wttr.in as the weather interface.
- Loading branch information
Showing
7 changed files
with
783 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# rofi-wttr | ||
|
||
A minimal weather line with forecast pop up on click. Using [rofi](https://github.com/davatorium/rofi) for the pop up and [wttr.in](https://wttr.in/) as the weather interface. | ||
|
||
![The statusbar weather](rofi-wttr-status-line.png) | ||
The statusbar | ||
|
||
![The weather forecast popup](rofi-wttr-detail.png) | ||
The popup with the default rofi theme | ||
|
||
## Depencencies | ||
|
||
* [rofi](https://github.com/davatorium/rofi) | ||
* curl | ||
|
||
## Installation | ||
|
||
* Copy the script into your directory of choice, e.g. ~/.i3blocks/blocklets | ||
* Give it execution permission (`chmod +x rofi-wttr`) | ||
* Optional: Customize your rofi theme via the `rofi-theme-selector` command | ||
* Optional: Customize the rofi launch options in the script | ||
* Optional: Customize the wttr curl arguments in the script | ||
* Add the following blocklet to your i3blocks.conf: | ||
|
||
```ini | ||
[rofi-wttr] | ||
command=$SCRIPT_DIR/rofi-wttr | ||
interval=3600 | ||
#BAR_POSITION=top | ||
#FONT=Monospace 10 | ||
#LABEL=🌡️ | ||
#LOCATION=Washington_DC | ||
#ROFI_CONFIG_FILE=/dev/null | ||
``` | ||
|
||
## Thanks | ||
Modeled off of [rofi-calendar](https://github.com/vivien/i3blocks-contrib/tree/master/rofi-calendar) with thanks to its authors. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[rofi-wttr] | ||
command=$SCRIPT_DIR/rofi-wttr | ||
interval=300 | ||
#BAR_POSITION=top | ||
#FONT=Monospace 10 | ||
#LABEL=🌡️ | ||
#LOCATION=Washington_DC | ||
#ROFI_CONFIG_FILE=/dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#! /usr/bin/env bash | ||
|
||
###### Variables ###### | ||
LABEL="${LABEL:- }" | ||
LOCATION="${LOCATION:- }" | ||
FONT="${FONT:-Monospace 10}" | ||
ROFI_CONFIG_FILE="${ROFI_CONFIG_FILE:-/dev/null}" | ||
BAR_POSITION="${BAR_POSITION:-bottom}" | ||
|
||
###### Variables ###### | ||
|
||
|
||
###### Functions ###### | ||
# print the full weather | ||
# see https://github.com/chubin/wttr.in#usage for full configuration options | ||
print_weather_report() { | ||
if [[ $LOCATION != " " ]]; then | ||
curl https://wttr.in/$LOCATION?T | ||
else | ||
curl https://wttr.in/?T | ||
fi | ||
} | ||
|
||
# print the one line weather | ||
# see https://github.com/chubin/wttr.in#one-line-output for formatting options | ||
print_weather_line() { | ||
if [[ $LOCATION != " " ]]; then | ||
curl -s https://wttr.in/${LOCATION}?u\&format="%C+%c+%t+(%f)+%w" | tr -d \" | ||
else | ||
curl -s 'https://wttr.in/?u\&format="%C+%c+%t+(%f)+%w"' | tr -d \" | ||
fi | ||
} | ||
|
||
###### Functions ###### | ||
|
||
|
||
###### Main body ###### | ||
|
||
# handle any click | ||
# rofi pop up | ||
case "$BLOCK_BUTTON" in | ||
1|2|3) | ||
IFS= | ||
weather_report=$(print_weather_report) | ||
|
||
# check bar position and adjust anchor accordingly | ||
if [[ $BAR_POSITION = "top" ]]; then | ||
anchor="northwest" | ||
else | ||
anchor="southwest" | ||
fi | ||
|
||
# open rofi | ||
# (add the following option to rofi command with proper config file, if needed) | ||
echo $weather_report \ | ||
| rofi \ | ||
-dmenu \ | ||
-markup-rows \ | ||
-font $FONT \ | ||
-m -3 \ | ||
-theme-str 'window {width: 53%; anchor: '"$anchor"'; location: northwest;}' \ | ||
-theme-str 'listview {lines: '"$(echo $weather_report | wc -l)"' ;scrollbar: false;}' \ | ||
-theme $ROFI_CONFIG_FILE \ | ||
-p "Detailed weather report" | ||
esac | ||
|
||
# print blocklet text | ||
|
||
if [[ $LABEL != " " ]]; then | ||
echo $LABEL$(print_weather_line) | ||
else | ||
echo $(print_weather_line) | ||
fi | ||
|
||
###### Main body ###### |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.