Open PredragBoksic opened 6 years ago
This system declares the following variable: declare -x DESKTOP_SESSION="plasma"
Hence, a possible workaround is:
set +u if [[ "${DESKTOP_SESSION}" =~ ^plasma? ]]; then is_kde=1 fi set -u
I tested it, and the Firefox is closing automatically at the end of the download now. However, I started to save a very long webpage and there were two follow-up questions: Do you want to replace the existing file? and Do you really want to close the window while the download is in progress?
It would be convenient to answer Yes in order to overwrite the saved file (webpage) automatically.
You can add new keystrokes (depending on your requirement) after line 225 per your requirements (see example on line 228: https://github.com/abiyani/automate-save-page-as/blob/53570667380fab73082a43c815de507f75a2e01d/save_page_as#L228)
Also, I would suggest using Chrome headless (https://developers.google.com/web/updates/2017/04/headless-chrome) mode now for automating these tasks. When I wrote this hacky tool, there wasn't any easy way to automate them, but now the landscape has changed since then.
Thank you for your knowledgeable answer. I will try the Chrome headless in the future. Initially, I saw that Chrome did not save complete pages as Firefox did.
The save_page_as works mostly well, except that the first run may not close the window for some reason. It is best to complete a single trial first and then allow the script to execute other page save tasks automatically with window closing.
I am using Firefox 89.0 (Arch Linux) and KDE.
Yes, the problem is that it defines is_kde
wrong, so tries to klose =) with ctrl + f4 instead of ctrl + w.
Changing
if [[ "${DESKTOP_SESSION}" =~ ^kde-? ]]; then
to
if [[ "${DESKTOP_SESSION}" == plasma ]]; then
fixed it.
@PredragBoksic
I started to save a very long webpage and there were two follow-up questions: Do you want to replace the existing file? and Do you really want to close the window while the download is in progress?
It would be convenient to answer Yes in order to overwrite the saved file (webpage) automatically.
See https://github.com/abiyani/automate-save-page-as/issues/32
//Close the browser tab/window (Ctrl+w for KDE, Ctrl+F4 otherwise)
This is the KDE desktop, but the Firefox is never closing by itself at the end of the operation.
Other small issues.
I noticed that the script does not work for a freshly installed Firefox - only the first time.
I noticed also, that the script did not work today only on the first execution of this test run: ./save_page_as -b firefox -d tmp "https://www.bing.com"