Skip to content

Instantly share code, notes, and snippets.

@renegarcia
Last active July 8, 2023 18:36
Show Gist options
  • Save renegarcia/3890018ebab038f1f2e8adc8e3903231 to your computer and use it in GitHub Desktop.
Save renegarcia/3890018ebab038f1f2e8adc8e3903231 to your computer and use it in GitHub Desktop.
Setup wallpaper image in plasma shell (Cli)
from subprocess import call
from argparse import ArgumentParser
JS = """
/*
* This script is meant to be run from the python interface below.
*/
const allDesktops = desktops();
for (desktop of allDesktops){{
desktop.wallpaperPlugin = "org.kde.image";
desktop.currentConfigGroup = Array("Wallpaper",
"org.kde.image",
"General");
desktop.writeConfig("Image", `file://{fname}`)
}}
"""
def main():
parser = ArgumentParser("set-wallpaper")
parser.add_argument("file", help="File location",)
args = parser.parse_args()
call([
"qdbus",
"org.kde.plasmashell",
"/PlasmaShell",
"org.kde.PlasmaShell.evaluateScript",
JS.format(fname=args.file),
])
if __name__ == "__main__":
main()
/*
* This script is meant to be run from the python interface (set-wallpaper.py).
*/
const allDesktops = desktops();
for (desktop of allDesktops){
desktop.wallpaperPlugin = "org.kde.image";
desktop.currentConfigGroup = Array("Wallpaper",
"org.kde.image",
"General");
desktop.writeConfig("Image", `file://{fname}`)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment