]> piware.de Git - bin.git/commitdiff
daytime-term: Read GNOME color scheme gsetting
authorMartin Pitt <martin@piware.de>
Tue, 7 Oct 2025 04:48:32 +0000 (06:48 +0200)
committerMartin Pitt <martin@piware.de>
Tue, 7 Oct 2025 04:52:18 +0000 (06:52 +0200)
Does not hit the network, and more natural.

daytime-term

index c7f0c5f05f1ab6de8d3e2965a7cd6b6acd6aefef..54c18eba8175ebfe724dd82f3b9f6d0bd0d81c21 100755 (executable)
@@ -1,5 +1,4 @@
 #!/bin/sh
-DATA=$HOME/.cache/sunrise.json
 set -eu
 
 if [ "${1:-}" = "night" ]; then
@@ -8,14 +7,7 @@ if [ "${1:-}" = "night" ]; then
 elif [ "${1:-}" = "day" ]; then
     night=
 else
-    # get daylight times at most once a day
-    if [ ! -e "$DATA" ] || [ $(( `date +%s` - `stat -c %Y $DATA` )) -gt 86400 ]; then
-        curl --silent --show-error --connect-timeout=5 -o "$DATA" 'https://api.sunrise-sunset.org/json?lat=48.22&lng=10.54&formatted=0' || true
-    fi
-    sunrise=$(jq -r .results.sunrise < ~/.cache/sunrise.json)
-    sunset=$(jq -r .results.sunset < ~/.cache/sunrise.json)
-    now=$(date '+%H%M')
-    if [ $now -le $(date -d "$sunrise" '+%H%M') ] || [ $now -ge $(date -d "$sunset" '+%H%M') ]; then
+    if [ "$(gsettings get org.gnome.desktop.interface color-scheme)" = "'prefer-dark'" ]; then
         night=1
     fi
 fi