I want to run oxipng *.png in /Users/user/Desktop/ immediately after a PNG screenshot (Cmd-Shift-3) is created in my Desktop folder.

I have the following plist file in ~/Library/LaunchAgents/ :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">

Then, I run launchctl load ~/Library/LaunchAgents/oxipng.plist. However, the PNG are never modified after creation.

How do I make oxipng run after a screenshot is saved to the Desktop folder?


1 Answer 1


Wildcards are expanded by shells only, so your plist just passes *.png to oxipng, a file which clearly doesn‘t exist. Create a shell script (which then runs cd ~/Desktop; oxipng *.png) and use launchd to trigger that.

  • Could you provide an example of the corresponding plist? I tried to run a .sh from the plist file, but it didn't do anything really. Commented Aug 26, 2022 at 9:08
  • @homocomputeris The same as the one you have, but with the shell script instead of oxipng. Ah, and use the full path (not just the name of the binary), otherwise it will for sure not work.
    – nohillside
    Commented Aug 26, 2022 at 10:27

You must log in to answer this question.

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