niri blur wallpaper as backdrop

This commit is contained in:
EdenQwQ 2025-05-18 18:11:24 +08:00
parent 2527621d28
commit 02a760f6c8
5 changed files with 32 additions and 14 deletions

6
flake.lock generated
View file

@ -754,11 +754,11 @@
"niri-unstable": {
"flake": false,
"locked": {
"lastModified": 1746124654,
"narHash": "sha256-LmhkAt2KLvf8lp+kEUQuTFmmv7iXO8IkwwSaPasfXJw=",
"lastModified": 1747486745,
"narHash": "sha256-ngQ+iTHmBJkEbsjYfCWTJdV8gHhOCTkV8K0at6Y+YHI=",
"owner": "YalTeR",
"repo": "niri",
"rev": "6c9705dd4b2eaba25f024d1a3efd7943fd393632",
"rev": "ae89cb6017668f3a81ccd92461cbbc70ab8377d0",
"type": "github"
},
"original": {

View file

@ -129,7 +129,7 @@ let
name = "Pictures/Wallpapers/generated/${name}-blurred.jpg";
value = {
source = pkgs.runCommand "${name}-blurred.jpg" { } ''
${pkgs.imagemagick}/bin/magick ${path} -blur 0x15 $out
${pkgs.imagemagick}/bin/magick ${path} -blur 0x30 $out
'';
};
};

View file

@ -10,6 +10,7 @@
];
home.packages = with pkgs; [
swww
swaybg
kanshi
wlsunset
wayneko

View file

@ -59,7 +59,7 @@ let
def set_wallpaper(monitor, wallpaper):
subprocess.run(
subprocess.Popen(
[
"swww",
"img",
@ -74,6 +74,20 @@ let
)
def set_backdrop_wallpaper(monitor, wallpaper):
subprocess.Popen(
[
"swaybg",
"-o",
monitor,
"-i",
wallpaper,
"-m",
"fill",
]
)
def get_wallpaper_name(wallpaper_path):
current_wallpaper_is_blurred = "blurred" in wallpaper_path
if current_wallpaper_is_blurred:
@ -92,14 +106,15 @@ let
return
wallpaper_name = get_wallpaper_name(current_wallpaper)
active_workspace_is_empty = active_workspace["active_window_id"] is None
if active_workspace_is_empty:
wallpaper = os.path.join(wallpapers_path, f"{wallpaper_name}.jpg")
else:
wallpaper = os.path.join(wallpapers_path, f"{wallpaper_name}-blurred.jpg")
wallpaper = os.path.join(wallpapers_path, f"{wallpaper_name}.jpg")
blurred_wallpaper = os.path.join(wallpapers_path, f"{wallpaper_name}-blurred.jpg")
if not active_workspace_is_empty:
wallpaper = blurred_wallpaper
real_wallpaper = os.path.realpath(wallpaper)
if current_wallpaper == real_wallpaper and not init:
return
set_wallpaper(active_workspace_monitor, wallpaper)
set_backdrop_wallpaper(active_workspace_monitor, blurred_wallpaper)
def change_wallpaper(init=False):

View file

@ -5,19 +5,21 @@ let
# kdl
''
overview {
zoom 0.36
backdrop-color "${base02}"
}
zoom 0.36
backdrop-color "${base02}"
}
layer-rule {
match namespace="wallpaper"
place-within-backdrop true
}
'';
finalNiriConfig =
builtins.replaceStrings
[
"output \"${config.lib.monitors.mainMonitorName}\" {"
"background-color \"${base01}\""
]
[
"output \"${config.lib.monitors.mainMonitorName}\" {\nfocus-at-startup"
"background-color \"${base01}\""
]
config.programs.niri.finalConfig
+ "\n"