feat(wallpaper): use swaybg instead of hyprpaper
This commit is contained in:
parent
4737aec6e2
commit
e3a95c6dc2
4 changed files with 17 additions and 47 deletions
|
@ -221,4 +221,6 @@ in
|
||||||
# Move/resize windows with mainMod + LMB/RMB and dragging
|
# Move/resize windows with mainMod + LMB/RMB and dragging
|
||||||
bindm = $mainMod, mouse:272, movewindow
|
bindm = $mainMod, mouse:272, movewindow
|
||||||
bindm = $mainMod, mouse:273, resizewindow
|
bindm = $mainMod, mouse:273, resizewindow
|
||||||
|
|
||||||
|
exec-once=${getExe config.my.programs.wallpaper.package} -r
|
||||||
''
|
''
|
||||||
|
|
|
@ -92,7 +92,6 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
# lock screen after timeout
|
# lock screen after timeout
|
||||||
home-manager.users.moritz = {
|
home-manager.users.moritz = {
|
||||||
services.swayidle = {
|
services.swayidle = {
|
||||||
|
@ -138,40 +137,6 @@ in
|
||||||
# adds pam module for swaylock
|
# adds pam module for swaylock
|
||||||
security.pam.services.swaylock = { };
|
security.pam.services.swaylock = { };
|
||||||
|
|
||||||
|
|
||||||
# start hyprpaper daemon using systemd unit (to set wallpaper)
|
|
||||||
systemd.user.services.hyprpaper =
|
|
||||||
let
|
|
||||||
wallpaper = "/home/moritz/.config/wallpapers/a_short_walk.png";
|
|
||||||
config = pkgs.writeTextFile {
|
|
||||||
name = "hyprpaper.conf";
|
|
||||||
text = ''
|
|
||||||
preload = ${wallpaper}
|
|
||||||
wallpaper = ,${wallpaper}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
wantedBy = [ "graphical-session.target" ];
|
|
||||||
serviceConfig = {
|
|
||||||
ExecStartPre = "${pkgs.coreutils}/bin/sleep 0.5";
|
|
||||||
ExecStart = "${getExe pkgs.hyprpaper} -c ${config}";
|
|
||||||
RestartSec = "500ms";
|
|
||||||
Restart = "on-failure";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.user.services.random-wallpaper = {
|
|
||||||
wantedBy = [ "graphical-session.target" ];
|
|
||||||
requires = [ "hyprpaper.service" ];
|
|
||||||
serviceConfig = {
|
|
||||||
ExecStartPre = "${pkgs.coreutils}/bin/sleep 0.5";
|
|
||||||
ExecStart = "${getExe config.my.programs.wallpaper.package} -r";
|
|
||||||
RestartSec = "500ms";
|
|
||||||
Restart = "on-failure";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# only consider graphical-session.target started when hyprland-sesstion.target is reached
|
# only consider graphical-session.target started when hyprland-sesstion.target is reached
|
||||||
systemd.user.targets.hyprland-session = {
|
systemd.user.targets.hyprland-session = {
|
||||||
partOf = [ "graphical-session.target" ];
|
partOf = [ "graphical-session.target" ];
|
||||||
|
|
|
@ -8,7 +8,7 @@ let
|
||||||
|
|
||||||
script = pkgs.writeShellApplication {
|
script = pkgs.writeShellApplication {
|
||||||
name = "wallpaper";
|
name = "wallpaper";
|
||||||
runtimeInputs = with pkgs; [ findutils coreutils feh hyprland jq fzf viu ];
|
runtimeInputs = with pkgs; [ findutils coreutils feh swaybg fzf viu ];
|
||||||
text = builtins.readFile ./wallpaper.sh;
|
text = builtins.readFile ./wallpaper.sh;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|
25
modules/programs/wallpaper/wallpaper.sh
Normal file → Executable file
25
modules/programs/wallpaper/wallpaper.sh
Normal file → Executable file
|
@ -14,20 +14,23 @@ function help() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function randomWallpaper() {
|
function randomWallpaper() {
|
||||||
find ~/.config/wallpapers/ -type f,l | shuf -n 1
|
echo "$WALLPAPERS" | shuf -n 1
|
||||||
|
}
|
||||||
|
|
||||||
|
function setWallpaperX {
|
||||||
|
feh --bg-fill "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
function setWallpaperWayland {
|
||||||
|
swaybg --mode fill -i "$1" 2>/dev/null &
|
||||||
}
|
}
|
||||||
|
|
||||||
function setWallpaper() {
|
function setWallpaper() {
|
||||||
case "${XDG_CURRENT_DESKTOP,,}" in
|
if [[ -z ${WAYLAND_DISPLAY+x} ]]; then
|
||||||
hyprland)
|
setWallpaperX "$1"
|
||||||
hyprctl hyprpaper preload "$1" &>/dev/null
|
else
|
||||||
hyprctl monitors -j | jq '.[].name' | xargs -I{} -P 0 hyprctl hyprpaper wallpaper '{}',"$1" &>/dev/null
|
setWallpaperWayland "$1"
|
||||||
hyprctl hyprpaper unload all &>/dev/null
|
fi
|
||||||
;;
|
|
||||||
*)
|
|
||||||
feh --bg-fill "$1" &>/dev/null
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Parse arguments
|
# Parse arguments
|
||||||
|
|
Loading…
Reference in a new issue