river: added random background with swaybg

This commit is contained in:
Aly Raffauf 2024-04-13 18:31:10 -04:00
parent 9f2de2ba5a
commit 0c907e69fc
4 changed files with 42 additions and 1 deletions

View file

@ -4,6 +4,7 @@
config, config,
... ...
}: { }: {
imports = [./randomWallpaper.nix];
options = { options = {
desktopEnv.river.enable = desktopEnv.river.enable =
lib.mkEnableOption "Enable riverwm with extra apps."; lib.mkEnableOption "Enable riverwm with extra apps.";
@ -41,8 +42,13 @@
xfce.xfce4-settings xfce.xfce4-settings
xfce.xfce4-taskmanager xfce.xfce4-taskmanager
xfce.xfconf xfce.xfconf
swayidle
]; ];
desktopEnv.river.randomWallpaper.enable = lib.mkDefault true;
programs.swaylock.enable = lib.mkDefault true;
services.cliphist.enable = lib.mkDefault true; services.cliphist.enable = lib.mkDefault true;
services.kanshi.enable = true; services.kanshi.enable = true;
services.kanshi.profiles.framework = { services.kanshi.profiles.framework = {
@ -162,6 +168,7 @@
pkill -f nm-applet pkill -f nm-applet
pkill -f swayosd-server pkill -f swayosd-server
pkill -f waybar pkill -f waybar
pkill -f swayidle
touchpad=`riverctl list-inputs|grep -i touchpad` touchpad=`riverctl list-inputs|grep -i touchpad`
for t in ''${touchpad[@]}; do for t in ''${touchpad[@]}; do
@ -326,6 +333,7 @@
swayosd-server & swayosd-server &
thunar --daemon & thunar --daemon &
waybar & waybar &
swayidle -w timeout 300 'swaylock -f -c 000000' before-sleep 'swaylock -f -c 000000' &
''; '';
}; };
} }

View file

@ -0,0 +1,31 @@
{
pkgs,
lib,
config,
...
}: let
swaybg-random = pkgs.writeShellScriptBin "swaybg-random" ''
directory=${config.home.homeDirectory}/.local/share/backgrounds
if [ -d "$directory" ]; then
while true; do
kill `pidof swaybg`
random_background=$(ls $directory/*.{png,jpg} | shuf -n 1)
swaybg -i $random_background
sleep 900
done
fi
'';
in {
options = {
desktopEnv.river.randomWallpaper.enable =
lib.mkEnableOption "Enables swaybg random wallpaper script.";
};
config = lib.mkIf config.desktopEnv.river.randomWallpaper.enable {
# Packages that should be installed to the user profile.
home.packages = with pkgs; [swaybg swaybg-random];
wayland.windowManager.river.extraConfig = "swaybg-random &";
};
}

View file

@ -5,4 +5,6 @@
... ...
}: { }: {
imports = [./hyprland]; imports = [./hyprland];
security.pam.services.swaylock = {};
} }