Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| scripting_pcmanfm [2025/10/27 12:08] – created pcmanfm scripts crcerror | scripting_pcmanfm [2025/10/29 20:35] (current) – Some juggling with text crcerror | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Scripts for PCManFM ====== | ====== Scripts for PCManFM ====== | ||
| - | PCMan File Manager (PCManFM) is a file manager designed to be a lightweight and fast replacement for Nautilus or Konqueror, for example. It aims to be a usable file manager (and nothing more) and follows the Freedesktop.org standards. For basic usage and on which platforms the program is available [: | + | PCMan File Manager (PCManFM) is a file manager designed to be a lightweight and fast replacement for Nautilus or Konqueror, for example. It aims to be a usable file manager (and nothing more) and follows the Freedesktop.org standards. For basic usage and on which platforms the program is available |
| + | |||
| + | ===== Path locations ==== | ||
| + | |||
| + | Build-in actions, desktop applets and default MIME are stored in: | ||
| + | * ''/ | ||
| + | * ''/ | ||
| + | * ''/ | ||
| + | |||
| + | The corrospending user-space for actions, desktop applets and default MIME are stored in: | ||
| + | * ''/ | ||
| + | * ''/ | ||
| + | * ''/ | ||
| ===== MIME types ===== | ===== MIME types ===== | ||
| - | Unlike Windows systems, it is much less common in Linux to identify files by their ‘file extensions’. Instead, the operating system recognises the file type based on file permissions and metadata, not just the extension. However, common file extensions are still used for organisation and compatibility, | + | Unlike Windows systems, it is much less common in Linux to identify files by the ‘file extensions’. Instead, the operating system recognises the file type based on file permissions and metadata, not just the extension. However, common file extensions are still used for organisation and compatibility, |
| - | So yes, we are talking about MIME (aka Multipurpose Internet Mail Extensions) types, rather then file extenions. Best praxis to determine the MIME-type that PCManFM uses is, if you just right-click the file and then read it' | + | So yes, we are talking about MIME (aka Multipurpose Internet Mail Extensions) types, rather then file extenions. Best praxis to determine the MIME-type that PCManFM uses is, if you just right-click the file and then read its properties. Or you can just select the file and you'll the file-description into the down-left corner of the filemanager. Valid descriptions are '' |
| ===== Link a MIME type to an application (manual) ===== | ===== Link a MIME type to an application (manual) ===== | ||
| - | You doubleclick | + | Doubleclick |
| **Important steps: | **Important steps: | ||
| - | - Fill in Application name (name it as you like) | + | - Fill: Application name (free selectable, |
| - | - tick: Set selected application as default for this file type | + | - Tick: Set selected application as default for this file type |
| - | So the needed | + | All data is set to: ''/ |
| < | < | ||
| Line 24: | Line 36: | ||
| </ | </ | ||
| - | So you see: I associated | + | So you see: Associated |
| The **.desktop**-file contains all the additional data and can be found in ''/ | The **.desktop**-file contains all the additional data and can be found in ''/ | ||
| Line 41: | Line 53: | ||
| ==== PCManFM special descriptors ==== | ==== PCManFM special descriptors ==== | ||
| - | ..... write here how %F &f works and some other thing like general | + | PCManFM and its desktop-files support several parameters, most common is the one for the **EXEC** section which is essential for file handling and file operation. |
| + | |||
| + | < | ||
| + | Parameter, Description, | ||
| + | %b, (first) basename, singular | ||
| + | %B, space-separated list of basenames, plural | ||
| + | %c, count of selected items, irrelevant | ||
| + | %d, (first) base directory, singular | ||
| + | %D, space-separated list of base directory of each selected items, plural | ||
| + | %f, (first) file name, singular | ||
| + | %F, space-separated list of selected file names, plural | ||
| + | %h, hostname of the (first) URI, irrelevant | ||
| + | %m, mimetype of the (first) selected item, singular | ||
| + | %M, space-separated list of the mimetypes of the selected items, plural | ||
| + | %n, username of the (first) URI, irrelevant | ||
| + | %s, scheme of the (first) URI, irrelevant | ||
| + | %u, (first) URI, singular | ||
| + | %U, space-separated list of selected URIs, plural | ||
| + | %w, (first) basename without the extension, singular | ||
| + | %W, space-separated list of basenames without their extension, plural | ||
| + | %x, (first) extension, singular | ||
| + | %X, space-separated list of extensions, plural | ||
| + | %%, the " | ||
| + | </ | ||
| + | |||
| + | === Action Defintions === | ||
| + | |||
| + | A custom action is a " | ||
| + | |||
| + | < | ||
| + | Key, Description, | ||
| + | Type, This can be Action or Menu. The latter creates a sub-menu with more actions, Yes | ||
| + | Name, The label of the action as it appears in the context menu - localized variant can be used like Name[fr], Yes | ||
| + | Icon, The name of a theme icon, No | ||
| + | Description, | ||
| + | Enabled, A user might define many actions or menus and choose to only enable | ||
| + | Profiles, The ordered list of the profiles attached to this action | ||
| + | </ | ||
| + | |||
| + | === Profile Defintion === | ||
| + | |||
| + | A profile tells the action what to do. Each profile that is added to the Profiles key must be defined in a '' | ||
| + | < | ||
| + | Key, Description, | ||
| + | Name, Not really needed and defaults to empty. It is just a convenience., | ||
| + | Exec, The command to execute possibly with arguments. Parameters are often used with this key., Yes | ||
| + | MimeTypes, The MIME type(s) list with which this action appears. Each mimetype may be fully specified (e.g. audio/ | ||
| + | Basenames, A list of base directory names the selection should match for this profile to appear. The * character is accepted as a wildcard. Base names may be negated (e.g. *;!*.h;), No | ||
| + | Folders, A list of paths the current base directory must be in for the action to appear. A folder path may be negated (e.g. / | ||
| + | SelectionCount, | ||
| + | </ | ||
| + | |||
| + | === Special | ||
| + | |||
| + | Some of well-known mimetypes include: | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| ==== PCManFM creating an entry in Contextmenu and using Cascaded Contextmenus ==== | ==== PCManFM creating an entry in Contextmenu and using Cascaded Contextmenus ==== | ||
| Line 49: | Line 118: | ||
| If you place your **.desktop** files to ''/ | If you place your **.desktop** files to ''/ | ||
| - | < | + | < |
| [Desktop Entry] | [Desktop Entry] | ||
| Type=Action | Type=Action | ||
| Line 62: | Line 131: | ||
| === Creating a Cascaded Contextmenu === | === Creating a Cascaded Contextmenu === | ||
| - | Again, just change the Type you want to descripe into the **.desktop** file and use **Type=Menu** - rather undocumented it seems not to work to set the Name only instead use **Tooltip** to get the name readable. Then arrange | + | Again, just change the **Type** you want to descripe into the **.desktop** file and use **Type=Menu** - rather undocumented it seems not to work to set the Name only instead use **Tooltip** to get the entry visible into the context menu. Then just enter the **.desktop**-files you want into your **ItemList** (remember, only the one placed in the DIR '' |
| - | < | + | < |
| [Desktop Entry] | [Desktop Entry] | ||
| Type=Menu | Type=Menu | ||
| Line 73: | Line 142: | ||
| </ | </ | ||
| + | ==== Scripting Example ==== | ||
| + | === File Toggle to set filenames to upper/lower case === | ||
| + | |||
| + | Here you see how PCManFMs internal parametes are used. '' | ||
| + | |||
| + | **Destination: | ||
| + | |||
| + | <code bash| system.toggle-filenames.desktop> | ||
| + | [Desktop Entry] | ||
| + | Type=Action | ||
| + | Name=Toggle filenames upper-/ | ||
| + | Profiles=Batocera | ||
| + | SelectionCount=< | ||
| + | |||
| + | [X-Action-Profile Batocera] | ||
| + | MimeTypes=all/ | ||
| + | Exec=bash -c "cd %d; [[ %b =~ [A-Z] ]] && { for f in %B; do mv \" | ||
| + | </ | ||
| + | |||
| + | === Create WINE autorun.cmd === | ||
| + | |||
| + | You enter the gamefolder and click on a windows-exe-file. From there select '' | ||
| + | |||
| + | * p1 = Location of all wine-games | ||
| + | * p2 = Directory of our current EXE | ||
| + | * p3 = Windows game directoy itself | ||
| + | |||
| + | So with clever subtrating the strings you can extract all data you need and you are able to write back the needed data to '' | ||
| + | |||
| + | **Destination: | ||
| + | |||
| + | <code bash| wine.create-autorun.desktop> | ||
| + | [Desktop Entry] | ||
| + | Type=Action | ||
| + | Name=Create autorun.cmd | ||
| + | Folders=/ | ||
| + | Profiles=Batocera | ||
| + | SelectionCount==1 | ||
| + | |||
| + | [X-Action-Profile Batocera] | ||
| + | MimeTypes=application/ | ||
| + | Exec=bash -c " | ||
| + | </ | ||
- scripting_pcmanfm.1761566880.txt.gz
- Last modified: 6 months ago
- by crcerror