конфиги начало
This commit is contained in:
parent
f0791a5ff3
commit
efc5fc1501
1
config
Normal file
1
config
Normal file
@ -0,0 +1 @@
|
|||||||
|
path_to_wallpapers = "/home/arthur/img/Wallpapers/wallpyper"
|
24
func.py
24
func.py
@ -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,20 @@ 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():
|
||||||
|
config = configParsing()
|
||||||
|
|
||||||
|
PATH = config['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':
|
||||||
@ -34,3 +40,5 @@ def setWallPaper():
|
|||||||
else:
|
else:
|
||||||
run(f"back4.sh auto {PATH}{media} & echo $! > /tmp/back4.sh.pid",True)
|
run(f"back4.sh auto {PATH}{media} & echo $! > /tmp/back4.sh.pid",True)
|
||||||
# > tmp/back4.sh.pid write PID for kill()
|
# > tmp/back4.sh.pid write PID for kill()
|
||||||
|
|
||||||
|
setWallPaper()
|
||||||
|
Loading…
Reference in New Issue
Block a user