0

I'm running Ventura (macOS 13.2) on an M1 MacBook Pro. I typically use five desktops (spaces). I have the desktop wallpaper on each to randomly change from a specified folder every hour. Everything works.

What I'd like to do is superimpose the file name of the wallpaper image on the desktop it's being displayed on. I know this can be done, because the Particulars applet (freeware by Fraser Hess) does this, as does an older wallpaper manager, Change Desktop.

I think I could use an AppleScript or Shortcut to get the file name, but I don't know how to display it (overlay) on the image. Any ideas?

1
  • OK, a follow up: I found a nifty little program on GitHub called "Plash" (available through Apple's App Store). It does exactly what I'm looking for: Overlays date/text/images on the desktop wallpaper. There's even the means to create a local "website" with a file called index.html. The example given uses Javascript as the <script> parameter. I'm trying to rework the example using <script src="/bin/zsh">. It's very slow going, as my HTML knowledge is about ten years out of date. Any tips? Mar 6 at 15:47

2 Answers 2

2

You can use GraphicsMagick to add the filename to the image.

Below is a “one liner” that will get the job done.

for f in *.jpg; do bname=$(basename $f .jpg); \
fname=${bname}-wp.jpg; \ 
gm convert $f xc:”white” \
-draw “text 10,10 ‘${fname}’ $fname; done

I’ve separated the commands on different lines for readability. You can put it all on one line by removing the backslashes. You can also cut/paste as is and it will execute in your shell.

This command does the following:

  • parses through all of the JPEG files (.jpg) in a directory. If you use a different format (PNG, for example), just change the extensions as necessary

  • it obtains the basename of the file without the extension (bname)

  • it then creates a new filename (fname) with the “-wp” for “wallpaper” appended to it (Eg. image-wp.jpg)

  • the gm convert command draws the text, sourced from the variable fname in white at XY coordinates 10,10 on the image

  • it saves the new image leaving the original untouched.

3
  • "It saves the new image leaving the original untouched." This is important, although I'm not crazy about building a new image instead of just overlaying text on the existing image. But since I can't find a Mac binary (SourceForge only has Windows exe files and Linux tarballs with source code). Feb 17 at 20:40
  • The link takes you to another answer with Homebrew and MacPorts versions.
    – Allan
    Feb 17 at 20:41
  • I'm getting closer, but Ventura seems to be the stumbling block. There are some tools (Geektool, Übersicht, BitBar) that can display the information (BitBar puts it into the menu bar instead of on the screen). Geektool's site is down, and it hasn't been updated since 2016. Übersicht seems like it would do the trick, as it will accept input from AppleScript. The problem is that Ventura "breaks" all existing scripts that identify the current desktop image. Grrr. Feb 19 at 21:14
0

I have managed to find an answer. It utilizes a combination of tools, but it works. Since I don't like answered questions to remain unanswered, here's my solution. May it help others.

Here's what I used:

  • Shell script
  • Shortcuts (included with macOS)
  • Plash (freeware, available on the App Store)
  • launchd (via launchctl)

Using the Shortcuts program, I started with a "run shell script" action that did a sqlite3 lookup into Apple's database holding the file names of wallpaper images. I then captured the result into a variable. Next, I added a text field that contained web directives as specified by Plash*. Then I replaced a placeholder text with the contents of the variable. Finally, I wrote out the contents to a local file called "index.html." This is the file Plash looks for when one specifies a "local website."

Then, I needed a way to update the overlay as images are changed. I wrote a two-line shell script to both run the Shortcut and then reload the Plash image.

Finally, I created a plist in my $HOME/Library/LaunchAgents folder to call the two-line script every ten minutes and loaded it via launchctl.

I may tweak the output display a bit, but the core operation is now established!

One thing just occurred to me that might make it even easier: Create a Shortcut that can live in my menu bar that replaces the plist/launchd automation, allowing me to update my overlay when I wish.

*Plash is a nifty piece of freeware created by Sindre Sorhus {https://sindresorhus.com}. It's feature-filled and the author is very responsive! There is a wealth of information about Plash on GitHub {https://github.com/sindresorhus/Plash}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .