meow
This commit is contained in:
parent
4d269a9e8d
commit
f9c369c584
12 changed files with 638 additions and 73 deletions
|
|
@ -1,11 +1,411 @@
|
|||
{ ... }:
|
||||
{
|
||||
services.wpaperd = {
|
||||
enable = true;
|
||||
settings = {
|
||||
eDP-1 = {
|
||||
path = ../assets/wp6553608.jpg;
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
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
|
||||
assetsPath = ../assets;
|
||||
wallpaperDir = "${config.home.homeDirectory}/.config/wallpapers";
|
||||
systemctl = "${pkgs.systemd}/bin/systemctl";
|
||||
in
|
||||
{
|
||||
programs.niri.settings = {
|
||||
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;
|
||||
};
|
||||
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";
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue