···11+#! /bin/bash
22+#
33+# Opens all the eww cards
44+55+EWW="eww-wayland"
66+CARD_NAMES=(np profile distro quickapps powermenu weather confirmation clock system sliders github youtube brightspace twitch calendar)
77+88+open() {
99+ for i in ${CARD_NAMES[*]};
1010+ do
1111+ $EWW open $i
1212+ done
1313+}
1414+1515+close() {
1616+ for i in ${CARD_NAMES[*]};
1717+ do
1818+ $EWW close $i
1919+ done
2020+}
2121+2222+close
2323+if [[ $1 != "close" ]]; then
2424+ open
2525+fi
···11(include "cards/np/eww.yuck")
22+(include "cards/profile/eww.yuck")
33+(include "cards/distro/eww.yuck")
44+(include "cards/quickapps/eww.yuck")
55+(include "cards/powermenu/eww.yuck")
66+(include "cards/weather/eww.yuck")
77+(include "cards/confirmation/eww.yuck")
88+(include "cards/clock/eww.yuck")
99+(include "cards/system/eww.yuck")
1010+(include "cards/sliders/eww.yuck")
1111+(include "cards/webshortcuts/eww.yuck")
1212+(include "cards/calendar/eww.yuck")
1313+1414+(include "cards/frame.yuck")
1515+1616+; Each card is an element that shows up on the bottom of the desktop
1717+; The full dashboard is scaled to be around 1280x720, centered on the screen
1818+; All cards are built in units of 6px, so the spacing remains even in between them
219320
···11+#!/bin/bash
22+33+## Collect data
44+cache_dir="$HOME/.cache/eww/weather"
55+cache_weather_stat=${cache_dir}/weather-stat
66+cache_weather_degree=${cache_dir}/weather-degree
77+cache_weather_quote=${cache_dir}/weather-quote
88+cache_weather_hex=${cache_dir}/weather-hex
99+cache_weather_icon=${cache_dir}/weather-icon
1010+1111+## Weather data
1212+KEYFILE="$HOME/.config/eww/scripts/openweatherkey"
1313+ID="5130076"
1414+UNIT="imperial" # Available options : 'metric' or 'imperial'
1515+1616+## Get Key
1717+if [[ ! -e $KEYFILE ]]; then
1818+ echo "Key not found! Make a file in the script's directory titled 'openweatherkey' and place your api key"
1919+ exit 1
2020+else
2121+ KEY="$(cat $KEYFILE)"
2222+fi
2323+2424+## Make cache dir
2525+if [[ ! -d "$cache_dir" ]]; then
2626+ mkdir -p ${cache_dir}
2727+fi
2828+2929+## Get data
3030+get_weather_data() {
3131+ weather=`curl -sf "http://api.openweathermap.org/data/2.5/weather?APPID="$KEY"&id="$ID"&units="$UNIT""`
3232+ echo ${weather}
3333+3434+ if [ ! -z "$weather" ]; then
3535+ weather_temp=`echo "$weather" | jq ".main.temp" | cut -d "." -f 1`
3636+ weather_icon_code=`echo "$weather" | jq -r ".weather[].icon" | head -1`
3737+ weather_description=`echo "$weather" | jq -r ".weather[].description" | head -1 | sed -e "s/\b\(.\)/\u\1/g"`
3838+3939+ #Big long if statement of doom
4040+ if [ "$weather_icon_code" == "50d" ]; then
4141+ weather_icon=" "
4242+ weather_quote="Forecast says it's misty \nMake sure you don't get lost on your way..."
4343+ weather_hex="#84afdb"
4444+ elif [ "$weather_icon_code" == "50n" ]; then
4545+ weather_icon=" "
4646+ weather_quote="Forecast says it's a misty night \nDon't go anywhere tonight or you might get lost..."
4747+ weather_hex="#84afdb"
4848+ elif [ "$weather_icon_code" == "01d" ]; then
4949+ weather_icon=" "
5050+ weather_quote="It's a sunny day, gonna be fun! \nDon't go wandering all by yourself though..."
5151+ weather_hex="#ffd86b"
5252+ elif [ "$weather_icon_code" == "01n" ]; then
5353+ weather_icon=" "
5454+ weather_quote="It's a clear night \nYou might want to take a evening stroll to relax..."
5555+ weather_hex="#fcdcf6"
5656+ elif [ "$weather_icon_code" == "02d" ]; then
5757+ weather_icon=" "
5858+ weather_quote="It's cloudy, sort of gloomy \nYou'd better get a book to read..."
5959+ weather_hex="#adadff"
6060+ elif [ "$weather_icon_code" == "02n" ]; then
6161+ weather_icon=" "
6262+ weather_quote="It's a cloudy night \nHow about some hot chocolate and a warm bed?"
6363+ weather_hex="#adadff"
6464+ elif [ "$weather_icon_code" == "03d" ]; then
6565+ weather_icon=" "
6666+ weather_quote="It's cloudy, sort of gloomy \nYou'd better get a book to read..."
6767+ weather_hex="#adadff"
6868+ elif [ "$weather_icon_code" == "03n" ]; then
6969+ weather_icon=" "
7070+ weather_quote="It's a cloudy night \nHow about some hot chocolate and a warm bed?"
7171+ weather_hex="#adadff"
7272+ elif [ "$weather_icon_code" == "04d" ]; then
7373+ weather_icon=" "
7474+ weather_quote="It's cloudy, sort of gloomy \nYou'd better get a book to read..."
7575+ weather_hex="#adadff"
7676+ elif [ "$weather_icon_code" == "04n" ]; then
7777+ weather_icon=" "
7878+ weather_quote="It's a cloudy night \nHow about some hot chocolate and a warm bed?"
7979+ weather_hex="#adadff"
8080+ elif [ "$weather_icon_code" == "09d" ]; then
8181+ weather_icon=" "
8282+ weather_quote="It's rainy, it's a great day! \nGet some ramen and watch as the rain falls..."
8383+ weather_hex="#6b95ff"
8484+ elif [ "$weather_icon_code" == "09n" ]; then
8585+ weather_icon=" "
8686+ weather_quote=" It's gonna rain tonight it seems \nMake sure your clothes aren't still outside..."
8787+ weather_hex="#6b95ff"
8888+ elif [ "$weather_icon_code" == "10d" ]; then
8989+ weather_icon=" "
9090+ weather_quote="It's rainy, it's a great day! \nGet some ramen and watch as the rain falls..."
9191+ weather_hex="#6b95ff"
9292+ elif [ "$weather_icon_code" == "10n" ]; then
9393+ weather_icon=" "
9494+ weather_quote=" It's gonna rain tonight it seems \nMake sure your clothes aren't still outside..."
9595+ weather_hex="#6b95ff"
9696+ elif [ "$weather_icon_code" == "11d" ]; then
9797+ weather_icon=""
9898+ weather_quote="There's storm for forecast today \nMake sure you don't get blown away..."
9999+ weather_hex="#ffeb57"
100100+ elif [ "$weather_icon_code" == "11n" ]; then
101101+ weather_icon=""
102102+ weather_quote="There's gonna be storms tonight \nMake sure you're warm in bed and the windows are shut..."
103103+ weather_hex="#ffeb57"
104104+ elif [ "$weather_icon_code" == "13d" ]; then
105105+ weather_icon=" "
106106+ weather_quote="It's gonna snow today \nYou'd better wear thick clothes and make a snowman as well!"
107107+ weather_hex="#e3e6fc"
108108+ elif [ "$weather_icon_code" == "13n" ]; then
109109+ weather_icon=" "
110110+ weather_quote="It's gonna snow tonight \nMake sure you get up early tomorrow to see the sights..."
111111+ weather_hex="#e3e6fc"
112112+ elif [ "$weather_icon_code" == "40d" ]; then
113113+ weather_icon=" "
114114+ weather_quote="Forecast says it's misty \nMake sure you don't get lost on your way..."
115115+ weather_hex="#84afdb"
116116+ elif [ "$weather_icon_code" == "40n" ]; then
117117+ weather_icon=" "
118118+ weather_quote="Forecast says it's a misty night \nDon't go anywhere tonight or you might get lost..."
119119+ weather_hex="#84afdb"
120120+ else
121121+ weather_icon=" "
122122+ weather_quote="Sort of odd, I don't know what to forecast \nMake sure you have a good time!"
123123+ weather_hex="#adadff"
124124+ fi
125125+ echo "$weather_icon" > ${cache_weather_icon}
126126+ echo "$weather_description" > ${cache_weather_stat}
127127+ echo "$weather_temp""°F" > ${cache_weather_degree}
128128+ echo -e "$weather_quote" > ${cache_weather_quote}
129129+ echo "$weather_hex" > ${cache_weather_hex}
130130+ else
131131+ echo "Weather Unavailable" > ${cache_weather_stat}
132132+ echo " " > ${cache_weather_icon}
133133+ echo -e "Ah well, no weather huh? \nEven if there's no weather, it's gonna be a great day!" > ${cache_weather_quote}
134134+ echo "-" > ${cache_weather_degree}
135135+ echo "#adadff" > ${tcache_weather_hex}
136136+ fi
137137+}
138138+139139+## Execute
140140+if [[ "$1" == "--getdata" ]]; then
141141+ get_weather_data
142142+elif [[ "$1" == "--icon" ]]; then
143143+ cat ${cache_weather_icon}
144144+elif [[ "$1" == "--temp" ]]; then
145145+ cat ${cache_weather_degree}
146146+elif [[ "$1" == "--hex" ]]; then
147147+ cat ${cache_weather_hex}
148148+elif [[ "$1" == "--stat" ]]; then
149149+ cat ${cache_weather_stat}
150150+elif [[ "$1" == "--quote" ]]; then
151151+ cat ${cache_weather_quote} | head -n1
152152+elif [[ "$1" == "--quote2" ]]; then
153153+ cat ${cache_weather_quote} | tail -n1
154154+fi