-
Notifications
You must be signed in to change notification settings - Fork 17
Configuration Examples
You can add these examples to your configuration by:
- Opening the configurator
- Opening the embedded JSON source editor (the
JSON
button in the top button row) - Copying the JSON source from the desired example (all of it!)
- Pasting that into the top-level
actions
JSON array in the configurator source editor, after the last existing action - Clicking on the source editor's
Save
button - Clicking on the configurator's
Save
button
Would it REALLY be so hard to prompt for the file name of the New Document when you use the Files built-in menu item for that??? And how many times have you forgotten to hit F2 to do the rename and ended up in the search tool (especially if you have come from a previous version of Nautilus where they did prompt for the name)?
Well, here goes (albeit without the "template" feature, but that would actually be pretty easy to add too):
, {
"type": "command",
"label": "New Document...",
"command_line": "FN=$(zenity --entry --text \"Enter file name\" --width 300) && touch ${FN}",
"cwd": "%f",
"use_shell": true,
"max_items": 1,
"permissions": "read-write",
"filetypes": [
"directory"
]
}
This example can be generalized to any use-case where some user input is required before the target command is executed.
Another missing feature from at least POP OS is the old ability to execute the meld
comparison tool on a multi-select, or save off a single selection and compare to it later.
A4N to the rescue again! And this really shows off the "no script required" features of the extension:
, {
"type": "command",
"label": "Compare",
"command_line": "meld %F",
"min_items": 2,
"max_items": 2,
"filetypes": ["standard"]
}, {
"type": "menu",
"label": "Compare...",
"actions": [{
"type": "command",
"label": "Compare later...",
"command_line": "echo -n %f > /tmp/${USER}-a4n-compare-later.txt",
"use_shell": true,
"max_items": 1,
"filetypes": ["standard"]
}, {
"type": "command",
"label": "Compare to previous",
"command_line": "if [ -e /tmp/${USER}-a4n-compare-later.txt ]; then meld %f \"$(cat /tmp/${USER}-a4n-compare-later.txt)\"; else zenity --title \"Cannot compare\" --error --text \"No previously saved selection\"; fi ",
"use_shell": true,
"max_items": 1,
"filetypes": ["standard"]
}]
}
Note obviously you must install the meld
comparison tool for this to work as-is - but, of course, you can adapt it to your preferred UI comparison tool - e.g. xxdiff
.
You just want to know if two files differ or match - particularly binary files? Use cmp
:
,{
"type": "command",
"label": "Quick compare",
"command_line": "TEXT=\"%B\"; RSLT=\"DIFFER\"; cmp -s %F && RSLT=\"MATCH\"; zenity --info --text \"${TEXT}\\n${RSLT}\" --title \"quick compare files\"",
"use_shell": true,
"min_items": 2,
"max_items": 2,
"filetypes": [
"file"
]
}
To compare to a previously selected file (as with meld
in the previous example), add this action to those of the Compare...
submenu in the previous example:
,{
"type": "command",
"label": "Quick compare to previous",
"command_line": "if [ -e /tmp/${USER}-a4n-compare-later.txt ]; then FILE=\"$(cat /tmp/${USER}-a4n-compare-later.txt)\"; TEXT=\"%f ${FILE}\"; RSLT=\"DIFFER\"; cmp -s \"%f\" \"${FILE}\" && RSLT=\"MATCH\"; zenity --info --text \"${TEXT}\\n${RSLT}\" --title \"Quick compare files\"; else zenity --title \"Cannot compare\" --error --text \"No previously saved selection\"; fi ",
"use_shell": true,
"max_items": 1,
"filetypes": [
"file"
]
}
(Contributed by @biokomiker)
,{
"type": "command",
"label": "encode video with H.265",
"command_line": "ffmpeg -y -hide_banner -i %b -vf yadif -c:v hevc %w.mp4 ; exiftool -ee -overwrite_original_in_place -tagsFromFile %b %w.mp4",
"cwd": "%d",
"use_shell": true,
"mimetypes": [
"video/*"
],
"filetypes": [
"!directory",
"standard"
]
}
Works with MTS files (Sony) and MOV files (Canon ?) which have H264 codec. Compression is ~ 10x. The exiftool
command copies the tag of the recorded time stamp.
(Contributed by @biokomiker)
{
"type": "command",
"label": "compress pdf",
"command_line": "gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dNOPAUSE -dQUIET -dBATCH -dAutoRotatePages=/None -dPDFSETTINGS=/ebook -r100 -sOutputFile=%w\"_compressed.pdf\" %b",
"cwd": "%d",
"mimetypes": [
"application/pdf"
],
"filetypes": [
"standard"
]
},
(-r
sets the resolution - -rXxY
or, if as above with only one dimension, used for both dimensions. This has a strong effect on file size. Without -r
, the file size is strongly affected by the -dPDFSETTINGS=
setting (above this is /ebook
) - if you set that to -dPDFSETTINGS=/screen
, for example, you will get tiny pdfs with very low resolution).
(Contributed by @biokomiker)
, {
"type": "command",
"label": "restore previous version",
"command_line": "deja-dup --restore %F",
"mimetypes": [],
"filetypes": [
"file",
"directory"
]
}
- Go to its folder
- Open a terminal
-
cat
the document
(or open it in an editor of course).
But I prefer this:
,{
"type": "command",
"label": "Cat Document",
"command_line": "zenity --text-info --width 600 --height 600 \"--filename=%f\" \"--title=%f\" \"--font=Courier New\" --no-wrap",
"use_shell": true,
"max_items": 1,
"filetypes": [
"file"
]
}
A shortcut through Open as Administrator followed by Open in Terminal:
,{
"type": "command",
"label": "Terminal as root",
"command_line": "pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY gnome-terminal -t \"ROOT: %f\" \"--working-directory=%f\"",
"cwd": "%f",
"use_shell": true,
"max_items": 1,
"filetypes": [
"directory"
]
}
There is a slight "gotya" with this if you are using a Wayland-based distribution. The auth window will show but the terminal may not. The fix is to install the package dbus-x11
- don't worry, it doesn't pull in anything that you won't already have.
,{
"type": "menu",
"label": "Hashes",
"actions": [
{
"type": "command",
"label": "MD5",
"command_line": "zenity --title \"MD5 of %f\" --info --text=$(md5sum %f | awk '{print $1}')",
"use_shell": true,
"max_items": 1,
"filetypes": [
"!directory"
]
},
{
"type": "command",
"label": "SHA256",
"command_line": "zenity --title \"SHA256 of %f\" --info --text=$(sha256sum %f | awk '{print $1}')",
"use_shell": true,
"max_items": 1,
"filetypes": [
"!directory"
]
}
]
}
Obviously, you need the hash summing commands to be installed, but add as many as you need!
The name says it all! Thanks to @Lukas-Schillinger for the contribution, according to whom, looking at google search for adding "Open in VS Code" to the context menu, this is a fairly sought after feature!
, {
"type": "command",
"label": "Open in VS Code",
"command_line": "code --new-window %f",
"filetypes": [
"directory",
"file"
]
}
The tool jless is a command line viewer of JSON and YAML files that, none-the-less, interacts well with the mouse (i.e. in a terminal emulator).
So here's how to use it as a Gnome Files action:
, {
"type": "command",
"label": "View with jless",
"command_line": "gnome-terminal --title %f -- jless %f",
"min_items": 1,
"max_items": 1,
"mimetypes": [
"application/json",
"application/yaml",
"application/x-yaml"
]
}
Using jless again, but this time to examine the data file in a SongBook Pro archive.
A little background: this archive is a zip file containing two files. The one we are interested in is named dataFile.txt
. Essentially this file contains a pure JSON object - except that it also has a first line that gives version info, outside of the JSON structure. So we want to extract the JSON object (everything after the first line) and view it in jless
... in a terminal.
The pipeline is a little complex, but this shows how you make gnome-terminal
execute its command string as a shell pipeline:
, {
"type": "command",
"label": "View with jless",
"command_line": "gnome-terminal --title %f -- sh -c 'unzip -p \"%f\" dataFile.txt | tail -n +2 | jless'",
"min_items": 1,
"max_items": 1,
"mimetypes": [
"application/zip"
],
"path_patterns": [
"*.sbp"
]
}
And note that you CAN use this example and the previous example together unambiguously because, although they have the same label, they have mutually exclusive mimetype filters.