Reload a firefox browser tab from bash

Save this in a script & run it whenever you need to reload the active tab. See Add Bash Script to Terminal.

SHOULD_SWITCH_BACK=$1 # y/Y means it will switch back to current window  
CURRENT_WINDOW=$(xdotool getactivewindow)  
xdotool search --desktop 0 ${BROWSER} windowactivate  
xdotool key ${KEY}  
if [[ $SHOULD_SWITCH_BACK == 'y' || $SHOULD_SWITCH_BACK == 'Y' ]]; then  
    xdotool windowfocus --sync ${CURRENT_WINDOW}  
    xdotool windowactivate --sync ${CURRENT_WINDOW}  

Thanks to stack exchange users & askubuntu users for their work that got me here.

Run it from PHP

To use this from PHP:

//or system($theDir.'/ y'); //to switch back to your active window