Browse Source

Merge pull request #297 from ajgrf/bg-ratio

Hooks.WallpaperSetter: Preserve aspect ratio while scaling images
master
Brent Yorgey 2 months ago
parent
commit
4ad6ecf892
No account linked to committer's email address
2 changed files with 9 additions and 2 deletions
  1. 7
    0
      CHANGES.md
  2. 2
    2
      XMonad/Hooks/WallpaperSetter.hs

+ 7
- 0
CHANGES.md View File

@@ -77,6 +77,13 @@
77 77
     Add a utility function `isOnAnyVisibleWS :: Query Bool` to allow easy
78 78
     cycling between all windows on all visible workspaces.
79 79
 
80
+
81
+  * `XMonad.Hooks.WallpaperSetter`
82
+
83
+    Preserve the aspect ratio of wallpapers that xmonad sets. When previous
84
+    versions would distort images to fit the screen size, it will now find a
85
+    best fit by cropping instead.
86
+
80 87
   * `XMonad.Util.Themes`
81 88
 
82 89
     Add adwaitaTheme and adwaitaDarkTheme to match their respective

+ 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