Add shuffle option

This commit is contained in:
James H
2021-12-04 00:27:12 +00:00
parent 47770eda6f
commit a107e4e966

View File

@@ -1,5 +1,6 @@
import argparse import argparse
import os import os
import random
import xml.etree.ElementTree as ET import xml.etree.ElementTree as ET
@@ -28,6 +29,7 @@ def main():
parser.add_argument("--xmlpath", type=str, help="Path to save the XML file containing the list of image files. (default: stored in the images folder)") parser.add_argument("--xmlpath", type=str, help="Path to save the XML file containing the list of image files. (default: stored in the images folder)")
parser.add_argument("--duration", "-d", type=int, help=f"Duration between each image in seconds (default: {DEFAULT_DURATION})") parser.add_argument("--duration", "-d", type=int, help=f"Duration between each image in seconds (default: {DEFAULT_DURATION})")
parser.add_argument("--transduration", "-t", type=int, help=f"Duration of transition between images (default: {DEFAULT_TRANSITION_DURATION})") parser.add_argument("--transduration", "-t", type=int, help=f"Duration of transition between images (default: {DEFAULT_TRANSITION_DURATION})")
parser.add_argument("-s", "--shuffle", action="store_true", help="Turn on shuffling of images")
args = parser.parse_args() args = parser.parse_args()
@@ -37,6 +39,7 @@ def main():
recursive = args.recursive recursive = args.recursive
duration = args.duration duration = args.duration
transduration = args.transduration transduration = args.transduration
shuffle = args.shuffle
gnomepath = os.path.abspath(os.path.expandvars(GNOME_BACKGROUNDS_PATH)) gnomepath = os.path.abspath(os.path.expandvars(GNOME_BACKGROUNDS_PATH))
@@ -61,6 +64,9 @@ def main():
files = getFiles(imagepath, recursive) files = getFiles(imagepath, recursive)
if shuffle:
random.shuffle(files)
if not os.path.exists(gnomepath): if not os.path.exists(gnomepath):
os.makedirs(gnomepath) os.makedirs(gnomepath)