#!/bin/sh

# system76-driver: Universal driver for System76 computers
# Copyright (C) 2005-2016 System76, Inc.
#
# This file is part of `system76-driver`.
#
# `system76-driver` is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# `system76-driver` is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with `system76-driver`; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

# 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

