#!/bin/sh
# Keep both paths warm for IRL StreamPilot.
# Ethernet remains the preferred route, while Wi-Fi stays associated so that
# removing the cable does not require a new scan, association, or DHCP lease.

IFACE="${1:-}"
ACTION="${2:-}"

case "$IFACE:$ACTION" in
  eth0:up|eth0:dhcp4-change|eth0:connectivity-change)
    nmcli device connect wlan0 >/dev/null 2>&1 || true
    ;;
  wlan0:up|wlan0:dhcp4-change|wlan0:connectivity-change)
    # Wi-Fi stays connected; route metrics keep Ethernet preferred.
    ;;
  eth0:down|eth0:pre-down)
    nmcli device connect wlan0 >/dev/null 2>&1 || true
    ;;
esac

exit 0
