aboutsummaryrefslogtreecommitdiff
path: root/.scripts/weather
diff options
context:
space:
mode:
Diffstat (limited to '.scripts/weather')
-rwxr-xr-x.scripts/weather62
1 files changed, 34 insertions, 28 deletions
diff --git a/.scripts/weather b/.scripts/weather
index e662db1..345e702 100755
--- a/.scripts/weather
+++ b/.scripts/weather
@@ -6,9 +6,9 @@ CACHE_ONELINE=$WEATHER_CACHE_DIR"/current_weather_oneline.txt"
TIME=""
OPTION=$2
-usage () {
- echo "Usage: $0 (help|update|show|get|reload|full|dark|text) [:help|p|q]"
- echo " help : show this page
+usage() {
+ echo "Usage: $0 (help|update|show|get|reload|full|dark|text) [:help|p|q]"
+ echo " help : show this page
show : show picture according to time
get : get image from wttr.in
reload : get and show
@@ -18,47 +18,53 @@ usage () {
example: weather f 'Kitchener_0pq'
weather f moon
" >&2
- exit 0
+ exit 0
}
onlyprinttext() {
- info=$(cat $CACHE_ONELINE)
- case $info in
- *DOCTYPE*) echo " n/a";;
- *) echo $info ;;
- esac
+ info=$(cat $CACHE_ONELINE)
+ case $info in
+ *DOCTYPE*) echo " n/a" ;;
+ *) echo $info ;;
+ esac
}
get_image() {
- hasnet || exit 1
- curl -s 'wttr.in/Tübingen_1pq.png' > $CACHEFILE
- curl -s 'wttr.in/?format=%t' > $CACHE_ONELINE
+ hasnet || exit 1
+ curl -s 'wttr.in/Tübingen_1pq.png' >$CACHEFILE
+ curl -s 'wttr.in/Tübingen?format=%t' >$CACHE_ONELINE
}
print_detail() {
- echo curl -s "wttr.in/"$OPTION
- curl -s "wttr.in"/$OPTION
+ echo curl -s "wttr.in/"$OPTION
+ curl -s "wttr.in"/$OPTION
}
show_image() {
- if [ ! -e $CACHEFILE ]; then
- get_image
- fi
+ if [ ! -e $CACHEFILE ]; then
+ get_image
+ fi
- n30f -t weather $CACHEFILE
+ n30f -t weather $CACHEFILE
}
# main
if [ ! -d $WEATHER_CACHE_DIR ]; then
- mkdir $WEATHER_CACHE_DIR
- get_image
+ mkdir $WEATHER_CACHE_DIR
+ get_image
fi
-case "$1" in
- h|-h*|--h*) usage ;;
- show|s) show_image ;;
- get|g) get_image ;;
- reload|r) get_image && show_image ;;
- full|f) print_detail; OPTION=$2;;
- text|t) onlyprinttext;;
- *) onlyprinttext; usage;;
+case "$1" in
+h | -h* | --h*) usage ;;
+show | s) show_image ;;
+get | g) get_image ;;
+reload | r) get_image && show_image ;;
+full | f)
+ print_detail
+ OPTION=$2
+ ;;
+text | t) onlyprinttext ;;
+*)
+ onlyprinttext
+ usage
+ ;;
esac