Created
May 2, 2009 11:30
-
-
Save samleb/105521 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if Internet Explorer is running, if so refresh | |
ps -xc|grep -sq "Internet Explorer" && osascript -e 'tell app "Internet Explorer"' -e 'activate' -e 'OpenURL "JavaScript:window.location.reload();" toWindow -1' -e 'end tell' | |
# Check if OmniWeb is running, if so refresh | |
ps -xc|grep -sq OmniWeb && osascript -e 'tell app "OmniWeb"' -e 'activate' -e 'reload first browser' -e 'end tell' | |
# Check if Firefox is running, if so refresh | |
ps -xc|grep -sqi firefox && osascript <<'APPLESCRIPT' | |
tell app "Firefox" to activate | |
tell app "System Events" | |
if UI elements enabled then | |
keystroke "r" using command down | |
-- Fails if System Preferences > Universal access > "Enable access for assistive devices" is not on | |
else | |
tell app "Firefox" to Get URL "JavaScript:window.location.reload();" inside window 1 | |
-- Fails if Firefox is set to open URLs from external apps in new tabs. | |
end if | |
end tell | |
APPLESCRIPT | |
# Check if Safari is running, if so refresh | |
ps -xc|grep -sq Safari && osascript -e 'tell app "Safari"' -e 'activate' -e 'do JavaScript "window.location.reload();" in first document' -e 'end tell' | |
# Check if Camino is running, if so refresh | |
ps -xc|grep -sq Camino && osascript -e 'tell app "Camino"' -e 'activate' -e 'tell app "System Events" to keystroke "r" using {command down}' -e 'end tell' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment