Allow users to add scripts used as context menu items for certain types of files and folders.
Currently, we have the Tools
menu and a context menu that appears when you right-click a file or folder.
We want to give the user an (easy!) way of extending these with custom scripts.
There should be a way to specify under which circumstances a certain context menu should be added, e.g.,
Name
: If the file or folder has certain name(s)
Name *.txt
: If the file or folder has certain suffix(es)
MIME
: If the file or folder has certain MIME type(s)
DirectoryContains
enclosing modifier: If the folder contains a file that has certain name(s)
DirectoryTreeContains
enclosing modifier: If the file or folder is in a folder or in a sub-folder of a folder that contains a file that has certain name(s) (e.g., to add git pull
to any file or folder that is in a git repository)
Brainstorming on the format
Git.app # A filer plugin is a normal `.app` bundle or `.AppDir`
Git.app/Git # Main executable
Git.app/Resources/DesktopActions.json # Configuration that specifies what files/folders to display the menu item(s) on
Git.app/Resources/arrow-down.png
Git.app/Resources/arrow-up.png
Contents of DesktopActions.json
:
{
"GitPushPull": {
"Conditions": [
{
"DirectoryTreeContains": [
{
"Name": ".git",
"MIME": "inode/directory"
}
]
},
{
"Name": ".git",
"MIME": "inode/directory"
}
],
"Actions": [
{
"Name": "Git Pull",
"Icon": "arrow-down",
"Args": "pull"
},
{
"Name": "Git Push",
"Icon": "arrow-up",
"Args": "push"
}
]
}
}
Renered as YAML:
GitPushPull:
Conditions:
- DirectoryTreeContains:
- Name: .git
MIME: inode/directory
- Name: .git
MIME: inode/directory
Actions:
- Name: Git Pull
Icon: arrow-down
Args: pull
- Name: Git Push
Icon: arrow-up
Args: push
Say, we have a file /home/user/helloSystem/ISO/build.sh
. When the user right-clicks on this
- The system checks whether the parent directory (or any of its parent directories) contains a
.git
with the MIME type inode/directory
- Because this is the case, two context menus get added: "Git Pull" with the icon from
Git.app/Resources/arrow-down.png
, and "Git Push" with the icon from Git.app/Resources/arrow-up.png
- When the user clicks "Git Pull", then
launch Git.app pull /home/user/helloSystem/ISO/build.sh
gets invoked
- From there,
Git.app/Git
can do as it pleases (e.g., show a GUI, etc.)
Too complicated to implement and use? Can we simplify?
Prior Art
KDE Service Menus
$HOME/.local/share/kservices5/ServiceMenus/
/usr/local/share/kservices5/ServiceMenus/
[Desktop Entry]
Type=Service
ServiceTypes=KonqPopupMenu/Plugin
MimeType=all/allfiles;
Actions=Shred
#X-KDE-Submenu=Shred
[Desktop Action Shred]
Name=Safe Remove
Icon=trash-empty
Exec=shred -u -f -z -n3 %u
GNOME Nautilus Scripts
https://help.ubuntu.com/community/NautilusScriptsHowto
~/.local/share/nautilus/scripts/
http://g-scripts.sourceforge.net/