From efc5fc1501c44bfe636e9d86f151d4fc3b445f1d Mon Sep 17 00:00:00 2001 From: Arthur Date: Sat, 2 Jul 2022 20:34:01 +0500 Subject: [PATCH 1/8] =?UTF-8?q?=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3=D0=B8?= =?UTF-8?q?=20=D0=BD=D0=B0=D1=87=D0=B0=D0=BB=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config | 1 + func.py | 24 ++++++++++++++++-------- main.py | 4 ++-- 3 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 config diff --git a/config b/config new file mode 100644 index 0000000..2eda8e2 --- /dev/null +++ b/config @@ -0,0 +1 @@ +path_to_wallpapers = "/home/arthur/img/Wallpapers/wallpyper" diff --git a/func.py b/func.py index 908eb29..3d137be 100644 --- a/func.py +++ b/func.py @@ -1,14 +1,7 @@ +import json import os import random import sys -home = os.path.expanduser('~') -sys.path.insert(0, home+"/.config") -#sys.path.insert(0, '.config/wallpyper') -from wallpyper import config - - -PATH = config.path_to_wallpapers -files = os.listdir(PATH) def run(command,output=False): devNull = ">/dev/null" @@ -26,7 +19,20 @@ def kill(): for pid in file: run(f'kill {pid}') +def configParsing(): + pathToConfig = os.path.expanduser('~')+'/.config/wallpyper/config' + + with open(pathToConfig) as file: + contentFile = file.read() + config = json.loads(contentFile) + return config + def setWallPaper(): + config = configParsing() + + PATH = config['path_to_wallpapers'] + files = os.listdir(PATH) + media = random.choices(files)[0] if media[-4:] != '.gif': @@ -34,3 +40,5 @@ def setWallPaper(): else: run(f"back4.sh auto {PATH}{media} & echo $! > /tmp/back4.sh.pid",True) # > tmp/back4.sh.pid write PID for kill() + +setWallPaper() diff --git a/main.py b/main.py index 0446342..7e74025 100755 --- a/main.py +++ b/main.py @@ -15,5 +15,5 @@ if __name__ == '__main__': start() sched = BlockingScheduler() - sched.add_job(start,'interval',minutes=1) - sched.start() + sched.add_job(start,'interval',minutes=configParsing()['value']) + sched.start() From 82047e0cc130c48bb0aa9e507605f4e7ea4dd23f Mon Sep 17 00:00:00 2001 From: Arthur Date: Sat, 2 Jul 2022 20:35:59 +0500 Subject: [PATCH 2/8] update --- config | 1 - 1 file changed, 1 deletion(-) delete mode 100644 config diff --git a/config b/config deleted file mode 100644 index 2eda8e2..0000000 --- a/config +++ /dev/null @@ -1 +0,0 @@ -path_to_wallpapers = "/home/arthur/img/Wallpapers/wallpyper" From bb669ed7fa587fd8ba43bc824f40e0fc8d7e0222 Mon Sep 17 00:00:00 2001 From: Arthur Date: Sun, 3 Jul 2022 17:04:20 +0500 Subject: [PATCH 3/8] =?UTF-8?q?=D0=95=D1=81=D1=82=D1=8C=20=D0=B1=D0=B0?= =?UTF-8?q?=D0=B7=D0=BE=D0=B2=D1=8B=D0=B5=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8?= =?UTF-8?q?=D0=B3=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README_ru.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/docs/README_ru.md b/docs/README_ru.md index da284a9..bfcb51e 100644 --- a/docs/README_ru.md +++ b/docs/README_ru.md @@ -47,6 +47,24 @@ ln -s <абсолютный_путь_к_скачанному_репозитор Абсолютный путь можно получить командной pwd в катологе WallPyPery. +## Настройка + +Создайте конфигурационный факл в ~/.config/wallpyper/config +И запиши туда этот конфиг: +``` +{ + "path_to_wallpapers":"your_path", + "second":"*", + "minute":"*/1", + "hour":"*" +} +``` +Где *path_to_wallpapers* это *абсолютный* путь к твоим обоям. +*second*, *minute* и *hour* устанавливают интервал изменения с помощью крона. + +(Больше информации о Cron)[https://ru.wikipedia.org/wiki/Cron] +(crontab.guru)[https://crontab.guru] + ## Автозагрузка Для **i3wm** добавте в свой ~/.config/i3/config строчку: From 4e8c78915f6cb70b70b3e0d85d9981eec7aa1d0b Mon Sep 17 00:00:00 2001 From: Arthur Date: Sun, 3 Jul 2022 17:07:01 +0500 Subject: [PATCH 4/8] 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() From 55d09ddd45fa6f0eb1efedcc73df20bf707ea51a Mon Sep 17 00:00:00 2001 From: KarimullinArthur Date: Sun, 3 Jul 2022 17:15:56 +0500 Subject: [PATCH 5/8] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 06e626c..7f20939 100644 --- a/README.md +++ b/README.md @@ -78,8 +78,8 @@ 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] +[More infarmation about cron](https://en.wikipedia.org/wiki/Cron) +[crontab.guru](https://crontab.guru) ## Auto Start From e7754a163860f606b25f0ecf399a9f8fc2e40135 Mon Sep 17 00:00:00 2001 From: Arthur Date: Sun, 3 Jul 2022 17:16:54 +0500 Subject: [PATCH 6/8] update --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 7f20939..fb53bea 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,7 @@ Where *path_to_wallpapers* is *absolute* path to wallpapers. [More infarmation about cron](https://en.wikipedia.org/wiki/Cron) + [crontab.guru](https://crontab.guru) ## Auto Start @@ -89,4 +90,5 @@ exec wallpyper ``` Author - Karimullin Arthur + Mail - KarimullinArthur@riseup.net From ab56d78a72b6396219c6b4014216fc6001b0c265 Mon Sep 17 00:00:00 2001 From: KarimullinArthur Date: Sun, 3 Jul 2022 17:18:23 +0500 Subject: [PATCH 7/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fb53bea..b3713b2 100644 --- a/README.md +++ b/README.md @@ -91,4 +91,4 @@ exec wallpyper Author - Karimullin Arthur - Mail - KarimullinArthur@riseup.net +Mail - KarimullinArthur@riseup.net From a898f5edd185757262b8ff7265c488c0902ed0d6 Mon Sep 17 00:00:00 2001 From: Arthur Date: Sun, 3 Jul 2022 17:46:29 +0500 Subject: [PATCH 8/8] =?UTF-8?q?=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 - func.py | 19 ++++++------------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index fb53bea..7653ae1 100644 --- a/README.md +++ b/README.md @@ -90,5 +90,4 @@ exec wallpyper ``` Author - Karimullin Arthur - Mail - KarimullinArthur@riseup.net diff --git a/func.py b/func.py index dc0552e..2dcf174 100644 --- a/func.py +++ b/func.py @@ -21,20 +21,15 @@ def kill(): def configParsing(): pathToConfig = os.path.expanduser('~')+'/.config/wallpyper/config' - try: - with open(pathToConfig) as file: - contentFile = file.read() - config = json.loads(contentFile) - return config - except FileNotFoundError: - createConfig() + with open(pathToConfig) as file: + contentFile = file.read() + config = json.loads(contentFile) + return config def setWallPaper(): - config = configParsing() - - PATH = configParsing['path_to_wallpapers'] + PATH = configParsing()['path_to_wallpapers'] files = os.listdir(PATH) - + media = random.choices(files)[0] if media[-4:] != '.gif': @@ -42,5 +37,3 @@ def setWallPaper(): else: run(f"back4.sh auto {PATH}{media} & echo $! > /tmp/back4.sh.pid",True) # > tmp/back4.sh.pid write PID for kill() - -setWallPaper()