nix/nixos/common/desktops/plasma6/default.nix
2024-03-30 15:27:21 +09:00

88 lines
2.4 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;
layout = "us";
xkbVariant = "";
autorun = true;
desktopManager.plasma6.enable = true;
};
environment.systemPackages = with pkgs; [
arc-kde-theme
arc-theme
papirus-icon-theme
plasma-theme-switcher
tailscale-systray
];
services.xrdp.defaultWindowManager = "startplasma-x11";
systemd.user.services = {
"get-theme-times" = {
enable = true;
path = [ pkgs.curl ];
script = ''
echo "Activating get-theme-times systemd service"
curl -s wttr.in/?format=%S > /tmp/wttr.sunrise
curl -s wttr.in/?format=%s > /tmp/wttr.sunset
chown albert:root /tmp/wttr.sunrise /tmp/wttr.sunset
echo "get-theme-times - complete"
'';
after = [ "networking-online.target" ];
serviceConfig.Type = "oneshot";
onSuccess = [ "set-theme.service" ];
};
set-theme = {
enable = true;
script = ''
echo "set-theme.service - Checking for theme settings"
if [ ! -f /tmp/wttr.sunrise ] ; then
systemctl --user start get-theme-times.service
fi
SUNRISE=`date -d \`cat /tmp/wttr.sunrise\` +%s`
SUNSET=`date -d \`cat /tmp/wttr.sunset\` +%s`
CURRENT=`date +%s`
if [ $CURRENT -gt $SUNRISE -a $CURRENT -lt $SUNSET ] ; then
/run/current-system/sw/bin/plasma-apply-colorscheme -system offscreen Arc
else
/run/current-system/sw/bin/plasma-apply-colorscheme -system offscreen 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 = [ "2min" ];
};
};
"set-theme" = {
enable = true;
wantedBy = [ "default.target" ];
timerConfig = {
Unit = "set-theme.service";
OnCalendar = [ "*:0..59" ];
OnBootSec = [ "3min" ];
};
};
};
}