Ubuntu即将进入睡眠模式时,如何发出警告(噪音/哔哔声)?


8

我在睡眠模式下的计时时间很短。我喜欢这种方式...(大约20分钟)。

闲置20分钟后,系统将进入自动睡眠模式,我需要按键盘才能重新激活。

Ubuntu即将进入睡眠模式时,是否有办法发出噪音/声音?

我确实收到了带有文本的通知警告,但是我经常不看屏幕。

Answers:


3

由于NotifyOSD团队花时间在通知中添加声音,以下是一个脚本,该脚本可以对您的特定用例完成同样好的工作。
(它只会在系统进入睡眠状态时发出哔哔声通知您,恐怕所有通知都不会发出哔哔声……)

  1. 复制并粘贴以下脚本:

    #!/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
    
  2. 进入 gedit

  3. 将其另存为sleep-beep您的Documents目录
  4. Ctrl+ Alt+ T转到终端
  5. 使脚本可执行,然后将其复制到正确的目录:

    sudo chmod +x ~/Documents/sleep-beep
    sudo cp ~/Documents/sleep-beep /etc/pm/sleep.d/sleep-beep
    
  6. 由于需要从命令行播放ogg文件,因此还需要:

    sudo apt-get install vorbis-tools
    

做完了!:-)


融化了什么?脚本从何处获得$ 1?
Ashhar Hasan 2015年

@AshharHasan:你跟踪我吗??? ;-)它是从另一个脚本获取的... :D
Fabby 2015年

1
我猜我现在将阅读一些文档。刚看到这个问题,似乎是我想要的东西。
Ashhar Hasan 2015年

是! RTFM总是很好! ;-) 但是投票更好!@AshharHasan
Fabby 2015年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.