arch/roles/dots/files/home/bin/pywall.py

43 lines
1.1 KiB
Python
Raw Normal View History

2024-09-04 00:54:15 +06:00
#!/bin/python3
import os
import random
import time
import sys
path = '/home/fs/Pictures/pic/new_hidpi_wallpaper'
2025-02-15 20:38:47 +06:00
# path = '/home/fs/Pictures/pic/mafu_wallpaper/'
minute = 10
2024-09-04 00:54:15 +06:00
2025-02-15 20:38:47 +06:00
server = os.getenv('XDG_SESSION_TYPE')
2024-09-04 00:54:15 +06:00
if server == 'wayland':
command = 'killall swaybg; swaybg -i "{}" -m fill &'
else:
2024-09-16 22:32:45 +06:00
command = 'feh --randomize --bg-fill "{}"'
2024-09-04 00:54:15 +06:00
if len(sys.argv) > 1:
if sys.argv[1] == '-w':
while True:
files = [os.path.join(path, f) for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))]
random_file = random.choice(files)
os.system(command.format(random_file))
time.sleep(minute * 60)
elif sys.argv[1] == 'black':
p = '/home/fs/Pictures/blank.png'
os.system(command.format(p))
if sys.argv[1] == '-r':
files = [os.path.join(path, f) for f in os.listdir(path) if os.path.isfile(os.path.join(path, f))]
random_file = random.choice(files)
os.system(command.format(random_file))
2024-10-14 00:46:34 +06:00
exit()
2024-09-04 00:54:15 +06:00
else:
os.system(command.format(sys.argv[1]))
2024-10-14 00:46:34 +06:00
exit()