Welcome to the wonderful world of Security Vulnerabilities and 
Work-arounds. Don't worry, this is my job.

OK, you need to register a new URL scheme handler. First create a Desktop 
Entry which specifies the mime-type. For example:

[Desktop Entry]
Type=Application
Name=TW Bash Script
Exec=twscript.sh %u
StartNotify=false
MimeType=x-scheme-handler/twscript;

Note that the %u passes the URL (eg. twscript://parameters%20here ) as a 
single parameter, according to the Desktop Entry 
Specification. https://specifications.freedesktop.org/desktop-entry-spec/latest/

Once you have created this Desktop Entry and installed it (put it in the 
local system applications directory ( ~/.local/share/applications/ or 
/usr/share/application/ ) then you must register the application with the 
MIME type (assuming you had named your Desktop Entry twscript.desktop

xdg-mime default twscript.desktop x-scheme-handler/twscript

Any script can then be added to the twscript.sh (make sure it's executable 
of course) and you can parse parameters just as any other script. The 
script should be placed anywhere in your executable path ~/.local/bin for 
example.

In the twscript.sh you'll have to add whatever parsing you need. You can't 
run separate scripts, but parameters are passed and can be checked and 
dealt with as appropriate.

Now, when an application finds the URL twscript:// it knows exactly what to 
do with it.

*WARNING! This will make your system vulnerable to anybody who knows the 
MIME type that you have used. They could create a script which would 
execute on your computer. I would advise against this, but there you go.*

Have fun,

Dragon.
On Saturday, 23 January 2021 at 19:19:16 UTC Mark S. wrote:

> Thanks for replying! It does have the correct shebang, and runs fine from 
> the command line. If I could include spaces in the file url, then I could 
> run "/usr/bin/sh /path/to/my/script.sh". But I I don't know how to do that 
> in a url line without converting to to %20 , which the OS wouldn't 
> understand.
>
> On Saturday, January 23, 2021 at 10:04:23 AM UTC-8 jwd wrote:
>
>> What you may be looking for is the correct "Shebang 
>> <https://en.wikipedia.org/wiki/Shebang_(Unix)>" line at the top of the 
>> script that determines the interpreter to use (assuming the executable bit 
>> has been set.)
>>
>> Typically I would use something like
>> #!/usr/bin/env bash
>> or, if you want to be specific
>> #!/path/to/your/systems/bash
>>
>> The former will use the bash executable found first in the PATH of the 
>> environment of the TiddlyDesktop process; the latter would be preferred 
>> unless the script might run on systems where the path to the interpreter my 
>> differ, e.g., Macs have an old version of bash by default; while different 
>> Linux distributions' bash may be in /bin or /usr/bin.
>>
>> HTH
>> On Friday, January 22, 2021 at 5:14:22 AM UTC-5 TiddlyTweeter wrote:
>>
>>> Ciao Mark S.
>>>
>>> I really looked into it. TBH I can't truthfully reply to your simple 
>>> question.
>>>
>>> Background: I using (mainly) Timimi to launch from TW (it is fairly 
>>> complex & now retired in the recent version); TiddlyDesktop (fussy, mainly 
>>> because it is Chrome inside?); BobEXE (very flexible on scripting; best of 
>>> the batch; but overkill for most of my limited needs).
>>>
>>> Outcome: too many variants to address your basic query simply.
>>>
>>> Best wishes
>>> TT
>>> On Monday, 18 January 2021 at 19:30:32 UTC+1 Mark S. wrote:
>>>
>>>> I don't suppose you remember if there was a way to insert spaces? A sh 
>>>> script should always know to run itself, but if I could specify 
>>>> "/usr/bin/bash ....myshellscript.sh " that should force the system to 
>>>> invoke it correctly.
>>>>
>>>> Thanks!
>>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/3e0ec1ac-0e8a-406b-8313-f8196ff262a5n%40googlegroups.com.

Reply via email to