sunrise.sh (2463B)
1 #!/usr/bin/env bash 2 3 curLocationFile="$XDG_CONFIG_HOME/regexghost/current_location.csv" 4 5 lat=$(cat "$curLocationFile" | cut -d "|" -f 1) 6 lon=$(cat "$curLocationFile" | cut -d "|" -f 2) 7 8 theme=$(cat "$XDG_CONFIG_HOME/regexghost/current_theme.txt") 9 10 if [[ "$theme" == "dracula" ]]; then 11 sunsetColour="8be9fd" 12 sunriseColour="ffff80" 13 goldenHourColour="ffff80" 14 elif [[ "$theme" == "christmas" ]]; then 15 sunsetColour="FD971F" 16 sunriseColour="F1C769" 17 goldenHourColour="F1C769" 18 elif [[ "$theme" == "tube" ]]; then 19 sunsetColour="e67823" 20 sunriseColour="ffd204" 21 goldenHourColour="ffd204" 22 fi 23 24 if [[ "$1" == "--sunrise" ]]; then 25 #json_tomorrow=$(curl -s "https://api.sunrisesunset.io/json?lat=${lat}&lng=${lon}&date=tomorrow&time_format=24") 26 json_tomorrow=$(curl -s "https://api.sunrise-sunset.org/json?lat=${lat}&lng=${lon}&date=tomorrow&formatted=0") 27 sunrise=$(echo "$json_tomorrow" | jq -r .results.sunrise | sed 's/.*T//g' | sed 's/:[0-9]*+.*//g') 28 astro_twilight=$(echo "$json_tomorrow" | jq -r .results.astronomical_twilight_begin | sed 's/.*T//g' | sed 's/:[0-9]*+.*//g') 29 if [[ "$2" == "--conky" ]]; then 30 echo "\${color #$sunriseColour}$astro_twilight - $sunrise \${color}" 31 else 32 echo "<span font='Font Awesome 7 Free Solid 9' foreground='#$sunriseColour'> </span> <span foreground='#$sunriseColour'>$astro_twilight - $sunrise </span>" 33 fi 34 elif [[ "$1" == "--sunset" ]]; then 35 #json_today=$(curl -s "https://api.sunrisesunset.io/json?lat=${lat}&lng=${lon}&time_format=24") 36 json_today=$(curl -s "https://api.sunrise-sunset.org/json?lat=${lat}&lng=${lon}&date=today&formatted=0") 37 sunset=$(echo "$json_today" | jq -r .results.sunset | sed 's/.*T//g' | sed 's/:[0-9]*+.*//g') 38 astro_twilight=$(echo "$json_today" | jq -r .results.astronomical_twilight_end | sed 's/.*T//g' | sed 's/:[0-9]*+.*//g') 39 if [[ "$2" == "--conky" ]]; then 40 echo "\${color #$sunsetColour}$sunset - $astro_twilight \${color}" 41 else 42 echo "<span font='Font Awesome 7 Free Solid 9' foreground='#$sunsetColour'> </span> <span foreground='#$sunsetColour'>$sunset - $astro_twilight </span>" 43 fi 44 #elif [[ "$1" == "--golden-hour" ]]; then 45 # json_today=$(curl -s "https://api.sunrisesunset.io/json?lat=${lat}&lng=${lon}&time_format=24") 46 # golden_hour=$(echo "$json_today" | jq -r .results.golden_hour | sed 's/:[0-9]*$//g') 47 # echo "<span font='Font Awesome 7 Free Solid 9' foreground='#$goldenHourColour'> </span> <span foreground='#$goldenHourColour'>$golden_hour </span>" 48 fi 49 50