├── debian ├── compat ├── rules ├── changelog └── control ├── resource ├── OneClickBingWallpaper.png ├── icons │ ├── 16x16 │ │ └── OneClickBingWallpaper.png │ ├── 22x22 │ │ └── OneClickBingWallpaper.png │ ├── 24x24 │ │ └── OneClickBingWallpaper.png │ ├── 28x28 │ │ └── OneClickBingWallpaper.png │ ├── 32x32 │ │ └── OneClickBingWallpaper.png │ ├── 36x36 │ │ └── OneClickBingWallpaper.png │ ├── 48x48 │ │ └── OneClickBingWallpaper.png │ ├── 64x64 │ │ └── OneClickBingWallpaper.png │ ├── 72x72 │ │ └── OneClickBingWallpaper.png │ └── 96x96 │ │ └── OneClickBingWallpaper.png ├── resource.qrc └── settings.json ├── translation_update.sh ├── translation_generate.sh ├── OneClickBingWallpaper.desktop ├── Go ├── go.mod ├── notify │ ├── notify_linux.go │ └── notify_windows.go ├── setter │ ├── setter_windows.go │ └── setter_linux.go ├── go.sum ├── util │ └── util.go ├── conf │ └── conf.go └── main.go ├── config.sh ├── OneClickBingWallpaperConfig.cpp ├── main.cpp ├── OneClickBingWallpaperConfig.h ├── .gitignore ├── OneClickBingWallpaperTranslation.h ├── README-zh.md ├── OneClickBingWallpaper.h ├── README.md ├── OneClickBingWallpaper.pro ├── BingWallpaper.py ├── i18n ├── en-US.ts └── zh-CN.ts ├── OneClickBingWallpaper.cpp └── LICENSE /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | %: 2 | ./config.sh 3 | ./translation_generate.sh 4 | dh $@ 5 | -------------------------------------------------------------------------------- /resource/OneClickBingWallpaper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/BingWallpaper/master/resource/OneClickBingWallpaper.png -------------------------------------------------------------------------------- /resource/icons/16x16/OneClickBingWallpaper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/BingWallpaper/master/resource/icons/16x16/OneClickBingWallpaper.png -------------------------------------------------------------------------------- /resource/icons/22x22/OneClickBingWallpaper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/BingWallpaper/master/resource/icons/22x22/OneClickBingWallpaper.png -------------------------------------------------------------------------------- /resource/icons/24x24/OneClickBingWallpaper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/BingWallpaper/master/resource/icons/24x24/OneClickBingWallpaper.png -------------------------------------------------------------------------------- /resource/icons/28x28/OneClickBingWallpaper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/BingWallpaper/master/resource/icons/28x28/OneClickBingWallpaper.png -------------------------------------------------------------------------------- /resource/icons/32x32/OneClickBingWallpaper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/BingWallpaper/master/resource/icons/32x32/OneClickBingWallpaper.png -------------------------------------------------------------------------------- /resource/icons/36x36/OneClickBingWallpaper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/BingWallpaper/master/resource/icons/36x36/OneClickBingWallpaper.png -------------------------------------------------------------------------------- /resource/icons/48x48/OneClickBingWallpaper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/BingWallpaper/master/resource/icons/48x48/OneClickBingWallpaper.png -------------------------------------------------------------------------------- /resource/icons/64x64/OneClickBingWallpaper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/BingWallpaper/master/resource/icons/64x64/OneClickBingWallpaper.png -------------------------------------------------------------------------------- /resource/icons/72x72/OneClickBingWallpaper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/BingWallpaper/master/resource/icons/72x72/OneClickBingWallpaper.png -------------------------------------------------------------------------------- /resource/icons/96x96/OneClickBingWallpaper.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ypingcn/BingWallpaper/master/resource/icons/96x96/OneClickBingWallpaper.png -------------------------------------------------------------------------------- /translation_update.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # this file is used to auto-generate .ts file 3 | 4 | ts_list=(`ls *.pro`) 5 | 6 | for ts in "${ts_list[@]}" 7 | do 8 | printf "\nprocess ${ts}\n" 9 | lupdate "${ts}" 10 | done -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | oneclickbingwallpaper (1.1) unstable; urgency=low 2 | 3 | * OneClickBingWallpaper 4 | 5 | 添加支持自定义壁纸更新命令 6 | 7 | add: custom wallpaper update command supported 8 | 9 | -- ypingcn Sat, 01 Jan 2021 16:00:00 +0800 10 | -------------------------------------------------------------------------------- /translation_generate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # this file is used to auto-generate .qm file from .ts file. 3 | # author: shibowen at linuxdeepin.com 4 | 5 | ts_list=(`ls i18n/*.ts`) 6 | 7 | for ts in "${ts_list[@]}" 8 | do 9 | printf "\nprocess ${ts}\n" 10 | lrelease "${ts}" 11 | done -------------------------------------------------------------------------------- /OneClickBingWallpaper.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=0.1 3 | Type=Application 4 | Exec=/usr/bin/OneClickBingWallpaper/OneClickBingWallpaper 5 | Name=SetBingWallpaper 6 | Name[zh_CN]=设置必应壁纸 7 | Comment=click and set newest Bing wallpaper 8 | Comment[zh_CN]=点击设置最新的必应壁纸 9 | Icon=OneClickBingWallpaper 10 | Categories=Other; 11 | -------------------------------------------------------------------------------- /Go/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/ypingcn/BingWallpaper/Go 2 | 3 | go 1.14 4 | 5 | require ( 6 | github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d // indirect 7 | github.com/reujab/wallpaper v0.0.0-20200229074030-4e1aa3ff8284 8 | github.com/sirupsen/logrus v1.4.2 9 | gopkg.in/toast.v1 v1.0.0-20180812000517-0a84660828b2 10 | ) 11 | -------------------------------------------------------------------------------- /Go/notify/notify_linux.go: -------------------------------------------------------------------------------- 1 | package notify 2 | 3 | import ( 4 | "fmt" 5 | "os/exec" 6 | ) 7 | 8 | // display a notification for linux 9 | func Notify(appName, title, content, iconPath string) { 10 | notify(appName, title, content, iconPath) 11 | } 12 | 13 | func notify(appName, title, content, iconPath string) { 14 | command := exec.Command("notify-send", "-i", iconPath, fmt.Sprintf("%s - %s", appName, title), content) 15 | command.Run() 16 | } 17 | -------------------------------------------------------------------------------- /Go/notify/notify_windows.go: -------------------------------------------------------------------------------- 1 | package notify 2 | 3 | import ( 4 | toast "gopkg.in/toast.v1" 5 | ) 6 | 7 | // display a notification for Windows 8 | func Notify(appName, title, content, iconPath string) { 9 | notify(appName, title, content, iconPath) 10 | } 11 | 12 | func notify(appName, title, content, iconPath string) toast.Notification { 13 | return toast.Notification{ 14 | AppID: appName, 15 | Title: title, 16 | Message: content, 17 | Icon: iconPath, 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # update pyFileMD5 in OneClickBingWallpaperConfig.cpp for security check 4 | 5 | MD5SUM=$(md5sum BingWallpaper.py | awk {'print $1'}) 6 | sed -i 's/{{MD5SUM}}/'$MD5SUM'/g' OneClickBingWallpaperConfig.cpp 7 | # sed -i 's/\/\/ QString OneClickBingWallpaperConfig::pyFileMD5/QString OneClickBingWallpaperConfig::pyFileMD5/g' OneClickBingWallpaperConfig.cpp 8 | 9 | COMMIT=$(git log --pretty=format:"%h" | head -1 | awk '{print $1}') 10 | sed -i 's/{{COMMIT}}/'$COMMIT'/g' OneClickBingWallpaperConfig.cpp 11 | -------------------------------------------------------------------------------- /OneClickBingWallpaperConfig.cpp: -------------------------------------------------------------------------------- 1 | #include "OneClickBingWallpaperConfig.h" 2 | 3 | // Please run ./config.sh first to update pyFileMD5 4 | QString OneClickBingWallpaperConfig::pyFileMD5 = "5dd0851e9102494852d6b3c1372e4f80"; 5 | // Please run ./config.sh first to update latestCommitHash 6 | QString OneClickBingWallpaperConfig::latestCommitHash = "e1e4133"; 7 | QString OneClickBingWallpaperConfig::pyFilePath = "/usr/bin/OneClickBingWallpaper/BingWallpaper.py"; 8 | QString OneClickBingWallpaperConfig::i18nFilePathPrefix = "/usr/bin/OneClickBingWallpaper/i18n/"; // TODO: change another name -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: oneclickbingwallpaper 2 | Section: utils 3 | Priority: optional 4 | Maintainer: ypingcn 5 | Build-Depends: debhelper (>=9), qt5-qmake, qt5-default, qtbase5-dev, python3, python-argparse, python3-requests, libdtkwidget-dev 6 | Standards-Version: 3.9.6 7 | Homepage: https://github.com/ypingcn/BingWallpaper 8 | 9 | Package: oneclickbingwallpaper 10 | Architecture: amd64 11 | Depends: ${shlibs:Depends}, ${misc:Depends} 12 | Description: OneClickBingWallpaper 13 | A Qt-based program for setting newest Bing Wallpaper, just click the tray icon. 14 | -------------------------------------------------------------------------------- /Go/setter/setter_windows.go: -------------------------------------------------------------------------------- 1 | package setter 2 | 3 | import ( 4 | "github.com/reujab/wallpaper" 5 | util "github.com/ypingcn/BingWallpaper/Go/util" 6 | ) 7 | 8 | // WallpaperSetter ... 9 | type WallpaperSetter interface { 10 | SetWallpaper(string) error 11 | } 12 | 13 | type WindowsSetter struct{} 14 | 15 | // NewSetter ... 16 | func New(desktop, command string) (WallpaperSetter, error) { 17 | return WindowsSetter{}, nil 18 | } 19 | 20 | // SetWallpaper for Windows 21 | func (setter WindowsSetter) SetWallpaper(imgPath string) error { 22 | if err := util.CheckImagePath(imgPath); err != nil { 23 | return err 24 | } 25 | if err := wallpaper.SetFromFile(imgPath); err != nil { 26 | return err 27 | } 28 | return nil 29 | } 30 | -------------------------------------------------------------------------------- /resource/resource.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | icons/16x16/OneClickBingWallpaper.png 4 | icons/22x22/OneClickBingWallpaper.png 5 | icons/24x24/OneClickBingWallpaper.png 6 | icons/28x28/OneClickBingWallpaper.png 7 | icons/32x32/OneClickBingWallpaper.png 8 | icons/36x36/OneClickBingWallpaper.png 9 | icons/48x48/OneClickBingWallpaper.png 10 | icons/64x64/OneClickBingWallpaper.png 11 | icons/72x72/OneClickBingWallpaper.png 12 | icons/96x96/OneClickBingWallpaper.png 13 | OneClickBingWallpaper.png 14 | 15 | 16 | settings.json 17 | 18 | 19 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #include "OneClickBingWallpaper.h" 2 | 3 | #include 4 | 5 | DWIDGET_USE_NAMESPACE 6 | 7 | #include 8 | #include 9 | 10 | #include "OneClickBingWallpaperConfig.h" 11 | 12 | int main(int argc, char *argv[]) 13 | { 14 | DApplication::loadDXcbPlugin(); 15 | DApplication a(argc, argv); 16 | 17 | a.setOrganizationName("ypingcn"); 18 | a.setApplicationName("oneclickwallpaper"); 19 | 20 | QSettings settings(a.organizationName(),a.applicationName()); 21 | 22 | OneClickBingWallpaperConfig::updateLanguagesSetting(settings); 23 | 24 | 25 | QTranslator translator; 26 | const QString i18nFilePath = OneClickBingWallpaperConfig::geti18nFilePath(settings); 27 | if(QFile::exists(i18nFilePath)) 28 | { 29 | translator.load(i18nFilePath); 30 | } 31 | 32 | a.setQuitOnLastWindowClosed(false); 33 | a.installTranslator(&translator); 34 | 35 | OneClickBingWallpaper w; 36 | 37 | return a.exec(); 38 | } 39 | -------------------------------------------------------------------------------- /OneClickBingWallpaperConfig.h: -------------------------------------------------------------------------------- 1 | #ifndef ONECLICKBINGWALLPAPERCONFIG_H 2 | #define ONECLICKBINGWALLPAPERCONFIG_H 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | #define MAJOR_VERSION 1 9 | #define MINOR_VERSION 1 10 | #define PATCH_VERSION 0 11 | 12 | class OneClickBingWallpaperConfig 13 | { 14 | public: 15 | static QString pyFileMD5; // Please run ./config.sh first to generate/update pyFileMD5 16 | static QString latestCommitHash; // Please run ./config.sh first to generate/update latestCommitHash 17 | static QString pyFilePath; 18 | static QString i18nFilePathPrefix; 19 | static void updateLanguagesSetting(QSettings &settings) 20 | { 21 | QLocale locale = QLocale::system(); 22 | QString localeName = QLocale::countryToString(locale.country()); 23 | QString localeShortName; 24 | 25 | if(localeName == QString("China")) 26 | { 27 | localeShortName = "zh-CN"; 28 | } 29 | else 30 | { 31 | localeShortName = "en-US"; 32 | } 33 | if(!settings.contains("lang")) 34 | settings.setValue("lang",localeShortName); 35 | } 36 | static QString geti18nFilePath(QSettings & settings) 37 | { 38 | return i18nFilePathPrefix+settings.value("lang").toString()+".qm"; 39 | } 40 | }; 41 | 42 | #endif // !ONECLICKBINGWALLPAPERCONFIG_H -------------------------------------------------------------------------------- /Go/go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 2 | github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= 3 | github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 4 | github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ= 5 | github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U= 6 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 7 | github.com/reujab/wallpaper v0.0.0-20200229074030-4e1aa3ff8284 h1:AXEamsrMLjIjIfOF5xIJwyNzdqcS4mJzJIM8UiL0a9o= 8 | github.com/reujab/wallpaper v0.0.0-20200229074030-4e1aa3ff8284/go.mod h1:Xb+5YBsfhPxSJOGF7b4UTZIOxRIg0Lh/FnRJQm5GPJY= 9 | github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= 10 | github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= 11 | github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 12 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 13 | golang.org/x/sys v0.0.0-20190422165155-953cdadca894 h1:Cz4ceDQGXuKRnVBDTS23GTn/pU5OE2C0WrNTOYK1Uuc= 14 | golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 15 | gopkg.in/toast.v1 v1.0.0-20180812000517-0a84660828b2 h1:MZF6J7CV6s/h0HBkfqebrYfKCVEo5iN+wzE4QhV3Evo= 16 | gopkg.in/toast.v1 v1.0.0-20180812000517-0a84660828b2/go.mod h1:s1Sn2yZos05Qfs7NKt867Xe18emOmtsO3eAKbDaon0o= 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | local_settings.py 56 | 57 | # Flask stuff: 58 | instance/ 59 | .webassets-cache 60 | 61 | # Scrapy stuff: 62 | .scrapy 63 | 64 | # Sphinx documentation 65 | docs/_build/ 66 | 67 | # PyBuilder 68 | target/ 69 | 70 | # Jupyter Notebook 71 | .ipynb_checkpoints 72 | 73 | # pyenv 74 | .python-version 75 | 76 | # celery beat schedule file 77 | celerybeat-schedule 78 | 79 | # SageMath parsed files 80 | *.sage.py 81 | 82 | # dotenv 83 | .env 84 | 85 | # virtualenv 86 | .venv 87 | venv/ 88 | ENV/ 89 | 90 | # Spyder project settings 91 | .spyderproject 92 | .spyproject 93 | 94 | # Rope project settings 95 | .ropeproject 96 | 97 | # mkdocs documentation 98 | /site 99 | 100 | # mypy 101 | .mypy_cache/ 102 | 103 | 104 | .*/ 105 | 106 | *.user 107 | .qmake.stash 108 | Makefile 109 | moc_* 110 | qrc_* 111 | *.o 112 | *.qm 113 | OneClickBingWallpaper 114 | -------------------------------------------------------------------------------- /OneClickBingWallpaperTranslation.h: -------------------------------------------------------------------------------- 1 | #ifndef ONECLICKBINGWALLPAPERTRANSLATION_H 2 | #define ONECLICKBINGWALLPAPERTRANSLATION_H 3 | 4 | #include 5 | 6 | void GenerateSettingTranslate() 7 | { 8 | auto base = QObject::tr("Basic"); // base 9 | auto baseFile = QObject::tr("File"); // base.file 10 | auto baseFileImageFolder = QObject::tr("Image Folder"); // base.file.image-folder 11 | auto baseUpdate = QObject::tr("Update"); // base.update 12 | auto baseUpdateType = QObject::tr("Type"); // base.update.type 13 | auto baseUpdateCustomCmd = QObject::tr("Custom Update Command"); // base.update.custom-command 14 | auto baseUpdateDesktop = QObject::tr("Desktop Environment"); // base.update.desktop 15 | auto baseNotification = QObject::tr("Notification"); // base.notification 16 | auto baseDomain = QObject::tr("Domain"); // base.domain 17 | auto baseAutoupdate = QObject::tr("Auto Update"); // base.autoupdate 18 | auto baseAutoupdateInterval = QObject::tr("Interval"); // base.autoupdate.interval 19 | auto baseSecurity = QObject::tr("Security"); // base.security 20 | auto baseOther = QObject::tr("Other"); // base.other 21 | 22 | auto baseNotificationText = QObject::tr("Send Notification"); 23 | auto baseDomainSubdomainText = QObject::tr("Subdomain for bing.com"); 24 | auto baseAutoupdateStartupenableText = QObject::tr("Autoupdate Bingwallpaper when tool startup"); 25 | auto baseSecurityPythoncheckText = QObject::tr("Check setting Python file's MD5"); 26 | auto baseOtherLanguageUpdateHintText = QObject::tr("Show hint of restart for updating language") 27 | 28 | auto restoreDefaults = QObject::tr("Restore Defaults"); 29 | } 30 | 31 | #endif // ONECLICKBINGWALLPAPERTRANSLATION_H 32 | -------------------------------------------------------------------------------- /README-zh.md: -------------------------------------------------------------------------------- 1 | # BingWallpaper 2 | 3 | [English Version](/README.md) 4 | 5 | 将当天的必应美图设置为桌面背景(支持图形化和命令行设置) 6 | 7 | ## 使用 8 | 9 | ### 命令行 10 | 11 | 本程序的主体部分是```BingWallpaper.py``` 文件,如无需用户界面或者其他情况(例如结合 crontab 做定时更新),可以直接在 Python3 环境中运行 12 | 13 | ```bash 14 | ## (需提前安装 Python 的 argparse requests) 15 | python3 BingWallpaper.py [参数] 16 | ``` 17 | 18 | 参数 19 | 20 | -d 指定桌面环境,暂时支持 cinnamon,deepin,gnome,kde,mate,xfce,欢迎 PR 添加其他桌面环境 21 | 22 | -c 自定义更改壁纸的命令,必须包含```{{}}```,此符号将会被替换成图片路径 23 | 24 | --auto 自动探测桌面环境,自动选择合适的命令进行设置,如果与 -d 选项同时使用,-d 选项将被忽略 25 | 26 | --random 随机选择一张壁纸进行设置而非使用当天的壁纸(需自行保证 ~/BingWallpaper 目录不为空且包含图片文件) 27 | 28 | --silent 成功设置后不发送通知 29 | 30 | -baseurl 指定 bing.com 的子域名,以防无法获取图片信息。如果与 --random 选项同时使用,--random 选项将被忽略。不使用该选项程序将会在以下子域名自动选择 https://www.bing.com、https://www2.bing.com、https://www4.bing.com、https://cn.bing.com 。自行指定的选项也要在以上四个选项中选择以免出现其他不可预料的问题。 31 | 32 | 33 | ### 用户界面 34 | 35 | 用户界面使用了 DTK (Deepin Tool Kit),无需使用请在源代码中移除相应部分。 36 | 37 | 建议 Ubuntu 18.04+、Linuxmint 19+、Deepin 15.9+ 用户下载 release 里的安装包,安装后使用图形化界面一键设置 38 | 39 | [2025.07]: 更推荐使用 Linuxmint 22.1+ 40 | 41 | ## 参与贡献 42 | 43 | 所有代码修改请在 dev 分支修改后再发 PR,所有的 commit 记录应简洁高效地记录修改原因,使用英文书写 commit,并在内容前加上修改类型,类型如下 44 | 45 | feat:新功能(feature) 46 | 47 | fix:修补bug 48 | 49 | docs:文档(documentation) 50 | 51 | style: 格式(不影响代码运行的变动) 52 | 53 | refactor:重构(即不是新增功能,也不是修改bug的代码变动) 54 | 55 | test:增加测试 56 | 57 | chore:构建过程或辅助工具的变动 58 | 59 | 例如 ```fix: case insensitive for -d option``` 60 | 61 | ## 源码运行程序 62 | 63 | ``` 64 | sudo apt install qt5-default libdtkwidget-dev 65 | cd BingWallpaper 66 | qmake 67 | make 68 | ``` 69 | 70 | [2025.07] 新版本 Linux 系统可以尝试下列命令 71 | 72 | ``` 73 | sudo apt install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libdtkwidget-dev 74 | ``` 75 | 76 | ## 源码构建 DEB 包 77 | 78 | ``` 79 | sudo apt install build-essential devscripts ubuntu-dev-tools debhelper dh-make patch gnupg fakeroot lintian pbuilder 80 | debuild 81 | ``` -------------------------------------------------------------------------------- /Go/util/util.go: -------------------------------------------------------------------------------- 1 | package util 2 | 3 | import ( 4 | "errors" 5 | "io" 6 | "io/ioutil" 7 | "log" 8 | "net/http" 9 | "net/url" 10 | "os" 11 | "os/user" 12 | "path" 13 | ) 14 | 15 | // CheckImagePath check path for image 16 | func CheckImagePath(imgPath string) error { 17 | if imgPath == "" { 18 | return errors.New("empty path") 19 | } 20 | 21 | if _, err := os.Stat(imgPath); os.IsNotExist(err) { 22 | return errors.New("image path is not exist for" + imgPath) 23 | } 24 | return nil 25 | } 26 | 27 | // DownloadConfig get config json from specific url 28 | func DownloadConfig(url string) ([]byte, error) { 29 | resp, err := http.Get(url) 30 | if err != nil { 31 | return []byte{}, err 32 | } 33 | defer resp.Body.Close() 34 | 35 | body, err := ioutil.ReadAll(resp.Body) 36 | if err != nil { 37 | return []byte{}, err 38 | } 39 | 40 | return body, nil 41 | } 42 | 43 | // DownloadFile get file from url to filePath with fileName 44 | func DownloadFile(url, filePath, fileName string) error { 45 | resp, err := http.Get(url) 46 | if err != nil { 47 | return err 48 | } 49 | defer resp.Body.Close() 50 | 51 | if _, err := os.Stat(filePath); os.IsNotExist(err) { 52 | os.MkdirAll(filePath, os.ModePerm) 53 | } 54 | 55 | localfile, err := os.Create(path.Join(filePath, fileName)) 56 | if err != nil { 57 | return err 58 | } 59 | defer localfile.Close() 60 | 61 | _, err = io.Copy(localfile, resp.Body) 62 | return err 63 | } 64 | 65 | // GetValueFromURLArgument get value from a URL argument 66 | func GetValueFromURLArgument(rawURL, valueName string) (string, error) { 67 | if len(rawURL) == 0 { 68 | return "", errors.New("empty string") 69 | } 70 | 71 | result, err := url.Parse(rawURL) 72 | if err != nil { 73 | return "", err 74 | } 75 | 76 | values, err := url.ParseQuery(result.RawQuery) 77 | if err != nil { 78 | return "", err 79 | } 80 | 81 | return values.Get(valueName), nil 82 | } 83 | 84 | // GetUserHomePath get user home path 85 | func GetUserHomePath() string { 86 | usr, err := user.Current() 87 | if err != nil { 88 | log.Fatal(err) 89 | return "" 90 | } 91 | return usr.HomeDir 92 | } 93 | -------------------------------------------------------------------------------- /Go/conf/conf.go: -------------------------------------------------------------------------------- 1 | package conf 2 | 3 | import ( 4 | "encoding/json" 5 | "io/ioutil" 6 | "os" 7 | ) 8 | 9 | // BingImages ... 10 | type BingImages struct { 11 | Startdate string `json:"startdate"` 12 | Fullstartdate string `json:"fullstartdate"` 13 | Enddate string `json:"enddate"` 14 | URL string `json:"url"` 15 | URLbase string `json:"urlbase"` 16 | Copyright string `json:"copyright"` 17 | Copyrightlink string `json:"copyrightlink"` 18 | Title string `json:"title"` 19 | Quiz string `json:"quiz"` 20 | Wp bool `json:"wp"` 21 | Hsh string `json:"hsh"` 22 | Drk int `json:"drk"` 23 | Top int `json:"top"` 24 | Bot int `json:"bot"` 25 | Hs []interface{} `json:"hs,omitempty"` 26 | } 27 | 28 | // BingTooltips ... 29 | type BingTooltips struct { 30 | Loading string `json:"loading"` 31 | Previous string `json:"previous"` 32 | Next string `json:"next"` 33 | Walle string `json:"walle"` 34 | Walls string `json:"walls"` 35 | } 36 | 37 | // BingConfig ... 38 | type BingConfig struct { 39 | Images []*BingImages `json:"images"` 40 | Tooltips *BingTooltips `json:"tooltips"` 41 | } 42 | 43 | // UpdateWallpaperConfig ... 44 | type UpdateWallpaperConfig struct { 45 | AutoDetect bool `json:"autoDetect,omitempty"` 46 | Silent bool `json:"silent,omitempty"` 47 | Random bool `json:"random,omitempty"` 48 | UpdateDuration int64 `json:"duration,omitempty"` 49 | Path string `json:"path,omitempty"` 50 | Desktop string `json:"desktop,omitempty"` 51 | Command string `json:"command,omitempty"` 52 | } 53 | 54 | // ReadFromFile for UpdateWallpaperConfig 55 | func (config *UpdateWallpaperConfig) ReadFromFile(path string) error { 56 | configFile, err := os.Open(path) 57 | if err != nil { 58 | return err 59 | } 60 | defer configFile.Close() 61 | 62 | rawConfig, err := ioutil.ReadAll(configFile) 63 | if err != nil { 64 | return err 65 | } 66 | 67 | json.Unmarshal(rawConfig, &config) 68 | 69 | return nil 70 | } 71 | -------------------------------------------------------------------------------- /OneClickBingWallpaper.h: -------------------------------------------------------------------------------- 1 | #ifndef ONECLICKBINGWALLPAPER_H 2 | #define ONECLICKBINGWALLPAPER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | 17 | DCORE_BEGIN_NAMESPACE 18 | class DSettings; 19 | DCORE_END_NAMESPACE 20 | 21 | DCORE_USE_NAMESPACE 22 | 23 | struct DesktopEnvironmentType 24 | { 25 | public: 26 | QString name; 27 | QString argument; 28 | }; 29 | 30 | struct LanguageType 31 | { 32 | public: 33 | QString name; 34 | QString value; 35 | }; 36 | 37 | static QVector vDesktopEnvironments = { 38 | {QObject::tr("Cinnamon"),"-d cinnamon"}, {QObject::tr("Deepin"),"-d deepin"}, 39 | {QObject::tr("Gnome"),"-d gnome"},{QObject::tr("KDE"),"-d kde"},{QObject::tr("LXQt"),"-d lxqt"}, 40 | {QObject::tr("Mate"),"-d mate"},{QObject::tr("WM"),"-d wm"},{QObject::tr("Xfce"),"-d xfce"}, 41 | {QObject::tr("Custom"),"-c"}, 42 | }; 43 | 44 | static QVector vLanguages = { 45 | {QObject::tr("简体中文"),"zh-CN"}, {QObject::tr("English"),"en-US"} 46 | }; 47 | 48 | class OneClickBingWallpaper : public QWidget 49 | { 50 | Q_OBJECT 51 | 52 | public: 53 | OneClickBingWallpaper(QWidget *parent = 0); 54 | ~OneClickBingWallpaper(); 55 | private: 56 | QSystemTrayIcon * trayIcon; 57 | QMenu * trayMenu, * moreMenu, * langMenu; 58 | 59 | QAction * updateAction; 60 | QVector vDEActions; 61 | 62 | QVector vLangActions; 63 | 64 | QAction * settingAction; 65 | QAction * aboutAction; 66 | QAction * visitBingAction; 67 | 68 | QAction * quitAction; 69 | 70 | QString configPath; 71 | Dtk::Core::QSettingBackend * backend; 72 | DSettings * dsettings; 73 | 74 | QTimer * timer; 75 | 76 | QString imagePath; 77 | 78 | void initAction(); 79 | void initMenu(); 80 | void initConnect(); 81 | void initSettingOptions(); 82 | void initOther(); 83 | 84 | private slots: 85 | void trayIconActivated(QSystemTrayIcon::ActivationReason); 86 | void settingsValueChanged(const QString &key, const QVariant &value); 87 | void updateWallpaper(QString argument); 88 | void updateLanguage(QString value); 89 | 90 | void showSettingWidget(); 91 | void showAboutWidget(); 92 | void visitBing(); 93 | }; 94 | 95 | #endif // ONECLICKBINGWALLPAPER_H 96 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BingWallpaper 2 | 3 | [中文版](/README-zh.md) 4 | 5 | Setting everyday's Bing wallpaper as the desktop wallpaper ( GUI and command line supported) 6 | 7 | ## Usage 8 | 9 | ### CLI 10 | 11 | The main part of this program is ```BingWallpaper.py```, if you don't need GUI or in other situation(like use crontab to update in regular time), you can use this file with Python3 12 | 13 | ```bash 14 | ## require python's module: argparse,requests 15 | python3 BingWallpaper.py [options] 16 | ``` 17 | 18 | options 19 | 20 | -d specific your desktop environment's name,cinnamon,deepin,gnome,kde,mate,xfce only, welcome your PR for more desktop environment support. 21 | 22 | -c custom command to update wallpaper,```{{}}``` must be added, and it will be replaced by the path name of image. 23 | 24 | --auto auto detect your desktop environment and use proper command to update.ignored if -d option is added. 25 | 26 | --random random image to update wallpaper instead of using the newest one.(You should make sure ~/BingWallpaper is not empty and contains at least one image file) 27 | 28 | --silent no notification after updating successfull. 29 | 30 | -baseurl to specific subdomain for bing.com for accident,ignored if --random option is added. https://www.bing.com , https://www2.bing.com , https://www4.bing.com , https://cn.bing.com will be choosed automatically if you don't use this option. And this option's value must be in the above four url to avoid other unknown accident. 31 | 32 | 33 | ### GUI 34 | 35 | The GUI of this program is built with DTK (Deepin Tool Kit), if you don't need it, remove relavant code manually. 36 | 37 | 38 | Ubuntu 18.04+, Linuxmint 19+, Deepin 15.9+ users are recommanded to install deb package in release branch to set wallpaper with the help of GUI. 39 | 40 | [2025.07]: Linuxmint 22.1+ is more recommended now 41 | 42 | ## Contribution 43 | 44 | All change must be committed in dev branch before PR, write commit log in English with concise and specific words.Add corresponding type: 45 | 46 | feat: new feature 47 | 48 | fix: bug fix 49 | 50 | docs: documentation 51 | 52 | style: code format ( changes that do not affect code operation ) 53 | 54 | refactor: refactoring ( i.e. code changes that are not new features or bug fixs ) 55 | 56 | test: add test case 57 | 58 | chore: changes of the building process or tools 59 | 60 | i.e. ```fix: case insensitive for -d option``` 61 | 62 | ## Run from source 63 | 64 | ``` 65 | sudo apt install qt5-default libdtkwidget-dev 66 | cd BingWallpaper 67 | qmake 68 | make 69 | ``` 70 | 71 | [2025.07] try following command for new version linux 72 | 73 | ``` 74 | sudo apt install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libdtkwidget-dev 75 | ``` 76 | 77 | ## Build DEB package from source 78 | 79 | ``` 80 | sudo apt install build-essential devscripts ubuntu-dev-tools debhelper dh-make patch gnupg fakeroot lintian pbuilder 81 | debuild 82 | ``` -------------------------------------------------------------------------------- /OneClickBingWallpaper.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2017-12-05T13:18:08 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = OneClickBingWallpaper 12 | TEMPLATE = app 13 | TRANSLATIONS += i18n/zh-CN.ts i18n/en-US.ts 14 | CONFIG += c++11 link_pkgconfig 15 | PKGCONFIG += dtkwidget 16 | 17 | # The following define makes your compiler emit warnings if you use 18 | # any feature of Qt which has been marked as deprecated (the exact warnings 19 | # depend on your compiler). Please consult the documentation of the 20 | # deprecated API in order to know how to port your code away from it. 21 | DEFINES += QT_DEPRECATED_WARNINGS 22 | 23 | # You can also make your code fail to compile if you use deprecated APIs. 24 | # In order to do so, uncomment the following line. 25 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 26 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 27 | 28 | 29 | SOURCES += \ 30 | main.cpp \ 31 | OneClickBingWallpaper.cpp \ 32 | OneClickBingWallpaperConfig.cpp 33 | 34 | HEADERS += \ 35 | OneClickBingWallpaper.h \ 36 | OneClickBingWallpaperConfig.h \ 37 | OneClickBingWallpaperTranslation.h 38 | 39 | RESOURCES += \ 40 | resource/resource.qrc 41 | 42 | 43 | icons.files = resource/OneClickBingWallpaper.png 44 | icons_16x16.files = resource/icons/16x16/OneClickBingWallpaper.png 45 | icons_22x22.files = resource/icons/22x22/OneClickBingWallpaper.png 46 | icons_24x24.files = resource/icons/24x24/OneClickBingWallpaper.png 47 | icons_28x28.files = resource/icons/28x28/OneClickBingWallpaper.png 48 | icons_32x32.files = resource/icons/32x32/OneClickBingWallpaper.png 49 | icons_36x36.files = resource/icons/36x36/OneClickBingWallpaper.png 50 | icons_48x48.files = resource/icons/48x48/OneClickBingWallpaper.png 51 | icons_64x64.files = resource/icons/64x64/OneClickBingWallpaper.png 52 | icons_72x72.files = resource/icons/72x72/OneClickBingWallpaper.png 53 | icons_96x96.files = resource/icons/96x96/OneClickBingWallpaper.png 54 | desktop.files = OneClickBingWallpaper.desktop 55 | local.files = i18n/*.qm 56 | 57 | isEmpty(INSTALL_PREFIX) { 58 | unix: INSTALL_PREFIX = /usr 59 | else: INSTALL_PREFIX = .. 60 | } 61 | 62 | unix: { 63 | desktop.path = $$INSTALL_PREFIX/share/applications 64 | local.path = $$INSTALL_PREFIX/bin/OneClickBingWallpaper/i18n 65 | icons.path = $$INSTALL_PREFIX/share/icons/hicolor/128x128/apps 66 | icons_16x16.path = $$INSTALL_PREFIX/share/icons/hicolor/16x16/apps 67 | icons_22x22.path = $$INSTALL_PREFIX/share/icons/hicolor/22x22/apps 68 | icons_24x24.path = $$INSTALL_PREFIX/share/icons/hicolor/24x24/apps 69 | icons_28x28.path = $$INSTALL_PREFIX/share/icons/hicolor/28x28/apps 70 | icons_32x32.path = $$INSTALL_PREFIX/share/icons/hicolor/32x32/apps 71 | icons_36x36.path = $$INSTALL_PREFIX/share/icons/hicolor/36x36/apps 72 | icons_48x48.path = $$INSTALL_PREFIX/share/icons/hicolor/48x48/apps 73 | icons_64x64.path = $$INSTALL_PREFIX/share/icons/hicolor/64x64/apps 74 | icons_72x72.path = $$INSTALL_PREFIX/share/icons/hicolor/72x72/apps 75 | icons_96x96.path = $$INSTALL_PREFIX/share/icons/hicolor/96x96/apps 76 | INSTALLS += desktop local icons 77 | INSTALLS += icons_16x16 icons_22x22 icons_24x24 icons_28x28 icons_32x32 icons_36x36 icons_48x48 icons_64x64 icons_72x72 icons_96x96 78 | } 79 | 80 | target.files = OneClickBingWallpaper 81 | target.files += BingWallpaper.py 82 | target.path = $$INSTALL_PREFIX/bin/OneClickBingWallpaper 83 | 84 | INSTALLS += target 85 | -------------------------------------------------------------------------------- /resource/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "groups": [ 3 | { 4 | "key": "base", 5 | "name": "Basic", 6 | "groups": [ 7 | { 8 | "key":"file", 9 | "name":"File", 10 | "options":[ 11 | { 12 | "key": "image-folder", 13 | "name": "Image Folder", 14 | "type": "lineedit", 15 | "default": "BingWallpaper/" 16 | } 17 | ] 18 | }, 19 | { 20 | "key": "update", 21 | "name": "Update", 22 | "options": [ 23 | { 24 | "key": "type", 25 | "name": "Type", 26 | "type": "combobox", 27 | "default": "latest" 28 | }, 29 | { 30 | "key": "desktop", 31 | "name": "Desktop Environment", 32 | "type": "combobox", 33 | "default": "--auto" 34 | }, 35 | { 36 | "key": "custom-command", 37 | "name": "Custom Update Command", 38 | "type": "lineedit", 39 | "default": "" 40 | } 41 | ] 42 | }, 43 | { 44 | "key": "notification", 45 | "name": "Notification", 46 | "options": [ 47 | { 48 | "key": "enable", 49 | "name": "", 50 | "type": "checkbox", 51 | "text":"Send Notification", 52 | "default": "true" 53 | } 54 | ] 55 | }, 56 | { 57 | "key": "domain", 58 | "name": "Domain", 59 | "options": [ 60 | { 61 | "key": "subdomain", 62 | "name": "Subdomain for bing.com", 63 | "type": "combobox", 64 | "default": "auto" 65 | } 66 | ] 67 | }, 68 | { 69 | "key": "autoupdate", 70 | "name": "Auto Update", 71 | "options": [ 72 | { 73 | "key": "interval", 74 | "name": "Interval", 75 | "type": "combobox", 76 | "default": "-1" 77 | } 78 | ] 79 | }, 80 | { 81 | "key": "security", 82 | "name": "Security", 83 | "options": [ 84 | { 85 | "key": "python-check", 86 | "name": "", 87 | "type": "checkbox", 88 | "text": "Check setting Python file's MD5", 89 | "default": "true" 90 | } 91 | ] 92 | }, 93 | { 94 | "key": "other", 95 | "name": "Other", 96 | "options": [ 97 | { 98 | "key": "language-update-hint", 99 | "name": "", 100 | "type": "checkbox", 101 | "text": "Show hint of restart for updating language", 102 | "default": "true" 103 | } 104 | ] 105 | } 106 | ] 107 | } 108 | ] 109 | } 110 | -------------------------------------------------------------------------------- /Go/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "encoding/json" 5 | "flag" 6 | "fmt" 7 | "io/ioutil" 8 | "math/rand" 9 | "os" 10 | "path" 11 | "time" 12 | 13 | logrus "github.com/sirupsen/logrus" 14 | 15 | "github.com/ypingcn/BingWallpaper/Go/conf" 16 | "github.com/ypingcn/BingWallpaper/Go/notify" 17 | "github.com/ypingcn/BingWallpaper/Go/setter" 18 | "github.com/ypingcn/BingWallpaper/Go/util" 19 | ) 20 | 21 | const ( 22 | configFileName = "./BingWallpaper.conf" 23 | logFileName = "./BingWallpaper.log" 24 | imgFolderName = "BingWallpaper" 25 | ) 26 | 27 | var optConf = flag.String("conf", configFileName, "config file path") 28 | var optDisableConf = flag.Bool("disable-file-conf", false, "disable all file configuration") 29 | 30 | var optDuration = flag.Int64("duration", 0, "update duration(seconds)") 31 | var optAuto = flag.Bool("auto", false, "auto detect desktop environment(Beta)") 32 | var optSilent = flag.Bool("silent", false, "do not send notify after finish setting") 33 | var optRandom = flag.Bool("random", false, "random pick image from default folder to set wallpaper") 34 | var optImgPath = flag.String("imgpath", path.Join(util.GetUserHomePath(), imgFolderName), "image folder for random mode") 35 | var optDesktop = flag.String("d", "", "desktop environment: xfce etc, Linux only") 36 | var optCommand = flag.String("c", "", "command in your device to set desktop background,%s will be replaced with the true images path(not end with )") 37 | 38 | var log = logrus.New() 39 | 40 | func init() { 41 | logrus.SetLevel(logrus.InfoLevel) 42 | log.Out = os.Stdout 43 | file, err := os.OpenFile(logFileName, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) 44 | if err != nil { 45 | log.Info("Failed to log to file, using default stderr.", err) 46 | } else { 47 | log.Out = file 48 | } 49 | } 50 | 51 | func setWallpaper(config conf.UpdateWallpaperConfig) { 52 | log.Info("setWallpaper begin") 53 | 54 | defer func() { 55 | log.Info("setWallpaper end") 56 | }() 57 | 58 | baseURLs := []string{"https://www.bing.com", "https://www2.bing.com", "https://www4.bing.com", "https://cn.bing.com"} 59 | apiPath := "/HPImageArchive.aspx?format=js&idx=0&n=1" 60 | 61 | downloadFinished := false 62 | imgName := "" 63 | imgPath := config.Path 64 | notifyTitle := "" 65 | notifyName := "" 66 | 67 | if config.Random { 68 | rand.Seed(time.Now().UnixNano()) 69 | files, err := ioutil.ReadDir(imgPath) 70 | if err != nil { 71 | log.Fatal(err) 72 | } 73 | imgName = files[rand.Int()%len(files)].Name() 74 | notifyTitle = "RANDOM" 75 | notifyName = imgName 76 | } else { 77 | for _, baseURL := range baseURLs { 78 | apiURL := baseURL + apiPath 79 | config, err := util.DownloadConfig(apiURL) 80 | if err != nil { 81 | log.Println("get config error for ", apiURL, " try next one") 82 | continue 83 | } 84 | 85 | bingConfig := &conf.BingConfig{} 86 | err = json.Unmarshal([]byte(config), bingConfig) 87 | if err != nil { 88 | log.Println("json unmarshal error for ", apiURL) 89 | continue 90 | } 91 | notifyTitle = "NEWEST" 92 | notifyName = bingConfig.Images[0].Copyright 93 | 94 | fileName, err := util.GetValueFromURLArgument(bingConfig.Images[0].URL, "id") 95 | 96 | now := time.Now().Format("2006-01-02") 97 | if err != nil { 98 | imgName = fmt.Sprintf("BingWallpaper-%s.jpg", now) 99 | } else { 100 | imgName = fmt.Sprintf("BingWallpaper-%s-%s.jpg", now, fileName) 101 | } 102 | 103 | if err := util.DownloadFile(baseURL+bingConfig.Images[0].URL, imgPath, imgName); err != nil { 104 | log.Println("download file error ", baseURL+bingConfig.Images[0].URL) 105 | log.Println(err) 106 | continue 107 | } 108 | 109 | downloadFinished = true 110 | 111 | break 112 | } 113 | 114 | if !downloadFinished { 115 | log.Fatal("error") 116 | return 117 | } 118 | } 119 | 120 | localSetter, err := setter.New(config.Desktop, config.Command) 121 | 122 | if err != nil { 123 | log.Fatal(err) 124 | return 125 | } 126 | 127 | localSetter.SetWallpaper(path.Join(imgPath, imgName)) 128 | 129 | if !config.Silent { 130 | notify.Notify("Bingwallpaper", notifyTitle, notifyName, "") 131 | } 132 | } 133 | 134 | func main() { 135 | flag.Parse() 136 | 137 | updateConfig := conf.UpdateWallpaperConfig{ 138 | AutoDetect: *optAuto, 139 | Silent: *optSilent, 140 | Random: *optRandom, 141 | UpdateDuration: *optDuration, 142 | Path: *optImgPath, 143 | Desktop: *optDesktop, 144 | Command: *optCommand, 145 | } 146 | 147 | if !*optDisableConf { 148 | if err := updateConfig.ReadFromFile(*optConf); err != nil { 149 | panic(err) 150 | } 151 | } 152 | 153 | timer := time.NewTimer(time.Second * 0) 154 | for { 155 | select { 156 | case <-timer.C: 157 | setWallpaper(updateConfig) 158 | } 159 | 160 | if updateConfig.UpdateDuration <= 0 { 161 | break 162 | } 163 | timer.Reset(time.Second * time.Duration(updateConfig.UpdateDuration)) 164 | 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /Go/setter/setter_linux.go: -------------------------------------------------------------------------------- 1 | package setter 2 | 3 | import ( 4 | "fmt" 5 | "os" 6 | "os/exec" 7 | "strings" 8 | 9 | util "github.com/ypingcn/BingWallpaper/Go/util" 10 | ) 11 | 12 | // WallpaperSetter ... 13 | type WallpaperSetter interface { 14 | SetWallpaper(string) error 15 | } 16 | 17 | // CinnamonSetter : for Cinnamon 18 | type CinnamonSetter struct{} 19 | 20 | // DeepinSetter : for Deepin 21 | type DeepinSetter struct{} 22 | 23 | // GnomeSetter : for Gnome 24 | type GnomeSetter struct{} 25 | 26 | // KDESetter : for KDE 27 | type KDESetter struct{} 28 | 29 | // MateSetter : for Mate 30 | type MateSetter struct{} 31 | 32 | // WMSetter : for WM 33 | type WMSetter struct{} 34 | 35 | // XfceSetter : for Xfce 36 | type XfceSetter struct{} 37 | 38 | // CommonSetter : for Common 39 | type CommonSetter struct { 40 | command string 41 | } 42 | 43 | // NewSetter ... 44 | func New(desktop, command string) (WallpaperSetter, error) { 45 | if desktop == "" { 46 | session := os.Getenv("DESKTOP_SESSION") 47 | keywords := map[string]string{ 48 | "cinnamon": "cinnamon", 49 | "deepin": "deepin", 50 | "gnome": "gnome", 51 | "mate": "mate", 52 | "plasma": "kde", 53 | "xfce": "xfce", 54 | } 55 | for val := range keywords { 56 | if strings.Compare(val, session) == 0 { 57 | desktop = val 58 | break 59 | } 60 | } 61 | } 62 | switch desktop { 63 | case "cinnamon": 64 | return CinnamonSetter{}, nil 65 | case "deepin": 66 | return DeepinSetter{}, nil 67 | case "gnome": 68 | return GnomeSetter{}, nil 69 | case "kde": 70 | return KDESetter{}, nil 71 | case "mate": 72 | return MateSetter{}, nil 73 | case "wm": 74 | return WMSetter{}, nil 75 | case "xfce": 76 | return XfceSetter{}, nil 77 | } 78 | if command != "" { 79 | return CommonSetter{command: command}, nil 80 | } 81 | return nil, fmt.Errorf("not supported desktop environment for %s with %s command", desktop, command) 82 | } 83 | 84 | // SetWallpaper ... 85 | func (setter CinnamonSetter) SetWallpaper(imgPath string) error { 86 | if err := util.CheckImagePath(imgPath); err != nil { 87 | return err 88 | } 89 | 90 | command := fmt.Sprintf("gsettings set org.cinnamon.desktop.background picture-uri \"file:///%s\"", imgPath) 91 | 92 | _, err := exec.Command("sh", "-c", command).Output() 93 | if err != nil { 94 | return err 95 | } 96 | return nil 97 | } 98 | 99 | // SetWallpaper ... 100 | func (setter DeepinSetter) SetWallpaper(imgPath string) error { 101 | if err := util.CheckImagePath(imgPath); err != nil { 102 | return err 103 | } 104 | 105 | command := fmt.Sprintf("gsettings set com.deepin.wrap.gnome.desktop.background picture-uri \"file:///%s\"", imgPath) 106 | _, err := exec.Command("sh", "-c", command).Output() 107 | if err != nil { 108 | return err 109 | } 110 | return nil 111 | } 112 | 113 | // SetWallpaper ... 114 | func (setter GnomeSetter) SetWallpaper(imgPath string) error { 115 | if err := util.CheckImagePath(imgPath); err != nil { 116 | return nil 117 | } 118 | 119 | command := fmt.Sprintf(` 120 | gsettings set org.gnome.desktop.background draw-background false && 121 | gsettings set org.gnome.desktop.background picture-uri file://%s && 122 | gsettings set org.gnome.desktop.background draw-background true 123 | `, imgPath) 124 | _, err := exec.Command("sh", "c", command).Output() 125 | if err != nil { 126 | return nil 127 | } 128 | return nil 129 | } 130 | 131 | // SetWallpaper ... 132 | func (setter KDESetter) SetWallpaper(imgPath string) error { 133 | if err := util.CheckImagePath(imgPath); err != nil { 134 | return nil 135 | } 136 | 137 | command := fmt.Sprintf(` 138 | var Desktops = desktops(); 139 | d = Desktops[0]; 140 | d.wallpaperPlugin= "org.kde.image"; 141 | d.currentConfigGroup = Array("Wallpaper","org.kde.image","General"); 142 | d.writeConfig("Image","%s"); 143 | `, imgPath) 144 | _, err := exec.Command("sh", "-c", command).Output() 145 | if err != nil { 146 | return err 147 | } 148 | return nil 149 | } 150 | 151 | // SetWallpaper ... 152 | func (setter MateSetter) SetWallpaper(imgPath string) error { 153 | if err := util.CheckImagePath(imgPath); err != nil { 154 | return err 155 | } 156 | command := fmt.Sprintf("gsettings set org.mate.background picture-filename %s", imgPath) 157 | _, err := exec.Command("sh", "-c", command).Output() 158 | if err != nil { 159 | return err 160 | } 161 | return nil 162 | } 163 | 164 | // SetWallpaper ... 165 | func (setter WMSetter) SetWallpaper(imgPath string) error { 166 | if err := util.CheckImagePath(imgPath); err != nil { 167 | return err 168 | } 169 | command := fmt.Sprintf("feh --bg-fill %s", imgPath) 170 | _, err := exec.Command("sh", "-c", command).Output() 171 | if err != nil { 172 | return err 173 | } 174 | return nil 175 | } 176 | 177 | // SetWallpaper ... 178 | func (setter XfceSetter) SetWallpaper(imgPath string) error { 179 | if err := util.CheckImagePath(imgPath); err != nil { 180 | return err 181 | } 182 | command := fmt.Sprintf("xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/last-image -s %s", imgPath) 183 | _, err := exec.Command("sh", "-c", command).Output() 184 | if err != nil { 185 | return err 186 | } 187 | return nil 188 | } 189 | 190 | // SetWallpaper ... 191 | func (setter CommonSetter) SetWallpaper(imgPath string) error { 192 | if err := util.CheckImagePath(imgPath); err != nil { 193 | return err 194 | } 195 | command := fmt.Sprintf(setter.command, imgPath) 196 | _, err := exec.Command("sh", "-c", command).Output() 197 | if err != nil { 198 | return err 199 | } 200 | return nil 201 | } 202 | -------------------------------------------------------------------------------- /BingWallpaper.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # -*- coding:utf-8 -*- 3 | 4 | from datetime import datetime 5 | import requests, time, os, argparse, filetype, random, sys 6 | 7 | 8 | class Logger(object): 9 | 10 | @staticmethod 11 | def _log(level, content, output_stream, **kwargs): 12 | time_prefix = datetime.now().strftime("[%Y-%m-%d %H:%M:%S.%f]") 13 | path = "%s/.oneclickbingwallpaper.log" % os.path.expanduser("~") 14 | 15 | if "path" in kwargs: 16 | path = kwargs["path"] 17 | 18 | level_str = f"{level:<5}" 19 | log_str = f"{time_prefix}|{level_str}|{content}\n" 20 | output_stream.write(log_str) 21 | 22 | with open(path, "a+") as file: 23 | file.write(log_str) 24 | 25 | @staticmethod 26 | def error(content, **kwargs): 27 | Logger._log("error", content, sys.stderr, **kwargs) 28 | 29 | @staticmethod 30 | def info(content, **kwargs): 31 | Logger._log("info", content, sys.stdout, **kwargs) 32 | 33 | 34 | class Downloader(object): 35 | 36 | @staticmethod 37 | def get(url, fileName): 38 | try: 39 | downloadReponse = requests.get(url) 40 | except: 41 | Logger.error("DownloadException|%s" % fileName) 42 | 43 | if downloadReponse.status_code != 200: 44 | Logger.error( 45 | "StatusCodeNot200|%s|%s" % (str(downloadReponse.status_code), fileName) 46 | ) 47 | 48 | lastIndex = fileName.rfind("/") 49 | if lastIndex: 50 | if not os.path.exists(fileName[:lastIndex]): 51 | os.mkdir(fileName[:lastIndex]) 52 | Logger.info("FolderNotExist|%s" % fileName[:lastIndex]) 53 | 54 | with open(fileName, "wb") as file: 55 | file.write(downloadReponse.content) 56 | 57 | 58 | class BingWallpaper(object): 59 | 60 | def __init__(self, de="", command=""): 61 | 62 | self.de = de 63 | self.command = command 64 | self.random = False 65 | self.path = "/HPImageArchive.aspx?format=js&idx=0&n=1" 66 | self.json = dict() 67 | self.imgFolder = "%s/BingWallpaper" % os.path.expanduser("~") 68 | self.silent = False 69 | self.notifyIconPath = ( 70 | "/usr/share/icons/hicolor/64x64/apps/OneClickBingWallpaper.png" 71 | ) 72 | 73 | def setBaseUrl(self, baseURL): 74 | url = "%s%s" % (baseURL, self.path) 75 | Logger.info(url) 76 | try: 77 | rsp = requests.get(url) 78 | except requests.exceptions.InvalidURL: 79 | Logger.error("InvaildURL|%s" % url) 80 | return -1 81 | except requests.exceptions.ConnectionError: 82 | Logger.error("ConnectionError|%s" % url) 83 | return -1 84 | 85 | if rsp.status_code == 200: 86 | try: 87 | self.json = ( 88 | rsp.json() 89 | ) # This *call* raises an exception if JSON decoding fails 90 | except ValueError: 91 | Logger.error("ValueError|%s" % (self.json())) 92 | return -1 93 | 94 | Logger.info(baseURL) 95 | else: 96 | Logger.error("StatusCodeNot200|%s|%s" % (str(rsp.status_code), url)) 97 | return -1 98 | 99 | try: 100 | imgLocation = self.json["images"][0]["url"] 101 | self.imgUrl = "%s%s" % (baseURL, imgLocation) 102 | imgArgs = imgLocation.split("&") 103 | for imgArg in imgArgs: 104 | if imgArg.startswith("/th?id="): 105 | imgLocation = imgArg 106 | break 107 | lastIndex = imgLocation.rfind(".") 108 | imgSuffix = imgLocation[ 109 | lastIndex + 1 : 110 | ] # if lastIndex=-1, imgSuffix=imgLocation 111 | self.imgName = "BingWallpaper-%s.%s" % ( 112 | time.strftime("%Y-%m-%d", time.localtime()), 113 | imgSuffix, 114 | ) 115 | self.imgPath = "%s/%s" % (self.imgFolder, self.imgName) 116 | except Exception as e: 117 | Logger.error("Exception|%s" % str(e)) 118 | return -1 119 | 120 | def setImageFolder(self, location): 121 | self.imgFolder = "%s/%s" % (os.path.expanduser("~"), location) 122 | 123 | def setWallpaper(self): 124 | Logger.info("setting begin") 125 | 126 | if (not os.path.exists(self.imgPath)) and (not self.random): 127 | Logger.info("FileNotExist|%s" % self.imgName) 128 | Downloader.get(self.imgUrl, self.imgPath) 129 | 130 | Logger.info("de|%s|command|%s" % (self.de, self.command)) 131 | 132 | if self.de: 133 | self.de = self.de.lower() 134 | 135 | if self.de == "cinnamon": 136 | self.command = ( 137 | 'gsettings set org.cinnamon.desktop.background picture-uri "file:///%s"' 138 | % self.imgPath 139 | ) 140 | Logger.info("cinnamon|status|%s" % str(os.system(self.command))) 141 | 142 | elif self.de == "deepin": 143 | self.command = ( 144 | 'gsettings set com.deepin.wrap.gnome.desktop.background picture-uri "file:///%s"' 145 | % self.imgPath 146 | ) 147 | # set GIO_EXTRA_MODULES env to fix `gsettings your settings will not be saved or shared with other applications`t 148 | check_env = os.getenv("GIO_EXTRA_MODULES") 149 | if not check_env: 150 | Logger.info("no GIO_EXTRA_MODULES environment") 151 | self.command = ( 152 | "GIO_EXTRA_MODULES=/usr/lib/x86_64-linux-gnu/gio/modules/ " 153 | + self.command 154 | ) 155 | Logger.info("deepin|status|%s" % str(os.system(self.command))) 156 | 157 | elif self.de == "gnome": 158 | shell = """ 159 | gsettings set org.gnome.desktop.background draw-background false && 160 | gsettings set org.gnome.desktop.background picture-uri file://# && 161 | gsettings set org.gnome.desktop.background draw-background true 162 | """ 163 | self.command = shell.replace("#", self.imgPath) 164 | Logger.info("gnome|status|%s" % str(os.system(self.command))) 165 | 166 | elif self.de == "kde": 167 | plasmashell = """ 168 | var Desktops = desktops(); 169 | d = Desktops[0]; 170 | d.wallpaperPlugin= "org.kde.image"; 171 | d.currentConfigGroup = Array("Wallpaper","org.kde.image","General"); 172 | d.writeConfig("Image","#"); 173 | """.replace( 174 | "#", self.imgPath 175 | ) 176 | self.command = "qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript '#'".replace( 177 | "#", plasmashell 178 | ) 179 | Logger.info("kde|status|%s" % str(os.system(self.command))) 180 | # if 'sh: 1: notify-send: not found' in kde , please install libnotify-bin 181 | # sudo apt install libnotify-bin 182 | 183 | elif self.de == "lxqt": 184 | self.command = "pcmanfm-qt --wallpaper-mode=fit --set-wallpaper=# ".replace( 185 | "#", self.imgPath 186 | ) 187 | Logger.info("lxqt|status|%s" % str(os.system(self.command))) 188 | 189 | elif self.de == "mate": 190 | self.command = ( 191 | "gsettings set org.mate.background picture-filename #".replace( 192 | "#", self.imgPath 193 | ) 194 | ) 195 | Logger.info("mate|status|%s" % str(os.system(self.command))) 196 | 197 | elif self.de == "wm": 198 | self.command = "feh --bg-fill %s" % self.imgPath 199 | Logger.info("feh|status|%s" % str(os.system(self.command))) 200 | 201 | elif self.de == "xfce": 202 | self.command = ( 203 | "xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitor0/workspace0/last-image -s %s" 204 | % self.imgPath 205 | ) 206 | Logger.info("xfce|status|%s" % str(os.system(self.command))) 207 | 208 | elif self.command: 209 | command = self.command.replace("{{}}", self.imgPath) 210 | Logger.info( 211 | "%s|%s|status|%s" % (self.command, command, str(os.system(command))) 212 | ) 213 | 214 | else: 215 | Logger.info("NotSupportDesktopEnvironment|%s" % str(self.de)) 216 | 217 | if (self.de or self.command) and (not self.silent): 218 | self.notify() 219 | Logger.info("setting finish") 220 | 221 | def notify(self): 222 | content = "" 223 | if not self.random: 224 | try: 225 | content = self.json["images"][0]["copyright"] 226 | lastIndex = content.rfind("(") 227 | content = content[:lastIndex] 228 | except Exception: 229 | pass 230 | else: 231 | content = self.imgName 232 | if os.path.exists(self.notifyIconPath): 233 | options = "--icon=%s" % self.notifyIconPath 234 | else: 235 | options = "" 236 | shell = 'notify-send "%s:%s" %s' % ( 237 | time.strftime("%Y-%m-%d", time.localtime()), 238 | content, 239 | options, 240 | ) 241 | Logger.info(shell) 242 | os.system(shell) 243 | 244 | def detect(self): 245 | session = os.getenv("DESKTOP_SESSION") 246 | keywords = { 247 | "cinnamon": "cinnamon", 248 | "deepin": "deepin", 249 | "gnome": "gnome", 250 | "Lubuntu": "lxqt", 251 | "mate": "mate", 252 | "plasma": "kde", 253 | "xfce": "xfce", 254 | } 255 | for key in keywords: 256 | if key in session: 257 | self.de = keywords[key] 258 | break 259 | 260 | def setRandomImage(self): 261 | self.random = True 262 | files = [] 263 | for item in os.listdir(self.imgFolder): 264 | filePath = os.path.join(self.imgFolder, item) 265 | kind = filetype.guess(filePath) 266 | if kind and kind.mime.startswith("image/"): 267 | files.append(item) 268 | self.imgName = files[random.randint(0, len(files) - 1)] 269 | self.imgPath = "%s/%s" % (self.imgFolder, self.imgName) 270 | 271 | def setSilent(self): 272 | self.silent = True 273 | 274 | 275 | if __name__ == "__main__": 276 | parser = argparse.ArgumentParser() 277 | parser.add_argument( 278 | "--auto", help="auto detect desktop environment(Beta)", action="store_true" 279 | ) 280 | parser.add_argument( 281 | "--random", 282 | help="random pick image from default folder to set wallpaper", 283 | action="store_true", 284 | ) 285 | parser.add_argument( 286 | "--silent", help="do not send notify after finish setting", action="store_true" 287 | ) 288 | parser.add_argument("-d", help="desktop environment: xfce etc") 289 | parser.add_argument( 290 | "-c", 291 | help="command in your device to set desktop background, {{}} will be replaced with the true images path", 292 | ) 293 | parser.add_argument( 294 | "-baseurl", 295 | help="[ignore if --random is true] alternative subdomain for bing.com, for example, -baseurl www2.bing.com. " 296 | "must begin with https:// or http://", 297 | ) 298 | parser.add_argument("-folder", help="folder location to get or save image folder") 299 | 300 | args = parser.parse_args() 301 | 302 | bw = BingWallpaper(args.d, args.c) 303 | 304 | if args.auto: 305 | ret = bw.detect() 306 | if args.silent: 307 | ret = bw.setSilent() 308 | if args.folder: 309 | ret = bw.setImageFolder(args.folder) 310 | if args.random: 311 | ret = bw.setRandomImage() 312 | elif args.baseurl: 313 | ret = bw.setBaseUrl(args.baseurl) 314 | else: 315 | path = "/HPImageArchive.aspx?format=js&idx=0&n=1" 316 | baseURLs = [ 317 | "https://www.bing.com", 318 | "https://www2.bing.com", 319 | "https://www4.bing.com", 320 | "https://cn.bing.com", 321 | ] 322 | for baseURL in baseURLs: 323 | url = "%s%s" % (baseURL, path) 324 | try: 325 | rsp = requests.get(url) 326 | except requests.exceptions.ConnectionError: 327 | Logger.error("ConnectionError|%s" % baseURL) 328 | else: 329 | if rsp.status_code == 200: 330 | ret = bw.setBaseUrl(baseURL) 331 | break 332 | else: 333 | ret = -1 334 | 335 | Logger.info("PreparationRet|%s" % str(ret)) 336 | 337 | if not ret or ret != -1: 338 | bw.setWallpaper() 339 | else: 340 | Logger.error("Setting Abort") 341 | -------------------------------------------------------------------------------- /i18n/en-US.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | OneClickBingWallpaper 6 | 7 | 8 | Update 9 | 10 | 11 | 12 | 13 | Setting 14 | 15 | 16 | 17 | 18 | About 19 | 20 | 21 | 22 | 23 | Quit 24 | 25 | 26 | 27 | 28 | Specific DE 29 | 30 | 31 | 32 | 33 | Language 34 | 35 | 36 | 37 | 38 | Disable 39 | 40 | 41 | 42 | 43 | Every 1 minute 44 | 45 | 46 | 47 | 48 | Every 5 minute 49 | 50 | 51 | 52 | 53 | Every 10 minute 54 | 55 | 56 | 57 | 58 | Every 15 minute 59 | 60 | 61 | 62 | 63 | Every 30 minute 64 | 65 | 66 | 67 | 68 | Every 60 minute 69 | 70 | 71 | 72 | 73 | Random 74 | 75 | 76 | 77 | 78 | 79 | Auto 80 | 81 | 82 | 83 | 84 | 85 | Folder Not Found 86 | 87 | 88 | 89 | 90 | Empty folder for %1 , 91 | if you want to update wallpaper for random, please make sure to put some image file in this folder, or use latest first 92 | 93 | 94 | 95 | 96 | Empty folder for %1. 97 | If you want to update wallpaper for random, please make sure to put some image file in this folder, or use latest first. 98 | Setting Abort, click YES to open folder, NO to ignore. 99 | 100 | 101 | 102 | 103 | A tool to set latest Bingwallpaper in Linux desktop. 104 | 105 | 106 | 107 | 108 | 109 | BingWallpaper folder %1 in home is not exist, tool will create it by default 110 | 111 | 112 | 113 | 114 | Visit Bing 115 | 116 | 117 | 118 | 119 | Latest 120 | 121 | 122 | 123 | 124 | Custom 125 | 126 | 127 | 128 | 129 | Folder not found 130 | 131 | 132 | 133 | 134 | Failed to create folder 135 | 136 | 137 | 138 | 139 | Failed to create folder %1 , you need to create folder manually. use %2 instead. 140 | 141 | 142 | 143 | 144 | 145 | Attention! Empty Folder 146 | 147 | 148 | 149 | 150 | Attention! Program works in custom update wallpaper command mode 151 | 152 | 153 | 154 | 155 | Please pay attention to your custom update wallpaper command. 156 | 157 | 158 | 159 | 160 | Attention! Need {{}} placeholder 161 | 162 | 163 | 164 | 165 | Need {{}} placeholder, it will be replaced to the final image path. 166 | 167 | 168 | 169 | 170 | Attention! Program works in latest mode 171 | 172 | 173 | 174 | 175 | Interval with latest mode means the same image will be setted in one day. 176 | 177 | 178 | 179 | 180 | Attention! Program will skipped md5 check 181 | 182 | 183 | 184 | 185 | Your program distributor has disabled md5 checking features.This option will be ignored 186 | 187 | 188 | 189 | 190 | BingWallpaper folder %1 in home is not exist, program will create it by default 191 | 192 | 193 | 194 | 195 | Python File Not Found 196 | 197 | 198 | 199 | 200 | Python file not found,please reinstall. 201 | 202 | 203 | 204 | 205 | Python File Have Modified 206 | 207 | 208 | 209 | 210 | Python File Have Modified 211 | Click YES to ignore it 212 | 213 | 214 | 215 | 216 | Error 217 | 218 | 219 | 220 | 221 | Something wrong 222 | 223 | 224 | 225 | 226 | Please check/adjust your setting or network connection, or just report this issue to maintainer with the following log. 227 | 228 | 229 | 230 | 231 | Restart required 232 | 233 | 234 | 235 | 236 | Language update require restart. if update fail, please quit and restart manually 237 | 238 | 239 | 240 | 241 | QObject 242 | 243 | 244 | Cinnamon 245 | 246 | 247 | 248 | 249 | Deepin 250 | 251 | 252 | 253 | 254 | Gnome 255 | 256 | 257 | 258 | 259 | KDE 260 | 261 | 262 | 263 | 264 | LXQt 265 | 266 | 267 | 268 | 269 | Mate 270 | 271 | 272 | 273 | 274 | WM 275 | 276 | 277 | 278 | 279 | Xfce 280 | 281 | 282 | 283 | 284 | Custom 285 | 286 | 287 | 288 | 289 | 简体中文 290 | 291 | 292 | 293 | 294 | English 295 | 296 | 297 | 298 | 299 | Basic 300 | 301 | 302 | 303 | 304 | File 305 | 306 | 307 | 308 | 309 | Image Folder 310 | 311 | 312 | 313 | 314 | Update 315 | 316 | 317 | 318 | 319 | Type 320 | 321 | 322 | 323 | 324 | Custom Update Command 325 | 326 | 327 | 328 | 329 | Desktop Environment 330 | 331 | 332 | 333 | 334 | Notification 335 | 336 | 337 | 338 | 339 | Domain 340 | 341 | 342 | 343 | 344 | Auto Update 345 | 346 | 347 | 348 | 349 | Interval 350 | 351 | 352 | 353 | 354 | Security 355 | 356 | 357 | 358 | 359 | Other 360 | 361 | 362 | 363 | 364 | Send Notification 365 | 366 | 367 | 368 | 369 | Subdomain for bing.com 370 | 371 | 372 | 373 | 374 | Autoupdate Bingwallpaper when tool startup 375 | 376 | 377 | 378 | 379 | Check setting Python file's MD5 380 | 381 | 382 | 383 | 384 | Show hint of restart for updating language 385 | 386 | 387 | 388 | 389 | Restore Defaults 390 | 391 | 392 | 393 | 394 | -------------------------------------------------------------------------------- /i18n/zh-CN.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | OneClickBingWallpaper 6 | 7 | 8 | Update 9 | 更新壁纸 10 | 11 | 12 | 13 | Setting 14 | 设置 15 | 16 | 17 | 18 | About 19 | 关于 20 | 21 | 22 | 23 | Quit 24 | 退出 25 | 26 | 27 | 28 | Specific DE 29 | 按桌面环境设置 30 | 31 | 32 | 33 | Language 34 | 语言 35 | 36 | 37 | 38 | Disable 39 | 关闭自动更新 40 | 41 | 42 | 43 | Every 1 minute 44 | 每分钟 45 | 46 | 47 | 48 | Every 5 minute 49 | 每 5 分钟 50 | 51 | 52 | 53 | Every 10 minute 54 | 每 10 分钟 55 | 56 | 57 | 58 | Every 15 minute 59 | 每 15 分钟 60 | 61 | 62 | 63 | Every 30 minute 64 | 每 30 分钟 65 | 66 | 67 | 68 | Every 60 minute 69 | 每 60 分钟 70 | 71 | 72 | 73 | Random 74 | 随机选择图片设置壁纸 75 | 76 | 77 | 78 | 79 | Auto 80 | 自动 81 | 82 | 83 | 84 | 85 | Folder Not Found 86 | 未找到所需的文件夹 87 | 88 | 89 | 90 | Empty folder for %1 , 91 | if you want to update wallpaper for random, please make sure to put some image file in this folder, or use latest first 92 | %1 文件夹为空。 93 | 如果想随机使用图片更新壁纸,请确认该文件夹中有图片文件,或者先用当天图片更新 94 | 95 | 96 | 97 | Empty folder for %1. 98 | If you want to update wallpaper for random, please make sure to put some image file in this folder, or use latest first. 99 | Setting Abort, click YES to open folder, NO to ignore. 100 | %1 文件夹为空。 101 | 如果想随机使用图片更新壁纸,请确认该文件夹中有图片文件,或者先用当天图片更新。 102 | 本次设置终止,点击 Yes 打开文件夹,点击 No 忽略。 103 | 104 | 105 | 106 | A tool to set latest Bingwallpaper in Linux desktop. 107 | 一个在 Linux 桌面环境上设置最新必应壁纸的工具。 108 | 109 | 110 | 111 | 112 | BingWallpaper folder %1 in home is not exist, tool will create it by default 113 | 程序将默认创建不存在的文件夹 %1 114 | 115 | 116 | 117 | Visit Bing 118 | 访问必应 119 | 120 | 121 | 122 | Latest 123 | 用当天的图片设置壁纸 124 | 用当天的图片设置壁纸 125 | 126 | 127 | 128 | Custom 129 | 自定义 130 | 131 | 132 | 133 | Folder not found 134 | 文件夹不存在 135 | 136 | 137 | 138 | Failed to create folder 139 | 文件夹创建失败 140 | 文件夹创建失败 141 | 142 | 143 | 144 | Failed to create folder %1 , you need to create folder manually. use %2 instead. 145 | 创建 %1 文件夹失败,需要手动处理该问题。配置仍用 %2 文件夹. 146 | 147 | 148 | 149 | 150 | Attention! Empty Folder 151 | 注意!空文件夹 152 | 153 | 154 | 155 | Attention! Program works in custom update wallpaper command mode 156 | 注意!当前程序以自定义更新命令模式运行 157 | 158 | 159 | 160 | Please pay attention to your custom update wallpaper command. 161 | 请留意您的自定义壁纸更新命令。 162 | 163 | 164 | 165 | Attention! Need {{}} placeholder 166 | 注意!需要 {{}} 占位符 167 | 168 | 169 | 170 | Need {{}} placeholder, it will be replaced to the final image path. 171 | 需要 {{}} 占位符,它将会被替换成最后的图片地址。 172 | 173 | 174 | 175 | Attention! Program works in latest mode 176 | 注意!程序使用用当天的图片设置壁纸 177 | 注意!程序使用用当天的图片设置壁纸 178 | 179 | 180 | 181 | Interval with latest mode means the same image will be setted in one day. 182 | 更新间隔和使用用当天的图片设置将会导致在同一天内重复设置同一张壁纸 183 | 更新间隔和使用用当天的图片设置将会导致在同一天内重复设置同一张壁纸。 184 | 185 | 186 | 187 | Attention! Program will skipped md5 check 188 | 注意!程序将会跳过MD5检查 189 | 190 | 191 | 192 | Your program distributor has disabled md5 checking features.This option will be ignored 193 | 您的程序分发者关闭了MD5检查功能,该配置将会被忽略 194 | 您的程序分发者关闭了MD5检查功能,该配置将会被忽略 195 | 196 | 197 | 198 | BingWallpaper folder %1 in home is not exist, program will create it by default 199 | 文件夹 %1 不存在,程序将会默认自动创建 200 | 201 | 202 | 203 | Python File Not Found 204 | 未找到 Pyhon 文件 205 | 206 | 207 | 208 | Python file not found,please reinstall. 209 | 未找到 Pyhon 文件,请重装程序。 210 | 211 | 212 | 213 | Python File Have Modified 214 | Python 文件已被修改 215 | 216 | 217 | 218 | Python File Have Modified 219 | Click YES to ignore it 220 | Python 文件已被修改 221 | 点击 Yes 跳过检查设置文件 222 | 223 | 224 | 225 | Error 226 | 错误 227 | 228 | 229 | 230 | Something wrong 231 | 设置过程出错 232 | 233 | 234 | 235 | Please check/adjust your setting or network connection, or just report this issue to maintainer with the following log. 236 | 请调整您的设置或者检查网络连接情况,或者用以下日志向维护者报告这个问题。 237 | 238 | 239 | 240 | Restart required 241 | 需要重启程序 242 | 243 | 244 | 245 | Language update require restart. if update fail, please quit and restart manually 246 | 更新语言需要重启程序,如更新失败,请手动退出再重开程序 247 | 248 | 249 | 250 | QObject 251 | 252 | 253 | Cinnamon 254 | Cinnamon 255 | 256 | 257 | 258 | Deepin 259 | Deepin 260 | 261 | 262 | 263 | Gnome 264 | Gnome 265 | 266 | 267 | 268 | KDE 269 | KDE 270 | 271 | 272 | 273 | LXQt 274 | 275 | 276 | 277 | 278 | Mate 279 | Mate 280 | 281 | 282 | 283 | WM 284 | WM 285 | 286 | 287 | 288 | Xfce 289 | Xfce 290 | 291 | 292 | 293 | Custom 294 | 自定义 295 | 296 | 297 | 298 | 简体中文 299 | 简体中文 300 | 301 | 302 | 303 | English 304 | English 305 | 306 | 307 | 308 | Basic 309 | 基本设置 310 | 311 | 312 | 313 | File 314 | 文件 315 | 316 | 317 | 318 | Image Folder 319 | 图片文件夹 320 | 321 | 322 | 323 | Update 324 | 壁纸更新 325 | 326 | 327 | 328 | Type 329 | 更新方式 330 | 331 | 332 | 333 | Custom Update Command 334 | 自定义更新命令 335 | 336 | 337 | 338 | Desktop Environment 339 | 桌面环境 340 | 341 | 342 | 343 | Notification 344 | 通知 345 | 346 | 347 | 348 | Domain 349 | 域名 350 | 351 | 352 | 353 | Auto Update 354 | 自动更新壁纸 355 | 356 | 357 | 358 | Interval 359 | 更新间隔 360 | 361 | 362 | 363 | Security 364 | 安全 365 | 366 | 367 | 368 | Other 369 | 其他 370 | 371 | 372 | 373 | Send Notification 374 | 发送通知 375 | 376 | 377 | 378 | Subdomain for bing.com 379 | 所用的 bing.com 子域名 380 | 381 | 382 | 383 | Autoupdate Bingwallpaper when tool startup 384 | 当程序启动时自动更新壁纸 385 | 386 | 387 | 388 | Check setting Python file's MD5 389 | 检查设置壁纸的 Python 文件是否被修改 390 | 391 | 392 | 393 | Show hint of restart for updating language 394 | 显示语言切换时的重启提示 395 | 396 | 397 | 398 | Restore Defaults 399 | 恢复默认设置 400 | 401 | 402 | 403 | -------------------------------------------------------------------------------- /OneClickBingWallpaper.cpp: -------------------------------------------------------------------------------- 1 | #include "OneClickBingWallpaper.h" 2 | #include "OneClickBingWallpaperConfig.h" 3 | 4 | 5 | #include 6 | 7 | DWIDGET_USE_NAMESPACE 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | 23 | #include 24 | 25 | OneClickBingWallpaper::OneClickBingWallpaper(QWidget *parent) 26 | : QWidget(parent) 27 | { 28 | DApplication * app; 29 | imagePath = QString("%1/%2").arg( 30 | QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first(), 31 | "BingWallpaper"); 32 | configPath = QString("%1/%2/%3.conf").arg( 33 | QStandardPaths::standardLocations(QStandardPaths::ConfigLocation).first(), 34 | app->organizationName(), 35 | app->applicationName() 36 | ); 37 | backend = new QSettingBackend(configPath); 38 | dsettings = DSettings::fromJsonFile(":/config/settings.json"); 39 | dsettings->setBackend(backend); 40 | 41 | timer = new QTimer(this); 42 | connect(timer, &QTimer::timeout, [this]() { 43 | auto desktopType = dsettings->option("base.update.desktop"); 44 | updateWallpaper(desktopType->value().toString()); 45 | }); 46 | auto interval = dsettings->option("base.autoupdate.interval"); 47 | if(interval->value().toInt() != -1) 48 | { 49 | timer->setInterval(interval->value().toInt()*60*1000); 50 | timer->start(); 51 | } 52 | 53 | initAction(); 54 | initMenu(); 55 | initConnect(); 56 | initSettingOptions(); 57 | initOther(); 58 | } 59 | 60 | OneClickBingWallpaper::~OneClickBingWallpaper() 61 | { 62 | 63 | } 64 | 65 | void OneClickBingWallpaper::initAction() 66 | { 67 | for(int i = 0 ; i < vDesktopEnvironments.size() ; i++) 68 | { 69 | DesktopEnvironmentType item = vDesktopEnvironments[i]; 70 | QAction * action = new QAction(item.name,this); 71 | connect(action,&QAction::triggered,[this,item]() 72 | { 73 | updateWallpaper(item.argument); 74 | }); 75 | vDEActions.push_back( action ); 76 | } 77 | for(int i = 0 ; i < vLanguages.size(); i++) 78 | { 79 | LanguageType item = vLanguages[i]; 80 | QAction * action = new QAction(item.name,this); 81 | connect(action, &QAction::triggered, [this,item]() 82 | { 83 | updateLanguage(item.value); 84 | }); 85 | vLangActions.push_back(action); 86 | } 87 | 88 | updateAction = new QAction(tr("Update"),this); 89 | 90 | settingAction = new QAction(tr("Setting"),this); 91 | 92 | aboutAction = new QAction(tr("About"),this); 93 | 94 | visitBingAction = new QAction(tr("Visit Bing"), this); 95 | 96 | quitAction = new QAction(tr("Quit"),this); 97 | } 98 | 99 | void OneClickBingWallpaper::initMenu() 100 | { 101 | trayMenu = new QMenu(this); 102 | moreMenu = new QMenu(tr("Specific DE"),this); 103 | langMenu = new QMenu(tr("Language"),this); 104 | 105 | QList actionList; 106 | for(auto item : vDEActions) 107 | { 108 | actionList << item ; 109 | } 110 | moreMenu->addActions(actionList); 111 | 112 | actionList.clear(); 113 | for(auto item : vLangActions) 114 | { 115 | actionList << item ; 116 | } 117 | langMenu->addActions(actionList); 118 | 119 | trayMenu->addAction(updateAction); 120 | trayMenu->addMenu(moreMenu); 121 | trayMenu->addMenu(langMenu); 122 | trayMenu->addAction(settingAction); 123 | trayMenu->addAction(aboutAction); 124 | trayMenu->addAction(visitBingAction); 125 | trayMenu->addSeparator(); 126 | trayMenu->addAction(quitAction); 127 | 128 | QIcon icon = QIcon(":/OneClickBingWallpaper.png"); 129 | trayIcon = new QSystemTrayIcon(this); 130 | trayIcon->setIcon(icon); 131 | trayIcon->show(); 132 | trayIcon->setContextMenu(trayMenu); 133 | } 134 | 135 | void OneClickBingWallpaper::initConnect() 136 | { 137 | connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); 138 | connect(dsettings,SIGNAL(valueChanged(QString,QVariant)),this,SLOT(settingsValueChanged(QString,QVariant))); 139 | 140 | connect(updateAction, &QAction::triggered, [this](){ 141 | auto desktopType = dsettings->option("base.update.desktop"); 142 | updateWallpaper(desktopType->value().toString()); 143 | }); 144 | 145 | connect(settingAction,SIGNAL(triggered()),this,SLOT(showSettingWidget())); 146 | 147 | connect(aboutAction,SIGNAL(triggered()),this,SLOT(showAboutWidget())); 148 | connect(visitBingAction,SIGNAL(triggered()),this,SLOT(visitBing())); 149 | 150 | connect(quitAction,&QAction::triggered,[](){ 151 | DApplication * app; 152 | app->exit(0); 153 | }); 154 | } 155 | 156 | void OneClickBingWallpaper::initSettingOptions() 157 | { 158 | auto interval = dsettings->option("base.autoupdate.interval"); 159 | QMap intervalOptions; 160 | intervalOptions.insert("keys", QStringList() << "-1" << "1" << "5" << "10" << "15" << "30" << "60"); 161 | intervalOptions.insert("values", QStringList() << tr("Disable") << tr("Every 1 minute") << tr("Every 5 minute") << tr("Every 10 minute") 162 | << tr("Every 15 minute") << tr("Every 30 minute") << tr("Every 60 minute")); 163 | interval->setData("items",intervalOptions); 164 | 165 | auto updateType = dsettings->option("base.update.type"); 166 | QMap updateTypeOptions; 167 | updateTypeOptions.insert("keys", QStringList() << "latest" << "random" ); 168 | updateTypeOptions.insert("values", QStringList() << tr("Latest") << tr("Random") ); 169 | updateType->setData("items",updateTypeOptions); 170 | 171 | auto subdomainType = dsettings->option("base.domain.subdomain"); 172 | QMap subdomainTypeOptions; 173 | subdomainTypeOptions.insert("keys", QStringList() << "auto" << "https://www.bing.com" << "https://cn.bing.com" << "https://www2.bing.com" << "https://www4.bing.com" ); 174 | subdomainTypeOptions.insert("values", QStringList() << tr("Auto") << "https://www.bing.com" << "https://cn.bing.com" << "https://www2.bing.com" << "https://www4.bing.com" ); 175 | subdomainType->setData("items",subdomainTypeOptions); 176 | 177 | auto desktopType = dsettings->option("base.update.desktop"); 178 | QMap desktopTypeOptions; 179 | desktopTypeOptions.insert("keys", QStringList() << "--auto" << "-d cinnamon" << "-d deepin" << "-d gnome" << "-d kde" << "-d lxqt" << "-d mate" << "-d wm" << "-d xfce" << "-c"); 180 | desktopTypeOptions.insert("values", QStringList() << tr("Auto") << "Cinnamon" << "Deepin" << "Gnome" << "KDE" <<"LXQt"<< "Mate" << "WM" << "Xfce" << tr("Custom")); 181 | desktopType->setData("items", desktopTypeOptions); 182 | } 183 | 184 | void OneClickBingWallpaper::initOther() 185 | { 186 | auto startupEnable = dsettings->option("base.autoupdate.interval"); 187 | auto desktopType = dsettings->option("base.update.desktop"); 188 | if( startupEnable->value().toInt() != -1 ) 189 | { 190 | updateWallpaper(desktopType->value().toString()); 191 | } 192 | } 193 | 194 | void OneClickBingWallpaper::trayIconActivated(QSystemTrayIcon::ActivationReason reason) 195 | { 196 | switch(reason) 197 | { 198 | case QSystemTrayIcon::Context: 199 | this->raise(); 200 | break; 201 | default: 202 | break; 203 | } 204 | } 205 | 206 | void OneClickBingWallpaper::settingsValueChanged(const QString &key, const QVariant &value) 207 | { 208 | qDebug() << "settingsValueChanged " << key << " " << value << Qt::endl; 209 | if(key == "base.file.image-folder") 210 | { 211 | QString newImagePath = QString("%1/%2").arg( 212 | QStandardPaths::standardLocations(QStandardPaths::HomeLocation).first(), 213 | value.toString()); 214 | QDir dir(newImagePath); 215 | qDebug() << "newImagePath" << newImagePath << Qt::endl; 216 | bool bUpdate = true; 217 | if(!dir.exists()) 218 | { 219 | QMessageBox::information(nullptr, tr("Folder not found"), 220 | tr("BingWallpaper folder %1 in home is not exist, tool will create it by default").arg(newImagePath), 221 | QMessageBox::Ok); 222 | bool bUpdate = dir.mkdir(newImagePath); 223 | qDebug() << "create folder " << newImagePath << ":" << bUpdate << Qt::endl; 224 | if(!bUpdate) 225 | { 226 | QMessageBox::information(nullptr, tr("Failed to create folder"), 227 | tr("Failed to create folder %1 , you need to create folder manually. use %2 instead.").arg(newImagePath, imagePath), 228 | QMessageBox::Ok); 229 | } 230 | } 231 | if (bUpdate) 232 | { 233 | imagePath = newImagePath; 234 | } 235 | else 236 | { 237 | auto option = dsettings->option("base.file.image-folder"); 238 | option->setValue(QVariant(imagePath)); 239 | } 240 | } 241 | if(key == "base.update.type" && value.toString() == "random") 242 | { 243 | QDir dir(imagePath); 244 | qDebug() << "imagePath " << imagePath << Qt::endl; 245 | if (!dir.exists()) 246 | { 247 | QMessageBox::information(nullptr, tr("Folder Not Found"), 248 | tr("BingWallpaper folder %1 in home is not exist, tool will create it by default").arg(imagePath), 249 | QMessageBox::Ok); 250 | bool res = dir.mkdir(imagePath); 251 | qDebug() << "create folder " << imagePath << ":" << res << Qt::endl; 252 | } 253 | dir.setFilter(QDir::Files); 254 | if (dir.entryInfoList().count() == 0) 255 | { 256 | QMessageBox::information(nullptr, tr("Attention! Empty Folder"), 257 | tr("Empty folder for %1 ,\n" 258 | "if you want to update wallpaper for random, please make sure to put some image file in this folder, or use latest first").arg(imagePath), 259 | QMessageBox::Ok); 260 | } 261 | } 262 | if(key == "base.update.desktop" && value.toString() == "custom") 263 | { 264 | QMessageBox::information(nullptr, tr("Attention! Program works in custom update wallpaper command mode"), 265 | tr("Please pay attention to your custom update wallpaper command."), QMessageBox::Ok); 266 | } 267 | if(key == "base.update.custom-command") 268 | { 269 | if(!value.toString().contains("{{}}")) 270 | { 271 | QMessageBox::warning(nullptr, tr("Attention! Need {{}} placeholder"), 272 | tr("Need {{}} placeholder, it will be replaced to the final image path."), 273 | QMessageBox::Ok); 274 | } 275 | } 276 | if(key == "base.autoupdate.interval") 277 | { 278 | auto isRandom = dsettings->option("base.update.type"); 279 | if(isRandom->value().toString() == "latest" and value.toInt() != -1 ) 280 | { 281 | QMessageBox::information(nullptr, tr("Attention! Program works in latest mode"), 282 | tr("Interval with latest mode means the same image will be setted in one day."), QMessageBox::Ok); 283 | } 284 | 285 | timer->stop(); 286 | if(value.toInt() != -1 ) 287 | { 288 | timer->setInterval(value.toInt() * 60 * 1000); 289 | timer->start(); 290 | } 291 | } 292 | if(key == "base.security.python-check") 293 | { 294 | if(OneClickBingWallpaperConfig::pyFileMD5 == "{{MD5SUM}}") 295 | { 296 | QMessageBox::information(nullptr, tr("Attention! Program will skipped md5 check"), 297 | tr("Your program distributor has disabled md5 checking features.This option will be ignored"), QMessageBox::Ok); 298 | } 299 | } 300 | } 301 | 302 | void OneClickBingWallpaper::updateWallpaper(QString argument) 303 | { 304 | bool pyFileVaild = true; 305 | auto pythonCheck = dsettings->option("base.security.python-check"); 306 | auto isRandom = dsettings->option("base.update.type"); 307 | auto imageFolder = dsettings->option("base.file.image-folder"); 308 | auto isNotifyEnable = dsettings->option("base.notification.enable"); 309 | auto subDomain = dsettings->option("base.domain.subdomain"); 310 | auto customCommand = dsettings->option("base.update.custom-command"); 311 | QDir dir(imagePath); 312 | 313 | if (!dir.exists()) 314 | { 315 | QMessageBox::information(nullptr, tr("Folder Not Found"), 316 | tr("BingWallpaper folder %1 in home is not exist, program will create it by default").arg(imagePath), 317 | QMessageBox::Ok); 318 | bool res = dir.mkdir(imagePath); 319 | qDebug() << "create folder " << imagePath << ":" << res << Qt::endl; 320 | } 321 | 322 | dir.setFilter(QDir::Files); 323 | 324 | if(!QFile::exists(OneClickBingWallpaperConfig::pyFilePath)) 325 | { 326 | QMessageBox::warning(nullptr, tr("Python File Not Found"), tr("Python file not found,please reinstall."), QMessageBox::Ok); 327 | return; 328 | } 329 | 330 | if(dir.entryInfoList().count() == 0 && isRandom->value().toString() == "random") 331 | { 332 | QMessageBox::StandardButton choice; 333 | choice = QMessageBox::information(nullptr, tr("Attention! Empty Folder"), 334 | tr("Empty folder for %1.\n" 335 | "If you want to update wallpaper for random, please make sure to put some image file in this folder, or use latest first.\n" 336 | "Setting Abort, click YES to open folder, NO to ignore.").arg(imagePath), 337 | QMessageBox::Yes, QMessageBox::No); 338 | if (choice == QMessageBox::Yes) 339 | { 340 | bool ok = QDesktopServices::openUrl(QUrl(imagePath)); 341 | qDebug() << "open folder :" << ok << Qt::endl; 342 | } 343 | return; 344 | } 345 | 346 | if(pythonCheck->value().toBool()) 347 | { 348 | QFile pyFile(OneClickBingWallpaperConfig::pyFilePath); 349 | if (pyFile.open(QFile::ReadOnly)) 350 | { 351 | QCryptographicHash hash(QCryptographicHash::Md5); 352 | hash.addData(&pyFile); 353 | QString md5 = hash.result().toHex(); 354 | qDebug() << OneClickBingWallpaperConfig::pyFilePath << md5 << Qt::endl; 355 | if (OneClickBingWallpaperConfig::pyFileMD5 != "{{MD5SUM}}" && md5 != OneClickBingWallpaperConfig::pyFileMD5) 356 | { 357 | QMessageBox::StandardButton choice; 358 | choice = QMessageBox::information(nullptr, tr("Python File Have Modified"), 359 | tr("Python File Have Modified\nClick YES to ignore it"), 360 | QMessageBox::Yes, QMessageBox::No); 361 | if (choice == QMessageBox::No) 362 | pyFileVaild = false; 363 | } 364 | } 365 | } 366 | 367 | if (pyFileVaild) 368 | { 369 | QProcess *process = new QProcess; 370 | if (argument == "-c") 371 | { 372 | argument = QString("%1 \"%2\"").arg(argument, customCommand->value().toString()); 373 | } 374 | QString command = QString("python3"); 375 | QStringList commandArg; 376 | commandArg.append(OneClickBingWallpaperConfig::pyFilePath); 377 | commandArg.append(argument); 378 | if (isRandom->value().toString() == "random") 379 | { 380 | commandArg.append(" --random"); 381 | } 382 | if (!isNotifyEnable->value().toBool()) 383 | { 384 | commandArg.append(" --silent"); 385 | } 386 | if (imageFolder->value().toString() != "") 387 | { 388 | commandArg.append(" -folder "); 389 | commandArg.append(imageFolder->value().toString()); 390 | } 391 | if (subDomain->value().toString() != "auto") 392 | { 393 | commandArg.append(" -baseurl "); 394 | commandArg.append(subDomain->value().toString()); 395 | } 396 | 397 | qDebug() << "command " << command << Qt::endl; 398 | qDebug() << "commandArg " << commandArg << Qt::endl; 399 | 400 | process->start(command, commandArg); 401 | process->waitForFinished(); 402 | 403 | QByteArray error_byte = process->readAllStandardError(); 404 | QString error = error_byte; 405 | 406 | if (process->exitCode() != 0 || process->exitStatus() != QProcess::ExitStatus::NormalExit) 407 | { 408 | QTextBrowser *text = new QTextBrowser(); 409 | text->resize(400, 300); 410 | text->setWindowTitle(tr("Error")); 411 | text->append("------------------------------------------------------"); 412 | text->append(tr("Something wrong ")); 413 | text->append(tr("Please check/adjust your setting or network connection, " 414 | "or just report this issue to maintainer with the following log.")); 415 | text->append("------------------------------------------------------"); 416 | text->append(error); 417 | text->show(); 418 | } 419 | qDebug() << "error:" << error << Qt::endl; 420 | } 421 | } 422 | 423 | void OneClickBingWallpaper::updateLanguage(QString value) 424 | { 425 | DApplication * app; 426 | QSettings settings(app->organizationName(),app->applicationName()); 427 | 428 | qDebug() << settings.value("lang") << Qt::endl; 429 | settings.setValue("lang",value); 430 | qDebug() << settings.value("lang") << Qt::endl; 431 | 432 | auto hint = dsettings->option("base.other.language-update-hint"); 433 | if(hint->value().toBool()) 434 | { 435 | QMessageBox::information(nullptr, tr("Restart required"), 436 | tr("Language update require restart. if update fail, please quit and restart manually"), 437 | QMessageBox::Ok); 438 | } 439 | if (app->arguments().size() <= 0) 440 | { 441 | QMessageBox::information(nullptr, tr("Unexcepted program argument"), 442 | tr("Unexcepted program argument"), 443 | QMessageBox::Ok); 444 | return; 445 | } 446 | app->quit(); 447 | QStringList emptyArg; 448 | QProcess::startDetached(app->arguments()[0], emptyArg); 449 | } 450 | 451 | void OneClickBingWallpaper::showSettingWidget() 452 | { 453 | DSettingsDialog * dialog = new DSettingsDialog(this); 454 | dialog->updateSettings(dsettings); 455 | dialog->move(( DApplication::desktop()->width()-dialog->width() )/2,( DApplication::desktop()->height()-dialog->height() )/2 ); 456 | dialog->show(); 457 | } 458 | 459 | void OneClickBingWallpaper::showAboutWidget() 460 | { 461 | DAboutDialog * dialog = new DAboutDialog(this); 462 | 463 | QIcon icon; 464 | icon.addFile(":/OneClickBingWallpaper.png",QSize(96,96)); 465 | QPixmap emptyPixmap; 466 | DApplication * app; 467 | 468 | QString version = QString("v%1.%2.%3").arg(QString::number(MAJOR_VERSION), QString::number(MINOR_VERSION), QString::number(PATCH_VERSION)); 469 | 470 | dialog->setAttribute(Qt::WA_DeleteOnClose) ; 471 | dialog->setProductIcon(icon); 472 | dialog->setProductName(app->applicationDisplayName()); 473 | dialog->setVersion(QString("%1 #%2").arg(version, OneClickBingWallpaperConfig::latestCommitHash)); 474 | dialog->setAcknowledgementLink("https://github.com/ypingcn/BingWallpaper/wiki/Acknowledgement"); 475 | dialog->setWebsiteName("https://github.com/ypingcn/BingWallpaper"); 476 | dialog->setWebsiteLink("https://github.com/ypingcn/BingWallpaper"); 477 | dialog->setCompanyLogo(emptyPixmap); 478 | dialog->setDescription(tr("A tool to set latest Bingwallpaper in Linux desktop.")); 479 | dialog->show(); 480 | dialog->move(( DApplication::desktop()->width()-dialog->width() )/2,( DApplication::desktop()->height()-dialog->height() )/2 ); 481 | } 482 | 483 | void OneClickBingWallpaper::visitBing() 484 | { 485 | QDesktopServices::openUrl(QUrl("https://www.bing.com")); 486 | } 487 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | --------------------------------------------------------------------------------