如果您一直开着电脑,并且正在寻找一种早上醒来的好方法,那很简单。您所需要的只是您的常规音乐播放器和“睡眠”命令。“睡眠”命令是一个内置工具(至少在Ubuntu中),它允许您为任意时间(秒、分钟、小时和天)设置计时器。如果我们将“睡眠”命令与我们最喜欢的音乐播放器和歌曲相结合,那么我们可以设置一个闹钟,在设定的时间后唤醒我们。这是它的工作原理。
在终端中设置睡眠定时器
首先,打开您的终端。
终端(Terminal)打开后,让我们回顾一下“睡眠”命令的工作原理。这很简单。要休眠 10 秒,请使用以下命令:
要休眠 10 分钟,请使用以下命令:
要休眠 10 小时,请使用以下命令:
最后,要睡 10 天,请使用以下命令:
你甚至可以组合命令,所以如果你想睡 5 小时 30 分钟,你可以使用一个 'sleep' 命令和两个时间:
这简单!当然,一旦你的时间过去了,什么都不会发生,因为'sleep'命令所做的只是倒计时你的睡眠量。为了使它成为一个真正的闹钟,我们需要添加到命令中。对于我们的音乐播放器,我们将使用 mplayer,但您也可以轻松使用Totem、VLC、Banshee或任何您喜欢的音乐播放器。
例如,要调用 mplayer,我们将使用以下命令:
将其输入终端(Terminal)(当然,替换音乐文件的实际路径和名称),我们将能够收听我们想要的任何歌曲。当然,缺点(在尝试创建我们的闹钟时)是歌曲会立即播放。
解决方案?一起使用“睡眠”命令和我们的音乐播放器。我们将把这两个命令与'&&'结合起来,它将运行第一个命令,然后只有在它完成后才运行第二个。我们的最终命令?假设我们要睡 8 小时:
这很简单!“睡眠”命令将等待 8 小时,然后当时间到时,将退出,允许第二个命令(实际播放音乐的位置)开始。 即时(Instant)闹钟。
当然,这有几个缺点。 首先(First)是许多人让他们的计算机在一定时间后进入睡眠或休眠状态。这对我们的闹钟来说显然不是一件好事。因此,可能必须关闭省电工具。此外,不要忘记在睡觉前仔细检查您的音量设置。如果你的声音一直被调低,那可不是一件好事。你可能第二天早上起不来!尽管如此,仅通过一个命令即可设置警报是利用终端(Terminal)的好方法;它确实提供了很多速度、动力和生产力。
Terminal Tricks: Use the Terminal as an alarm clock
If yoυ keep your computer on all the timе, and are looking for a nice wау tо wake up in the morning, it’s simplе. All you need is your regular music player and the ‘slеep’ command. The ‘sleep’ command is a built-in tool (at least in Ubuntu), that allows you to set a timer for any amount of time (seconds, minutes, hours, and days). If we couple the ‘sleep’ command with our favorite music player and song, then we can set an аlarm that will wake us up after a ѕet amoυnt of time. Herе’s how it works.
Set Sleep Timer in Terminal
First, open your Terminal.
Once the Terminal is open, let’s go over how the ‘sleep’ command works. It’s very simple. To sleep for 10 seconds, use this command:
To sleep for 10 minutes, use this command:
To sleep for 10 hours, use this command:
Finally, to sleep for 10 days, use this command:
You can even combine commands, so if you wanted to sleep for 5 hours and 30 minutes, you would use a single ‘sleep’ command with both times:
It’s easy! Of course, once your time has elapsed, nothing else will happen, because all the ‘sleep’ command does is count down your sleep amount. To make this a true alarm clock, we’ll need to add to the command. For our music player, we’ll use mplayer, but you could just as easily use Totem, VLC, Banshee, or whatever your favorite music player is.
To invoke mplayer, for instance, we would use this command:
Typing this into the Terminal (replacing the actual path and name of the music file, of course), we would be able to listen to whatever song we want. Of course, the drawback (when trying to create our alarm clock), is that the song plays immediately.
The solution? Use the ‘sleep’ command and our music player together. We’ll combine the two commands with ‘&&’ which will run the first command, then only after it completes run the second. Our final command? Assuming we want to sleep for 8 hours:
It’s simple! The ‘sleep’ command will wait 8 hours, then when the time is up, will quit, allowing the second command – where the music is actually played – to begin. Instant alarm clock.
There are a couple drawbacks to this, of course. First is that many people have their computers to either sleep or hibernate after a certain amount of time. This obviously would not be a good thing for our alarm clock. As such, power saving tools may have to be turned off. In addition, don’t forget to double check your volume settings before heading to bed. It wouldn’t be a good thing if your sound had been turned all the way down; you might not wake up the next morning! Still, being able to set up an alarm in only a single command is a great way to take advantage of the Terminal; it really does offer a lot of speed, power and productivity.