There are two files
A) a desktop file - which is really just a launcher
and
B) a script which (A) will call.
This is where you put A (it starts from your home dir)
~/.local/share/applications/pcmanfm_open_libreoffice.desktop
This is what is inside A
[Desktop Entry]
Name=pcmanfm_open_libreoffice
GenericName=pcmanfm_open_libreoffice
Exec=/usr/local/bin/pcmanfm_open_libreoffice %u
Icon=libreoffice-document-new
Type=Application
Terminal=false
Categories=Office;
Keywords=documents;
(don’t put anything else inside A)
This is where you put B (it starts from root)
/usr/local/bin/pcmanfm_open_libreoffice
and must be executable.
This is what is inside B
#!/usr/bin/perl
my $url=$ARGV[0];
if($url=~m#^(/|file:).*run/user/[0-9]+/gvfs/([^:]+):server=([^,/]+),share=([^,/]+)/#) {
$url="smb://$3/$4/".$';
}
exec('libreoffice',$url);
(don’t put anything else inside B)
myfile.odt > Right-Click > Open With > Other Applications
> Office > pcmanfm_open_libreoffice
(that last bit should automatically show up because A exists)
>Set selected application as default action of this file type
>OK
The next time you use myfile.odt > Right-Click > Open With >
pcmanfm_open_libreoffice
should show up.
-End
( The only time you need a Custom Command is when you only have B (can’t be bothered to install A).