guillaumeboehm / wal-telegram

A bash script that generates themes for Telegram based on an arbitrary 16-colors palette or by sourcing the colors generated by pywal/wal.
MIT License
49 stars 9 forks source link

how do I get wal-telegram to use the current wallpaper for me in KDE Plasma #11

Closed kun-codes closed 2 years ago

kun-codes commented 2 years ago

The current wallpaper location can be found in ~/.config/plasma-org.kde.plasma.desktop-appletsrc afaik

guillaumeboehm commented 2 years ago

Is plasma-org.kde.plasma.desktop-appletsrc the image ? Or the directory of the image ? The telegram theme expects a jpg or png extension I believe so it wouldn't work with different names.

kun-codes commented 2 years ago

It is a file which has the current wallpaper location. I don't know how to tell wal-telegram the location of the current wallpaper.

guillaumeboehm commented 2 years ago

A file containing the location ? Not a symlink ? If it's a text file with the location you'd have to make a little script to first get the path in a variable and then call wal-telegram -b "$VARIABLE".

kun-codes commented 2 years ago

The problem is, I don't know how to get the path from the file, can you point me to a resource by which I can learn it myself first? Any Linux command line tools?

guillaumeboehm commented 2 years ago

It would probably depend on the format of the file. I would probably end up using the awk command or maybe grep ? You can always send me the content of the file I can maybe help you with it.

kun-codes commented 2 years ago

alright, I will try sending you the file by today

kun-codes commented 2 years ago

here it the file

[ActionPlugins][0]
RightButton;NoModifier=org.kde.contextmenu
wheel:Vertical;NoModifier=org.kde.switchdesktop

[ActionPlugins][1]
RightButton;NoModifier=org.kde.contextmenu

[Containments][38]
activityId=ca590bcf-0670-414d-9cbd-508004ad0f5b
formfactor=0
immutability=1
lastScreen=0
location=0
plugin=org.kde.plasma.folder
wallpaperplugin=org.kde.image

[Containments][38][Configuration]
PreloadWeight=26

[Containments][38][Wallpaper][org.kde.image][General]
Image=file:///usr/share/wallpapers/Next/contents/images/1920x1080.jpg

[Containments][57]
ItemGeometries-1743x980=Applet-86:544,368,640,176,0;
ItemGeometries-1920x1080=Applet-86:640,384,640,176,0;
ItemGeometriesHorizontal=Applet-86:640,384,640,176,0;
activityId=c1745ce0-dc26-4cfa-9384-5492528356f5
formfactor=0
immutability=1
lastScreen=0
location=0
plugin=org.kde.desktopcontainment
wallpaperplugin=org.kde.image

[Containments][57][Applets][86]
immutability=1
plugin=com.github.prayag2.modernclock

[Containments][57][Applets][86][Configuration]
UserBackgroundHints=

[Containments][57][Applets][86][Configuration][ConfigDialog]
DialogHeight=660
DialogWidth=880

[Containments][57][ConfigDialog]
DialogHeight=720
DialogWidth=960

[Containments][57][Configuration]
PreloadWeight=0

[Containments][57][General]
ToolBoxButtonState=topcenter
ToolBoxButtonX=527

[Containments][57][Wallpaper][org.kde.image][General]
Image=file:///home/<my-username>/.local/share/wallpapers/wp9434242.png
SlidePaths=/home/<my-username>local/share/wallpapers,/usr/share/wallpapers

[Containments][57][Wallpaper][org.kde.potd][General]
Category=1339089
FillMode=2
Provider=unsplash

[Containments][57][Wallpaper][org.kde.slideshow][General]
Image=file:///home/<my-username>/.local/share/wallpapers/liy7fsmre3581.jpg
SlidePaths=/home/<my-username>/.local/share/wallpapers,/usr/share/wallpapers

[Containments][62]
activityId=
formfactor=2
immutability=1
lastScreen=0
location=4
plugin=org.kde.panel
wallpaperplugin=org.kde.image

[Containments][62][Applets][63]
immutability=1
plugin=org.kde.plasma.kickoff

[Containments][62][Applets][63][Configuration]
PreloadWeight=100

[Containments][62][Applets][63][Configuration][General]
favoritesPortedToKAstats=true

[Containments][62][Applets][63][Configuration][Shortcuts]
global=Alt+F1

[Containments][62][Applets][64]
immutability=1
plugin=org.kde.plasma.pager

[Containments][62][Applets][66]
immutability=1
plugin=org.kde.plasma.marginsseparator

[Containments][62][Applets][67]
immutability=1
plugin=org.kde.plasma.systemtray

[Containments][62][Applets][67][Configuration]
PreloadWeight=100
SystrayContainmentId=68

[Containments][62][Applets][78]
immutability=1
plugin=org.kde.plasma.digitalclock

[Containments][62][Applets][78][Configuration]
PreloadWeight=80

[Containments][62][Applets][79]
immutability=1
plugin=org.kde.plasma.showdesktop

[Containments][62][Applets][88]
immutability=1
plugin=org.kde.plasma.taskmanager

[Containments][62][Applets][88][Configuration][General]
launchers=

[Containments][62][ConfigDialog]
DialogHeight=93
DialogWidth=1920

[Containments][62][General]
AppletOrder=63;64;88;67;78;79;66

[Containments][68]
activityId=
formfactor=2
immutability=1
lastScreen=0
location=4
plugin=org.kde.plasma.private.systemtray
wallpaperplugin=org.kde.image

[Containments][68][Applets][69]
immutability=1
plugin=org.kde.plasma.clipboard

[Containments][68][Applets][69][Configuration]
PreloadWeight=70

[Containments][68][Applets][70]
immutability=1
plugin=org.kde.plasma.devicenotifier

[Containments][68][Applets][70][Configuration]
PreloadWeight=100

[Containments][68][Applets][71]
immutability=1
plugin=org.kde.plasma.keyboardlayout

[Containments][68][Applets][72]
immutability=1
plugin=org.kde.plasma.notifications

[Containments][68][Applets][72][Configuration]
PreloadWeight=95

[Containments][68][Applets][73]
immutability=1
plugin=org.kde.plasma.volume

[Containments][68][Applets][73][Configuration]
PreloadWeight=80

[Containments][68][Applets][73][Configuration][ConfigDialog]
DialogHeight=660
DialogWidth=880

[Containments][68][Applets][73][Configuration][General]
raiseMaximumVolume=true
volumeStep=2

[Containments][68][Applets][74]
immutability=1
plugin=org.kde.plasma.manage-inputmethod

[Containments][68][Applets][75]
immutability=1
plugin=org.kde.plasma.keyboardindicator

[Containments][68][Applets][76]
immutability=1
plugin=org.kde.plasma.nightcolorcontrol

[Containments][68][Applets][77]
immutability=1
plugin=org.kde.kdeconnect

[Containments][68][Applets][77][Configuration]
PreloadWeight=100

[Containments][68][Applets][80]
immutability=1
plugin=org.kde.plasma.battery

[Containments][68][Applets][80][Configuration]
PreloadWeight=100

[Containments][68][Applets][80][Configuration][General]
showPercentage=true

[Containments][68][Applets][81]
immutability=1
plugin=org.kde.plasma.networkmanagement

[Containments][68][Applets][81][Configuration]
PreloadWeight=100

[Containments][68][Applets][82]
immutability=1
plugin=org.kde.plasma.bluetooth

[Containments][68][Applets][85]
immutability=1
plugin=org.kde.plasma.mediacontroller

[Containments][68][Applets][85][Configuration]
PreloadWeight=0

[Containments][68][General]
extraItems=org.kde.plasma.battery,org.kde.plasma.clipboard,org.kde.plasma.devicenotifier,org.kde.plasma.keyboardlayout,org.kde.plasma.mediacontroller,org.kde.plasma.networkmanagement,org.kde.plasma.notifications,org.kde.plasma.volume,org.kde.plasma.manage-inputmethod,org.kde.plasma.keyboardindicator,org.kde.plasma.nightcolorcontrol,org.kde.kdeconnect,org.kde.plasma.bluetooth
knownItems=org.kde.plasma.battery,org.kde.plasma.clipboard,org.kde.plasma.devicenotifier,org.kde.plasma.keyboardlayout,org.kde.plasma.mediacontroller,org.kde.plasma.networkmanagement,org.kde.plasma.notifications,org.kde.plasma.volume,org.kde.plasma.manage-inputmethod,org.kde.plasma.keyboardindicator,org.kde.plasma.nightcolorcontrol,org.kde.kdeconnect,org.kde.plasma.bluetooth

[Containments][89]
activityId=c1745ce0-dc26-4cfa-9384-5492528356f5
formfactor=0
immutability=1
lastScreen=1
location=0
plugin=org.kde.plasma.folder
wallpaperplugin=org.kde.image

[Containments][89][Wallpaper][org.kde.image][General]
Image=file:///usr/share/wallpapers/Next/contents/images/1920x1080.jpg

[Containments2Appletsts][36][Configuration][General]
launchers=

[ScreenMapping]
itemsOnDisabledScreens=1,c1745ce0-dc26-4cfa-9384-5492528356f5,8,desktop:/backlog.txt,desktop:/init.lua,desktop:/test.py,desktop:/BetterDiscord-Linux.AppImage,desktop:/brave-mfhpbolkhgobaabcbabdlnhidbjpoogc-Default.desktop,desktop:/IMG_20211114_135320_406.jpg,desktop:/proxy-image.png,desktop:/IMG_20211114_135320_406.webp
screenMapping=

At

[Containments][57]
ItemGeometries-1743x980=Applet-86:544,368,640,176,0;
ItemGeometries-1920x1080=Applet-86:640,384,640,176,0;
ItemGeometriesHorizontal=Applet-86:640,384,640,176,0;
activityId=c1745ce0-dc26-4cfa-9384-5492528356f5
formfactor=0
immutability=1
lastScreen=0
location=0
plugin=org.kde.desktopcontainment
wallpaperplugin=org.kde.image

the last line it shows the current selected wallpaper plugin in kde afaik

and in

[Containments][57][Wallpaper][org.kde.image][General]
Image=file:///home/<my-username>/.local/share/wallpapers/wp9434242.png
SlidePaths=/home/<my-username>local/share/wallpapers,/usr/share/wallpapers

it shows the image file path

Sorry in case it is too confusing to follow

guillaumeboehm commented 2 years ago

Hum ok, so before anything just know I'm in no way a scripting veteran so I might tell you some really dumb scripting habits and stuff xD But what I'd probably do is (if there is really no other place to know what your current wallpaper is) grep with a regex like grep -Pzo '(?<=\[Containments\]\[57\]\[Wallpaper\]\[org\.kde\.image\]\[General\]\nImage=)([^\n]*)' <your_file>, if the number 57 never changes, or eventually change the 57 for \d+ to match any number and extend the regex to include file://home/ which seems to select only the line you'd want.

You can do your research but to guide you a bit, grep returns the matches found in a file on a given pattern. The -P option uses perl regexp which is more powerfull, -z basically allows you to do multiline matching, and -o prints only what's matched by the regex. If you're not familiar with regex you can mess around on regex101.com which is a must use to test your regex and all.

So what you can do is either use a long command with wal-telegram -b $(<grep comand>) or make a little script that you'd call on system boot I assume.

kun-codes commented 2 years ago

thanks for the help the command

grep -Pzo '(?<=\[Containments\]\[57\]\[Wallpaper\]\[org\.kde\.image\]\[General\]\nImage=)([^\n]*)' ~/.config/plasma-org.kde.plasma.desktop-appletsrc

returns

file:///home/<my-username>/.local/share/wallpapers/wp9434242.png⏎ 

how do I remove the file:// part so that it works with wal-telegram?

kun-codes commented 2 years ago

Quick Update: I managed to do it by this command

wal-telegram -b $(grep -Pzo '(?<=\[Containments\]\[57\]\[Wallpaper\]\[org\.kde\.image\]\[General\]\nImage=file://)([^\n]*)' ~/.config/plasma-org.kde.plasma.desktop-appletsrc)
guillaumeboehm commented 2 years ago

Yep my bad didn't think of that, is everything working as you need with that ?

kun-codes commented 2 years ago

yup, it works but I think it won't work if change the active wallpaper plugin, the one which we are working with is org.kde.image

I think you may close the comment now, I might comment again if I need some help

kun-codes commented 2 years ago

Thank you so much for the help

guillaumeboehm commented 2 years ago

Sure no problem at all