skip to Main Content

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

2

Answers


  1. 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.

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search