2024-12-12 16:17 : id 409
This commit is contained in:
parent
80a01bbc29
commit
a1e466958d
@ -117,6 +117,13 @@ in
|
||||
};
|
||||
"scripts/mode-switcher-based-on-sunlight.sh" = {
|
||||
text = ''
|
||||
run_a_command() {
|
||||
if [[ "$light" == "DAY" ]]; then
|
||||
notify-send "day"
|
||||
else
|
||||
notify-send "night"
|
||||
fi
|
||||
};
|
||||
#!/bin/bash
|
||||
# Set your latitude and longitude
|
||||
LATITUDE="53.43N"
|
||||
@ -124,14 +131,14 @@ in
|
||||
|
||||
# Calculate the sunrise and sunset times for today using sunwait
|
||||
light=$(sunwait poll $LATITUDE $LONGITUDE)
|
||||
echo $sunrise_time
|
||||
echo $sunset_time
|
||||
|
||||
if [[ "$light" == "DAY" ]]; then
|
||||
echo "It's daylight. Running daytime command..."
|
||||
else
|
||||
echo "It's night. Running nighttime command..."
|
||||
fi
|
||||
run_a_command
|
||||
while sleep 5; do
|
||||
new_light=$(sunwait poll $LATITUDE $LONGITUDE)
|
||||
if [[ "$new_light" != "$light" ]]; do
|
||||
run_a_command
|
||||
do
|
||||
done
|
||||
'';
|
||||
executable = true;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user