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

Firefox window does not close automatically in KUbuntu 18 #16

Open
PredragBoksic opened this issue Jul 24, 2018 · 5 comments
Open

Firefox window does not close automatically in KUbuntu 18 #16

PredragBoksic opened this issue Jul 24, 2018 · 5 comments

Comments

@PredragBoksic
Copy link

//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"

@PredragBoksic
Copy link
Author

PredragBoksic commented Jul 24, 2018

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.

@abiyani
Copy link
Owner

abiyani commented Jul 29, 2018

You can add new keystrokes (depending on your requirement) after line 225 per your requirements (see example on line 228:

xdotool windowactivate "${browser_wid}" key --clearmodifiers "ctrl+w"
)

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.

@PredragBoksic
Copy link
Author

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.

@Ashark
Copy link

Ashark commented Jun 4, 2021

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.

@Ashark
Copy link

Ashark commented Jun 4, 2021

@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 #32

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

No branches or pull requests

3 participants