我发布这个是为了提供一个答案,作为一种比使用 nautilus-actions
(启动nautilus-actions-config-tool
)更简单的方法,同时避免每次从头开始编写整个动作文件。
另一方面,虽然nautilus-actions-config-tool
不会使用,nautilus-actions
但必须安装才能出现在上下文菜单中。
小智 7
虽然此解决方案 nautilus-actions
不会用于添加新的上下文菜单操作,但 Nautilus 必须安装它才能具有操作功能,并且操作要出现在上下文菜单中。
这个想法是有一个现成但不完整的动作文件,可以为每个新的上下文菜单动作编辑并以新名称保存。每次都可以使用启动器文件(就像应用程序一样)或从上下文菜单本身(使用先前创建的另一个特定操作文件)访问此通用文件。
创建文件夹~/.local/share/file-manager/actions
。
要创建现成的操作文件,请执行以下操作:
gedit ~/.local/share/file-manager/actions/new-action.desktop
Run Code Online (Sandbox Code Playgroud)
使用这些行:
[Desktop Entry]
Type=Action
ToolbarLabel=<name-of-action>
Name=<name-of-action>
Profiles=profile-zero;
#TargetContext=false
#keep the above commented if you WANT the action to appear when you select files of the type specified by the line MymeTypes; un-comment it if you DO NOT WANT your new action to appear when you select the specified files
#TargetLocation=true
#keep the above commented if you DO NOT WANT the action to appear when right clicking an empty area; remove the comment when you WANT that.
[X-Action-Profile profile-zero]
Folders=*;
Exec=
Name=Default profile
MymeTypes=
#the above line specifies the types of files for which your new action appears when you select them (remove the line 'TargetContext=false' to achieve that)
#DO NOT SAVE directly after editing!
#USE "SAVE AS" TO SAVE YOUR NEW ACTION FILE!
Run Code Online (Sandbox Code Playgroud)
当然可以直接访问,但最好有一种更简单的方法来打开现成的文件。这可以通过启动器文件完成:
gedit ~/.local/share/applications/Nautilus_action.desktop
Run Code Online (Sandbox Code Playgroud)
有了这个内容:
[Desktop Entry]
Type=Application
Name=New Nautilus action
Icon=nautilus
Categories=System;Settings;
Exec=sh -c 'gedit ~/.local/share/file-manager/actions/new-action.desktop'
Run Code Online (Sandbox Code Playgroud)
使其可执行:
chmod +x ~/.local/share/applications/Nautilus_action.desktop
Run Code Online (Sandbox Code Playgroud)
之后,它可以从菜单或应用程序启动器启动:
以上是为了打开 generic ~/.local/share/file-manager/actions/new-action.desktop
,编辑并用不同的 name 保存它。
运行启动器“New Nautilus action”
当通用文件在 gedit 中打开时,编辑这些将定义新 Nautilus 菜单操作的行(即:菜单名称、操作文件名和要执行的命令):
工具栏标签=
姓名=
执行=
目标上下文=假
#
如果您希望在选择文件(由行MymeTypes指定的类型;请参阅下面的!
选项)时出现菜单操作,应注释以上内容(在其之前)。如果您不希望它出现在选择中(一种罕见的情况,即您希望操作仅出现在文件夹内的空白区域),请删除注释 ( #
)。目标位置=真
考虑到上面这行,如果您不希望在右键单击空白区域时出现新的菜单操作,请#
在其前添加;如果您需要在单击文件夹内的空白区域时显示操作,请删除注释。
将在您选择新操作时出现的文件的 MIME 类型添加到以下行(删除/注释“TargetContext=false”行以实现该目的):
MymeTypes=;
添加 mime 类型,如:inode/directory
文件夹、audio/*
音频等,以指定您希望操作出现的选项;!
在它之前排除某种 mime 类型的使用。(例如:如果您使用操作将音频转换为 mp3,您希望它出现在除 mp3 文件之外的所有音频中;在这种情况下,它应该是MymeTypes=!audio/mp3;audio/*
。)在 Nautilus 中查看文件的属性(基本/类型)以查看其哑剧类型。
不要直接保存文件,否则您的新操作将覆盖通用操作文件!
使用“另存为”以不同的名称保存文件。
归档时间: |
|
查看次数: |
10947 次 |
最近记录: |