Nemo Actions

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
User avatar
sadi
Level 2
Level 2
Posts: 65
Joined: Sat Aug 21, 2010 3:16 pm
Location: Istanbul

Nemo Actions

Post by sadi »

Nemo Actions

Nemo file manager allows users to add entries to its context menu, which means it will take only one click to perform some complex file operations, for example, involving a number of commands. The folder /usr/share/nemo/actions contains some default actions as well as an example of a Nemo action, named sample.nemo_action, which may also be used as a template to create custom Nemo actions.

The file extension for action files is .nemo_action which may be self-sufficient or powered by some executable script file.

There are two directories where custom action files can be placed:
/usr/share/nemo/actions/ for system-wide actions
~/.local/share/nemo/actions/ for user actions

Some Examples and Resources

At the present, Linux Mint does not have a specific place for users to exchange/download custom Nemo actions, so this topic might be a starting point, where users can exchange information, tips, recommendations and custom actions.

The following is a list of git repositories including various Nemo actions created by users, ranging from 3 weeks to 5 years old, ordered here from the newest to the oldest.

Please use them at your own risk!

The fact that they are listed here does not mean they have been tested or they are recommended. It’s just a list created as a result of a simple search for “Nemo actions” at GitHub.

https://github.com/kelebek333/nemo-ffsend
• ffsend.nemo_action

https://github.com/brunetton/nemo-actions
• concatenate_wav.nemo_action
• convert_to_flac.nemo_action
• convert_to_mp3-128.nemo_action
• convert_to_mp3-192.nemo_action
• convert_to_mp3-256.nemo_action
• extract_sound.nemo_action
• flac_to_wav.nemo_action
• image-resize-1200.nemo_action
• image-resize-1500.nemo_action
• image-resize-2000.nemo_action
• image-resize-500.nemo_action
• image-resize-900.nemo_action
• paste_link.nemo_action
• pdf_repair.nemo_action
• pdf_to_djvu.nemo_action
• pdfimages_extract.nemo_action
• remove_empty_dirs.nemo_action
• stabilize_video-dir.nemo_action
• stabilize_video-file.nemo_action

https://github.com/dkebler/paste-link-here
• link-clipboard.nemo_action
• paste-link.nemo_action

https://github.com/kelebek333/nemo-actions
• nemo-refresh.nemo_action
• open-files-as-root.nemo_action
• peazip-add-archive.nemo_action
• peazip-extract-archive.nemo_action
• peazip-open-archive.nemo_action
• print.nemo_action
• printlibreoffice.nemo_action
• python2.nemo_action
• python3.nemo_action

https://github.com/DanielBonnery/System ... mo_actions
• XXXtex.nemo_action
• pdflatexme.nemo_action

https://github.com/DuMuT6p/my-nemo-actions
• enqueue-in-audacious.nemo_action
• force-screen-turn-off.nemo_action
• refreshless-refresh.nemo_action

https://github.com/pedro-augusto-santan ... _selection
• new_folder_with_selection.nemo_action

https://github.com/ckrmml/nemo_actions
• open_with_atom.nemo_action
• open_with_gitkraken.nemo_action
• run-with-nvidia.nemo_action

https://github.com/damko/nemo_actions
• compare-meld.nemo_action
• gpg_encr.nemo_action
• lock.nemo_action
• md2html.nemo_action
• md2pdf.nemo_action
• md5hash-check.nemo_action
• md5hash.nemo_action
• normalize_name.nemo_action
• open_as_root.nemo_action
• pdfshuffler.nemo_action
• recursively_set_std_permissions.nemo_action
• share_pictures.nemo_action
• unlock.nemo_action

https://github.com/schorschii/nemo-acti ... ess-images
• compress-images.nemo_action

https://github.com/cbop-dev/MyTags
Nemo extension and action for tagging files and managing file tags.

https://github.com/diegosanz/nemo-open-with-atom
• atom.nemo_action

https://github.com/felipem775/nemo-actions-scripts
• (CovertImages)toPDF.nemo_action

https://github.com/luluco250/Nemo_OpenWithVSCode
• VSCode_Open_Background.nemo_action
• VSCode_Open_Folder.nemo_action

https://github.com/rodolpheh/nemo-actions
• CompressMultiplePDF.nemo_action

https://github.com/JollyDevelopment/nemo-actions
• compress-dirs.nemo_action
• compress-files.nemo_action

https://github.com/rapgenic/nemo-run-with-nvidia
• run-with-nvidia.nemo_action

https://github.com/erickj/nemo-actions
• deja-dup_restore-missing.nemo_action
• deja-dup_revert.nemo_action

https://github.com/Ragnarokkr/nemo-actions
• MTNA-Folders-TemplateCreator-Photo.nemo_action

https://github.com/Acidburn0zzz/Nemo-UltraCopier
• nemo-ultracopier-folder.nemo_action
• nemo-ultracopier.nemo_action

https://github.com/Alfcx/linux-mint-nemo-actions
• convert-doc-to-odt.nemo_action
• convert-to-pdf.nemo_action
• pdf-downsizer.nemo_action
• pdf-merger.nemo_action
• pdf-metadata-editor.nemo_action
• pdf-rotator.nemo_action
• scan-to-sandwich-pdf.nemo_action

https://github.com/Jubei-Mitsuyoshi/aaa-nemo-actions
• mount-android-image.nemo_action
• mount-virtual-disk.nemo_action
• unsquash_fs.nemo_action
Last edited by sadi on Sun Dec 22, 2019 4:39 am, edited 1 time in total.
Linux Mint 19.3 Cinnamon
User avatar
smurphos
Level 18
Level 18
Posts: 8501
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Nemo Actions

Post by smurphos »

I've just uploaded my current collection of nemo actions to a github repo.

https://github.com/smurphos/nemo_action ... on_scripts

Nemo Actions Index

Desktop context menu actions

Close windows actions.

A set of two actions and an associated shell script to allow the user to gracefully close all open windows on the current workspace or all workspaces via right click on the desktop. The script requires wmctrl and xdotool apt install wmctrl xdotool

close_windows_in_workspace.nemo_action
close_all_windows.nemo_action
close_windows.sh


Workspace management actions

A set of six actions to allow easy management of workspaces from the desktop context menu. The next and previous workspace actions require xdotool apt install xdotool

new-workspace.nemo_action
delete-workspace.nemo_action
previous_workspace.nemo_action
next_workspace.nemo_action
workspace_overview.nemo_action
window_overview.nemo_action


Background slide-show actions

An action to quickly toggle the desktop background slide-show, along with an action to select the next wallpaper when the slide-show is active.

toggle_slideshow.nemo_action
next-wallpaper.nemo_action


Session management actions

The first two actions give quick access from the desktop context menu to the shutdown and logoff session dialogues.

session_menu_logout.nemo_action
session_menu_poweroff.nemo_action


These five actions immediately invoke the requested action.

session_reboot.nemo_action
session_shutdown.nemo_action
session_suspend.nemo_action
session_lock.nemo_action
session_logout.nemo_action


General Actions

Open with admin privileges actions

These actions give you a choice of applications to edit text based files with admin privileges.

The sudo_nano action and associated script will open the file in nano a terminal based text editor, elevating privileges only if necessary.

sudo_nano.nemo_action
sudo_nano_check.sh


The xed_admin action and associated script will open the file in the text editor xed elevating privileges with admin:// if necessary.

xed_admin.nemo_action
xed_admin_check.sh


File actions as admin

These actions and their associated shell scripts allow the user to undertake a range of file management activities with elevated privileges if needed from a regular instance of Nemo.

They will all request password authentication if elevated privileges are necessary to complete the action. All require zenity - apt install zenity

Copy/paste (Admin)

Supports single and multiple selections. Uses zenity to select destination.

copy_paste_admin.nemo_action
copy_paste_admin.sh


Cut/paste (Admin)

Supports single and multiple selections. Uses zenity to select destination.

cut_paste_admin.nemo_action
cut_paste_admin.sh


Creating links (Admin)

Supports single selections only . Uses zenity to select destination.

create_link_in_target.nemo_action
create_link_in_target.sh


Create Directory (Admin)

This action has two nemo_action files, one for right-click on a directory, and one for right-click on empty space.

create_dir_admin.nemo_action
create_dir_admin_background.nemo_action
create_dir_admin.sh


Create File (Admin)

This action has two nemo_action files, one for right-click on a directory, and one for right-click on empty space.

create_file_admin.nemo_action
create_file_admin_background.nemo_action
create_file_admin.sh


Delete (Admin)

Supports single and multiple selections.

delete_admin.nemo_action
delete_admin.sh


Rename (Admin)

Supports single selections only.

rename_admin.nemo_action
rename_admin.sh


Bulk rename actions

Both these actions open the bulk rename utility GPrename - apt install gprename One action is for a single folder selection to bulk rename files in that folder. The other is for multiple selections and opens GPrename in the parent folder.

bulk_rename_files.nemo_action
bulk_rename_folders.nemo_action


Media info

Shows information about media files in a separate window. Requires mediainfo-gui - apt install mediainfo-gui

media-info.nemo_action

Search folders

Opens the selected folder in Searchmonkey - apt install searchmonkey for more fine-tuned file system searches including search by contents.

searchmonkey.nemo_action

View a tree-view directory structure in your browser

An action and associated shell script to produce an html tree-view of the directory and file structure below the selected directory. Requires tree - apt install tree

print_tree.nemo_action
print_tree.sh


Copy a random selection of files from a directory

Ever wanted to grab a random selection of music files or pictures from a collection? This action is for you. Uses zenity - apt install zenity to ask the user to confirm number of files and where to paste them.

get_random_file.nemo_action
get_random_files.sh


Toggle checked emblem

An action and associated shell script to quickly add or remove a ✓ emblem to the file/folder.

toggle_checked.nemo_action
toggle_checked.sh


Update a files modification date

touch_file.nemo_action

Check a shell script for errors

This action and associated shell script will check your shell scripts for errors with shellcheck apt install shellcheck Scripts with no issues will be marked with a checked emblem, scripts with warnings will be marked with a warning emblem and the shellcheck output along with the shell script itself will be opened in a text editor for review.

shellcheck.nemo_action
shellcheck.sh
Last edited by smurphos on Sat Apr 13, 2019 8:25 am, edited 4 times in total.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
User avatar
sadi
Level 2
Level 2
Posts: 65
Joined: Sat Aug 21, 2010 3:16 pm
Location: Istanbul

Re: Nemo Actions

Post by sadi »

I've also posted a small selection here: https://github.com/Sadi58/nemo-actions
  • Dir-Search-Text: A simple bash script to search for text in a directory and display list via zenity (dependency)
  • EXIF-Data: A simple bash script to retrieve the metadata of selected audio/video/image file(s) using exiftool (dependency) and display via zenity (dependency)
  • Folder-Contents: A simple bash script to list contents of a directory with several options (filenames/pathnames/recursive) and display list via zenity (dependency)
  • Image-to-JPG: A simple bash script to convert selected image files to jpeg format using convert (dependency)
Linux Mint 19.3 Cinnamon
User avatar
smurphos
Level 18
Level 18
Posts: 8501
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Nemo Actions

Post by smurphos »

sadi wrote: Sun Apr 07, 2019 8:51 am I've also posted a small selection here: https://github.com/Sadi58/nemo-actions
  • Dir-Search-Text: A simple bash script to search for text in a directory and display list via zenity (dependency)
  • EXIF-Data: A simple bash script to retrieve the metadata of selected audio/video/image file(s) using exiftool (dependency) and display via zenity (dependency)
  • Folder-Contents: A simple bash script to list contents of a directory with several options (filenames/pathnames/recursive) and display list via zenity (dependency)
I've just tried these three - very nice indeed. :)

A note of caution and a tip for users trying any action sourced from a third party. If the Icon-Name specifies an icon that doesn't actually exist in the icon path of your system the action won't appear at all in the context menu. So if you are having issues with an action not showing up commenting it's Icon-Name out with a # is a good trouble-shooting step.

Also at least one release of Nemo (I think in Mint 19 IIRC) required actions to use symbolic icons only although that restriction was dropped in the current release.

I neglected to double check that all of the Icon-Names in my uploaded actions exist in Adwaita. A job for tomorrow.

I've also added a few more to my repo that allow file actions (delete, rename. copy/paste) that require admin privileges to be undertaken without having to open nemo as root.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
User avatar
sadi
Level 2
Level 2
Posts: 65
Joined: Sat Aug 21, 2010 3:16 pm
Location: Istanbul

Re: Nemo Actions

Post by sadi »

smurphos wrote: Mon Apr 08, 2019 2:39 am A note of caution and a tip for users trying any action sourced from a third party. If the Icon-Name specifies an icon that doesn't actually exist in the icon path of your system the action won't appear at all in the context menu. So if you are having issues with an action not showing up commenting it's Icon-Name out with a # is a good trouble-shooting step.

Also at least one release of Nemo (I think in Mint 19 IIRC) required actions to use symbolic icons only although that restriction was dropped in the current release.

I neglected to double check that all of the Icon-Names in my uploaded actions exist in Adwaita. A job for tomorrow.
I haven't noticed this and tested under my current Linux Mint 19.1 Cinnamon 64-bit system.
If there's an icon problem the action still shows in the context menu and works as usual.
If the icon cannot be found I see a symbolic warning icon instead of a proper one, and if no icon is specified the icon column is blank in the plugins window / actions pane of Nemo.

Maybe such an action will fail if the user has enabled icons in menus?
Linux Mint 19.3 Cinnamon
User avatar
smurphos
Level 18
Level 18
Posts: 8501
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Nemo Actions

Post by smurphos »

sadi wrote: Mon Apr 08, 2019 4:34 am I haven't noticed this and tested under my current Linux Mint 19.1 Cinnamon 64-bit system.
Yeah you are right - I think I'm thinking of whatever nemo version it was where symbolic icons were briefly a requirement, and I think that nemo version has been superseded in whatever Mint release it was in... :roll:
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
User avatar
sadi
Level 2
Level 2
Posts: 65
Joined: Sat Aug 21, 2010 3:16 pm
Location: Istanbul

Re: Nemo Actions

Post by sadi »

Linux Mint 19.2 Cinnamon: New feature in Nemo Actions: "The condition for nemo actions can now be an external script or command."

I would be nice if someone could give a couple of examples for this new feature, as the file 0-Sample.Nemo.Action only contains this:
# Conditions - semicolon-separated array of special conditions:
# "desktop" current (parent) folder is desktop
# "removable" target (first selection) is removable
# "gsettings <schema> <boolean key>" is true
# "gsettings <schema> <key> <key-type> <[eq|ne|gt|lt]> <value>"
# "dbus <name>" exists
Linux Mint 19.3 Cinnamon
Fuzzy
Level 4
Level 4
Posts: 251
Joined: Thu Jul 28, 2011 11:54 am

Re: Nemo Actions

Post by Fuzzy »

Wow! Thanks for sharing this capability! I had no idea this was in mint/nemo. I'm using LMDE3, and after reading through your postings, I was able to setup one very helpful action...and one really (for me) helpful script.

The action is basically an image resize using Imagemagick's convert command.

The script is a bash script that I had been using from terminal to santitize URLs (removing tracking information, etc) - now, with the addition of xsel, all I have to do is copy the link and right-click in nemo, choose the script and poof - I'm taken to the sanitized URL! Really nice. Thank you both for sharing your ideas and pointing out this feature.

I'll be using the action menu for a few more image resizing tasks as well. Really nice!

I do need to figure out how to get the convert command to place copies of the selected files into a subfolder - but using the same name as the file(s) original had. Right now, it grabs the filename of the first file, and appends a -0 -1 -2 etc to the end of the name, and names all the files in that standard. Meaning, if I had a file named Happya.jpg and a file named Happyb.jpg - after running my nemo action (convert), it places both files into a folder named "Resized" (like I want it to), but instead of being Happya.jpg and Happyb.jpg, the resized files appear as Happya-0.jpg and Happya-1.jpg.

I'll have to do a little more reading to figure that out, but that's no big deal.

Thanks again...very excited about this!

Fuzzy
User avatar
choochooal
Level 1
Level 1
Posts: 44
Joined: Tue Jun 28, 2011 7:54 pm

Re: Nemo Actions

Post by choochooal »

I have located a long list of actions and tried applying some of them to my Cinnamon Mint 19.3 system. For credit: https://github.com/smurphos/nemo_action ... on_scripts
The ones where a script is required don't seem to work. I put the script in the scripts folder. The exec lines is exec=<scripts/whatever.sh> But they don't run. If I changed the action to exec=<whatever.sh> and put the script in the actions folder, it runs fine.
So what's up? And some scripts I have seen don't have the <> in the exec and some do, is there a rule here that I'm missing?

As for the icon, I found that a full path name like /home/alan/Icons/arrow.png does not work. However I have a custom icon theme and if I put the arrow.png in ~/.icons/theme/scalable/mimetypes/arrow.svg and then just enter the icon name 'arrow' it shows on the right-click now. I have not tested just putting the svg in my Icons folder and pathing to it, rather than using my icon theme. Not sure if actions are looking for SVG images and not PNG but someone might want to test that.
Linux Mint 20.3 Cinnamon 64-bit. Dual boot with Windows 10
User avatar
smurphos
Level 18
Level 18
Posts: 8501
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Nemo Actions

Post by smurphos »

Hi choochooal,

For my actions as written the shell scripts should go in ~/.local/share/nemo/actions/scripts (not a folder that exists by default).

~/.local/share/nemo/scripts is for scripts that you want to be able to launch from the scripts context menu entry.

Re the <> notation it indicates to look the actions directory for the script - so

Exec=<blah.sh> means look for and run ~/.local/share/nemo/actions/blah.sh
Exec=<scripts/blah.sh> means look for and run ~/.local/share/nemo/actions/scripts/blah.sh

Re icons it only accepts the name of icons that are available in your current icon-theme path.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
User avatar
choochooal
Level 1
Level 1
Posts: 44
Joined: Tue Jun 28, 2011 7:54 pm

Re: Nemo Actions

Post by choochooal »

Thanks smurphos. That seems so straight forward. And got some cool actions I have to look at more closely.
Linux Mint 20.3 Cinnamon 64-bit. Dual boot with Windows 10
LittleScriptMan
Level 3
Level 3
Posts: 158
Joined: Thu Jan 13, 2022 8:42 am

Re: Nemo Actions

Post by LittleScriptMan »

smurphos wrote: Thu Jul 23, 2020 12:29 pm ~/.local/share/nemo/scripts is for scripts that you want to be able to launch from the scripts context menu entry.
I noticed, almost by accident, that Nemo scripts can also be easily used in command line. A small example with a little script creating a symlink of the current directory on the desktop :

Code: Select all

#!/bin/bash
# Sod : Symlink on desktop - Creates a symlink of the current directory on the desktop
# present working directory in variable CurDir
CurDir=$(pwd)
# use Bash Parameter Expansion to remove the longest pattern ending with a / = just keep last dir in variable name
name=${CurDir##*/}
# use Bash Parameter Expansion for first character uppercase of variable name and store it in SLName
SLName=${name^}
# Create a symlink named SLName for CurDir on Desktop
ln -s "$CurDir" ~/Bureau/"$SLName"
This script Sod.sh must be created/saved in ~/.local/share/nemo/scripts and execution must be allowed.

As already said above, it appears in the Scripts menu when you right click and creates the link on the desktop as expected.

After adding the nemo scripts path to the PATH variable :

Code: Select all

if [ -d "$HOME/.local/share/nemo/scripts" ]; then export PATH=$HOME/.local/share/nemo/scripts:$PATH; fi
the Sod script also works in CLI/Terminal : any folder you're exploring through the command line (mostly using cd) can be symlinked on the desktop.

It was an interesting "discovery" for me to realize scripts located in the nemo/scripts folder could be added to the PATH and work under command line.
Interests : Firefox, Cinnamon & Bash Scripts
LM Version : LMDE5 (LMDE4 just in case)
LittleScriptMan
Level 3
Level 3
Posts: 158
Joined: Thu Jan 13, 2022 8:42 am

Re: Nemo Actions

Post by LittleScriptMan »

LittleScriptMan wrote: Wed Apr 13, 2022 4:39 pm
smurphos wrote: Thu Jul 23, 2020 12:29 pm ~/.local/share/nemo/scripts is for scripts that you want to be able to launch from the scripts context menu entry.
I noticed, almost by accident, that Nemo scripts can also be easily used in command line. A small example with a little script creating a symlink of the current directory on the desktop :

Code: Select all

#!/bin/bash
# Sod : Symlink on desktop - Creates a symlink of the current directory on the desktop
# present working directory in variable CurDir
CurDir=$(pwd)
# use Bash Parameter Expansion to remove the longest pattern ending with a / = just keep last dir in variable name
name=${CurDir##*/}
# use Bash Parameter Expansion for first character uppercase of variable name and store it in SLName
SLName=${name^}
# Create a symlink named SLName for CurDir on Desktop
ln -s "$CurDir" ~/Desktop/"$SLName"
This script Sod.sh must be created/saved in ~/.local/share/nemo/scripts and execution must be allowed.

As already said above, it appears in the Scripts menu when you right click and creates the link on the desktop as expected.

After adding the nemo scripts path to the PATH variable :

Code: Select all

if [ -d "$HOME/.local/share/nemo/scripts" ]; then export PATH=$HOME/.local/share/nemo/scripts:$PATH; fi
the Sod script also works in CLI/Terminal : any folder you're exploring through the command line (mostly using cd) can be symlinked on the desktop.

It was an interesting "discovery" for me to realize scripts located in the nemo/scripts folder could be added to the PATH and work under command line.
Interests : Firefox, Cinnamon & Bash Scripts
LM Version : LMDE5 (LMDE4 just in case)
User avatar
smurphos
Level 18
Level 18
Posts: 8501
Joined: Fri Sep 05, 2014 12:18 am
Location: Irish Brit in Portugal
Contact:

Re: Nemo Actions

Post by smurphos »

All my nemo scripts actually live in ~/.local/bin so are already on the $PATH (that directory is added automagically to $PATH if it exists). I then put symlinks to relevant the scripts in ~/.local/share/nemo/scripts. Same effect different way.
For custom Nemo actions, useful scripts for the Cinnamon desktop, and Cinnamox themes visit my Github pages.
zzapper2
Level 1
Level 1
Posts: 18
Joined: Mon Jun 22, 2020 10:48 am

Re: Nemo Actions

Post by zzapper2 »

Sadi
Is there a YouTube or other Demo Video?
User avatar
Koentje
Level 6
Level 6
Posts: 1488
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: Nemo Actions

Post by Koentje »

I don't know if i need to open a new topic or can post it here, but i made a small nemo action script myself. While busy with srt (subtitel files) i sometimes need quick info on the metadata of a video file. It is pretty simple, but maybe useful for some?

Place Video-metadata.nemo_action into folder ~/.local/share/nemo/actions.
Place videometa.sh into a folder and change in Video-metadata.nemo_action the Exec to the path of the bash script.

Have fun!
video-matadata-1.0.tar.gz
(981 Bytes) Downloaded 59 times
User avatar
Koentje
Level 6
Level 6
Posts: 1488
Joined: Tue Jan 04, 2022 6:23 pm
Location: Netherlands

Re: Nemo Actions

Post by Koentje »

I made some adjustments, so now it also reads audio metadata and shows it in a mono font for easier read.
media-metadata-1.1.tar.gz
(991 Bytes) Downloaded 52 times
User avatar
dentex
Level 1
Level 1
Posts: 42
Joined: Thu Sep 23, 2010 3:45 am
Location: Italy
Contact:

Re: Nemo Actions -

Post by dentex »

Hello,
I made this script that can be used as nemo action. Please check if you find it useful. :D

https://github.com/dentex/apply_custom_icon

I would have answered to this thread viewtopic.php?t=206301 but it's locked. :?
duracell80
Level 3
Level 3
Posts: 111
Joined: Fri Sep 23, 2022 5:51 pm

Re: Nemo Actions

Post by duracell80 »

That is really cool !!

I guess it applies the folder thumbnail as an emblem? Would be very helpful for properly organizing wallpapers/backgrounds in Nemo. Was it Windows 7 or Vista that started doing folder previews like that or previous? I can't remember exactly but I do recall that being pretty innovative at the time.

I wonder if this could become part of default nemo behavior, if each folder in the ~/Pictures directory was scanned at startup/login it could randomly pick the 4 images to montage for each folder in the Pictures directory. With the configuration abstracted into nemo settings. It would have to standardize around say a file such as .folder-thumb. If any folder contained an image file .folder-thumb then it could be appended as an emblem.

Emblems would work well if they can cover the whole folder image area, then the folder icons / colors can be changed without having to regenerate the composite folder+preview together.
duracell80
Level 3
Level 3
Posts: 111
Joined: Fri Sep 23, 2022 5:51 pm

Re: Nemo Actions

Post by duracell80 »

Convert a HEIF to JPEG directly in Nemo (helpful for those not upgrading too).

Sample files:
https://filesamples.com/formats/heif
https://filesamples.com/samples/image/heif/sample1.heif

Code: Select all

$ mkdir -p ~/.local/share/powertoys
$ sudo apt install zenity libheif-examples

$ nano ~/.local/share/nemo/actions/pt-convert-heif_jpg.nemo_action
- paste following code to file and save
~/.local/share/nemo/actions/pt-convert-heif_jpg.nemo_action

Code: Select all

[Nemo Action]
Name=Convert HEIF to JPG
Comment=Converts a high efficiency image format file to jpeg
EscapeSpaces=true
Exec=/home/youruser/.local/share/powertoys/convert_heif.sh "jpg" %F
Selection=S
Extensions=heic;heif
Dependencies=heif-convert;zenity
Optionally swap JPG for PNG in the Nemo Action

Code: Select all

$ nano ~/.local/share/powertoys/convert_heif.sh
- paste into that file and save
~/.local/share/powertoys/convert_heif.sh

Code: Select all

#!/bin/sh

FILE_DIR=$(dirname "$2")
FILE_BIT=$(basename "$2")

FILE_NME=${FILE_BIT%%.*}
FILE_EXT=${FILE_BIT##*.}

(
echo "50"
echo "# Converting HEIF Image to ${FILE_NME}.${1}"
sleep 2
echo "65"
if [ "$1" = "jpg" ]; then
    heif-convert "$2" "${FILE_DIR}/${FILE_NME}.jpg"
    echo "75"
    sleep 2
    echo "# Completed ${FILE_NME}.$1"
    echo "100"

elif [ "$1" = "png" ]; then
    heif-convert "$2" "${FILE_DIR}/${FILE_NME}.png"
    echo "95"
    sleep 2
    echo "# Completed ${FILE_NME}.$1"
    echo "100"
fi

) |
zenity --progress \
  --title="Converting to ${1}" \
  --text="Running convert ..." \
  --percentage=25 \
  --width=500 \
  --timeout=60

if [ "$?" = -1 ] ; then
        zenity --error \
          --text="Conversion canceled"
fi
Optional, logout log back in, fire up nemo and right click on a downloaded sample file from https://filesamples.com/formats/heif
Post Reply

Return to “Scripts & Bash”