PCManFM Mod - User-Definable Commands And More

The dedicated forum for PCMan File Manager - http://wiki.lxde.org/en/PCManFM
IgnorantGuru
Posts: 30
Joined: Sat Feb 27, 2010 7:35 pm
Contact:

PCManFM Mod - User-Definable Commands And More

Post by IgnorantGuru »

Hello LXDEers. I just got around to checking out this forum. I would like to invite you to give my mod of PCManfFM 0.5.2 a try. After dropping KDE and changing to Openbox, I selected PCManFM for my FM, but I missed having some commands I could customize, and a few other features. So I wrote this mod for my own use and have been sharing it on my blog and on the Arch forum for awhile (thread link).

I've also spoken with PCMan about adding some of these ideas to his new version and he seemed very receptive. So if you like the features in the mod please let him know. I haven't had much success running the git versions of his rewrite yet, which is why I modded the stable 0.5.2, but I'm going to keep an eye on the new version.

You can check out the website for details on the mod and download. It can be installed alongside the normal 0.5.2 version, or if you use Arch you can use the AUR. Others can use the installmod scripts that builds and installs it with one command.

Below are the key features of the mod reprinted.

1) Adds five user-definable commands to the right-click and Tools
menus (and keys F4, F6-F9). The menu names and commands are
derived from .desktop files. When run, all selected
files are passed to the command. (see NOTES below)

2) An example opener script is included as the default F4
user command, which opens all selected files. (see NOTES below)

3) A "Run Command..." (Ctrl-R) has been added to the Tools and
right-click menus. This allows the user to run an
arbitrary command line, include %U to insert all selected
files into the command, and optionally run the command
in a terminal to see the output.

4) When a single symlink is selected, its target and target's
size are displayed in the status bar

5) A "Paste as Link" command has been added to the edit menu and
Ctrl-Shift-V to paste links to files on the clipboard

6) The default home folder can be set in the main config file
(see NOTES below)

7) "no_execute" can be set in the main config file to prevent
launching of executables (see NOTES below)

8) A different program icon is used when in super user mode

9) The Go|Home key is changed from Alt-Home to Escape

10) The default button on the delete dialog is changed to Yes

11) When enter is pressed in the Rename/Overwrite dialog, rename is
assumed

12) Ctrl-F is assigned to Create New Folder instead of search
(pressing any normal key still initiates a search)

13) The F5 Refresh function has been improved

14) .desktop files display their actual filenames rather than name

15) File list is given focus when a dir is entered or a new tab added

16) Copying and pasting a single folder into its own parent now
asks for a new name rather than attemting to copy the folder into
itself. Pasting a folder into a selected folder no longer works.

17) Bugfix: Right-clicking on a dangling sym-link now displays menu

18) Bugfix: A bug which prevented opening multiple folders on the
pcmanfm command line has been corrected

19) Bugfix: Fixed error message on create new folder cancel

20) Bugfix: Fixed syntax errors in ca.po to prevent make error


There are also two examples on the website that show how to add a right-click command to resize all selected image files to any size you select, and how to create an archive of all selected files. Of course, the main power of this mod is that it allows you to customize the commands.

Feel free to let me know how it works for you.

http://igurublog.wordpress.com/downloads/mod-pcmanfm/
http://aur.archlinux.org/packages.php?ID=34819
http://bbs.archlinux.org/viewtopic.php?id=91426
Check out my blog for useful scripts, mods and tips... http://igurublog.wordpress.com
maces
Posts: 503
Joined: Sat Oct 25, 2008 6:04 pm
Contact:

Re: PCManFM Mod - User-Definable Commands And More

Post by maces »

Hi,

will test it, especially 1) sounds very interesting :)

maces
maces
Posts: 503
Joined: Sat Oct 25, 2008 6:04 pm
Contact:

Re: PCManFM Mod - User-Definable Commands And More

Post by maces »

Works nice here, thx for thr PKGBUILD :)
How can I get terminal back to F4? I'm so used to it. nothing happens when no files are selected.

maces
IgnorantGuru
Posts: 30
Joined: Sat Feb 27, 2010 7:35 pm
Contact:

Re: PCManFM Mod - User-Definable Commands And More

Post by IgnorantGuru »

maces wrote:Works nice here, thx for thr PKGBUILD :)
How can I get terminal back to F4? I'm so used to it. nothing happens when no files are selected.
Well there are a few ways you could do so. If you want to edit the source, the keyboard shortcuts are in main-window.c and ptk-file-menu.c. Just search for all instances of "GDK_F4" and assign it to the Open Terminal command instead. (If you want more specifics let me know.) You can compare them with main-window.c-orig to see how F4 was assigned in the original version 0.5.2. It's not much of a hassle to change.

Another option would be to edit /usr/share/applications/pcmanfm-user-f4.desktop, and set

Code: Select all

Name=Terminal
Exec=bash -c xterm
(or whatever terminal you prefer)
But the terminal will always open in your home folder. (the bash -c part is required so it will ignore the files passed to it)

Yet another option would be to write a custom script for F4 that opens the currently selected folder in a terminal. For example:

Code: Select all

#!/bin/bash

if [ "$1" = "" ]; then
    xterm &
else
	if [ ! -d "$1" ]; then
		cd "$(dirname "$1")"
	else
		cd "$1"
	fi
	xterm &
fi
As long as a file or folder is selected that will work.

Also note that you can open a terminal without any modifications with Alt-t, t if you want to get used to that keyboard combo instead.
Check out my blog for useful scripts, mods and tips... http://igurublog.wordpress.com
maces
Posts: 503
Joined: Sat Oct 25, 2008 6:04 pm
Contact:

Re: PCManFM Mod - User-Definable Commands And More

Post by maces »

thx for the fast and detailed reply. I've chosen the last way, it's the simplest. But I will have a look at the first was, too.

maces
IgnorantGuru
Posts: 30
Joined: Sat Feb 27, 2010 7:35 pm
Contact:

Re: PCManFM Mod - User-Definable Commands And More

Post by IgnorantGuru »

maces wrote:thx for the fast and detailed reply. I've chosen the last way, it's the simplest. But I will have a look at the first was, too.
Always fun to toy with the source. :) Even if you're not a programmer it's sometimes not too difficult to customize things like keyboard shortcuts and icons. All my patches can be located by searching for "// MOD" or in some cases "//MOD" (sorry for the inconsistency - I meant to always use the first but I notice I didn't).
Check out my blog for useful scripts, mods and tips... http://igurublog.wordpress.com
phillipe
Posts: 41
Joined: Mon Apr 27, 2009 4:12 pm

Re: PCManFM Mod - User-Definable Commands And More

Post by phillipe »

Why remove the name and icons from ".desktop" files?!
==> Phillipe Smith ( SmithuX ) <==
Email: phillipe@archlinux.com.br
WebSite: http://www.smithux.com
IgnorantGuru
Posts: 30
Joined: Sat Feb 27, 2010 7:35 pm
Contact:

Re: PCManFM Mod - User-Definable Commands And More

Post by IgnorantGuru »

phillipe wrote:Why remove the name and icons from ".desktop" files?!
I feel it is a more standard, consistent, and useful way for a file manager to behave. File managers should show the filenames in the folder, just like ls does, not an interpreted name based on the files' contents. This is more the role of a menu editor, not a file manager. I found it very annoying.

At any rate, you can examine the source if you don't want that change. The icons went with the name - I disabled the code that treated .desktop files differently. At some point I may make this optional via the config file, but for now you can re-enable it in a single code block IIRC.
Check out my blog for useful scripts, mods and tips... http://igurublog.wordpress.com
phillipe
Posts: 41
Joined: Mon Apr 27, 2009 4:12 pm

Re: PCManFM Mod - User-Definable Commands And More

Post by phillipe »

IgnorantGuru wrote:
phillipe wrote:Why remove the name and icons from ".desktop" files?!
I feel it is a more standard, consistent, and useful way for a file manager to behave. File managers should show the filenames in the folder, just like ls does, not an interpreted name based on the files' contents. This is more the role of a menu editor, not a file manager. I found it very annoying.

At any rate, you can examine the source if you don't want that change. The icons went with the name - I disabled the code that treated .desktop files differently. At some point I may make this optional via the config file, but for now you can re-enable it in a single code block IIRC.
I'm agree with you my friend.
I only made this question, because if we put a .desktop file on desktop, the application name and the icon aren't showed.
Anyway, I really liked the changes that you made on pcmanfm.
I didn't like much of pcmanfm2 too. =(
==> Phillipe Smith ( SmithuX ) <==
Email: phillipe@archlinux.com.br
WebSite: http://www.smithux.com
IgnorantGuru
Posts: 30
Joined: Sat Feb 27, 2010 7:35 pm
Contact:

Re: PCManFM Mod - User-Definable Commands And More

Post by IgnorantGuru »

phillipe wrote:I only made this question, because if we put a .desktop file on desktop, the application name and the icon aren't showed.
Strange - I don't use the desktop features so I wasn't aware of that (I don't even HAVE a desktop). Thanks for letting me know. I'm not really sure how the desktop features work but I may see if I can find a more elegant solution. I just want the actual filenames in the folder view. But it may be hard to change one without the other.

As for the new version, I'm sure PCMan has put some excellent work into it. Not sure if it's for me with the gvfs dependencies, but we'll see how it works out once it matures a bit. I know what he means about Linux always breaking backwards compatibility - drives me crazy, and it does force one into uncomfortable choices. Still, I think keeping gvfs more of a modular dependency would be helpful, with more direct FS access always there as a fallback. Just my thoughts - I don't really know all of what he's trying to accomplish with the new version.
Check out my blog for useful scripts, mods and tips... http://igurublog.wordpress.com
Locked