Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Managing subprocesses #5673

Open
The-Compiler opened this issue Aug 12, 2020 · 6 comments
Open

Managing subprocesses #5673

The-Compiler opened this issue Aug 12, 2020 · 6 comments
Labels
priority: 2 - low Issues which are currently not very important.

Comments

@The-Compiler
Copy link
Member

The-Compiler commented Aug 12, 2020

It'd nice if qutebrowser had a way to manage its subprocesses:

  • Anything started via :spawn
  • Userscripts currently running
  • Open editors
  • Per-tab QtWebEngine suprocesses (since Qt 5.15)

This could probably work via commands and the completion. Possibly useful commands:

@The-Compiler The-Compiler added the priority: 2 - low Issues which are currently not very important. label Aug 12, 2020
@emanuele6
Copy link
Contributor

Thank you!

@LiteracyFanatic
Copy link
Contributor

I think this would be really useful, especially having access to the rendering subprocesses. In addition to listing the info on an HTML page, I would want a way to get a hold of the the PIDs and associated metadata (page title, URL, etc.) in an easily parsable format from a shell script. My main use case would be memory monitoring and integration with nohang. qutebrowser is usually the victim when it needs to kill something to prevent a hang, but it'd be nice to have the information necessary to prevent killing certain important tabs.

@The-Compiler
Copy link
Member Author

I just pushed a first version of a :process command. It doesn't handle QtWebEngine processes yet though, only things spawned by qutebrowser itself (such as :spawn, or external editors).

@ghost
Copy link

ghost commented Aug 12, 2021

edit: problem 1 (progress bar) solved by calling wget with --progress=bar:force

Hello. I started to use :spawn with ranger/dmenu (to find dirs and create new file names) and wget as a replacement of the default download functions qutebrowser provides. I'm also using :spawn (with ranger/youtube-dl) to download youtube videos and do some other tasks (things like curl+some post process). All this works fine except for the output messages wich (unless I'm missing something) qutebrowser doesn't handle very well (It keeps stacking download progress messages, which can be turned off but that gives no feedback at all). Also I have to use config.bind(',k', 'spawn pkill wget') to cancel downloads which is not that great. There is any hope qutebrowser could better support progress messages and process killing? If not I think I could try to search/write an external download manager, a generic process manager more or less.

Thanks a lot, here is my script replacing the download functions. More here

config.bind(',d', 'hint links spawn -u   download-file {hint-url}')
config.bind(',D', 'spawn -u  download-file {url}')
#!/usr/bin/env sh
prev_path=$(head -n 1 ~/.qutebrowser_tmp_path)
filename=$(echo $1 | sed -n 's/.*\///p')
truncate -s 0 ~/.qutebrowser_tmp_path
xterm -e ranger $prev_path --show-only-dirs --choosedir ~/.qutebrowser_tmp_path
path=$(head -n 1 ~/.qutebrowser_tmp_path)
if [ "$path" != "" ]; then
   name="$(echo -e $filename | dmenu)"
   wget "$1" -O "$path/$name" -nv --show-progress --progress=bar:force 2>&1 && echo "Download completed"
else
   echo "Download canceled"
fi

@toofar
Copy link
Member

toofar commented Aug 13, 2021

There is the :process command for doing some things with spawned processes, haven't used it in anger myself https://qutebrowser.org/doc/help/commands.html#process
I'm not aware of if anyone has done anything particularly generic around managing processes from userscripts or whatever. If you end up making a download manager then there is probably stuff better to build around than wget (like aria2 which apparently has RPC already).

@ghost
Copy link

ghost commented Aug 13, 2021

Thank you, Aria2 looks very great. Having solved the progress bar problem, I think the baby functions I wrote are already doing a decent job. A dedicated, multi protocol, standalone download/process manager still sounds cool. I mean, something like a daemon serving one http interface showing all progress bars, process-kill buttons and what not. Another vim-like CLI interface could be also nice. But I don't know, it's a lot of work for something already working decently enough with some basic tools and very little of code. Maybe I'll get into It although The-Compiler also mentioned something similar to be done in qutebrowser, If I'm not mistaken.

:process-list listing all processes on a HTML page

Also you where right, I didn't knew the :process command already can take pids and actions. I'll try to use that somehow. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: 2 - low Issues which are currently not very important.
Projects
None yet
Development

No branches or pull requests

4 participants