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)    
KEY="CTRL+F5"    
BROWSER="Firefox"    
    
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}    
fi    

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

Run it from PHP

To use this from PHP:

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