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

REQ: Simple percent output #348

Closed
xxxserxxx opened this issue Apr 3, 2021 · 6 comments
Closed

REQ: Simple percent output #348

xxxserxxx opened this issue Apr 3, 2021 · 6 comments
Milestone

Comments

@xxxserxxx
Copy link
Contributor

It would be nice to have an option to print progress as a simple percent of total, one number per line. This would facilitate piping progress to other programs and increase user options for using axel.

An example is using axel from within other programs and scripts. Currently, the user has three options: (1) the nice, fancy progress bar; (2) an alternate progress bar; (3) silence. The first two require a terminal and assume control of the progress display; the third provides no status on the download at all. Some example applications:

  1. A GUI program could exec() axel and read stdout and display progress within the GUI
  2. The user could piping the output on the command line to a different progress indicator, e.g., zenity -- progress --auto-close.
  3. A script could pipe the output to a download status widget in the window manager bar

In my particular case, the web browser surf by default manages downloads by forking off a terminal and calling curl. This is easily replaced by axel, but in tiling window managers, futzing with the new terminal so that it doesn't take over focus and. interrupt browsing, or take up too much space, or obscure the browser is troublesome. It would be useful to be able to report on the download either in the bar or in a smaller floating window.

The -p (--percentage) flag is unused and would be a natural choice. Output would be a series of simple percentages from 0 to 100 with no other formatting, one per line.

@ismaell ismaell added this to the v2.18 milestone Apr 5, 2021
ismaell pushed a commit that referenced this issue Aug 18, 2021
Closes: <#348>
Closes: <#350>

[ismael@iodev.co.uk: Edited patch & commit msg]
Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
@xxxserxxx
Copy link
Contributor Author

Thank you!

davidpolverari pushed a commit to davidpolverari/axel that referenced this issue Aug 26, 2021
Closes: axel-download-accelerator#348
Closes: axel-download-accelerator#350

[ismael@iodev.co.uk: Edited patch & commit msg]
Signed-off-by: Ismael Luceno <ismael@iodev.co.uk>
@luckman212
Copy link

@ismaell Thank you for this. 2 things:

  1. the manpage isn't updated, I didn't know this option even existed until I stumbled onto it...
  2. can you post an example syntax of how this can be used e.g. with coreutils progress? I tried various things but couldn't get it to work. It just endlessly prints the percentages e.g. screen after screen of fast-scrolling 4...5...6...7....

@ismaell
Copy link
Member

ismaell commented Feb 19, 2022

@luckman212 noted.

As for point 2, it's meant to be used with tools that scan for lines with just a number, like dialog --gauge. Example:

axel -p http://mirror-master.dragonflybsd.org/iso-images/dfly-x86_64-6.2.1_REL.img.bz2 |
    dialog --gauge "Downloading DragonFly BSD" 6 40

That will show a progress meter for the download.

@xxxserxxx
Copy link
Contributor Author

@ismaell it works perfectly, too. axel -p ... | zenity --progress --auto-close is awesome.

@luckman212
Copy link

@ismaell Thank you for the comments, yes tested with dialog and works well! I was trying with pv and progress etc.

@luckman212
Copy link

Just want to add, I had problems with dialog where it would get stuck sometimes and stop updating. I think maybe it was caused by too much / too fast / repeating output same numbers from axel.

I "solved" it by piping to awk first to clean it up and only output the numbers when they actually change...

axel -p https://downloads.freepbxdistro.org/ISO/SNG7-PBX16-64bit-2202-2.iso |
awk '/^[0-9]+$/ {if($0!=last) print; fflush(); last=$0 }' |
dialog --gauge "Downloading FreePBX" 6 40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants