{ pkgs, ... }: { systemd.user.services = { "get-theme-times" = { enable = false; path = [ pkgs.curl pkgs.fx ]; script = '' echo "Activating get-theme-times systemd service" curl -s "https://api.sunrise-sunset.org/json?lat=35.680&lng=135.03&tzid=Asia/Tokyo" | fx .results.sunrise > /tmp/wttr.sunrise curl -s "https://api.sunrise-sunset.org/json?lat=35.680&lng=135.03&tzid=Asia/Tokyo" | fx .results.sunset > /tmp/wttr.sunset chmod ogu+rw /tmp/wttr.sunset /tmp/wttr.sunrise echo "get-theme-times - complete" ''; after = [ "networking-online.target" ]; serviceConfig.Type = "oneshot"; onSuccess = [ "set-theme.service" ]; }; set-theme = { enable = false; script = '' #!/bin/env bash echo "set-theme.service - Checking for theme settings" if [ ! -f /tmp/wttr.sunrise ] ; then systemctl --user start get-theme-times.service fi echo "Getting dates:" SUNRISE=`date --date="$(cat /tmp/wttr.sunrise)" +%s` echo "Sunrise: $SUNRISE" SUNSET=`date --date="$(cat /tmp/wttr.sunset)" +%s` echo "Sunset: $SUNSET" CURRENT=`date +%s` echo "Current: $CURRENT" if [ $CURRENT -gt $SUNRISE -a $CURRENT -lt $SUNSET ] ; then # /run/current-system/sw/bin/plasma-apply-colorscheme -system offscreen Arc /run/current-system/sw/bin/plasma-apply-colorscheme Arc else # /run/current-system/sw/bin/plasma-apply-colorscheme -system offscreen ArcDark /run/current-system/sw/bin/plasma-apply-colorscheme ArcDark fi echo "set-theme.service - Complete" ''; serviceConfig.Type = "oneshot"; }; }; systemd.user.timers = { "get-theme-times" = { enable = false; wantedBy = [ "default.target" ]; timerConfig = { Unit = "get-theme-times.service"; OnCalendar = [ "*:00" ]; OnBootSec = [ "1min" ]; }; }; "set-theme" = { enable = false; wantedBy = [ "default.target" ]; timerConfig = { Unit = "set-theme.service"; OnCalendar = [ "*:0..59" ]; OnBootSec = [ "2min" ]; }; }; }; }