nix/nixos/common/desktops/plasma6/default.nix
2024-06-26 13:55:48 +09:00

93 lines
2.8 KiB
Nix

{ pkgs, ... }: {
# Enable sound with pipewire.
sound.enable = true;
hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
};
# Configure keymap in X11
services.xserver = {
enable = true;
xkb.layout = "us";
xkb.variant = "";
autorun = true;
};
services.desktopManager.plasma6.enable = true;
environment.systemPackages = with pkgs; [
arc-kde-theme
arc-theme
];
services.xrdp.defaultWindowManager = "startplasma-x11";
services.displayManager.sddm.settings.General.DisplayServer = "x11-user";
systemd.user.services = {
"get-theme-times" = {
enable = true;
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 = true;
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 = true;
wantedBy = [ "default.target" ];
timerConfig = {
Unit = "get-theme-times.service";
OnCalendar = [ "*:00" ];
OnBootSec = [ "1min" ];
};
};
"set-theme" = {
enable = true;
wantedBy = [ "default.target" ];
timerConfig = {
Unit = "set-theme.service";
OnCalendar = [ "*:0..59" ];
OnBootSec = [ "2min" ];
};
};
};
}