install.fairie/dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_ksetwallpaper
Brian Zalewski 7bd467cb73 Update dotfiles/.local/share/chezmoi/home/Library/Application Support/tabby/plugins/symlink_package-lock.json, dotfiles/.local/share/chezmoi/home/Library/Developer/Xcode/UserData/FontAndColorThemes/Betelgeuse Dark.dvtcolortheme, dotfiles/.local/share/chezmoi/home/Library/Developer/Xcode/UserData/FontAndColorThemes/Betelgeuse Light.dvtcolortheme, dotfiles/.local/share/chezmoi/home/Library/Preferences/com.apple.Terminal.plist, dotfiles/.local/share/chezmoi/home/run_update, dotfiles/.local/share/chezmoi/home/AppData/Local/clink/oh-my-posh.lua, dotfiles/.local/share/chezmoi/home/.chezmoitemplates/chassis-info, dotfiles/.local/share/chezmoi/home/.chezmoitemplates/cpu-info, dotfiles/.local/share/chezmoi/home/.chezmoitemplates/profile.sh, dotfiles/.local/share/chezmoi/home/dot_cache/zsh/.gitkeep, dotfiles/.local/share/chezmoi/home/dot_local/assets/Betelgeuse.macOS.terminal, dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_bwc, dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_chrome-profile-export, dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_chrome-profile-import, dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_firefox-profile-export, dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_firefox-profile-import, dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_fonttest, dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_install-dotfiles, dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_install-terminal-theme, dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_ksetwallpaper, dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_logg, dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_opener, dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_provision, dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_quickstart, dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_ramqube, dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_run, dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_slack, dotfiles/.local/share/chezmoi/home/dot_local/bin/executable_squash-symlink, dotfiles/.local/share/chezmoi/home/dot_local/konsole/Default.profile, dotfiles/.local/share/chezmoi/home/dot_local/scripts/macos.bash, dotfiles/.local/share/chezmoi/home/dot_local/scripts/motd.bash, dotfiles/.local/share/chezmoi/home/dot_local/scripts/p10k.zsh, dotfiles/.local/share/chezmoi/home/dot_local/share/fonts/FontAwesome.ttf, dotfiles/.local/share/chezmoi/home/dot_local/share/fonts/Weather-Icons.ttf, dotfiles/.local/share/chezmoi/home/dot_local/share/git-core/templates/hooks/post-commit, dotfiles/.local/share/chezmoi/home/dot_local/state/bash/.gitkeep, dotfiles/.local/share/chezmoi/home/dot_local/state/zsh/.gitkeep, dotfiles/.local/share/chezmoi/home/dot_ssh/authorized_keys.github.tmpl, dotfiles/.local/share/chezmoi/home/dot_ssh/id_rsa.pub, dotfiles/.local/share/chezmoi/home/dot_ssh/private_config.tmpl, dotfiles/.local/share/chezmoi/home/dot_ssh/private_id_rsa.tmpl, dotfiles/.local/share/chezmoi/home/dot_vim/autoload/lightline/colorscheme/Betelgeuse.vim, dotfiles/.local/share/chezmoi/home/dot_vim/colors/Betelgeuse.vim, dotfiles/.local/share/chezmoi/home/dot_vim/vimrc, dotfiles/.local/share/chezmoi/home/private_dot_config/Kvantum/kvantum.config, dotfiles/.local/share/chezmoi/home/private_dot_config/alacritty/alacritty.yml, dotfiles/.local/share/chezmoi/home/private_dot_config/asdf/asdfrc.tmpl, dotfiles/.local/share/chezmoi/home/private_dot_config/asdf/default-cargo-pkgs.tmpl, dotfiles/.local/share/chezmoi/home/private_dot_config/asdf/default-golang-pkgs.tmpl, dotfiles/.local/share/chezmoi/home/private_dot_config/asdf/default-npm-packages, dotfiles/.local/share/chezmoi/home/private_dot_config/asdf/default-python-pkgs.tmpl, dotfiles/.local/share/chezmoi/home/private_dot_config/asdf/default-ruby-pkgs.tmpl, dotfiles/.local/share/chezmoi/home/private_dot_config/bashtop/bashtop.cfg, dotfiles/.local/share/chezmoi/home/private_dot_config/bat/config, dotfiles/.local/share/chezmoi/home/private_dot_config/brew/Brewfile.tmpl, dotfiles/.local/share/chezmoi/home/private_dot_config/brew/whalebrew, dotfiles/.local/share/chezmoi/home/private_dot_config/crontab/config, dotfiles/.local/share/chezmoi/home/private_dot_config/direnv/direnv.toml, dotfiles/.local/share/chezmoi/home/private_dot_config/fd/ignore, dotfiles/.local/share/chezmoi/home/private_dot_config/firejail/bitwarden.local, dotfiles/.local/share/chezmoi/home/private_dot_config/firejail/chromium.local, dotfiles/.local/share/chezmoi/home/private_dot_config/firejail/code.local, dotfiles/.local/share/chezmoi/home/private_dot_config/firejail/gcloud.local, dotfiles/.local/share/chezmoi/home/private_dot_config/firejail/google-chrome-stable.local, dotfiles/.local/share/chezmoi/home/private_dot_config/firejail/slack.local, dotfiles/.local/share/chezmoi/home/private_dot_config/firejail/thunderbird.local, dotfiles/.local/share/chezmoi/home/private_dot_config/fontconfig/fonts.conf, dotfiles/.local/share/chezmoi/home/private_dot_config/ghorg/conf.yaml.tmpl, dotfiles/.local/share/chezmoi/home/private_dot_config/git/attributes, dotfiles/.local/share/chezmoi/home/private_dot_config/git/commit-template, dotfiles/.local/share/chezmoi/home/private_dot_config/git/config.tmpl, dotfiles/.local/share/chezmoi/home/private_dot_config/git/ignore, dotfiles/.local/share/chezmoi/home/private_dot_config/gtk-1.0/.gitkeep, dotfiles/.local/share/chezmoi/home/private_dot_config/gtk-2.0/gtkrc, dotfiles/.local/share/chezmoi/home/private_dot_config/gtk-3.0/settings.ini, dotfiles/.local/share/chezmoi/home/private_dot_config/himalaya/config.toml.tmpl, dotfiles/.local/share/chezmoi/home/private_dot_config/k9s/plugin.yml, dotfiles/.local/share/chezmoi/home/private_dot_config/kitty/Betelgeuse-dark.conf, dotfiles/.local/share/chezmoi/home/private_dot_config/kitty/Betelgeuse-light.conf, dotfiles/.local/share/chezmoi/home/private_dot_config/kitty/kitty.conf, dotfiles/.local/share/chezmoi/home/private_dot_config/ngrok/ngrok.yml.tmpl, dotfiles/.local/share/chezmoi/home/private_dot_config/npm/npmrc.tmpl, dotfiles/.local/share/chezmoi/home/private_dot_config/oh-my-posh/Betelgeuse-minimal.omp.json, dotfiles/.local/share/chezmoi/home/private_dot_config/oh-my-posh/Betelgeuse.omp.json, dotfiles/.local/share/chezmoi/home/private_dot_config/pg/.gitkeep, dotfiles/.local/share/chezmoi/home/private_dot_config/pgcli/config, dotfiles/.local/share/chezmoi/home/private_dot_config/powershell/user_profile.ps1, dotfiles/.local/share/chezmoi/home/private_dot_config/private_Code/User/extensions/theme-betelgeuse-vscode/themes/themer-dark-color-theme.json, dotfiles/.local/share/chezmoi/home/private_dot_config/private_Code/User/extensions/theme-betelgeuse-vscode/themes/themer-light-color-theme.json, dotfiles/.local/share/chezmoi/home/private_dot_config/private_Code/User/extensions/theme-betelgeuse-vscode/README.md, dotfiles/.local/share/chezmoi/home/private_dot_config/private_Code/User/extensions/theme-betelgeuse-vscode/icon.svg, dotfiles/.local/share/chezmoi/home/private_dot_config/private_Code/User/extensions/theme-betelgeuse-vscode/package.json, dotfiles/.local/share/chezmoi/home/private_dot_config/private_Code/User/extensions.json, dotfiles/.local/share/chezmoi/home/private_dot_config/private_Code/User/keybindings.json, dotfiles/.local/share/chezmoi/home/private_dot_config/private_Code/User/settings.json, dotfiles/.local/share/chezmoi/home/private_dot_config/putty/.gitkeep, dotfiles/.local/share/chezmoi/home/private_dot_config/readline/inputrc, dotfiles/.local/share/chezmoi/home/private_dot_config/ripgrep/config, dotfiles/.local/share/chezmoi/home/private_dot_config/rofi/config.rasi.tmpl, dotfiles/.local/share/chezmoi/home/private_dot_config/shell/aliases.tmpl, dotfiles/.local/share/chezmoi/home/private_dot_config/shell/exports, dotfiles/.local/share/chezmoi/home/private_dot_config/shell/functions, dotfiles/.local/share/chezmoi/home/private_dot_config/shell/motd, dotfiles/.local/share/chezmoi/home/private_dot_config/shell/profile, dotfiles/.local/share/chezmoi/home/private_dot_config/slack-term/config.tmpl, dotfiles/.local/share/chezmoi/home/private_dot_config/tabby/config.yaml.tmpl, dotfiles/.local/share/chezmoi/home/private_dot_config/tabby/package-lock.json, dotfiles/.local/share/chezmoi/home/private_dot_config/terminator/config, dotfiles/.local/share/chezmoi/home/private_dot_config/tmux/.gitkeep, dotfiles/.local/share/chezmoi/home/private_dot_config/wget/wgetrc, dotfiles/.local/share/chezmoi/home/private_dot_config/xfce4/terminal/terminalrc, dotfiles/.local/share/chezmoi/home/private_dot_config/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml, dotfiles/.local/share/chezmoi/home/private_dot_config/xsettingsd/xsettingsd.conf, dotfiles/.local/share/chezmoi/home/private_dot_config/chromium-flags.conf, dotfiles/.local/share/chezmoi/home/private_dot_config/gtkrc, dotfiles/.local/share/chezmoi/home/private_dot_config/kcminputrc, dotfiles/.local/share/chezmoi/home/private_dot_config/kdeglobals, dotfiles/.local/share/chezmoi/home/private_dot_config/konsolerc, dotfiles/.local/share/chezmoi/home/private_dot_config/ksplashrc, dotfiles/.local/share/chezmoi/home/private_dot_config/ktimezonedrc, dotfiles/.local/share/chezmoi/home/private_dot_config/kwinrc, dotfiles/.local/share/chezmoi/home/private_dot_config/mimeapps.list, dotfiles/.local/share/chezmoi/home/private_dot_config/plasma-localerc, dotfiles/.local/share/chezmoi/home/private_dot_config/plasmarc, dotfiles/.local/share/chezmoi/home/dot_Xresources, dotfiles/.local/share/chezmoi/home/dot_bash_logout, dotfiles/.local/share/chezmoi/home/dot_bash_profile, dotfiles/.local/share/chezmoi/home/dot_bashrc, dotfiles/.local/share/chezmoi/home/dot_editorconfig, dotfiles/.local/share/chezmoi/home/dot_zshrc, dotfiles/.local/share/chezmoi/home/run_once_before_install-software.sh.tmpl, dotfiles/.local/share/chezmoi/home/run_onchange_after_bash-completions, dotfiles/.local/share/chezmoi/home/run_onchange_after_crontab.tmpl, dotfiles/.local/share/chezmoi/.chezmoiroot
2022-11-22 19:59:10 +00:00

107 lines
4 KiB
Python

#!/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<allDesktops.length;i++) {
d = allDesktops[i];
d.wallpaperPlugin = "%s";
d.currentConfigGroup = Array("Wallpaper", "%s", "General");
d.writeConfig("Image", "file://%s")
}
"""
bus = dbus.SessionBus()
plasma = dbus.Interface(bus.get_object(
'org.kde.plasmashell', '/PlasmaShell'), dbus_interface='org.kde.PlasmaShell')
plasma.evaluateScript(jscript % (plugin, plugin, filepath))
def set_lockscreen_wallpaper(filepath,plugin='org.kde.image'):
if os.path.exists(SCREEN_LOCK_CONFIG):
new_data=[]
with open(SCREEN_LOCK_CONFIG, "r") as kscreenlockerrc:
new_data = kscreenlockerrc.readlines()
is_wallpaper_section=False
for num,line in enumerate(new_data,1):
if "[Greeter][Wallpaper]["+plugin+"][General]" in line:
is_wallpaper_section = True
if "Image=" in line and is_wallpaper_section:
new_data[num-1] = "Image="+filepath+"\n"
break
with open(SCREEN_LOCK_CONFIG, "w") as kscreenlockerrc:
kscreenlockerrc.writelines(new_data)
def is_locked():
is_locked=subprocess.check_output("qdbus org.kde.screensaver /ScreenSaver org.freedesktop.ScreenSaver.GetActive",shell=True,universal_newlines=True).strip()
if is_locked == "true":
is_locked = True
else:
is_locked = False
return is_locked
def get_walls_from_folder(directory):
return glob.glob(directory+'/*')
def wallpaper_slideshow(wallapapers, plugin, timer, lock_screen):
if timer > 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")