diff --git a/home/desktop/wallpaper.nix b/home/desktop/wallpaper.nix index d42eb4cb..9e06527f 100644 --- a/home/desktop/wallpaper.nix +++ b/home/desktop/wallpaper.nix @@ -6,12 +6,16 @@ let imports = [ "System.Random" ]; bins = [ pkgs.coreutils pkgs.sway ]; } '' + linkPath = "/home/maralorn/volatile/wallpaper.jpg" main = do mode <- cat "/home/maralorn/tmp/mode" |> captureTrim (lines . decodeUtf8 -> files) <- ls ([i|/home/maralorn/.wallpapers/#{mode}|] :: String) |> captureTrim ((files Unsafe.!!) -> file) <- getStdRandom $ randomR (0, length files - 1) - cp ([i|/home/maralorn/.wallpapers/#{mode}/#{file}|] :: String) "/home/maralorn/volatile/wallpaper.jpg" - swaymsg "output * bg /home/maralorn/volatile/wallpaper.jpg fill" + (decodeUtf8 -> current) <- readlink linkPath |> captureTrim + let new = [i|/home/maralorn/.wallpapers/#{mode}/#{file}|] :: String + when (new /= current) $ do + ln "-s" new linkPath + swaymsg "output * bg /home/maralorn/volatile/wallpaper.jpg fill" ''; in { home.packages = [ randomWallpaper ];