-
-
Save willwhui/861bf7eaa713935cf9ce2b1f3cd919e7 to your computer and use it in GitHub Desktop.
Ubuntu14.04-20.04 |
合盖后先 sleep再hibernate
综合起来这样做,运行:
sudo vi /etc/systemd/sleep.conf
打开这个配置文件后,
去掉AllowSuspendThenHibernate=yes
的注释(不过,按道理说默认是yes,应该不用去掉也可以工作)
去掉#HibernateDelaySec=10min
一行的注释,改为:
HibernateDelaySec=600
表示suspend后,10分钟之后开始hibernate
运行:
sudo vi /etc/systemd/logind.conf
修改里面的几行为:
HandleLidSwitch=suspend-then-hibernate
HandleLidSwitchExternalPower=suspend-then-hibernate
HandleLidSwitchDocked=suspend-then-hibernate
然后重启对应的服务:
systemctl restart systemd-logind.service
如果现在测试一下hibernate功能的话,会发现:
从休眠状态恢复后,并非休眠前的情况,而是类似于关机重启。
解决之前,为了防止后续的操作导致启动失败,可以先做个准备,让系统启动菜单显示几秒钟,在/etc/default/grub
文件中做如下更改:
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=2
接下来,开始操作解决休眠恢复无效的方案。
参见这里
上文配置过程中会出现如下警告:
update-initramfs: Generating /boot/initrd.img-5.4.0-100-generic
W: initramfs-tools configuration sets RESUME=UUID=b355eafd-25fb-4934-9c3c-1ca6071659c2
W: but no matching swap device is available.
...
根据这里的说明,是因为文件etc/initramfs-tools/conf.d/resume
中的设置是不必要的,删除或注释调它
#RESUME=UUID=b355eafd-25fb-4934-9c3c-1ca6071659c2 resume_offset=3487744
重新运行
sudo update-initramfs -c -k all
然后重启,测试hibernate功能,看是否成功
sudo systemctl hibernate
注:必须保证有足够大的swapfile,增大swapfile的做法参考这里
注:目前建议的swapfile大小参见这里
注:如果swapfile太小,将无法进入hibernate状态,sudo systemctl suspend-then-hibernate
和 sudo systemctl hibernate
等方法都将不可用,因为不够将内存和已经交换到swapfile的数据同时写入swapfile
蓝牙耳机声音卡顿
原因:给耳机的声音缓存不够
解决方案:设置一个适合的缓存
可用的方案:
参见:
https://askubuntu.com/questions/475987/a2dp-on-pulseaudio-terrible-choppy-skipping-audio
As none of the other answers worked on my system (Ubuntu 18.04 LTS on a 2012 MacBook Air), I found my solution on the german ubuntuusers wiki. English summary of the german instructions:
The choppy output might be caused by the A2DP implementation, and how it buffers sound before encoding it. For me, changing this buffer's size solved the choppy sound problem. You need to perform three steps:
The output should be something like
We see that the buffers have currently 0 latency. In the next step, you will need the NAME and PORT of your output. In this example, these are bluez_card.28_11_A5_84_B6_F9 and speaker-output, respectively.
The latency unit of the following command is microseconds, so I'm using a 50 millisecond buffer for my command here:
As there is usually no documentation about this, you may have to experiment with higher or lower buffer values. Many people people posted their working latencies in the comments to this answer. Check them out for guidance on the latency value.