Skip to content

Commit

Permalink
New Feature: Watchdog that reboots the system if the screen stops cha…
Browse files Browse the repository at this point in the history
…nging
  • Loading branch information
schlomo committed Dec 19, 2012
1 parent 3e2fa1f commit 03ba782
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ DPKG_OPTS=-b
cp -r src build
git log | gzip -9 >build/usr/share/doc/kiosk-browser/changelog.gz
chmod -R g-w build
chmod 0440 build/etc/sudoers.d/kiosk-browser
visudo -c -f build/etc/sudoers.d/kiosk-browser
fakeroot ${DPKG} ${DPKG_OPTS} build out
rm -Rf build

test: out/*.deb
lintian -i out/*.deb

info: out/*.deb
Expand Down
Binary file removed out/kiosk-browser_1.18_all.deb
Binary file not shown.
Binary file added out/kiosk-browser_1.20_all.deb
Binary file not shown.
1 change: 1 addition & 0 deletions src/DEBIAN/conffiles
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/etc/sudoers.d/kiosk-browser
6 changes: 4 additions & 2 deletions src/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
Package: kiosk-browser
Version: 1.18
Version: 1.20
Priority: optional
Section: web
Architecture: all
Maintainer: Schlomo Schapiro <[email protected]>
Pre-Depends: nodm
Depends: chromium-browser, x11-xserver-utils, metacity, xdotool
Depends: chromium-browser, x11-xserver-utils, metacity, xdotool, x11-apps, sudo, imagemagick
Homepage: https://github.com/ImmobilienScout24/kiosk-browser
Description: Kiosk Browser
Setup system to work as a kiosk browser, showing only a full-screen browser.
.
Configuration options in /etc/default/kiosk-browser
KIOSK_BROWSER_START_PAGE sets the start page
Also add your own customization to that file, e.g. xrandr calls.
.
See project homepage for full list of config options.
7 changes: 7 additions & 0 deletions src/DEBIAN/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,10 @@ sed -i -e 's/NODM_X_OPTIONS=.*/NODM_X_OPTIONS="-nocursor -nolisten tcp"/' -e 's/
# allow kiosk user to only write in directories needed by chromium
mkdir -p /var/lib/kiosk-browser/{.cache,.config/chromium,.pki}
chown -R kiosk-browser:kiosk-browser /var/lib/kiosk-browser/{.cache,.config/chromium,.pki}

# restart if running, nodm has no status so we simply check for any kiosk-browser processes
if pgrep -u kiosk-browser >/dev/null ; then
service nodm stop
sleep 20 # wait for chromium and other subprocesses to exit
service nodm start
fi
1 change: 1 addition & 0 deletions src/etc/sudoers.d/kiosk-browser
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kiosk-browser ALL=NOPASSWD: /sbin/reboot
25 changes: 25 additions & 0 deletions src/var/lib/kiosk-browser/.xsession
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ if [[ ! "$KIOSK_BROWSER_START_PAGE" ]] ; then
KIOSK_BROWSER_START_PAGE=https://github.com/ImmobilienScout24/kiosk-browser
fi

if [[ ! "$KIOSK_BROWSER_WATCHDOG_TIMEOUT" ]] ; then
# default stale screen watchdog is 1h
KIOSK_BROWSER_WATCHDOG_TIMEOUT=3600
fi

# configure displays
xrandr $(
xrandr_position=
Expand All @@ -51,6 +56,26 @@ xset -dpms
xset s off
xset s noblank

# start watchdog, reboot system if screen stops to change
if (( KIOSK_BROWSER_WATCHDOG_TIMEOUT > 0 )) ; then
LASTHASH=""
LASTCHANGED="$SECONDS"
while sleep "${KIOSK_BROWSER_WATCHDOG_CHECK_INTERVAL:-17}" ; do
HASH=$(import -display :0 -window root -monochrome jpg:- | identify -format '%#' -)
#declare -p HASH LASTHASH LASTCHANGED SECONDS
if [[ "$HASH" = "$LASTHASH" ]] ; then
if (( SECONDS > LASTCHANGED + KIOSK_BROWSER_WATCHDOG_TIMEOUT )) ; then
sudo /sbin/reboot
break
fi
else
LASTHASH="$HASH"
LASTCHANGED="$SECONDS"
fi
done </dev/null 1>&2 &
trap "kill $!" 0 # kill watchdog on exit
fi

#forget about running jobs
disown -a

Expand Down

0 comments on commit 03ba782

Please sign in to comment.