#!/bin/sh
# SPDX-License-Identifier: GPL-2.0-or-later
# SPDX-FileCopyrightText: 2005-2016 System76, Inc.

# Starting with 16.04, there are WiFi reliability issues when resuming from
# suspend, at least with certain WiFi cards.  In particular, this problem seems
# to effect Haswell generation cards like the 7260.  It does not seem to effect
# Skylake generation cards like the 3165, 8260.
#
# This seems fundamentally a user-space issue, not a kernel issue.
#
# This script is installed at /lib/systemd/system-sleep/system76-nm-restart.

set -e

if [ "$2" = "suspend" ] || [ "$2" = "hybrid-sleep" ]; then
    case "$1" in
        pre) true ;;
        post) sleep 1 && sudo systemctl restart NetworkManager ;;
    esac
fi

