#!/bin/python3 import os import random import time import sys path = '/home/fs/Pictures/pic/new_hidpi_wallpaper' # path = '/home/fs/Pictures/pic/mafu_wallpaper/' minute = 10 server = os.getenv('XDG_SESSION_TYPE') if server == 'wayland': command = 'killall swaybg; swaybg -i "{}" -m fill &' else: command = 'feh --randomize --bg-fill "{}"' 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)) exit() else: os.system(command.format(sys.argv[1])) exit()