From 4e8c78915f6cb70b70b3e0d85d9981eec7aa1d0b Mon Sep 17 00:00:00 2001 From: Arthur Date: Sun, 3 Jul 2022 17:07:01 +0500 Subject: [PATCH] update --- README.md | 29 +++++++++++++++++++++++++++++ func.py | 14 ++++++++------ main.py | 7 ++++++- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 51b15fb..06e626c 100644 --- a/README.md +++ b/README.md @@ -26,16 +26,22 @@ Arch: pacman -S feh ``` + + **foo-Wallpaper-feh-gif** is just bash script, you can download it [here](https://github.com/thomas10-10/foo-Wallpaper-Feh-Gif/blob/master/back4.sh) ``` curl -L https://raw.githubusercontent.com/thomas10-10/foo-Wallpaper-Feh-Gif/master/install.sh | bash ``` + + Install apscheduler ``` pip install apscheduler ``` + + Then download WallPyPer and make main.py an run file. ``` git clone https://github.com/KarimullinArthur/WallPyPer.git @@ -55,9 +61,32 @@ ln -s /main.py wallpyper The absolute path you cat get via command *pwd* +## Configuration + +Create conifg in *~/.config/wallpyper/config* +and put this: +``` +{ + "path_to_wallpapers":"your_path", + "second":"*", + "minute":"*/1", + "hour":"*" +} +``` + +Where *path_to_wallpapers* is *absolute* path to wallpapers. +*second*, *minute* and *hour* set auto change via cron. + + +(More infarmation about cron)[https://en.wikipedia.org/wiki/Cron] +(crontab.guru)[https://crontab.guru] + ## Auto Start For **i3wm** add in your ~/.conifg/i3/config one string: ``` exec wallpyper ``` + +Author - Karimullin Arthur + Mail - KarimullinArthur@riseup.net diff --git a/func.py b/func.py index 3d137be..dc0552e 100644 --- a/func.py +++ b/func.py @@ -21,16 +21,18 @@ def kill(): def configParsing(): pathToConfig = os.path.expanduser('~')+'/.config/wallpyper/config' - - with open(pathToConfig) as file: - contentFile = file.read() - config = json.loads(contentFile) - return config + try: + with open(pathToConfig) as file: + contentFile = file.read() + config = json.loads(contentFile) + return config + except FileNotFoundError: + createConfig() def setWallPaper(): config = configParsing() - PATH = config['path_to_wallpapers'] + PATH = configParsing['path_to_wallpapers'] files = os.listdir(PATH) media = random.choices(files)[0] diff --git a/main.py b/main.py index 7e74025..b71e19e 100755 --- a/main.py +++ b/main.py @@ -15,5 +15,10 @@ if __name__ == '__main__': start() sched = BlockingScheduler() - sched.add_job(start,'interval',minutes=configParsing()['value']) + + sched.add_job(start,'cron',\ + second=configParsing()['second'],\ + minute=configParsing()['minute'],\ + hour=configParsing()['hour']) + sched.start()