dotfiles/modules/niri/settings.nix

284 lines
7.4 KiB
Nix
Raw Normal View History

2025-09-09 18:38:16 +02:00
{
config,
lib,
pkgs,
...
2025-09-09 18:03:42 +02:00
}:
let
makeCommand = command: {
command = [ command ];
};
qs = "${pkgs.quickshell}/bin/qs";
wl-paste = "${pkgs.wl-clipboard}/bin/wl-paste";
2025-09-09 21:20:12 +02:00
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";
2025-09-09 18:03:42 +02:00
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}")
2025-09-09 21:20:12 +02:00
(makeCommand swww-daemon)
2025-09-09 18:03:42 +02:00
{
command = [
"${wl-paste}"
"--watch"
"cliphist"
"store"
];
}
{
command = [
"${wl-paste}"
"--type text"
"--watch"
"cliphist"
"store"
];
}
{
command = [
"${qs}"
"-c"
"DankMaterialShell"
];
}
2025-09-09 21:20:12 +02:00
# 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
''
];
}
2025-09-09 18:03:42 +02:00
];
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;
2025-09-09 18:38:16 +02:00
active.color = "#ff69b4";
inactive.color = "#7d0d2d";
2025-09-09 18:03:42 +02:00
};
shadow = {
2025-09-09 18:38:16 +02:00
enable = true;
2025-09-09 18:03:42 +02:00
};
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;
2025-09-09 21:20:12 +02:00
# 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";
2025-09-09 18:03:42 +02:00
};
}