sunrise.sh (2610B)
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 --connect-timeout 5 -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 elif [[ "$2" == "--blank" ]]; then 32 echo "$sunrise" 33 else 34 echo "<span font='Font Awesome 7 Free Solid 9' foreground='#$sunriseColour'> </span> <span foreground='#$sunriseColour'>$astro_twilight - $sunrise </span>" 35 fi 36 elif [[ "$1" == "--sunset" ]]; then 37 #json_today=$(curl -s "https://api.sunrisesunset.io/json?lat=${lat}&lng=${lon}&time_format=24") 38 json_today=$(curl --connect-timeout 5 -s "https://api.sunrise-sunset.org/json?lat=${lat}&lng=${lon}&date=today&formatted=0") 39 sunset=$(echo "$json_today" | jq -r .results.sunset | sed 's/.*T//g' | sed 's/:[0-9]*+.*//g') 40 astro_twilight=$(echo "$json_today" | jq -r .results.astronomical_twilight_end | sed 's/.*T//g' | sed 's/:[0-9]*+.*//g') 41 if [[ "$2" == "--conky" ]]; then 42 echo "\${color #$sunsetColour}$sunset - $astro_twilight \${color}" 43 elif [[ "$2" == "--blank" ]]; then 44 echo "$sunset" 45 else 46 echo "<span font='Font Awesome 7 Free Solid 9' foreground='#$sunsetColour'> </span> <span foreground='#$sunsetColour'>$sunset - $astro_twilight </span>" 47 fi 48 #elif [[ "$1" == "--golden-hour" ]]; then 49 # json_today=$(curl -s "https://api.sunrisesunset.io/json?lat=${lat}&lng=${lon}&time_format=24") 50 # golden_hour=$(echo "$json_today" | jq -r .results.golden_hour | sed 's/:[0-9]*$//g') 51 # echo "<span font='Font Awesome 7 Free Solid 9' foreground='#$goldenHourColour'> </span> <span foreground='#$goldenHourColour'>$golden_hour </span>" 52 fi 53 54