nix/nixos/common/desktops/plasma6/default.nix
2024-01-05 20:48:33 +09:00

88 lines
No EOL
2.4 KiB
Nix

{ lib, inputs, config, pkgs, username, hostname, gpu, ... }: {
imports = [ inputs.kde2nix.nixosModules.plasma6 ];
# 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;
videoDrivers = [ ] ++ lib.optional (builtins.isString gpu) gpu;
desktopManager.plasma6.enable = true;
};
environment.systemPackages = with pkgs; [
arc-kde-theme
arc-theme
papirus-icon-theme
plasma-theme-switcher
tailscale-systray
];
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
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 -platform offscreen Arc
else
/run/current-system/sw/bin/plasma-apply-colorscheme -platform 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" ];
};
};
};
}