This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Wallpaper

Tags: None
(comma "," separated)
dzon
Registered Member
Posts
493
Karma
3

Wallpaper

Mon Dec 26, 2022 1:54 pm
Can't remember if I posted this before, so... I find it kinda strange that Gwenview doesn't have a function "set as wallpaper" ( unless I'm blind as f..k). You can add that if you like.
Here's two ways, one with python and one...um..regular. All needs to be in ~/.local/share/applications.

Python script:

#!/usr/bin/env python3
import dbus
import argparse

def setwallpaper(filepath, plugin = 'org.kde.image'):
jscript = """
var allDesktops = desktops();
print (allDesktops);
for (i=0;i<allDesktops.length;i++) {
d = allDesktops[i];
d.wallpaperPlugin = "%s";
d.currentConfigGroup = Array("Wallpaper", "%s", "General");
d.writeConfig("Image", "file://%s")
}
"""
bus = dbus.SessionBus()
plasma = dbus.Interface(bus.get_object('org.kde.plasmashell', '/PlasmaShell'), dbus_interface='org.kde.PlasmaShell')
plasma.evaluateScript(jscript % (plugin, plugin, filepath))






if __name__ == '__main__':
parser = argparse.ArgumentParser(description='KDE Wallpaper setter')
parser.add_argument('file', help='Wallpaper file name')
parser.add_argument('--plugin', '-p', help='Wallpaper plugin (default is org.kde.image)', default='org.kde.image')
args = parser.parse_args()
setwallpaper(args.file, args.plugin)

Corresponding desktop file:

[Desktop Entry]
Comment[nl_BE]=
Comment=
Exec=~/.local/share/applications/ksetwallpaper.py
GenericName[nl_BE]=
GenericName=
Icon=buho
MimeType=image/jpeg;image/png;image/svg+xml;image/svg+xml-compressed;image/bmp;image/webp;image/tiff;
Name[nl_BE]=ksetwallpaper.py
Name=ksetwallpaper.py
NoDisplay=true
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=

The "regular" one:

[Desktop Entry]
ServiceTypes=KonqPopupMenu/Plugin
Actions=setAsWallpaper;
Type=Service
MimeType=image/jpeg;image/png;image/svg+xml;image/svg+xml-compressed;image/bmp;image/webp;image/tiff;
X-KDE-Priority=TopLevel

[Desktop Action setAsWallpaper]
Name=Set as Wallpaper
Name[ar]=عين كخلفية
Name[az]=Divar Kağızı təyin edin
Name[bg]=Задаване като тапет
Name[ca]=Estableix com a fons de pantalla
Name[ca@valencia]=Establix com a fons de pantalla
Name[cs]=Nastavit jako tapetu
Name[da]=Sæt som baggrundsbillede
Name[de]=Als Hintergrundbild festlegen
Name[en_GB]=Set as Wallpaper
Name[es]=Definir como fondo del escritorio
Name[eu]=Ezarri horma-paper gisa
Name[fi]=Aseta taustakuvaksi
Name[fr]=Définir comme fond d'écran
Name[hu]=Beállítás háttérképként
Name[ia]=Fixa como Tapete de papiro
Name[id]=Atur sebagai Wallpaper
Name[is]=Setja sem bakgrunnsmynd
Name[it]=Imposta come sfondo
Name[ja]=壁紙として設定
Name[ka]=ფონის სურათად დაყენება
Name[ko]=배경 그림으로 설정
Name[nl]=Als achtergrondafbeelding instellen
Name[nn]=Bruk som bakgrunns­bilete
Name[pl]=Ustaw jako tapetę
Name[pt]=Definir como Papel de Parede
Name[pt_BR]=Definir como papel de parede
Name[ro]=Stabilește ca tapet
Name[ru]=Сделать фоном рабочего стола
Name[sk]=Nastaviť ako pozadie plochy
Name[sl]=Postavi kot sliko ozadja
Name[sv]=Använd som skrivbordsunderlägg
Name[ta]=பின்புல படமாக அமை
Name[tr]=Duvar Kağıdı Olarak Ayarla
Name[uk]=Встановити зображенням тла
Name[vi]=Đặt làm phông nền
Name[x-test]=xxSet as Wallpaperxx
Name[zh_CN]=设为壁纸
Icon=viewimage
Exec=/usr/lib/qt5/bin/qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript 'const allDesktops = desktopsForActivity(currentActivity()); 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", "%u")}'

Either way, you'll have the functionality in Gwenview. https://imgur.com/a/op5U9Y2 PS: works in the thumbnails as well.


This realm's name is Maya. And she speaks Hertz. But Ahamkara makes a fuzz about it.


Bookmarks



Who is online

Registered users: bartoloni, Bing [Bot], Google [Bot], Yahoo [Bot]