Merge pull request #3 from KarimullinArthur/config

Config file
This commit is contained in:
KarimullinArthur 2022-07-03 18:11:57 +05:00 committed by GitHub
commit 103b3ece03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 71 additions and 10 deletions

View File

@ -26,16 +26,22 @@ Arch:
pacman -S feh 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) **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 curl -L https://raw.githubusercontent.com/thomas10-10/foo-Wallpaper-Feh-Gif/master/install.sh | bash
``` ```
Install apscheduler Install apscheduler
``` ```
pip install apscheduler pip install apscheduler
``` ```
Then download WallPyPer and make main.py an run file. Then download WallPyPer and make main.py an run file.
``` ```
git clone https://github.com/KarimullinArthur/WallPyPer.git git clone https://github.com/KarimullinArthur/WallPyPer.git
@ -55,9 +61,38 @@ ln -s <abs_path_to_download_repo>/main.py wallpyper
The absolute path you cat get via command *pwd* 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 ## Auto Start
For **i3wm** add in your ~/.conifg/i3/config one string: For **i3wm** add in your ~/.conifg/i3/config one string:
``` ```
exec wallpyper exec wallpyper
``` ```
Author - Karimullin Arthur
<<<<<<< HEAD
Mail - KarimullinArthur@riseup.net
=======
Mail - KarimullinArthur@riseup.net
>>>>>>> ab56d78a72b6396219c6b4014216fc6001b0c265

View File

@ -47,6 +47,24 @@ ln -s <абсолютный_путь_к_скачанному_репозитор
Абсолютный путь можно получить командной pwd в катологе WallPyPery. Абсолютный путь можно получить командной 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 строчку: Для **i3wm** добавте в свой ~/.config/i3/config строчку:

19
func.py
View File

@ -1,14 +1,7 @@
import json
import os import os
import random import random
import sys 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): def run(command,output=False):
devNull = ">/dev/null" devNull = ">/dev/null"
@ -26,7 +19,17 @@ def kill():
for pid in file: for pid in file:
run(f'kill {pid}') 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(): def setWallPaper():
PATH = configParsing()['path_to_wallpapers']
files = os.listdir(PATH)
media = random.choices(files)[0] media = random.choices(files)[0]
if media[-4:] != '.gif': if media[-4:] != '.gif':

View File

@ -15,5 +15,10 @@ if __name__ == '__main__':
start() start()
sched = BlockingScheduler() sched = BlockingScheduler()
sched.add_job(start,'interval',minutes=1)
sched.start() sched.add_job(start,'cron',\
second=configParsing()['second'],\
minute=configParsing()['minute'],\
hour=configParsing()['hour'])
sched.start()