Occasionally, I have a good idea, and occasionally, I can make it work.
Case in point.
Sometimes I will use an old and obscure window manager for Linux called WMX. It’s minimalist and spartan. No panels, no background, barely a menu. It can launch a terminal and scroll through workspaces. You can set up a menu on the scroll wheel/middle button. When I don’t want bells and whistles, like when I’m writing, this is what I use.
Instead of calling WMX directly, I launch it from a script that launches the screensaver, sets an environment variable, and uses feh to set a wallpaper. To set a wallpaper, the feh command has to call the file directly, so I have a line like:
feh --bg-fill /home/allyn/Pictures/backgrounds/historical/baltimore-1872.jpg &
I have WMX alongside the Cinnamon desktop environment. It occurred to me, what if I could just have feh call the wallpaper that I have set in Cinnamon? That’s just stored in dconf. gsettings get org.cinnamon.desktop.background picture-uri will extract the filename. That command comes out in a format like this: 'file:///home/allyn/Pictures/backgrounds/bbc-ulysses/1600-blue-mouldy.jpg' feh would not work with that, so I had to take the single quotes off and, just in case, the file prefix and leading slashes, to get it down to this: /home/allyn/Pictures/backgrounds/bbc-ulysses/1600-blue-mouldy.jpg.
It did not come together quickly, I had to consult the Googles which led me to several Stack Overflow pages, I experimented with grep and awk and pipes, but I was able to cobble together code that did what I wanted: extract the filename, truncate it down, pass it to feh. This is what I have in my bash script that launches WMX.
# Wallpaper
background_uri=$(gsettings get org.cinnamon.desktop.background picture-uri)
wallpaper=${background_uri:8:-1}
feh --bg-fill $wallpaper
The first line is just a comment.
The second line uses gsettings to get the path to the wallpaper and assigns it to a variable.
The third line chops the first 8 characters as well as the last off the variable and assigns that result to a new variable.
The fourth and final line calls feh (which sets the background image or wallpaper) and passes it the new, truncated variable.
Voila!

I look at it, and it looks so simple, but I spent about two hours on it last night and another half hour this morning. Bash scripting isn’t something I know. I can write a script that chains a lot of commands together, but variables were new and unknown to me… and they’re still new and unknown! 😆
So now, when/if I change my Cinnamon wallpaper, the wallpaper will change automatically in WMX. If I want to change that, I can just comment out the line that sets the wallpaper using my variable and call a specific file directly as above.