99-notify 1.1 KB

123456789101112131415161718192021222324252627282930
  1. #Notify user of interface state changes
  2. display_notice()
  3. {
  4. export DISPLAY=:0
  5. export TEXTDOMAIN=dhcpcd_notify
  6. export OUTPUT_CHARSET=UTF-8
  7. . gettext.sh
  8. case "$reason" in
  9. BOUND|REBOOT|STATIC) #up
  10. gtkdialog-splash -placement bottom -timeout 4 -bg green -text "`eval_gettext \"\\\$new_ip_address acquired on \\\$interface\"`" ;;
  11. CARRIER) #ifup
  12. ssid="$(wpa_cli -i $interface status 2>/dev/null | grep ^ssid | cut -f 2 -d =)"
  13. gtkdialog-splash -placement bottom-left -timeout 4 -bg orange -text "`eval_gettext \"Requesting IP address for \\\$interface \\\$ssid\"`" &
  14. ;;
  15. RELEASE) #release
  16. gtkdialog-splash -placement bottom -timeout 4 -bg orange -text "`eval_gettext \"Releasing \\\$interface\"`" ;;
  17. NOCARRIER) #down
  18. gtkdialog-splash -placement bottom -timeout 4 -bg hotpink -text "`eval_gettext \"\\\$interface is down\"`" ;;
  19. IPV4LL|TIMEOUT|FAIL) #timeout
  20. gtkdialog-splash -placement bottom -timeout 4 -bg red -text "`eval_gettext \"IP address request failed on \\\$interface\"`" ;;
  21. esac
  22. }
  23. if echo "$reason" | grep -q -E 'BOUND|REBOOT|STATIC|CARRIER|RELEASE|NOCARRIER|IPV4LL|TIMEOUT|FAIL';then
  24. [ -f /etc/dhcpcd_state_notify ] && display_notice
  25. fi