39 lines
1.4 KiB
C#
39 lines
1.4 KiB
C#
using System.Diagnostics;
|
|
|
|
namespace RandomWallpaper
|
|
{
|
|
public static class KDEScripts
|
|
{
|
|
public static String GetChangeWallpaperScript(String desktopID, String imageName)
|
|
{
|
|
return $$"""
|
|
var targetDesktop = {{desktopID}};
|
|
var targetImage = "file://{{imageName}}";
|
|
|
|
var d = desktops()[targetDesktop];
|
|
d.currentConfigGroup = Array('Wallpaper',d.wallpaperPlugin,'General');
|
|
// identify the wallpaper plugin so we can read it properly
|
|
if (d.wallpaperPlugin == 'org.kde.slideshow') {
|
|
print(d.readConfig('Image').replace('file://',''));
|
|
d.writeConfig("Image", targetImage);
|
|
} else if (d.wallpaperPlugin == 'org.kde.image') {
|
|
print(d.readConfig('Image').replace('file://',''));
|
|
d.writeConfig("Image", targetImage);
|
|
}
|
|
else {
|
|
print('Unsupported wallpaper plugin: '+d.wallpaperPlugin+'\n');
|
|
}
|
|
""";
|
|
}
|
|
public static void RunPlasmaScript(String script)
|
|
{
|
|
using var process = Process.Start(
|
|
new ProcessStartInfo
|
|
{
|
|
FileName = "qdbus",
|
|
ArgumentList = { "org.kde.plasmashell", "/PlasmaShell", "evaluateScript", script }
|
|
});
|
|
process.WaitForExit();
|
|
}
|
|
}
|
|
} |