Initial support for other DEs

This commit is contained in:
amalthomas-exe 2022-04-01 16:45:39 +05:30
commit de9e5f0bed

32
main.py
View file

@ -10,9 +10,38 @@ def setDEWallpaper(de,style):
type = ".png"
else:
type = ".jpg"
if de=="plasma":
if de in ["/usr/share/xsessions/plasma","NEON","neon","PLASMA","Plasma","plasma","KDE","Kde","kde"]:
print("Inside",de)
os.system("qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript 'var allDesktops = desktops();print (allDesktops);for (i=0;i<allDesktops.length;i++) {d = allDesktops[i];d.wallpaperPlugin = \"org.kde.image\";d.currentConfigGroup = Array(\"Wallpaper\", \"org.kde.image\", \"General\");d.writeConfig(\"Image\", \"file:///usr/share/linuxDynamicWallpapers/images/"+style+"/"+str(datetime.datetime.now().hour)+type+"\")}'")
elif de in ["cinnamon","Cinnamon"]:
print("Inside",de)
os.system(f"gsettings set org.cinnamon.desktop.background picture-uri \"file:///usr/share/linuxDynamicWallpapers/images/{style}/{datetime.datetime.now().hour}""{type}\"")
elif de in ["Xfce Session","xfce session","XFCE","xfce","Xubuntu","xubuntu"]:
print("Inside",de)
SCREEN = subprocess.getoutput("echo $(xrandr --listactivemonitors | awk -F ' ' 'END {print $1}' | tr -d \:)")
MONITOR = subprocess.getoutput("echo $(xrandr --listactivemonitors | awk -F ' ' 'END {print $2}' | tr -d \*+)")
os.system(f"xfconf-query --channel xfce4-desktop --property /backdrop/screen{SCREEN}/monitor{MONITOR}/workspace0/last-image --set usr/share/linuxDynamicWallpapers/images/{style}/{datetime.datetime.now().hour}""{type}")
elif de in ["MATE","Mate","mate"]:
print("Inside",de)
os.system(f"gsettings set org.mate.background picture-filename usr/share/linuxDynamicWallpapers/images/{style}/{datetime.datetime.now().hour}""{type}")
elif de in ["LXDE","Lxde","lxde"]:
print("Inside",de)
os.system("pcmanfm --set-wallpaper=\"usr/share/linuxDynamicWallpapers/images/{style}/{datetime.datetime.now().hour}""{type}\"")
elif de in ["PANTHEON","Pantheon","pantheon","GNOME","Gnome","gnome","Gnome-xorg","gnome-xorg","UBUNTU","Ubuntu","ubuntu","DEEPIN","Deepin","deepin","POP","Pop","pop"]:
print("Inside",de)
os.system(f"gsettings set org.gnome.desktop.background picture-uri file:///usr/share/linuxDynamicWallpapers/images/{style}/{datetime.datetime.now().hour}""{type}")
else:
print("Inside",de)
os.system("feh --bg-fill usr/share/linuxDynamicWallpapers/images/{style}/{datetime.datetime.now().hour}""{type}")
@app.route("/")
def index():
return render_template("index.html")
@ -21,6 +50,7 @@ def index():
def setWallpaper():
wallpaper = request.args.get("wallpaper").lower()
print(wallpaper)
DE = subprocess.getoutput("echo $DESKTOP_SESSION")
setDEWallpaper("plasma",wallpaper)
#os.system(f'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin DISPLAY=:0 DESKTOP_SESSION=plasma DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus" /usr/bin/dwall -s {wallpaper}')
os.system(f'notify-send "Linux Dynamic Wallpapers" "Set wallpaper to {wallpaper.upper()}" ')