Revert "[StumpWM, bin] Add weather module to StumpWM..."
This reverts commit d78be92786
.
This commit is contained in:
parent
ee7e82ea03
commit
1c911b9821
@ -2044,77 +2044,18 @@ CACHEFILE=$([ -n "$XDG_CACHE_HOME" ] && echo "$XDG_CACHE_HOME/wallpaper" || echo
|
|||||||
|
|
||||||
* Weather
|
* Weather
|
||||||
:PROPERTIES:
|
:PROPERTIES:
|
||||||
|
:HEADER-ARGS: :shebang "#!/usr/bin/env fish" :mkdirp yes :tangle ~/.local/bin/we
|
||||||
:CUSTOM_ID: Weather-4ed00bb0
|
:CUSTOM_ID: Weather-4ed00bb0
|
||||||
:END:
|
:END:
|
||||||
** StumpWM utilities
|
A quick and useful script I often use is a ~curl~ request to [[http://v2.wttr.in/][v2.wttr.in]] to get a
|
||||||
:PROPERTIES:
|
weather forecast in the terminal. By default, I want the request to be about the
|
||||||
:CUSTOM_ID: Weather-StumpWM-utilities-okvit9r05gj0
|
city I live in, but it is also possible for the script to accept as its
|
||||||
:END:
|
arguments a search inquiry.
|
||||||
*** ~stump-choose-city~
|
#+BEGIN_SRC fish
|
||||||
:PROPERTIES:
|
if count $argv > /dev/null
|
||||||
:CUSTOM_ID: Weather-StumpWM-utilities-stump-choose-city-adyit9r05gj0
|
set -l SEARCH (string join '+' $argv)
|
||||||
:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :mkdirp yes :tangle ~/.local/bin/stump-choose-city
|
curl http://v2.wttr.in/~$SEARCH
|
||||||
:END:
|
|
||||||
This script does two things. First, I get to choose a location which
|
|
||||||
weather will be displayed in StumpWM’s mode-line. The script stores
|
|
||||||
the selected location in the file ~$HOME/.cache/weather-city~, but only
|
|
||||||
if the input is not an empty string, otherwise nothing will change.
|
|
||||||
Secondly, if this change is applied, ~stump-weather~ (described below)
|
|
||||||
is called in order to update what StumpWM displays.
|
|
||||||
#+begin_src sh
|
|
||||||
CITY=$(rofi -p "City:" -dmenu | sed -r 's/ +/\+/g')
|
|
||||||
if [ -n "$CITY" ]; then
|
|
||||||
printf "%s" "$CITY" > "$HOME"/.cache/weather-city
|
|
||||||
stump-weather > /dev/null 2>&1
|
|
||||||
fi
|
|
||||||
#+end_src
|
|
||||||
|
|
||||||
*** ~stump-weather~
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: Weather-StumpWM-utilities-stump-weather-i21jt9r05gj0
|
|
||||||
:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :mkdirp yes :tangle ~/.local/bin/stump-weather
|
|
||||||
:END:
|
|
||||||
This stript is quite simple: it displays some weather information in
|
|
||||||
the format /Location: weather temperature (felt temperature)/. We use
|
|
||||||
the content of the file ~$HOME/.cache/weather-city~ to know which
|
|
||||||
location to use in our request to ~wttr.in~. If ~wttr.in~ is unreachable
|
|
||||||
after two second, the request aborts and the script displays an error
|
|
||||||
message instead.
|
|
||||||
#+begin_src sh
|
|
||||||
CITY=$(cat "$HOME/.cache/weather-city")
|
|
||||||
WEATHER=$(curl wttr.in/~"${CITY}"?format="${CITY}:+%C+%t+(%f)" --connect-timeout 1 2> /dev/null)
|
|
||||||
if [ -n "$WEATHER" ]; then
|
|
||||||
printf "%s" "$WEATHER"
|
|
||||||
else
|
else
|
||||||
printf "wttr.in unreachable"
|
curl http://v2.wttr.in/Aubervilliers
|
||||||
fi
|
end
|
||||||
#+end_src
|
|
||||||
|
|
||||||
** ~we~
|
|
||||||
:PROPERTIES:
|
|
||||||
:CUSTOM_ID: Weather-we-514jt9r05gj0
|
|
||||||
:HEADER-ARGS: :shebang "#!/usr/bin/env sh" :mkdirp yes :tangle ~/.local/bin/we
|
|
||||||
:END:
|
|
||||||
A quick and useful script I often use is a ~curl~ request to [[http://v2.wttr.in/][v2.wttr.in]]
|
|
||||||
to get a weather forecast in the terminal. If the user passes no
|
|
||||||
arguments to ~we~, the script will use the location designated in
|
|
||||||
~$HOME/.cache/weather-city~. Otherwise, it will use the options passed
|
|
||||||
by the user.
|
|
||||||
#+BEGIN_SRC sh
|
|
||||||
COUNT=0
|
|
||||||
LOCATION=""
|
|
||||||
if [ "$#" = 0 ]; then
|
|
||||||
LOCATION=$(cat "$HOME"/.cache/weather-city)
|
|
||||||
fi
|
|
||||||
if [ -z "$LOCATION" ]; then
|
|
||||||
for ARG in $*; do
|
|
||||||
if [ "${COUNT}" = 0 ]; then
|
|
||||||
LOCATION="${ARG}"
|
|
||||||
else
|
|
||||||
LOCATION="${LOCATION}+${ARG}"
|
|
||||||
fi
|
|
||||||
COUNT=$((COUNT + 1))
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
curl https://v2.wttr.in/~"${LOCATION}"
|
|
||||||
#+END_SRC
|
#+END_SRC
|
||||||
|
@ -494,11 +494,10 @@ be separated by a Powerline separator with the code point ~0xE0B0~ in
|
|||||||
the font I am using (see §[[#Theme-Fonts-28pc8141v5j0]]).
|
the font I am using (see §[[#Theme-Fonts-28pc8141v5j0]]).
|
||||||
#+name: modeline-format
|
#+name: modeline-format
|
||||||
| Formatter | What it does | Command? |
|
| Formatter | What it does | Command? |
|
||||||
|---------------+-------------------------------------------------------+----------|
|
|-----------+-------------------------------------------------------+----------|
|
||||||
| ~%g~ | Display list of groups | |
|
| ~%g~ | Display list of groups | |
|
||||||
| ~%W~ | Display list of windows in the current group and head | |
|
| ~%W~ | Display list of windows in the current group and head | |
|
||||||
| ~^>~ | Rest of the modeline align to the right | |
|
| ~^>~ | Rest of the modeline align to the right | |
|
||||||
| ~stump-weather~ | Display the current weather | yes |
|
|
||||||
| ~mu-unread~ | Display number of unread emails | yes |
|
| ~mu-unread~ | Display number of unread emails | yes |
|
||||||
| ~%m~ | Display current MPD song | |
|
| ~%m~ | Display current MPD song | |
|
||||||
| ~%I~ | Display Wifi status | |
|
| ~%I~ | Display Wifi status | |
|
||||||
@ -519,8 +518,8 @@ the font I am using (see §[[#Theme-Fonts-28pc8141v5j0]]).
|
|||||||
elements)
|
elements)
|
||||||
#+end_src
|
#+end_src
|
||||||
|
|
||||||
#+RESULTS[4a774559ef9c88c74aa62a42c6f53fdc401815aa]: modeline-format-gen
|
#+RESULTS[7f62146daae5aab6014d303b57c306fe44c4087b]: modeline-format-gen
|
||||||
: (("%g") ("%W") ("^>") ("stump-weather" . t) ("mu-unread" . t) ("%m") ("%I") ("%l") ("%C") ("%M") ("%B") ("%d"))
|
: (("%g") ("%W") ("^>") ("mu-unread" . t) ("%m") ("%I") ("%l") ("%C") ("%M") ("%B") ("%d"))
|
||||||
|
|
||||||
#+begin_src lisp :noweb yes
|
#+begin_src lisp :noweb yes
|
||||||
(defvar *mode-line-formatter-list*
|
(defvar *mode-line-formatter-list*
|
||||||
|
Loading…
Reference in New Issue
Block a user