代码拉取完成,页面将自动刷新
同步操作将从 Gitee 极速下载/QuickWall 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env python3
"""Uses unsplash API to set wallpapers from the cli."""
import requests
import argparse
from QuickWall.SetPaper import SetPaper
from QuickWall.utility import (
is_nitrogen,
clear_cache,
migrate_to_new_loc
)
from QuickWall.logger import Logger
from QuickWall.setter import WallSetter
from QuickWall.wall import Wall
from QuickWall.blacklist import Blacklist
# Declare the logger
logger = Logger("main")
def parse():
"""Parse the arguments."""
parser = argparse.ArgumentParser(description="QuickWall - Quickly set\
latest wallpapers from Unsplash\
directly from the commandline.",
epilog="If you find any bugs, feel\
free to raise an issue in the GitHub\
[https://github.com/deepjyoti30/QuickWall] page.")
parser.add_argument('--version', action='version', version='0.0.2',
help='show the program version number and exit')
parser.add_argument('--clear-cache', help="Clear the cache from the\
cache folder (~/.cache/QuickWall)", action='store_true')
parser.add_argument('--setter', help="Wallpaper setter to be used.\
Currently supported ones: nitrogen, feh (default: nitrogen)",
type=str, default=None)
parser.add_argument('-d', '--disable-blacklist', help="Disable adding the\
image to blacklisted ones.", action="store_true")
parser.add_argument('--remove-id', help="Remove the passed ID\
from the blacklist.", default=None, type=str, metavar="ID")
parser.add_argument('--dir', help="Directory to download the wallpapers",
type=str, default=None)
parser.add_argument('--id', help="Get a photo by its ID.",
type=str, default=None, metavar="ID")
parser.add_argument('--random', help="Get random wallpapers.",
action="store_true")
parser.add_argument('--search', help="Show wallpapers based on the\
passed term", type=str, metavar="TERM")
parser.add_argument('--migrate', help="ONLY FOR EARLY USERS. Move the files\
from ~/.QuickWall to ~/.cache/QuickWall.", action="store_true")
parser.add_argument('--set-lockscreen', help="Set lockscreen wallpaper (currently for KDE)",
action='store_true')
args = parser.parse_args()
return args
def main():
# Parse the arguments
args = parse()
if args.clear_cache:
clear_cache()
exit(0)
if args.migrate:
migrate_to_new_loc()
exit(0)
if args.remove_id:
blacklist = Blacklist(args.remove_id).remove_blacklist()
exit(0)
wall = Wall(photo_id=args.id, random=args.random, search=args.search)
# Get the wallpaper setter
if args.setter is None:
args.setter = WallSetter._detect_setter()
wall_setter = WallSetter(args.setter, args.set_lockscreen)
setter = wall_setter.get_setter()
logger.info("Getting the wallpapers using Unsplash API...")
paper_list = wall.get_list()
# If the dir is None, update it
if args.dir is None:
args.dir = "~/.cache/QuickWall"
set_paper = SetPaper(paper_list, setter, args.dir, args.disable_blacklist)
set_paper.do()
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
logger.info("Keyboard Interrupt passed. Exiting..!")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。