1

I like to send a shortcut for refreshing a tab to Firefox.

What I have:

  • I have a Linux with working terminal, Firefox and installed xdotool

What I have found / tryed:

What I tryed on terminal (dont get error message, a its looks for me, like i dont realy get a reload of webpage). It can be it send the output of terminal to the terminal and not to the firefox.:

xdotool key F5
xdotool key Ctrl + R

Question:

  • How to do this by terminal for active tab on active Firefox on active workspace ?
  • How to do this by on workspace 2 running terminal for active tab on active Firefox on workspace 1 ?

Remark and new knowledge:

  • now I have found the follow, which are able to reload the active a tab from Firefox Browser on Debian (dont know it works on other Browser too)

  • dont know on this time it works on more than one browser on one or more workspaces and how to use this for one specific workspace, like run this on terminal or bash on workspace 2 and use it for one or more than one Firefox on workspace one.

    xdotool search --onlyvisible --classname Navigator windowactivate --sync key F5

  • Now I changed the code from MarcoLucidi a little bit. Now it reload a a active tab (can be on active browser on workspace 1 ). I will test tomorrow a little bit. See the follow:

    xdotool key --window "$(xdotool search --classname Navigator | head -1)" F5

  • 1
    `xdotool getactivewindow key F5`? – Cyrus Oct 03 '20 at 12:04
  • 2
    `xdotool key --window "$(xdotool search --class Firefox | head -1)" F5`? – MarcoLucidi Oct 03 '20 at 12:51
  • 1
    @Alfred.37 so it doesn't work? what if you replace `F5` with `Ctrl+q`, does it closes Firefox window? – MarcoLucidi Oct 03 '20 at 14:20
  • I can refrsh the FF by F5 by keyboard a not by terminal. And I can close the FF by Ctrl + q by keyboard a not by terminal. Thats sounds for me, I am still not send the terminal output by xdotool to a specific program. –  Oct 03 '20 at 14:29
  • It can its possible on follow: xdotool key --windowid I guess its need to get the programm or window id which created on start of FF or by start of FF tab. I dont know how to do this. –  Oct 03 '20 at 14:52
  • 1
    fwiw, ran a google search on 'xdotool examples browser` and received several hits, eg, [this](https://stackoverflow.com/q/43286199) and [this](https://stackoverflow.com/q/12026953) – markp-fuso Oct 03 '20 at 14:56
  • Now i have found the follow, which are a partly solution. xdotool search --onlyvisible --classname Navigator windowactivate --sync key F5 What i need to find now, i addet as remark section on my question. –  Oct 03 '20 at 22:55
  • @ MarcoLucidi I changed your code a little bit. Now it doing a reload of webpage. I will test tomorrow a little bit. See the follow: xdotool key --window "$(xdotool search --classname Navigator | head -1)" F5 –  Oct 03 '20 at 22:59
  • @ Cyrus, xdotool getactivewindow key F5 dont reload the webpage. –  Oct 04 '20 at 08:48

2 Answers2

0

Sample for send F5 to browser by bash, for reload the page:

xdotool sleep 0.5 search --onlyvisible --classname Navigator windowactivate --sync key F5
xdotool sleep 0.5 search --onlyvisible --classname Navigator windowactivate --sync keyup F5

Sample for send Ctrl+F5 to browser by bash, for reload cache and the page:

xdotool sleep 0.5 search --onlyvisible --classname Navigator windowactivate --sync key Ctrl+F5
xdotool sleep 0.5 search --onlyvisible --classname Navigator windowactivate --sync keyup Ctrl
xdotool sleep 0.5 search --onlyvisible --classname Navigator windowactivate --sync keyup F5

Remark: The keyup fix the buggy xdotool a little bit.

0

Now found the bug on bug tracker:

Found the follow bug reason:

"The fact that xdotool doesn't seem to work is probably related to applications detecting and discarding synthesized events:

Sending keystrokes to a specific window uses a different API than simply typing to the active window.

[...]

Many programs observe this flag and reject these events."

Source: Automatic web-page refresh using xdotool - not sending key after window focus

Found the follow solution:

"With that in mind I was able to make it work with the series of commands below. This reloads both Chromium and Firefox.

cwid=$(xdotool getwindowfocus) # Save the current window
twid=$(xdotool search --name somename)
xdotool windowactivate $twid
sleep 0.1 # The key event might be sent before the window has been fully activated
xdotool key --window $twid F5
xdotool windowactivate $cwid # Done, now go back to where we were

" Source: Automatic web-page refresh using xdotool - not sending key after window focus