![当 Ubuntu 即将进入睡眠模式时如何发出警告(噪音/哔哔声)?](https://linux22.com/image/1048493/%E5%BD%93%20Ubuntu%20%E5%8D%B3%E5%B0%86%E8%BF%9B%E5%85%A5%E7%9D%A1%E7%9C%A0%E6%A8%A1%E5%BC%8F%E6%97%B6%E5%A6%82%E4%BD%95%E5%8F%91%E5%87%BA%E8%AD%A6%E5%91%8A%EF%BC%88%E5%99%AA%E9%9F%B3%2F%E5%93%94%E5%93%94%E5%A3%B0%EF%BC%89%EF%BC%9F.png)
我的睡眠模式时间很短。我喜欢这种方式……(大约 20 分钟)。
闲置 20 分钟后,我的系统将进入自动睡眠模式,我需要按下键盘才能重新激活。
当 Ubuntu 即将进入睡眠模式时,有没有办法发出噪音/哔哔声?
我确实收到了带有文字的通知警告,但我经常不看屏幕。
答案1
由于 NotifyOSD 团队正在花时间为通知添加声音,这里有一个脚本可以完成相同的任务,足以满足您的特定使用情况。
(它只会在系统进入睡眠状态时发出哔声通知您,恐怕所有通知都不会发出哔声……)
复制粘贴以下脚本:
#!/bin/bash # # This script plays a sound if the system is going into hibernation/sleep mode # as an answer to http://askubuntu.com/questions/552999/how-to-warn-noise-bleep-when-ubuntu-is-about-to-go-into-sleep-mode/553026 # Original script name: /etc/pm/sleep.d/sleep-beep # # Copyright (c) Fabby 2015 # This program 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 3 of the License, or (at your option) any later version. # This program 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 AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. See the GNU General Public License for more details. # You DID NOT receive a copy of the GNU General Public License along with this program as the license is bigger then this program. # Therefore, see http://www.gnu.org/licenses/ for more details. case $1 in suspend|suspend_hybrid|hibernate) notify-send --urgency=NORMAL --icon=face-tired "Going to sleep" ogg123 /usr/share/sounds/ubuntu/stereo/desktop-login.ogg ;; resume|thaw) # No need to do anything here, but easy to add if needed ;; esac
进入
gedit
- 将其保存
sleep-beep
为你的 Documents 目录 - 按Ctrl+ Alt+T进入终端
使脚本可执行,然后将其复制到正确的目录:
sudo chmod +x ~/Documents/sleep-beep sudo cp ~/Documents/sleep-beep /etc/pm/sleep.d/sleep-beep
由于它需要从命令行播放 ogg 文件,因此它还需要:
sudo apt-get install vorbis-tools