diff --git a/home-manager/home.nix b/home-manager/home.nix index 39eb28b..08c55ca 100644 --- a/home-manager/home.nix +++ b/home-manager/home.nix @@ -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; };