How to run a KDE plasma script from command line without GUI

d-buskdescripting

I want to run a plasma JavaScript file from command line, but the only solution I found so far involves a graphical script editor and requires a user interaction to run the script:

qdbus org.kde.plasma-desktop /MainApplication loadScriptInInteractiveConsole "$PLASMA_SCRIPT_FILE"

Is there any solution that does not require a user interaction?

Best Answer

Yes, you can (several places link to this question so I'm anwering here). Just use:

qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript

It takes a script, not a path for it, so valid use is for example:

qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript 'var foo = 1;'
Related Question