How to add option to make a file executable in PCManFM's context menu?

How to add option to make a file executable in PCManFM's context menu?

Nautilus 和 Thunar 在属性/权限下有这样的上下文菜单选项,但没有 PCManFM,Lubuntu 的默认文件和桌面管理器(至少在目前的 v. 1.1 中还没有)。

但是在“打开方式”/(再次)“打开方式”/“自定义命令行”下,可以添加新的自定义命令。

在此处输入图片描述

在此处输入图片描述

这将创建一个带有扩展名的文件.desktop~/.local/share/applications该文件可以进一步编辑以获得适当的名称和图标。

以这种方式添加什么命令才能使文件可执行?

也就是:如何使用sudo chmod +x filename才能让它这样工作?

答案1

考虑答案中的示例 - 使用“打开方式”选项:

该命令sudo chmod +x必须在终端(gnome-terminal -e "sudo chmod +x %f")中运行,或者该行Terminal=true应该位于桌面文件中~/.local/share/applications/make_exec.desktop

[Desktop Entry]
Name=Make file executable
Exec=sudo chmod +x %f 
Icon=path/to/icon
Terminal=true
Type=Application
StartupNotify=true
NoDisplay=true
MimeType=text/plain;

For an application to appear in the context menu, it may need a desktop file in /usr/share/applications, but also you may need to edit as administrator /usr/share/applications/mimeinfo.cache and in the line of the intended file type to add the application.desktop.

So, in the present case, open /usr/share/applications/mimeinfo.cache and add make_exec.desktop to the line text/plain.


Considering the creation of custom actions - like in Thunar, Nautilus or Dolphin:

PCManFM supports custom actions.

Those created with Nautilus configuration tool (for Nautilus) appear in PCManFM too. These are .desktop files created in ~/.local/share/file-manager/actions. So, they can be added manually without the Nautilus tool.

The form of these files should be like those presented here or here.

So, for the present purpose, create the file ~/.local/share/file-manager/actions/make_executable.desktop with these lines:

[Desktop Entry]
Name = Make executable
Tooltip = Make this file executable
Icon = terminal
Profiles = make_exec;

[X-Action-Profile make_exec]
Name = Make executable
MimeTypes = text/plain;
SelectionCount = 1
Schemes = file;
Exec = sudo chmod +x %f

相关内容