Browse Source

Hooks.WallpaperSetter: Preserve aspect ratio while scaling images

master^2
Alex Griffin 4 months ago
parent
commit
fcced8991a
2 changed files with 8 additions and 2 deletions
  1. 6
    0
      CHANGES.md
  2. 2
    2
      XMonad/Hooks/WallpaperSetter.hs

+ 6
- 0
CHANGES.md View File

@@ -71,6 +71,12 @@
71 71
     Add a utility function `isOnAnyVisibleWS :: Query Bool` to allow easy
72 72
     cycling between all windows on all visible workspaces.
73 73
 
74
+  * `XMonad.Hooks.WallpaperSetter`
75
+
76
+    Preserve the aspect ratio of wallpapers that xmonad sets. When previous
77
+    versions would distort images to fit the screen size, it will now find a
78
+    best fit by cropping instead.
79
+
74 80
 
75 81
 ## 0.15
76 82
 

+ 2
- 2
XMonad/Hooks/WallpaperSetter.hs View File

@@ -221,7 +221,7 @@ layerCommand (rect, path) = do
221 221
   res <- getPicRes path
222 222
   return $ case needsRotation rect <$> res of
223 223
     Nothing -> ""
224
-    Just rotate ->
224
+    Just rotate -> let size = show (rect_width rect) ++ "x" ++ show (rect_height rect) in
225 225
                      " \\( '"++path++"' "++(if rotate then "-rotate 90 " else "")
226
-                      ++ " -scale "++(show$rect_width rect)++"x"++(show$rect_height rect)++"! \\)"
226
+                      ++ " -scale "++size++"^ -gravity center -extent "++size++" +gravity \\)"
227 227
                       ++ " -geometry +"++(show$rect_x rect)++"+"++(show$rect_y rect)++" -composite "

Loading…
Cancel
Save