Skip to content

Commit

Permalink
Fix MacOS don't refresh new wallpaper picture
Browse files Browse the repository at this point in the history
Signed-off-by: Thibault Meyer <meyer.thibault@gmail.com>
  • Loading branch information
thibaultmeyer committed Nov 13, 2023
1 parent fdfadac commit a75e882
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/bingwallpaper/bingwallpaperchanger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ impl BingWallpaperChanger {

// Checks if current downloaded wallpaper is up to date
if system_date_as_str == wallpaper_date_as_str {
// TODO: Probably no longer needed
return self.change_wallpaper();
}

Expand Down Expand Up @@ -166,9 +167,13 @@ impl BingWallpaperChanger {
// Read more: https://developer.apple.com/documentation/appkit/nsscreen/1388393-screens
file.write_all("import Cocoa
do {
// Useless as the downloaded image is exactly the same size as the screen.
// But it does force Dock to update the wallpaper.
let randomScaling = Int.random(in: 0 ..< 5)
for screen in NSScreen.screens {
let url = URL(fileURLWithPath: CommandLine.arguments[1])
try NSWorkspace.shared.setDesktopImageURL(url, for: screen, options: [:])
try NSWorkspace.shared.setDesktopImageURL(url, for: screen, options: [NSWorkspace.DesktopImageOptionKey.imageScaling: randomScaling])
}
} catch {
print(error)
Expand Down

0 comments on commit a75e882

Please sign in to comment.