Skip to content

HaoweiCh/himawaripy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

himawaripy 让实时气象卫星返回图像做你桌面

himawaripy 是基于Python3的脚本,它能获取近乎实时的气象卫星图像( 来源于ひまわり8号 )并设置为所有桌面的背景。

本项目将持续把功能更新PR到原项目,也希望各位将功能更新PR到原项目和其他更新PR到本项目,谢谢。

Set a cronjob (or systemd service) that runs in every 10 minutes to automatically get the near-realtime picture of Earth.

正在开发的功能

  • 在mac下也支持省电模式(电池放电状态下不更新背景)
  • 生成的卫星图片在mac(16:10)下可以显示完整的地球
  • 生成的卫星图片在mac(16:10)下可以定位到中国🇨🇳

支持的桌面环境

已测试

  • Unity 7
  • Mate 1.8.1
  • Pantheon
  • LXDE
  • OS X
  • GNOME 3
  • Cinnamon 2.8.8
  • KDE

未测试

  • 上述未涉及到的桌面环境(P话)

参数

usage:  [-h] [--version] [--auto-offset | -o OFFSET] [-l {4,8,16,20}]
        [-d DEADLINE] [--save-battery] [--output-dir OUTPUT_DIR]

set (near-realtime) picture of Earth as your desktop background

optional arguments:
  -h, --help            show this help message and exit
  --version             show program's version number and exit
  --auto-offset         determine offset automatically
  -o OFFSET, --offset OFFSET
                        UTC time offset in hours, must be less than or equal
                        to +10
  -l {4,8,16,20}, --level {4,8,16,20}
                        increases the quality (and the size) of each tile.
                        possible values are 4, 8, 16, 20
  -d DEADLINE, --deadline DEADLINE
                        deadline in minutes to download all the tiles, set 0
                        to cancel
  --save-battery        stop updating on battery
  --output-dir OUTPUT_DIR
                        directory to save the temporary background image

基本上,--auto-offset 可以准确的判断出你的时区,当然,你也可以通过 -o (或 --offset) 手动设置时区。
If your timezone is beyond GMT by more than 10 hours, use the closest one (either +10 or -12).

Increasing the level will increase the quality of the image as well as the time taken to download all the tiles and the memory consumption. For instance choosing 20 will make himawaripy use ~700 MiB of memory at its peak and the image will be around ~200 MB.

提醒,如果你想定时生成实时壁纸的话,-d 能确保脚本只在指定时间内完成否则取消。默认无时间限制

不想在用电池时更新壁纸?--save-battery 适合你

Nitrogen

If you use nitrogen for setting your wallpaper, you have to enter this in your ~/.config/nitrogen/bg-saved.cfg.

[:0.0]
file=/home/USERNAME/.himawari/himawari-latest.png
mode=4
bgcolor=#000000

安装过程

确保已经安装了 Python3 并已安装包 python3-setuptools

cd ~
git clone https://github.com/boramalper/himawaripy.git

# 安装
sudo python3 setup.py install

# 检查有否安装成功
himawaripy --auto-offset

# 这可以获取 himawaripy 安装位置
which -- himawaripy

# 定时启动 himawaripy

    ## Either set up a cronjob
        crontab -e

        ### Add the line:
        */10 * * * * <INSTALLATION_PATH> # command line arguments here

    ## OR, alternatively use the provided systemd timer

        ### Configure
        vi systemd/himawaripy.service
        # Replace "<INSTALLATION_PATH>" with the output of the aforementioned command and command line arguments

        ### Copy systemd configuration
        cp systemd/himawaripy.{service,timer} ~/.config/systemd/user/

        ### Enable and start the timer
        systemctl --user enable --now himawaripy.timer

For KDE Users

KDE 5.7+

To change the wallpaper in KDE 5.7+, desktop widgets must be unlocked. If you dom't want to leave them unlocked, the pre-KDE 5.7 method can still be used.

To unlock desktop widgets (from the KDE userbase):

Open the Desktop Toolbox or the Panel Toolbox or right click on the Desktop - if you see an item labeled Unlock Widgets then select that, and then proceed to add widgets to your Desktop or your Panel.

Before KDE 5.7

So the issue here is that KDE does not support changing the desktop wallpaper from the commandline, but it does support polling a directory for file changes through the "Slideshow" desktop background option, whereby you can point KDE to a folder and have it load a new picture at a certain interval.

The idea here is to:

  • Set the cron for some interval (say 9 minutes)
  • Open Desktop Settings -> Wallpaper -> Wallpaper Type -> Slideshow
  • Add the ~/.himawari dir to the slideshow list
  • Set the interval check to 10 minutes (one minute after the cron, also depending on your download speed)

Many thanks to xenithorb for the solution!

For Mac OSX Users

OSX has deprecated crontab, and replaced it with launchd. To set up a launch agent, copy the provided sample plist file in osx/org.boramalper.himawaripy.plist to ~/Library/LaunchAgents, and edit the following entries if required

mkdir -p ~/Library/LaunchAgents/
cp osx/org.boramalper.himawaripy.plist ~/Library/LaunchAgents/
  • ProgrammingArguments needs to be the path to himawaripy installation. This should be /usr/local/bin/himawaripy by default, but himawaripy may be installed elsewhere.

  • StartInterval controls the interval between successive runs, set to 10 minutes (600 seconds) by default, edit as desired.

Finally, to launch it, enter this into the console:

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

卸载

# Remove the cronjob
crontab -e
# Remove the line
*/10 * * * * <INSTALLATION_PATH>

# OR if you used the systemd timer
systemctl --user disable --now himawaripy.timer
rm $HOME/.config/systemd/user/himawaripy.{timer,service}

# Uninstall the binary
sudo rm -f <INSTALLATION_PATH>

# Uninstall the package
sudo pip3 uninstall himawaripy

<INSTALLATION_PATH> can be found using the command which -- himawaripy.

If you would like to share why, you can contact me on github or send an e-mail.

Attributions

Thanks to MichaelPote for the initial implementation using Powershell Script.

Thanks to Charlie Loyd for image processing logic (hi8-fetch.py).

Obviously, thanks to the Japan Meteorological Agency for opening these pictures to public.

About

Set near-realtime picture of Earth as your desktop background

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%