Problems at use | Problèmes à l'utilisation
Subscription date : 22 February 2012
Messages : 11
|
I've configured a quick browser icon in my main dock to point to a folder that contains various shortcuts.
Most of these work as expected when selected (program starts) but the bash scripts open in an editor rather than being executed. Is theee was way to get round this?
(The scripts do work when launched from Nautilus say, or the terminal, that is they are set to execute) |
fabounet, Thursday 09 August 2012 à 18:03
|
|
Subscription date : 30 November 2007
Messages : 17118
|
when you click on a script in Nautilus, it asks you to run or edit it.
of course you probably want to ru it, but I guess that the default behavior is to edit it !
(cairo-dock and nautilus are both based on gvfs to open files)
so there is maybe an option to look for in gconf (or dconf)
a workaround would be to change the command and run the script in a terminal:
xterm -e path-to-the-bash-script |
Subscription date : 22 February 2012
Messages : 11
|
fabounet : when you click on a script in Nautilus, it asks you to run or edit it.
of course you probably want to ru it, but I guess that the default behavior is to edit it !
(cairo-dock and nautilus are both based on gvfs to open files)
so there is maybe an option to look for in gconf (or dconf)
a workaround would be to change the command and run the script in a terminal:
xterm -e path-to-the-bash-script
Okay, thanks.
I'm not very keen on the workaround. I'll have to have a rethink.
JFTR I think this is the reason nautilus runs scripts rather than edits them. The "Executable Tet Files" option:
A similar option in the dock maybe? |
Subscription date : 30 November 2007
Messages : 17118
|
ok, so it seems they forced their own solution here ...
but I think that a .sh file should have a different mimetype than a usual text file
therefors it should be possible to handle it differently with gvfs
can you please try xdg-open <path-to-your-bash-script>
also, look in ~/.local/share/applications/mimeapps.list if you can set up explicitely how to open script or executable files. |
Subscription date : 22 February 2012
Messages : 11
|
fabounet : ok, so it seems they forced their own solution here ...
but I think that a .sh file should have a different mimetype than a usual text file
therefors it should be possible to handle it differently with gvfs
can you please try xdg-open <path-to-your-bash-script>
also, look in ~/.local/share/applications/mimeapps.list if you can set up explicitely how to open script or executable files.
xdg-open opens .sh files using gvim, which seems to agree with the option in mimeapps.list:
application/x-shellscript=userapp-gvim-JZGMFW.desktop;gedit.desktop;
This doesn't just apply to shell scripts BTW. Python scripts have the same behaviour running from the dock applet. They open in a text editor rather than executing
It's more like a similar mechanism to a command line execution is needed. Something like, "if the execute bit of the text file is set and the first two bytes of the text file are shebang, then run the command interpreter specified by the rest of the line, on the rest of the file." Something like that. |
matttbe, Saturday 11 August 2012 à 10:30
|
|
Subscription date : 24 January 2009
Messages : 12573
|
Yes, good idea! There is maybe a function to do that with one line with GIO :http://developer.gnome.org/gio/stable/
But is it only for this applet or for all? |
fabounet, Tuesday 14 August 2012 à 17:25
|
|
Subscription date : 30 November 2007
Messages : 17118
|
so the dock is just following the mime types as they are defined for the user.
i think the best way would be for you to change this mime association, if possible.
if not, we can modify the dock to bypass the mime rule as you proposed, but that sounds a bit hackish |
matttbe, Tuesday 14 August 2012 à 23:03
|
|
Subscription date : 24 January 2009
Messages : 12573
|
Yes but it can be interesting to launch scripts directly from this applet (or display a dialogue to say that it's a script and it can be launched or opened by a text editor) and detect if the user is dropping a script or a text file into the dock. |
Subscription date : 22 February 2012
Messages : 11
|
From GContentType maybe g_content_type_can_be_executable http://developer.gnome.org/gio/stable/gio-GContentType.html#g-content-type-can-be-executable
g_content_type_guess can take a file name or a few bytes to look for a signature to obtain the type string.
My user-case is I have a directory called shortcuts that has a bunch of things mainly, backup scripts and searching "tools". Most of these are bash scripts that either run in a shell (that they self-launch), or run in the background and do something to indicate they've completed, or run zenity for a windowed interface where needed.
In the past I've simply run these from the directory but it seems to me that this functionality is not inappropriate for the quick browser widget |
fabounet, Thursday 16 August 2012 à 16:27
|
|
Subscription date : 30 November 2007
Messages : 17118
|
ok, well I think we can add it in the integration plug-ins or in the quick-browser applet directly. |
Subscription date : 22 February 2012
Messages : 11
|
fabounet : ok, well I think we can add it in the integration plug-ins or in the quick-browser applet directly.
cool |
Problems at use | Problèmes à l'utilisation
|