Last active
November 6, 2018 13:50
-
-
Save razius/8503625 to your computer and use it in GitHub Desktop.
Watches the folder or files passed as arguments to the script and when detects a change it automatically refreshes the current selected Chrome tab or window.
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 | |
# | |
# Watches the folder or files passed as arguments to the script and when it | |
# detects a change it automatically refreshes the current selected Chrome tab or | |
# window. | |
# | |
# http://razius.com/articles/auto-refreshing-google-chrome-on-file-changes/ | |
# | |
# Usage: | |
# ./chrome-refresh.sh /folder/to/watch /some/folder/file_to_watch.html | |
TIME_FORMAT='%F %H:%M' | |
OUTPUT_FORMAT='%T Event(s): %e fired for file: %w. Refreshing.' | |
while inotifywait -q -r --timefmt "${TIME_FORMAT}" --format "${OUTPUT_FORMAT}" "$@"; do | |
CHROME_WINDOW_ID=$(xdotool search --onlyvisible --class google-chrome | head -1) | |
xdotool key --window $CHROME_WINDOW_ID 'CTRL+r' | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can also use
xdotool search "Google Chrome" windowactivate --sync key --clearmodifiers ctrl+r
Stumbled upon thiswhile trying to achieve something similar. Thanks :)