Skip to content

Instantly share code, notes, and snippets.

@bitsgalore
Last active November 3, 2021 02:45
Show Gist options
  • Save bitsgalore/fc69e55c67830413f97c to your computer and use it in GitHub Desktop.
Save bitsgalore/fc69e55c67830413f97c to your computer and use it in GitHub Desktop.
Caja scripts for context menu actions in Linux Mint Mate

In Linux Mint Mate (with Caja file manager), store file under ~/.config/caja/scripts/ (in my case subfolder ~/.config/caja/scripts/pandoc-convert). The example here uses $CAJA_SCRIPT_SELECTED_FILE_PATHS, but I couldn't get this to work on my machine.

#!/bin/sh
# Analyze file with jpylyzer, display result with
# default text editor
# I/O stuff
fileIn=$1
fileOut=/tmp/"$fileIn".xml
# Viewer - default text editor (should work across most Linux flavors)
viewer=xdg-open
# Run Jpylyzer
jpylyzer "$fileIn" > "$fileOut"
# Display result
$viewer "$fileOut"
# Alternative would be to use Zenity:
# jpylyzer "$fileIn" |zenity --text-info --title "Jpylyzer output $fileIn" --width=640 --height=480
#!/bin/sh
# Convert Markdown file to docx using pandoc
fileIn=$1
fileOut=$fileIn.docx
pandoc -s -S --ascii -N --toc-depth=2 "$fileIn" -o "$fileOut"
@oblongau
Copy link

oblongau commented Nov 3, 2021

"The example here [broken link] uses $CAJA_SCRIPT_SELECTED_FILE_PATHS, but I couldn't get this to work on my machine."
I had been trying to use:

for f in "$CAJA_SCRIPT_SELECTED_FILE_PATHS"
do
   <something with $f>
done

but it did not work properly for multiple selected files. But the following works:

echo "$CAJA_SCRIPT_SELECTED_FILE_PATHS"|while read f
do
   <something with $f>
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment