nix/nixos/common/desktops/plasma6/default.nix
2024-01-03 18:48:16 +09:00

78 lines
No EOL
2.1 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 = ''
curl -s wttr.in/?format=%S > /tmp/wttr.sunrise
curl -s wttr.in/?format=%s > /tmp/wttr.sunset
'';
after = [ "networking-online.target" ];
serviceConfig.Type = "oneshot";
onSuccess = [ "set-theme.service" ];
};
set-theme = {
enable = true;
script = ''
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
'';
serviceConfig.Type = "oneshot";
};
};
systemd.user.timers = {
"get-theme-times" = {
enable = true;
partOf = [ "get-theme-times.service" ];
timerConfig.OnCalendar = ["1 hour"];
timerConfig.OnBootSec= [ "2min" ];
};
"set-theme" = {
enable = true;
partOf = [ "set-theme.service" ];
timerConfig.OnCalendar = [ "*:0..59" ];
timerConfig.OnBootSec= [ "3min" ];
};
};
}