Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Add Win10 support #118

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ Finally, to launch it, enter this into the console:

launchctl load ~/Library/LaunchAgents/org.boramalper.himawaripy.plist

### For Win10 Users

1. Edit `win\auto.bat` if you like.
2. add `win\run_silently.vbs` to schedule, and config it to once per 10 minutes.

## Uninstallation

Expand Down
30 changes: 28 additions & 2 deletions himawaripy/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,33 @@
from distutils.version import LooseVersion


def set_wallpaper_from_bmp(bmp_path):
import win32api
import win32gui
from win32.lib import win32con
#打开指定注册表路径
reg_key = win32api.RegOpenKeyEx(
win32con.HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, win32con.KEY_SET_VALUE)
#最后的参数:2拉伸,0居中,6适应,10填充,0平铺
win32api.RegSetValueEx(reg_key, "WallpaperStyle", 0, win32con.REG_SZ, "0")
#最后的参数:1表示平铺,拉伸居中等都是0
win32api.RegSetValueEx(reg_key, "TileWallpaper", 0, win32con.REG_SZ, "0")
#刷新桌面
win32gui.SystemParametersInfo(
win32con.SPI_SETDESKWALLPAPER, bmp_path, win32con.SPIF_SENDWININICHANGE)


def set_background(file_path):
de = get_desktop_environment()

if de == "mac":
if de == "windows":
import PIL.Image
img_path = file_path
img_dir = os.path.dirname(img_path)
bmpImage = PIL.Image.open(img_path)
new_bmp_path = os.path.join(img_dir, 'wallpaper.bmp')
bmpImage.save(new_bmp_path, "BMP")
set_wallpaper_from_bmp(new_bmp_path)
elif de == "mac":
subprocess.call(
[
"osascript",
Expand Down Expand Up @@ -249,3 +272,6 @@ def fetch_envvar(varname):
os.environ[varname] = val
else:
print("Could NOT retrieve env. var. {}".format(varname))

if __name__ == "__main__":
set_background("e:\data\hima\himawari-20210211T021000.png")
10 changes: 8 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
from setuptools import setup, find_packages
import platform

with open("README.md", "r") as f:
with open("README.md", "r", encoding='UTF-8') as f:
long_description = f.read()

install_requires = ["appdirs", "pillow", "python-dateutil"]
sys = platform.system()
if sys == "Windows":
install_requires.append("pypiwin32")

setup(
name="himawaripy",
version="2.2.0",
Expand All @@ -14,7 +20,7 @@
"as its taken by Himawari 8 (ひまわり8号) and sets it as your desktop background.",
long_description=long_description,
long_description_content_type="text/markdown",
install_requires=["appdirs", "pillow", "python-dateutil"],
install_requires=install_requires,
packages=find_packages(),
entry_points={"console_scripts": ["himawaripy=himawaripy.__main__:main"]},
)
1 change: 1 addition & 0 deletions win/auto.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
himawaripy --auto-offset --output-dir e:\data\hima
6 changes: 6 additions & 0 deletions win/run_silently.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Dim path
set oShell = CreateObject("WScript.Shell")
set fso = CreateObject("Scripting.FileSystemObject")
path = fso.GetAbsolutePathName("./auto.bat")
' msgbox path
oShell.run path, 0, ture