Rearrange things

This commit is contained in:
albert 2024-07-26 19:33:58 +09:00
parent 7c5adfc8b5
commit c5fa18ec13
Signed by: albert
GPG key ID: 3895DD267CA11BA9
2 changed files with 70 additions and 64 deletions

View file

@ -1,4 +1,9 @@
{ pkgs, ... }: { { pkgs, ... }: {
imports = [
# ./set-darkmode-service.nix
];
# Enable sound with pipewire. # Enable sound with pipewire.
security.rtkit.enable = true; security.rtkit.enable = true;
services.pipewire = { services.pipewire = {
@ -29,68 +34,4 @@
services.xrdp.defaultWindowManager = "startplasma-x11"; services.xrdp.defaultWindowManager = "startplasma-x11";
services.displayManager.sddm.settings.General.DisplayServer = "x11-user"; services.displayManager.sddm.settings.General.DisplayServer = "x11-user";
services.geoclue2.enable = true; services.geoclue2.enable = true;
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" ];
};
};
};
} }

View file

@ -0,0 +1,65 @@
{ 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" ];
};
};
};
}