From fcced8991a545e127799c97e4afd38dfa582aecf Mon Sep 17 00:00:00 2001 From: Alex Griffin Date: Mon, 18 Mar 2019 16:17:18 -0500 Subject: [PATCH] Hooks.WallpaperSetter: Preserve aspect ratio while scaling images --- CHANGES.md | 6 ++++++ XMonad/Hooks/WallpaperSetter.hs | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b9df3753..fd14aba9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -71,6 +71,12 @@ Add a utility function `isOnAnyVisibleWS :: Query Bool` to allow easy cycling between all windows on all visible workspaces. + * `XMonad.Hooks.WallpaperSetter` + + Preserve the aspect ratio of wallpapers that xmonad sets. When previous + versions would distort images to fit the screen size, it will now find a + best fit by cropping instead. + ## 0.15 diff --git a/XMonad/Hooks/WallpaperSetter.hs b/XMonad/Hooks/WallpaperSetter.hs index d4f5ccb2..1c24dfa9 100644 --- a/XMonad/Hooks/WallpaperSetter.hs +++ b/XMonad/Hooks/WallpaperSetter.hs @@ -221,7 +221,7 @@ layerCommand (rect, path) = do res <- getPicRes path return $ case needsRotation rect <$> res of Nothing -> "" - Just rotate -> + Just rotate -> let size = show (rect_width rect) ++ "x" ++ show (rect_height rect) in " \\( '"++path++"' "++(if rotate then "-rotate 90 " else "") - ++ " -scale "++(show$rect_width rect)++"x"++(show$rect_height rect)++"! \\)" + ++ " -scale "++size++"^ -gravity center -extent "++size++" +gravity \\)" ++ " -geometry +"++(show$rect_x rect)++"+"++(show$rect_y rect)++" -composite "