diff options
Diffstat (limited to '.config/sway/bin/wallpaper.py')
-rwxr-xr-x | .config/sway/bin/wallpaper.py | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/.config/sway/bin/wallpaper.py b/.config/sway/bin/wallpaper.py index 449e5f3..906b9fe 100755 --- a/.config/sway/bin/wallpaper.py +++ b/.config/sway/bin/wallpaper.py @@ -4,6 +4,7 @@ import sys, os import argparse, json import random, re, subprocess, time +import datetime """ @@ -93,7 +94,33 @@ while True: found_file_paths = filtered_file_paths # select file - selected_file_path = random.choice(found_file_paths) + selected_file_path = '' + tries = 0 + while True: + selected_file_path = random.choice(found_file_paths) + + now_hour = datetime.datetime.now().hour + if now_hour > 6 and now_hour < 17: # daylight + break + + identify_process = subprocess.run(['identify', '-format', '%[fx:mean]', selected_file_path], capture_output=True, text=True) + brightness = float(identify_process.stdout) + if brightness < 0.35: # non-bright image + break + else: + # remove identified bright image from possible selections + found_file_paths.remove(selected_file_path) + + if args.unique: + already_selected_file_paths[selected_config['id']].append(selected_file_path) + + # can't find suitable image + tries += 1 + if tries >= len(found_file_paths) - 1: + if args.unique: + already_selected_file_paths[selected_config['id']] = [] + + break if args.unique: already_selected_file_paths[selected_config['id']].append(selected_file_path) |