Initial commit

This commit is contained in:
2026-02-09 10:27:26 -05:00
commit a5d079b211
6 changed files with 510 additions and 0 deletions

39
KDEWallpaperScripts.cs Normal file
View File

@@ -0,0 +1,39 @@
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();
}
}
}