wallpaper

This commit is contained in:
Lucy von Overheidt 2025-09-09 22:06:57 +02:00
parent f9c369c584
commit 36c8d05a0d
4 changed files with 43 additions and 559 deletions

View file

@ -136,6 +136,7 @@
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.backupFileExtension = "backup"; home-manager.backupFileExtension = "backup";
home-manager.extraSpecialArgs = { inherit inputs; };
home-manager.users.lucy = home-manager.users.lucy =
{ config { config
, pkgs , pkgs
@ -148,6 +149,22 @@
./modules/home.nix ./modules/home.nix
]; ];
home.packages = with pkgs; [
inputs.self.packages.${pkgs.system}.wallpapers
];
home.file = {
".local/share/wallpapers/anime-cat-girl-snow.mp4".source = "${
inputs.self.packages.${pkgs.system}.wallpapers
}/share/wallpapers/anime-cat-girl-snow.mp4";
".local/share/wallpapers/static-wallpaper.jpg".source = "${
inputs.self.packages.${pkgs.system}.wallpapers
}/share/wallpapers/static-wallpaper.jpg";
".local/share/wallpapers/anime-cat-girl-snow-optimized.mp4".source = "${
inputs.self.packages.${pkgs.system}.wallpapers
}/share/wallpapers/anime-cat-girl-snow-optimized.mp4";
};
# Configure dconf settings here or inside home.nix # Configure dconf settings here or inside home.nix
# Example: # Example:
# home.sessionVariables = { # home.sessionVariables = {

View file

@ -2,6 +2,7 @@
config, config,
lib, lib,
pkgs, pkgs,
inputs,
... ...
}: }:
let let
@ -10,13 +11,8 @@ let
}; };
qs = "${pkgs.quickshell}/bin/qs"; qs = "${pkgs.quickshell}/bin/qs";
wl-paste = "${pkgs.wl-clipboard}/bin/wl-paste"; wl-paste = "${pkgs.wl-clipboard}/bin/wl-paste";
swww = "${pkgs.swww}/bin/swww"; wallpapers = inputs.self.packages.${pkgs.system}.wallpapers;
swww-daemon = "${pkgs.swww}/bin/swww-daemon";
# Your assets - adjust paths as needed
assetsPath = ./assets;
wallpaperDir = "${config.home.homeDirectory}/.config/wallpapers";
systemctl = "${pkgs.systemd}/bin/systemctl";
in in
{ {
programs.niri.settings = { programs.niri.settings = {
@ -30,9 +26,17 @@ in
QT_WAYLAND_DISABLE_WINDOWDECORATION = "1"; QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
SDL_VIDEODRIVER = "wayland"; SDL_VIDEODRIVER = "wayland";
}; };
spawn-at-startup = [ spawn-at-startup = [
(makeCommand "${lib.getExe pkgs.hyprlock}") (makeCommand "${lib.getExe pkgs.hyprlock}")
(makeCommand swww-daemon) {
command = [
"${lib.getExe pkgs.mpvpaper}"
"-vs"
"-o"
"'no-audio loop' ALL ${wallpapers}/share/wallpapers/*.mp4"
];
}
{ {
command = [ command = [
"${wl-paste}" "${wl-paste}"
@ -57,23 +61,6 @@ in
"DankMaterialShell" "DankMaterialShell"
]; ];
} }
# Set animated wallpaper on startup
{
command = [
"${pkgs.bash}/bin/bash"
"-c"
''
sleep 3
while ! ${swww} query &>/dev/null; do
sleep 1
done
${swww} img "${wallpaperDir}/anime-cat-girl-snow.mp4" \
--transition-type fade \
--transition-duration 2 \
--transition-fps 30
''
];
}
]; ];
input = { input = {
touchpad = { touchpad = {
@ -94,6 +81,7 @@ in
warp-mouse-to-focus.enable = true; warp-mouse-to-focus.enable = true;
workspace-auto-back-and-forth = true; workspace-auto-back-and-forth = true;
}; };
outputs = { outputs = {
"eDP-1" = { "eDP-1" = {
scale = 1.0; scale = 1.0;
@ -103,6 +91,7 @@ in
}; };
}; };
}; };
overview = { overview = {
workspace-shadow.enable = false; workspace-shadow.enable = false;
backdrop-color = "transparent"; backdrop-color = "transparent";
@ -130,6 +119,7 @@ in
default-column-width = { default-column-width = {
proportion = 0.5; proportion = 0.5;
}; };
gaps = 6; gaps = 6;
struts = { struts = {
left = 0; left = 0;
@ -137,6 +127,7 @@ in
top = 0; top = 0;
bottom = 0; bottom = 0;
}; };
tab-indicator = { tab-indicator = {
hide-when-single-tab = true; hide-when-single-tab = true;
place-within-column = true; place-within-column = true;
@ -148,136 +139,8 @@ in
length.total-proportion = 0.1; length.total-proportion = 0.1;
}; };
}; };
prefer-no-csd = true; prefer-no-csd = true;
hotkey-overlay.skip-at-startup = true; hotkey-overlay.skip-at-startup = true;
# Wallpaper keybindings
binds = with config.lib.niri.actions; {
# Switch between your wallpapers
# Interactive wallpaper selection
"Mod+Shift+A".action = spawn [
"${pkgs.bash}/bin/bash"
"-c"
''
selected=$(find "${wallpaperDir}" -type f \( -name "*.gif" -o -name "*.mp4" -o -name "*.webm" -o -name "*.jpg" -o -name "*.png" \) | ${pkgs.fzf}/bin/fzf --preview='basename {}')
if [ -n "$selected" ]; then
${swww} img "$selected" \
--transition-type fade \
--transition-duration 2 \
--transition-fps 30
fi
''
];
};
};
home.packages = with pkgs; [
swww
fzf
ffmpeg
];
# Create cache directory for wallpaper state
home.file = {
# Create wallpaper directory
".config/wallpapers/.keep".text = "";
# Create cache directory for rotation state
# Initialize wallpaper rotation state (starts at 0, so first rotation goes to index 1)
".cache/wallpaper-rotation-state".text = "0";
# Copy your animated wallpaper
".config/wallpapers/anime-cat-girl-snow.mp4" = {
source = "${assetsPath}/Anime Live Wallpaper - Anime Cat Girl Snow - HD - no copyright [SiMc3l0ido0].mp4";
};
# Copy your static wallpaper
".config/wallpapers/static-wallpaper.jpg" = {
source = "${assetsPath}/wp6553608.jpg";
};
# Create optimized version of the MP4 using a script
".config/wallpapers/anime-cat-girl-snow-optimized.mp4" = {
source =
pkgs.runCommand "optimized-wallpaper"
{
buildInputs = [ pkgs.ffmpeg ];
}
''
${pkgs.ffmpeg}/bin/ffmpeg -i "${assetsPath}/Anime Live Wallpaper - Anime Cat Girl Snow - HD - no copyright [SiMc3l0ido0].mp4" \
-vf "scale=1920:1080:force_original_aspect_ratio=increase,crop=1920:1080" \
-r 30 -c:v libx264 -crf 28 -preset medium \
-t 30 -an "$out"
'';
};
# SWWW configuration
".config/swww/config".text = ''
resize=crop
fill_color=000000
filter=Lanczos3
'';
};
# Wallpaper rotation service
systemd.user.services.wallpaper-rotation = {
Unit = {
Description = "Rotate between wallpapers";
After = [ "graphical-session.target" ];
};
Service = {
Type = "oneshot";
ExecStart = "${pkgs.writeShellScript "rotate-wallpaper" ''
wallpapers=(
"${wallpaperDir}/anime-cat-girl-snow.mp4"
"${wallpaperDir}/anime-cat-girl-snow-optimized.mp4"
"${wallpaperDir}/static-wallpaper.jpg"
)
# Wait for swww to be available
while ! ${swww} query &>/dev/null; do
sleep 1
done
# Get random wallpaper
random_wallpaper="''${wallpapers[$RANDOM % ''${#wallpapers[@]}]}"
${swww} img "$random_wallpaper" \
--transition-type random \
--transition-duration 3 \
--transition-fps 30
''}";
};
};
# Optional: Timer for automatic wallpaper rotation
systemd.user.timers.wallpaper-rotation = {
Unit = {
Description = "Timer for wallpaper rotation";
};
Timer = {
OnBootSec = "10min";
OnUnitActiveSec = "10min";
Unit = "wallpaper-rotation.service";
};
Install = {
WantedBy = [ "timers.target" ];
};
};
# Shell aliases
programs.bash.shellAliases = {
wallpaper = "${swww} img";
wallpaper-anime = "${swww} img ${wallpaperDir}/anime-cat-girl-snow.mp4 --transition-type fade --transition-fps 30";
wallpaper-static = "${swww} img ${wallpaperDir}/static-wallpaper.jpg --transition-type fade";
wallpaper-optimized = "${swww} img ${wallpaperDir}/anime-cat-girl-snow-optimized.mp4 --transition-type fade --transition-fps 30";
wallpaper-rotate = "${systemctl} --user start wallpaper-rotation.service";
wallpaper-auto-start = "${systemctl} --user start wallpaper-rotation.timer";
wallpaper-auto-stop = "${systemctl} --user stop wallpaper-rotation.timer";
}; };
} }

View file

@ -106,7 +106,7 @@ in
go-hello = "${nix} flake init --template templates#go-hello"; go-hello = "${nix} flake init --template templates#go-hello";
haskell-hello = "${nix} flake init --template templates#haskell-hello"; haskell-hello = "${nix} flake init --template templates#haskell-hello";
g = "${lib.getExe pkgs.git}"; g = "${lib.getExe pkgs.git}";
copy = "${pkgs.wl-wl-clipboard}/bin/wl-copy"; copy = "${pkgs.wl-clipboard}/bin/wl-copy";
}; };
}; };
carapace.enable = true; carapace.enable = true;

View file

@ -1,411 +1,15 @@
{ { config
config, , pkgs
lib, , lib
pkgs, , inputs
... , ...
}: }:
let
makeCommand = command: {
command = [ command ];
};
qs = "${pkgs.quickshell}/bin/qs";
wl-paste = "${pkgs.wl-clipboard}/bin/wl-paste";
swww = "${pkgs.swww}/bin/swww";
swww-daemon = "${pkgs.swww}/bin/swww-daemon";
# Your assets - adjust paths as needed let
assetsPath = ../assets; wallpapers = inputs.self.packages.${pkgs.system}.wallpapers;
wallpaperDir = "${config.home.homeDirectory}/.config/wallpapers";
systemctl = "${pkgs.systemd}/bin/systemctl";
in in
{ {
programs.niri.settings = { programs.mpvpaper = {
environment = {
CLUTTER_BACKEND = "wayland";
DISPLAY = ":0";
GDK_BACKEND = "wayland,x11";
MOZ_ENABLE_WAYLAND = "1";
NIXOS_OZONE_WL = "1";
QT_QPA_PLATFORM = "wayland;xcb";
QT_WAYLAND_DISABLE_WINDOWDECORATION = "1";
SDL_VIDEODRIVER = "wayland";
};
spawn-at-startup = [
(makeCommand "${lib.getExe pkgs.hyprlock}")
(makeCommand swww-daemon)
{
command = [
"${wl-paste}"
"--watch"
"cliphist"
"store"
];
}
{
command = [
"${wl-paste}"
"--type text"
"--watch"
"cliphist"
"store"
];
}
{
command = [
"${qs}"
"-c"
"DankMaterialShell"
];
}
# Set animated wallpaper on startup and start rotation timer
{
command = [
"${pkgs.bash}/bin/bash"
"-c"
''
# Wait for swww daemon to be ready
sleep 3
timeout=30
while ! ${swww} query &>/dev/null && [ $timeout -gt 0 ]; do
sleep 1
timeout=$((timeout - 1))
done
if [ $timeout -eq 0 ]; then
echo "Timeout waiting for swww daemon"
exit 1
fi
# Ensure wallpaper directory exists
mkdir -p "${wallpaperDir}"
# Set initial wallpaper (the video)
if [ -f "${wallpaperDir}/anime-cat-girl-snow.mp4" ]; then
${swww} img "${wallpaperDir}/anime-cat-girl-snow.mp4" \
--transition-type fade \
--transition-duration 2 \
--transition-fps 30
# Initialize state file
echo "0" > "$HOME/.cache/wallpaper-rotation-state"
# Start the rotation timer automatically
${systemctl} --user start wallpaper-rotation.timer
else
echo "Wallpaper file not found: ${wallpaperDir}/anime-cat-girl-snow.mp4"
fi
''
];
}
];
input = {
touchpad = {
click-method = "button-areas";
dwt = true;
dwtp = true;
natural-scroll = true;
scroll-method = "two-finger";
tap = true;
tap-button-map = "left-right-middle";
middle-emulation = true;
accel-profile = "adaptive";
};
focus-follows-mouse = {
enable = true;
max-scroll-amount = "90%";
};
warp-mouse-to-focus.enable = true;
workspace-auto-back-and-forth = true;
};
outputs = {
"eDP-1" = {
scale = 1.0;
position = {
x = 0;
y = 0;
};
};
};
overview = {
workspace-shadow.enable = false;
backdrop-color = "transparent";
};
gestures = {
hot-corners.enable = true;
};
layout = {
focus-ring.enable = false;
border = {
enable = true;
width = 2;
active.color = "#ff69b4";
inactive.color = "#7d0d2d";
};
shadow = {
enable = true; enable = true;
}; };
preset-column-widths = [
{ proportion = 0.25; }
{ proportion = 0.5; }
{ proportion = 0.75; }
{ proportion = 1.0; }
];
default-column-width = {
proportion = 0.5;
};
gaps = 6;
struts = {
left = 0;
right = 0;
top = 0;
bottom = 0;
};
tab-indicator = {
hide-when-single-tab = true;
place-within-column = true;
position = "left";
corner-radius = 20.0;
gap = -12.0;
gaps-between-tabs = 10.0;
width = 4.0;
length.total-proportion = 0.1;
};
};
prefer-no-csd = true;
hotkey-overlay.skip-at-startup = true;
# Wallpaper keybindings
binds = with config.lib.niri.actions; {
# Switch between your wallpapers sequentially
"Mod+Shift+W".action = spawn [
"${pkgs.bash}/bin/bash"
"-c"
''
wallpapers=(
"${wallpaperDir}/anime-cat-girl-snow.mp4"
"${wallpaperDir}/static-wallpaper.jpg"
"${wallpaperDir}/anime-cat-girl-snow-optimized.mp4"
)
# Check if swww is running
if ! ${swww} query &>/dev/null; then
echo "swww daemon not running"
exit 1
fi
current_wallpaper=$(${swww} query | head -n1 | awk '{print $NF}')
for i in "''${!wallpapers[@]}"; do
if [[ "''${wallpapers[$i]}" == "$current_wallpaper" ]]; then
next_index=$(( (i + 1) % ''${#wallpapers[@]} ))
# Check if next wallpaper exists
if [ -f "''${wallpapers[$next_index]}" ]; then
${swww} img "''${wallpapers[$next_index]}" \
--transition-type random \
--transition-duration 2 \
--transition-fps 30
# Update the rotation state to sync with manual change
mkdir -p "$HOME/.cache"
echo "$next_index" > "$HOME/.cache/wallpaper-rotation-state"
exit 0
fi
fi
done
# If current wallpaper not in list, set first available one
for i in "''${!wallpapers[@]}"; do
if [ -f "''${wallpapers[$i]}" ]; then
${swww} img "''${wallpapers[$i]}" \
--transition-type fade \
--transition-duration 2 \
--transition-fps 30
mkdir -p "$HOME/.cache"
echo "$i" > "$HOME/.cache/wallpaper-rotation-state"
exit 0
fi
done
''
];
# Interactive wallpaper selection
"Mod+Ctrl+W".action = spawn [
"${pkgs.bash}/bin/bash"
"-c"
''
if ! ${swww} query &>/dev/null; then
echo "swww daemon not running"
exit 1
fi
selected=$(find "${wallpaperDir}" -type f \( -name "*.gif" -o -name "*.mp4" -o -name "*.webm" -o -name "*.jpg" -o -name "*.png" \) 2>/dev/null | ${pkgs.fzf}/bin/fzf --preview='basename {}' || true)
if [ -n "$selected" ] && [ -f "$selected" ]; then
${swww} img "$selected" \
--transition-type fade \
--transition-duration 2 \
--transition-fps 30
fi
''
];
};
};
home.packages = with pkgs; [
swww
fzf
ffmpeg
];
# Create directories and files
home.file = {
# Create wallpaper directory
".config/wallpapers/.keep".text = "";
# Create cache directory for rotation state
# Initialize wallpaper rotation state (starts at 0, so first rotation goes to index 1)
".cache/wallpaper-rotation-state".text = "0";
# Copy your animated wallpaper
".config/wallpapers/anime-cat-girl-snow.mp4" = {
source = "${assetsPath}/Anime Live Wallpaper - Anime Cat Girl Snow - HD - no copyright [SiMc3l0ido0].mp4";
};
# Copy your static wallpaper
".config/wallpapers/static-wallpaper.jpg" = {
source = "${assetsPath}/wp6553608.jpg";
};
# Create optimized version of the MP4 using a script
".config/wallpapers/anime-cat-girl-snow-optimized.mp4" = {
source =
pkgs.runCommand "optimized-wallpaper"
{
buildInputs = [ pkgs.ffmpeg ];
meta.timeout = 300; # 5 minute timeout for ffmpeg
}
''
# Ensure input file exists
if [ ! -f "${assetsPath}/Anime Live Wallpaper - Anime Cat Girl Snow - HD - no copyright [SiMc3l0ido0].mp4" ]; then
echo "Source video not found!"
exit 1
fi
${pkgs.ffmpeg}/bin/ffmpeg -i "${assetsPath}/Anime Live Wallpaper - Anime Cat Girl Snow - HD - no copyright [SiMc3l0ido0].mp4" \
-vf "scale=1920:1080:force_original_aspect_ratio=increase,crop=1920:1080" \
-r 30 -c:v libx264 -crf 28 -preset medium \
-t 30 -an -y "$out"
'';
};
# SWWW configuration
".config/swww/config".text = ''
resize=crop
fill_color=000000
filter=Lanczos3
'';
};
# Wallpaper rotation service with sequential switching
systemd.user.services.wallpaper-rotation = {
Unit = {
Description = "Rotate between wallpapers sequentially";
After = [ "graphical-session.target" ];
};
Service = {
Type = "oneshot";
ExecStart = "${pkgs.writeShellScript "rotate-wallpaper" ''
wallpapers=(
"${wallpaperDir}/anime-cat-girl-snow.mp4"
"${wallpaperDir}/static-wallpaper.jpg"
"${wallpaperDir}/anime-cat-girl-snow-optimized.mp4"
)
# Wait for swww to be available with timeout
timeout=30
while ! ${swww} query &>/dev/null && [ $timeout -gt 0 ]; do
sleep 1
timeout=$((timeout - 1))
done
if [ $timeout -eq 0 ]; then
echo "Timeout waiting for swww daemon"
exit 1
fi
# Get current wallpaper index from state file
state_file="$HOME/.cache/wallpaper-rotation-state"
if [ -f "$state_file" ]; then
current_index=$(cat "$state_file" 2>/dev/null || echo "0")
else
current_index=0
fi
# Ensure current_index is a valid number
if ! [[ "$current_index" =~ ^[0-9]+$ ]]; then
current_index=0
fi
# Move to next wallpaper, ensuring it exists
attempts=0
max_attempts=''${#wallpapers[@]}
while [ $attempts -lt $max_attempts ]; do
next_index=$(( (current_index + 1) % ''${#wallpapers[@]} ))
if [ -f "''${wallpapers[$next_index]}" ]; then
echo "$next_index" > "$state_file"
${swww} img "''${wallpapers[$next_index]}" \
--transition-type random \
--transition-duration 3 \
--transition-fps 30
echo "Switched to wallpaper $next_index: ''${wallpapers[$next_index]}"
exit 0
fi
current_index=$next_index
attempts=$((attempts + 1))
done
echo "No valid wallpapers found"
exit 1
''}";
};
};
# Timer for automatic wallpaper rotation every 5 minutes
systemd.user.timers.wallpaper-rotation = {
Unit = {
Description = "Timer for wallpaper rotation every 5 minutes";
};
Timer = {
OnBootSec = "5min";
OnUnitActiveSec = "5min";
Unit = "wallpaper-rotation.service";
Persistent = true;
};
Install = {
WantedBy = [ "timers.target" ];
};
};
# Shell aliases
programs.bash.shellAliases = {
wallpaper = "${swww} img";
wallpaper-anime = "${swww} img ${wallpaperDir}/anime-cat-girl-snow.mp4 --transition-type fade --transition-fps 30";
wallpaper-static = "${swww} img ${wallpaperDir}/static-wallpaper.jpg --transition-type fade";
wallpaper-optimized = "${swww} img ${wallpaperDir}/anime-cat-girl-snow-optimized.mp4 --transition-type fade --transition-fps 30";
wallpaper-rotate = "${systemctl} --user start wallpaper-rotation.service";
wallpaper-auto-start = "${systemctl} --user start wallpaper-rotation.timer";
wallpaper-auto-stop = "${systemctl} --user stop wallpaper-rotation.timer";
wallpaper-status = "${systemctl} --user status wallpaper-rotation.timer";
wallpaper-logs = "journalctl --user -u wallpaper-rotation.service -f";
};
} }