15.04 暂停后没有 wifi

15.04 暂停后没有 wifi

在 15.04 上挂起后,我的 wifi 无法正常工作。我可以通过点击菜单栏中的 wifi 图标(以及启用 wifi 选项)来成功,但我想使用脚本来自动执行该过程。以下是我的尝试

1)创建可执行的bash脚本,/etc/pm/sleep.d/10_resume_wifi内容如下

#!/bin/sh
  case "$1" in
   hibernate|suspend) ;;
   thaw|resume)
      nmcli r wifi off && nmcli r wifi on ;;
esac

2)创建/etc/system.d/system/wifi-resume.service内容如下的可执行文件

[Unit]
Description=Restart wifi after waking up
After=suspend.target

[Service]
Type=simple
ExecStart=-/etc/pm/sleep.d/10_resume_wifi

[Install]
WantedBy=suspend.target

然后运行sudo systemctl enable wifi-resume.service

这不起作用,从dmesg暂停状态恢复后,我收到以下几行

[11168.786104] cfg80211: World regulatory domain updated:
[11168.786111] cfg80211:  DFS Master region: unset
[11168.786113] cfg80211:   (start_freq - end_freq @ bandwidth), (max_antenna_gain, max_eirp), (dfs_cac_time)
[11168.786119] cfg80211:   (2402000 KHz - 2472000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[11168.786124] cfg80211:   (2457000 KHz - 2482000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[11168.786128] cfg80211:   (2474000 KHz - 2494000 KHz @ 20000 KHz), (300 mBi, 2000 mBm), (N/A)
[11168.786133] cfg80211:   (5170000 KHz - 5250000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[11168.786137] cfg80211:   (5735000 KHz - 5835000 KHz @ 40000 KHz), (300 mBi, 2000 mBm), (N/A)
[11168.968257] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
[11169.004818] ata3: SATA link up 1.5 Gbps (SStatus 113 SControl 300)
[11169.006600] ata3.00: ACPI cmd ef/10:03:00:00:00:a0 (SET FEATURES) filtered out
[11169.009053] ata3.00: ACPI cmd ef/10:03:00:00:00:a0 (SET FEATURES) filtered out
[11169.009061] ata3.00: configured for UDMA/100
[11169.200846] firewire_core 0000:04:00.0: rediscovered device fw0
[11171.088442] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[11171.089310] ata1.00: ACPI cmd ef/10:03:00:00:00:a0 (SET FEATURES) filtered out
[11171.090296] ata1.00: ACPI cmd ef/10:03:00:00:00:a0 (SET FEATURES) filtered out
[11171.090469] ata1.00: configured for UDMA/100
[11171.615861] ERROR @wl_cfg80211_scan : WLC_SCAN error (-22)

点击进入 wifi 后,我得到的输出略有不同dmesg

[11331.635796] cfg80211: Calling CRDA for country: US
[11331.639456] cfg80211: Regulatory domain changed to country: US
[11331.639465] cfg80211:  DFS Master region: FCC

对于为什么基于脚本的方法不起作用,您有什么建议吗?我是新手,所以可能会出现一些错误。提前谢谢!

答案1

经过进一步挖掘,我发现了一个脚本(发布这里),用于在挂起后将我的计算机连接到 wifi。简而言之,我创建了/etc/systemd/system/wifi-resume.service包含以下内容的可执行脚本:

[Unit]
Description=Local system resume actions
After=suspend.target

[Service]
Type=oneshot
ExecStart=/bin/systemctl restart network-manager.service

[Install]
WantedBy=suspend.target

并运行命令sudo systemctl enable wifi-resume.service

非常感谢 Sean 提供的解决方案。

答案2

解决方案对我来说很有效:

sudo touch /etc/pm/sleep.d/10_restart_network_manager
sudo chmod +x /etc/pm/sleep.d/10_restart_network_manager
sudo gedit /etc/pm/sleep.d/10_restart_network_manager

将此代码粘贴到文件中:

#!/bin/sh

case $1 in
    resume|thaw)
        sudo /bin/systemctl restart network-manager.service
    ;;
esac

答案3

经过多次尝试,我终于找到了解决方案。在 下创建一个可执行文件/etc/pm/sleep.d/,并将其命名为 ie 10_resume_wifi,如下所示:

sudo touch /etc/pm/sleep.d/10_resume_wifi
sudo chmod +x /etc/pm/sleep.d/10_resume_wifi
sudo gedit /etc/pm/sleep.d/10_resume_wifi

将此代码粘贴到文件中:

#!/bin/sh

case $1 in
     suspend|suspend_hybrid|hibernate)
        sudo nmcli n off
        ;;
     resume|thaw)
        sudo nmcli n on
        ;;
esac

保存并关闭文件,就这样。

这是唯一始终有效的解决方案。 笔记:我发现的其他解决方案使用了旧版本的命令行

相关内容