Closed linqingfan closed 7 months ago
Hey there! There is no built-in way, but an action that uses Zenity would be fairly easy to write - so here is your example...
{
"type": "command",
"label": "Create a file using Gedit",
"command_line": "name=$(zenity --entry --width 300 --title \"Create file\" --text \"File name\") && gedit \"$name\"",
"cwd": "%d",
"use_shell": true,
"max_items": 1,
"permissions": "read-write",
"filetypes": [
"directory"
]
}
Hey there! There is no built-in way, but an action that uses Zenity would be fairly easy to write - so here is your example...
{ "type": "command", "label": "Create a file using Gedit", "command_line": "name=$(zenity --entry --width 300 --title \"Create file\" --text \"File name\") && gedit \"$name\"", "cwd": "%d", "use_shell": true, "max_items": 1, "permissions": "read-write", "filetypes": [ "directory" ] }
It works! Thanks for the advice. I noticed there is a slight error, I just changed "%d" to "%f"
On furthur analysis, is quite puzzling why "%f" works instead of "%d". I m using the GUI under "Current working directory" option. If I use %d, when I m in /home/user/ directory, the folder directory will be in /home, 1 level up. I tried in other directory, it is always 1 level up. There is no such problem in vscode... Probably it is the problem of gedit ?
Hey there... No actually that's correct. %d is the 'directory' of the selected item. If the selected item is your home directory the %d will be the directory it is in ... /home. %f is the full path to the selected item.
So if you want to run a command in a selected directory then current directory should be %f.
In other words my example is wrong 😁 ... sorry about that.
On Fri, Jan 12, 2024, 05:08 linqingfan @.***> wrote:
On furthur analysis, is quite puzzling why "%f" works instead of "%d". I m using the GUI under "Current working directory" option. If I use %d, when I m in /home/user/ directory, the folder directory will be in /home, 1 level up. It tried in other directory, it is always 1 level up. There is no such problem in vscode... Probably it is the problem of gedit ?
— Reply to this email directly, view it on GitHub https://github.com/bassmanitram/actions-for-nautilus/issues/56#issuecomment-1888402717, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADAKLWUDEN53SOK2RVOZCWDYOCZMNAVCNFSM6AAAAABBWDD7CKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBYGQYDENZRG4 . You are receiving this because you were assigned.Message ID: @.***>
Thks
May I know if there is a way to request for user input in action? A simple example would be to create a file using gedit. gedit filename where filename is provided by user before executed?