From f052636222164e2aa3c9e1a841d238e8534b751d Mon Sep 17 00:00:00 2001 From: Brian Zalewski Date: Wed, 2 Nov 2022 21:57:48 +0000 Subject: [PATCH] Update dotfiles/.local/bin/ksetwallpaper Deleted dotfiles/.config/plasma-org.kde.plasma.desktop-appletsrc --- .../plasma-org.kde.plasma.desktop-appletsrc | 2 - dotfiles/.local/bin/ksetwallpaper | 107 ++++++++++++++++++ 2 files changed, 107 insertions(+), 2 deletions(-) delete mode 100644 dotfiles/.config/plasma-org.kde.plasma.desktop-appletsrc create mode 100644 dotfiles/.local/bin/ksetwallpaper diff --git a/dotfiles/.config/plasma-org.kde.plasma.desktop-appletsrc b/dotfiles/.config/plasma-org.kde.plasma.desktop-appletsrc deleted file mode 100644 index 80c6e168..00000000 --- a/dotfiles/.config/plasma-org.kde.plasma.desktop-appletsrc +++ /dev/null @@ -1,2 +0,0 @@ -[Containments][1][Wallpaper][org.kde.image][General] -Image=file:///usr/share/wallpapers/Next/contents/images/3440x1440.jpg diff --git a/dotfiles/.local/bin/ksetwallpaper b/dotfiles/.local/bin/ksetwallpaper new file mode 100644 index 00000000..c52d8e66 --- /dev/null +++ b/dotfiles/.local/bin/ksetwallpaper @@ -0,0 +1,107 @@ +#!/usr/bin/env python3 +import time +import dbus +import argparse +import glob +import random +import os +import subprocess +from pathlib import Path +HOME = str(Path.home()) +SCREEN_LOCK_CONFIG = HOME+"/.config/kscreenlockerrc" +def setwallpaper(filepath, plugin='org.kde.image'): + jscript = """ + var allDesktops = desktops(); + print (allDesktops); + for (i=0;i 0: + wallpaper_count = len(wallapapers) + delta_s = timer + s = int(delta_s % 60) + m = int((delta_s / 60) % 60) + h = int((delta_s / 3600) % 3600) + if h > 0: + timer_show = f"{h}h {m}m {s}s" + elif m > 0: + timer_show = f"{m}m {s}s" + elif s > 0: + timer_show = f"{s}s" + print( + f"Looping through {wallpaper_count} wallpapers every {timer_show}") + while True: + if is_locked() != True: + random_int = random.randint(0, wallpaper_count-1) + wallpaper_now = wallapapers[random_int] + setwallpaper(wallpaper_now, plugin) + if lock_screen == True: + set_lockscreen_wallpaper(wallpaper_now, plugin) + time.sleep(timer) + else: + raise ValueError('Invalid --timer value') + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='KDE Wallpaper setter') + parser.add_argument('--file','-f', help='Wallpaper file name', default=None) + parser.add_argument( + '--plugin', '-p', help='Wallpaper plugin (default is org.kde.image)', default='org.kde.image') + parser.add_argument('--dir', '-d', type=str, + help='Absolute path of folder containging your wallpapers for slideshow', default=None) + parser.add_argument('--timer', '-t', type=int, + help='Time in seconds between wallpapers', default=900) + parser.add_argument('--lock-screen', '-l', action="store_true", + help="Set lock screen wallpaper") + args = parser.parse_args() + + if args.file != None: + setwallpaper(filepath=args.file, plugin=args.plugin) + if args.lock_screen == True: + set_lockscreen_wallpaper(filepath=args.file, plugin=args.plugin) + + elif args.dir != None: + wallpapers = get_walls_from_folder(args.dir) + + wallpaper_slideshow(wallapapers=wallpapers, + plugin=args.plugin, timer=args.timer,lock_screen=args.lock_screen) + else: + print("Need help? use -h or --help")