[qutebrowser] How to run a userscript in Windows

Florian Bruhin me at the-compiler.org
Mon Sep 5 10:27:08 CEST 2016


Hey,

I re-added the mailinglist in your reply, as you wrote to me directly
;)

* David Nebauer <davidnebauer3 at bigpond.com> [2016-09-03 00:19:17 +0930]:
> > * Daniel Schadt <daniel at kingdread.de> [2016-08-31 22:36:47 +0200]:
> > > > command called: spawn ['--userscript', 'SCRIPT.py']
> > > So as far as I can tell, the only things you can run on
> > > Windows as (user)script are native .exe and .bat/.cmd files.
> > > 
> > > So to solve this, you can either use
> > >      "\path\to\python.exe \path\to\script.py"
> > > as command for spawn (without the --userscript flag), or you can write
> > > a simple .bat file that just calls your real userscript under the hood.
> 
> I tried using bat/cmd userscripts as wrappers that call the python script
> but nothing worked, so I tried the simplest possible case -- 'hello.bat' in
> the userscript directory containing a single line:
> 
>         Echo message-info "Hello from a userscript!" >> "%QUTE_FIFO%"
> 
> Calling userscript hello or hello.bat resulted in the same failure I
> reported for the python script. Here are the log messages for one example:

Hmm, that's odd. Can you open an issue at
https://github.com/The-Compiler/qutebrowser so I can take a look at it
whenever I next feel like dealing with Windows stuff? ;)
> 
>     command called: spawn ['--userscript', 'hello.bat']
> [...]
>     Userscript to run:
> C:\Users\ME\AppData\Local\qutebrowser\data\userscripts\hello.bat

I'm guessing the hello.bat is in that location?

>     Error while spawning userscript: The process failed to start.

Unfortunately that's all Qt (and probably the Windows API) can give
us... It usually means the file is not at that location, or not
executable.

> It's not a quoting problem; running the bat file from a dos prompt worked
> fine if I first set QUTE_FIFO to a dummy file name. It created a file
> containing the correctly quoted command:
> 
>         message-info "Hello from a userscript!"
> 
> So now I'm wondering if the userscript mechanism works at all in windows.
> Has anyone ever run a userscript in windows successfully? If so, can someone
> post an example? If I start with something that works I may be able to build
> it up to run my python script.
> 
> Please note, it's not enough to simply execute a bat/cmd/exe file; it has to
> execute in an environment where the userscript variables (QUTE_FIFO, etc.)
> are available to the userscript.

FWIW the qutebrowser testsuite doesn't run an userscript on Windows,
but I don't remember why that was.

Florian

-- 
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://listi.jpberlin.de/pipermail/qutebrowser/attachments/20160905/ace36d4c/attachment.asc>


More information about the qutebrowser mailing list