Skip to content

Instantly share code, notes, and snippets.

@ronjouch
Created August 17, 2013 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronjouch/6258621 to your computer and use it in GitHub Desktop.
Save ronjouch/6258621 to your computer and use it in GitHub Desktop.
PNGQuanter, Nautilus script that calls PNGQuant from Nautilus's 'script' menu
#!/bin/bash
# AUTHOR: Ronan Jouchet <ronan@jouchet.fr>, based on another author-less Nautilus script
# VERSION: 1.0
# LICENSE: MIT
# REQUIRES: -
# NAME: PNGQuanter
# DESCRIPTION: Reduce size with a call to pngquant
# INSTALL: Put script in ~/.local/share/nautilus/scripts and ensure it's executable
# Check that the user didn't select directories
for File in "$@"
do
if [ -d "$File" ]; then
zenity --error --text="'$File' is a directory.
PNGQuanter cannot handle directories."
exit
fi
done
# Use trash-put (provided by trash-cli) if present, else just rm
if which trash-put >/dev/null; then
pngquant "$@" && trash-put "$@"
else
pngquant "$@" && rm "$@"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment