#!/bin/sh
# Called by the NM dispatcher (90-mood-portal) as the user. One prompt per 2 minutes.
stamp="$XDG_RUNTIME_DIR/mood-portal.stamp"
[ -f "$stamp" ] && [ $(( $(date +%s) - $(stat -c %Y "$stamp") )) -lt 120 ] && exit 0
touch "$stamp"
a=$(notify-send -a "Wi-Fi" -i network-wireless -u critical -t 60000 -A open="Sign in" \
  "This Wi-Fi needs you to sign in" "Your school or café network has a login page. Click to open it." 2>/dev/null)
[ "$a" = open ] && exec mood-browser "http://nmcheck.gnome.org/check_network_status.txt"
exit 0
