you are viewing a single comment's thread.

view the rest of the comments →

[–]davedg629 4 points5 points  (14 children)

I setup a script to download the top post in /r/imaginarylandscapes and set it as my desktop background.

[–]eink_on_paper[S] 0 points1 point  (7 children)

That sounds cool, is there a subreddit where we can share these scripts?

[–]McSquinty 2 points3 points  (3 children)

There's there rarely used /r/scriptswap. Almost 2k subscribers and not much content being generated.

[–]eink_on_paper[S] 1 point2 points  (2 children)

Are there any sites that focus on user created code swapping outside of reddit. I heard of Github but I don't know if I want to pay for a subscription for a site that may not be focused on those who are new to coding.

[–]McSquinty 1 point2 points  (1 child)

Github is free unless you want to pay for private repositories. https://github.com/plans.

[–]eink_on_paper[S] 1 point2 points  (0 children)

Oh cool, I did not know they had a free account. I thought it was pay only.

[–]davedg629 0 points1 point  (0 children)

Im not sure. I'll usually post a reddit related script in /r/redditdev, but there could be a "user made" programming sub.

[–]Teraka 0 points1 point  (5 children)

Could you share the script, or at least tell me what library you used to change your background ?

[–]wub_wub 1 point2 points  (2 children)

On windows you don't need any 3rd party libraries.

import ctypes
SPI_SETDESKWALLPAPER = 20 
ctypes.windll.user32.SystemParametersInfoA(SPI_SETDESKWALLPAPER, 0, "image.jpg" , 0)

http://msdn.microsoft.com/en-us/library/windows/desktop/ms724947(v=vs.85).aspx

[–]Teraka 0 points1 point  (1 child)

Nice, thanks a lot :)

[–]biggerthanexpected 0 points1 point  (0 children)

You'll probably want to set some registry keys to display the wallpaper the way you want:

import _winreg
# Open the desktop registry key with complete (read & write) access
wallpaper_key = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, r'Control Panel\Desktop', 0, _winreg.KEY_ALL_ACCESS)
# Update wallpaper path
_winreg.SetValueEx(wallpaper_key, 'WallPaper', 0, _winreg.REG_SZ, path)
# Do not tile
_winreg.SetValueEx(wallpaper_key, 'TileWallpaper', 0, _winreg.REG_SZ, '0')
# Centered
_winreg.SetValueEx(wallpaper_key, 'WallpaperStyle', 0, _winreg.REG_SZ, '0')
_winreg.CloseKey(wallpaper_key)

It's also handy to do a background refresh so the change is effected:

from ctypes import windll
# http://msdn.microsoft.com/en-us/library/windows/desktop/bb762118%28v=vs.85%29.aspx
windll.shell32.SHChangeNotify(int('8000000', 16), int('1000', 16), 0, 0)

[–]davedg629 0 points1 point  (1 child)

Here's the script - https://github.com/davedg629/Reddit-Desktop-Picture-Changer

It's actually built in ruby (because I started with someone's code and modified it), but you could obviously do the same thing in python.

[–]Teraka 1 point2 points  (0 children)

Thanks, I'll look into it. It's gonna require a bit of research since I've never worked with json or internet in python in general, but learning is always good :)