Mercurial > bottledash
diff contrib/dashboardctl @ 38:3fc74bcbd2cf
Fix indentation; add Vim modeline
author | Gernot Schulz <gernot@intevation.de> |
---|---|
date | Tue, 20 Oct 2015 08:24:56 +0200 |
parents | 58ca5b1d33a5 |
children | c3955e5cf3b3 |
line wrap: on
line diff
--- a/contrib/dashboardctl Tue Oct 20 08:22:26 2015 +0200 +++ b/contrib/dashboardctl Tue Oct 20 08:24:56 2015 +0200 @@ -33,102 +33,102 @@ } start_bottledash () { - # taken from start-bottledash-hohup - nohup python3 /home/pi/bottledash/dash.py 2>&1 > $BOTTLEDASH_LOG & - echo $! > $BOTTLEDASH_PID - sleep 10 + # taken from start-bottledash-hohup + nohup python3 /home/pi/bottledash/dash.py 2>&1 > $BOTTLEDASH_LOG & + echo $! > $BOTTLEDASH_PID + sleep 10 } stop_bottledash () { - kill $(cat $BOTTLEDASH_PID) + kill $(cat $BOTTLEDASH_PID) } start_chromium () { - # taken from show-dashboard - rm -R $HOME/.cache/chromium/Default/Cache/ - DISPLAY=:0.0 nohup chromium --new --noerrdialogs --kiosk \ - http://localhost:8080 2>&1 > $CHROMIUM_LOG & - echo $! > $CHROMIUM_PID + # taken from show-dashboard + rm -R $HOME/.cache/chromium/Default/Cache/ + DISPLAY=:0.0 nohup chromium --new --noerrdialogs --kiosk \ + http://localhost:8080 2>&1 > $CHROMIUM_LOG & + echo $! > $CHROMIUM_PID } stop_chromium () { - kill $(cat $CHROMIUM_PID) + kill $(cat $CHROMIUM_PID) } xdo_reload_chromium () { - # Start Chromium if necessary - if [ -f "$BOTTLEDASH_PID" ] && [ -d /proc/$(cat "$CHROMIUM_PID") ]; then - # Send F5 to Chromium - WID=$(xdotool search --onlyvisible --class chromium | head -1) - xdotool windowactivate ${WID} - xdotool key F5 - else - start_chromium - fi + # Start Chromium if necessary + if [ -f "$BOTTLEDASH_PID" ] && [ -d /proc/$(cat "$CHROMIUM_PID") ]; then + # Send F5 to Chromium + WID=$(xdotool search --onlyvisible --class chromium | head -1) + xdotool windowactivate ${WID} + xdotool key F5 + else + start_chromium + fi } check_new_db () { - if [ ! -f "$NEWDB" ]; then - echo 0 ; return - fi - OLDSIZE=$(md5sum $OLDDB | awk '{print $1}') - NEWSIZE=$(md5sum $NEWDB | awk '{print $1}') - if [ "$OLDSIZE" != "$NEWSIZE" ]; then - echo 1 - else - echo 0 - fi + if [ ! -f "$NEWDB" ]; then + echo 0 ; return + fi + OLDSIZE=$(md5sum $OLDDB | awk '{print $1}') + NEWSIZE=$(md5sum $NEWDB | awk '{print $1}') + if [ "$OLDSIZE" != "$NEWSIZE" ]; then + echo 1 + else + echo 0 + fi } update_db () { - if [ $(check_new_db) -eq 1 ]; then - mv "$NEWDB" "$OLDDB" - fi + if [ $(check_new_db) -eq 1 ]; then + mv "$NEWDB" "$OLDDB" + fi } case $1 in - '--start') - start_bottledash - start_chromium - ;; - '--stop') - stop_bottledash - stop_chromium - ;; - '--restart-bd') - stop_bottledash - start_bottledash - ;; - '--reload-browser') - xdo_reload_chromium - ;; - '--reload') - stop_bottledash - start_bottledash - xdo_reload_chromium - ;; - '--check-db') - check_new_db - ;; - '--smart-reload') - if [ $(check_new_db) -eq 1 ]; then - update_db - stop_bottledash - start_bottledash - sleep 10 - xdo_reload_chromium - fi - ;; - '-h'|'--help') - usage - exit 0 - ;; - *) - echo "ERROR: unknown command: $1" >&2 - usage - exit 2 - ;; + '--start') + start_bottledash + start_chromium + ;; + '--stop') + stop_bottledash + stop_chromium + ;; + '--restart-bd') + stop_bottledash + start_bottledash + ;; + '--reload-browser') + xdo_reload_chromium + ;; + '--reload') + stop_bottledash + start_bottledash + xdo_reload_chromium + ;; + '--check-db') + check_new_db + ;; + '--smart-reload') + if [ $(check_new_db) -eq 1 ]; then + update_db + stop_bottledash + start_bottledash + sleep 10 + xdo_reload_chromium + fi + ;; + '-h'|'--help') + usage + exit 0 + ;; + *) + echo "ERROR: unknown command: $1" >&2 + usage + exit 2 + ;; esac -# vim: set ft=sh : +# vim: set ft=sh ts=4 sw=4 expandtab :