EdenQwQ/home/programs/desktop/niri/autostart.nix
2026-02-20 12:27:10 +08:00

66 lines
1.8 KiB
Nix

{
pkgs,
lib,
user,
config,
...
}:
let
niri-autostart = pkgs.writeShellApplication {
name = "niri-autostart";
runtimeInputs = with pkgs; [
swww
mihomo
wlsunset
systemd
killall
waycorner
config.programs.caelestia.cli.package
];
extraShellCheckFlags = [ ];
bashOptions = [ ];
text =
# bash
''
killall swhkd
killall swhks
swhks &
doas swhkd -c ~/.config/niri/swhkd/niri.swhkdrc &
swww kill
swww-daemon --namespace "background" &
swww-daemon --namespace "backdrop" &
# swww restore --namespace "background"
# swww restore --namespace "backdrop"
mihomo -d ~/.config/clash &
wlsunset -s 00:00 -S 00:00 -t 5000 -T 5001 &
''
+ (
builtins.attrNames config.monitors
|> map (monitor: [
"swww img --namespace background -o ${monitor} \"/home/${user}/Pictures/Wallpapers/generated/$(cat ~/Pictures/Wallpapers/${monitor}-file)\""
"sleep 0.2"
"swww img --namespace backdrop -o ${monitor} \"/home/${user}/Pictures/Wallpapers/generated/$(cat ~/Pictures/Wallpapers/${monitor}-blurred-file)\""
"sleep 0.2"
])
|> builtins.concatLists
|> builtins.concatStringsSep "\n"
)
+ "\n"
+ (
if config.desktopShell == "caelestia" then
# bash
''
caelestia wallpaper -f "/home/${user}/Pictures/Wallpapers/generated/$(cat ~/Pictures/Wallpapers/${config.lib.monitors.mainMonitorName}-file)"
caelestia scheme set -n dynamic -m dark
''
else
''''
);
};
in
{
programs.niri.settings.spawn-at-startup = [
{ command = [ "${niri-autostart}/bin/niri-autostart" ]; }
{ command = [ "${pkgs.xwayland-satellite}/bin/xwayland-satellite" ]; }
];
}