nix/nixos/common/desktops/plasma6/default.nix
2024-01-03 09:08:23 +09:00

89 lines
No EOL
2.3 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 wttr.in?format=j1 > /tmp/wttr.in";
after = [ "networking-online.target" ];
serviceConfig.Type = "oneshot";
onSuccess = [
"light-theme.service"
"dark-theme.service"
];
};
light-theme = {
enable = true;
path = [ pkgs.at pkgs.fx pkgs.nodejs pkgs.bash ];
script = ''
SUNRISE=`fx /tmp/wttr.in .weather[0].astronomy[0].sunrise`
NOW=`date +'%I:%M %p'`
if [[ $SUNRISE == $NOW ]] ; then
plasma-apply-colorscheme -platform offscreen ArcDark
fi
'';
serviceConfig.Type = "oneshot";
};
dark-theme = {
enable = true;
path = [ pkgs.at pkgs.fx pkgs.nodejs pkgs.bash ];
script = ''
SUNSET=`fx /tmp/wttr.in .weather[0].astronomy[0].sunset`
NOW="04:56 PM"
echo "Sunset: $SUNSET."
echo "Now : $NOW."
if [[ $SUNSET != $NOW ]] ; then
echo "Not sunset."
fi
if [[ $SUNET == $NOW ]] ; then
echo "Setting ArcDark colorscheme"
plasma-apply-colorscheme -platform offscreen ArcDark
fi
'';
serviceConfig.Type = "oneshot";
};
};
systemd.user.timers = {
"light-theme" = {
enable = false;
partOf = [ "light-theme.service" ];
timerConfig.OnCalendar = [ "*-*-* *:*:00" ];
};
"dark-theme" = {
enable = false;
partOf = [ "dark-theme.service" ];
timerConfig.OnCalendar = [ "*-*-* *:*:00" ];
};
};
}