Tuesday, August 23, 2016

Adding menu items to Nemo (Linux Mint file manager)

So, I'm running Linux Mint 18. Its default file manager is Nemo (Version 3.0.6)

I'm trying out right-click context menu options in Nemo.

STEP 1:
Create a test script in Perl. I've saved it as /home/sbb/bin/nemotest.pl, and chmod +x 'd it. Its sole purpose is to print out the given arguments.


1:  #!/usr/bin/perl  
2:    
3:  use strict;  
4:  use warnings;  
5:    
6:  while (my $e=shift) {  
7:   print "$e\n";  
8:  }  
9:  sleep 10;  

STEP 2:
Create an action script in ~/.local/share/name/actions . Call it test.nemo_action  (The file extension is important).

1:  [Nemo Action]  
2:  Name=Test  
3:  Comment=  
4:  Exec=gnome-terminal -x /bin/sh -c "/home/sbb/bin/nemotest.pl %U %F %P %p"  
5:  Selection=s  
6:  Extensions=any;  
7:  EscapeSpaces=true  

STEP 3:
Try it. Fire up Nemo, right-click on a file.


If all goes well, the result should be:


We can now see the output produced by each of the % variables in the .nemo_action file. Note that spaces in the file name are handled nicely.

STEP 5:
More reading.
Here's a link with some useful information.

I've tried multiple selections as well. Selection=m in the nemo_action file will make the menu item apply to multiple selections. In this case, the %U and %F substitutions will put multiple items on the command line.

Directories too. Extensions=dir; and you're right clicking with directories.

A handy note: Nemo reads the .nemo_action files on the fly, so you don't have to exit and restart Nemo each time you make a change to the files.

Another handy note: http://codeformatter.blogspot.com.au/ does the code formatting.

No comments:

Post a Comment