refactor(hm/price): separate swww
into its own module
84
users/price/conf/swww-wallpapers/default.nix
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
|
let
|
||||||
|
wallpapers = ./wallpapers;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
home.packages = [ pkgs.swww ];
|
||||||
|
systemd.user = {
|
||||||
|
services = {
|
||||||
|
swww-daemon = {
|
||||||
|
Service =
|
||||||
|
let
|
||||||
|
cleanup-socket-script = pkgs.writeShellScript "swww-daemon-cleanup-socket" ''
|
||||||
|
# Remove the existing swww.socket if it exists, avoids some issues with swww-daemon
|
||||||
|
# startup where swww-daemon claims the address is already in use
|
||||||
|
if [[ -w "$XDG_RUNTIME_DIR/swww.socket" ]]; then
|
||||||
|
rm -f $XDG_RUNTIME_DIR/swww.socket || exit 1
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
{
|
||||||
|
RestartSec = 3;
|
||||||
|
PassEnvironment = [ "XDG_RUNTIME_DIR" ];
|
||||||
|
ExecStartPre = "${cleanup-socket-script}";
|
||||||
|
ExecStopPost = "${cleanup-socket-script}";
|
||||||
|
ExecStart = "${pkgs.swww}/bin/swww-daemon";
|
||||||
|
};
|
||||||
|
Install.WantedBy = [ "graphical-session.target" ];
|
||||||
|
Unit = {
|
||||||
|
Description = "Wayland Wallpaper Service";
|
||||||
|
PartOf = [ "graphical-session.target" ];
|
||||||
|
After = [ "graphical-session.target" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
swww-watch-wallpapers = {
|
||||||
|
Service = {
|
||||||
|
RestartSec = 3;
|
||||||
|
Environment = [
|
||||||
|
"SWWW_TRANSITION_FPS=120"
|
||||||
|
"SWWW_TRANSITION_STEP=30"
|
||||||
|
"SWWW_TRANSITION_DURATION=0.75"
|
||||||
|
];
|
||||||
|
ExecStart = "${
|
||||||
|
pkgs.writeShellApplication {
|
||||||
|
name = "swww-watch-wallpapers";
|
||||||
|
runtimeInputs = with pkgs; [
|
||||||
|
swww
|
||||||
|
coreutils
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
set -eEuo pipefail
|
||||||
|
|
||||||
|
main() {
|
||||||
|
local prev_mons_connected=0
|
||||||
|
local mons_connected=0
|
||||||
|
local cached_swww_query
|
||||||
|
|
||||||
|
while sleep 1; do
|
||||||
|
cached_swww_query="$(swww query)"
|
||||||
|
mons_connected="$(wc -l <<< "$cached_swww_query")"
|
||||||
|
if ((mons_connected != prev_mons_connected)); then
|
||||||
|
prev_mons_connected="$mons_connected"
|
||||||
|
swww img -t random ${wallpapers}/Nebula.jpg
|
||||||
|
if [[ "$cached_swww_query" =~ "eDP-1: "* ]]; then
|
||||||
|
swww img -t wipe --transition-angle 40 -o eDP-1 ${wallpapers}/Autumn-Leaves.jpg
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
main
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
}/bin/swww-watch-wallpapers";
|
||||||
|
};
|
||||||
|
Install.WantedBy = [ "swww-daemon.service" ];
|
||||||
|
Unit = {
|
||||||
|
Description = "Wayland Wallpaper Service";
|
||||||
|
PartOf = [ "swww-daemon.service" ];
|
||||||
|
After = [ "swww-daemon.service" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Before Width: | Height: | Size: 3.9 MiB After Width: | Height: | Size: 3.9 MiB |
Before Width: | Height: | Size: 8.3 MiB After Width: | Height: | Size: 8.3 MiB |
Before Width: | Height: | Size: 474 KiB After Width: | Height: | Size: 474 KiB |
Before Width: | Height: | Size: 4.3 MiB After Width: | Height: | Size: 4.3 MiB |
Before Width: | Height: | Size: 1.7 MiB After Width: | Height: | Size: 1.7 MiB |
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
Before Width: | Height: | Size: 8.0 MiB After Width: | Height: | Size: 8.0 MiB |
Before Width: | Height: | Size: 344 KiB After Width: | Height: | Size: 344 KiB |
@ -152,12 +152,7 @@ in
|
|||||||
]
|
]
|
||||||
++ [ rust-analyzer ];
|
++ [ rust-analyzer ];
|
||||||
|
|
||||||
file = {
|
file = softLinkDots ".config";
|
||||||
".local/share/wallpapers" = {
|
|
||||||
source = ./dots/.local/share/wallpapers;
|
|
||||||
force = true;
|
|
||||||
};
|
|
||||||
} // softLinkDots ".config";
|
|
||||||
|
|
||||||
sessionVariables = {
|
sessionVariables = {
|
||||||
_ZL_DATA = "${config.xdg.cacheHome}/zlua";
|
_ZL_DATA = "${config.xdg.cacheHome}/zlua";
|
||||||
@ -483,56 +478,6 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
services = {
|
services = {
|
||||||
swww-daemon = {
|
|
||||||
Service =
|
|
||||||
let
|
|
||||||
cleanup-socket-script = pkgs.writeShellScript "swww-daemon-cleanup-socket" ''
|
|
||||||
# Remove the existing swww.socket if it exists, avoids some issues with swww-daemon
|
|
||||||
# startup where swww-daemon claims the address is already in use
|
|
||||||
if [[ -w "$XDG_RUNTIME_DIR/swww.socket" ]]; then
|
|
||||||
rm -f $XDG_RUNTIME_DIR/swww.socket || exit 1
|
|
||||||
fi
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
{
|
|
||||||
RestartSec = 3;
|
|
||||||
PassEnvironment = [ "XDG_RUNTIME_DIR" ];
|
|
||||||
ExecStartPre = "${cleanup-socket-script}";
|
|
||||||
ExecStopPost = "${cleanup-socket-script}";
|
|
||||||
ExecStart = "${pkgs.swww}/bin/swww-daemon";
|
|
||||||
};
|
|
||||||
Install.WantedBy = [ "compositor.target" ];
|
|
||||||
Unit = {
|
|
||||||
Description = "Wayland Wallpaper Service";
|
|
||||||
PartOf = [ "compositor.target" ];
|
|
||||||
After = [ "compositor.target" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
swww-wallpapers = {
|
|
||||||
Service = {
|
|
||||||
RestartSec = 3;
|
|
||||||
Type = "oneshot";
|
|
||||||
Environment = [
|
|
||||||
"SWWW_TRANSITION_FPS=120"
|
|
||||||
"SWWW_TRANSITION_STEP=30"
|
|
||||||
"SWWW_TRANSITION_DURATION=0.75"
|
|
||||||
];
|
|
||||||
ExecStart =
|
|
||||||
let
|
|
||||||
wallpaper-dir = "${dotsDir}/.local/share/wallpapers";
|
|
||||||
in
|
|
||||||
[
|
|
||||||
"${pkgs.swww}/bin/swww img -t random ${wallpaper-dir}/Nebula.jpg"
|
|
||||||
"${pkgs.swww}/bin/swww img -t wipe --transition-angle 40 -o eDP-1 ${wallpaper-dir}/Autumn-Leaves.jpg"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
Install.WantedBy = [ "swww-daemon.service" ];
|
|
||||||
Unit = {
|
|
||||||
Description = "Wayland Wallpaper Service";
|
|
||||||
PartOf = [ "swww-daemon.service" ];
|
|
||||||
After = [ "swww-daemon.service" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
keyd-application-mapper = {
|
keyd-application-mapper = {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "Keyd - Linux Keyboard Remapper";
|
Description = "Keyd - Linux Keyboard Remapper";
|
||||||
|