Quote:
Originally Posted by
drew77
I simply want to know if a download is occurring in Firefox.
If download is occurring then do not go into a suspend state.
Absolutely nothing that you are doing in the script you have shown us in this thread will tell you anything about whether or not Firefox is downloading a file unless it happens to be downloading a single file named
/home/andy/Downloads/myfile.iso unless there is something going on behind the scenes such that the command
xdotool getactivewindow key Ctrl has the side effect of causing
/home/andy/Downloads/myfile.iso to change size if
Firefox is downloading a file.
Does running the command
xdotool getactivewindow key Ctrl cause the size of
/home/andy/Downloads/myfile.iso to change?
Note that MadeInGermany is correct about
du -s reporting file sizes as a number of blocks (512-byte blocks if the version of
du on your version of Ubuntu adheres to the standards; but quite likely on most versions of Linux systems you'll get counts of a larger sized block). If you want to detect small increments of change, please do not use
wc -c pathname as suggested by apmcd47; that will increase the CPU an IO load on your system significantly if you are downloading a large file. Using
ls -n pathname would be a much better choice. It will report changes in file size to the number of bytes in the file and only has to do a
stat() on the file to get its size; using
wc -c pathname is usually implemented by
wc opening, reading, and counting every byte in
pathname. (Note that
ls -n output is like
ls -l output except it prints the file owner's user ID and file group's group ID instead of looking up and printing the file owner's user name and file group's group name; therefore, it is slightly faster and uses fewer system resources to get the job done. If you were using a UNIX system instead of a Linux system, I'd suggest using
ls -og which avoids printing user and group names or IDs completely.)