You are not logged in.

#1 2019-01-22 08:05:58

artiljerija1914
Member
Registered: 2019-01-06
Posts: 20

[SOLVED] using sleep to schedule a task: my alarm clock didn't work

Hi! Here's a really noobish one. So my phone is dead and have no way to wake me up. I downloaded an .mp3 file (air raid siren sound) and renamed it alarm.mp3 and ran this:
sleep 5h && mplayer alarm.mp3
It didn't work unfortunately. Of course I tested it first whether it would run when the screen was locked and it did. What did I do wrong?

Last edited by artiljerija1914 (2019-01-23 16:57:51)

Offline

#2 2019-01-22 08:19:29

ugjka
Member
From: Latvia
Registered: 2014-04-01
Posts: 1,962
Website

Re: [SOLVED] using sleep to schedule a task: my alarm clock didn't work

Did you get any error messages in the terminal from mplayer?

Offline

#3 2019-01-22 08:24:51

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,428

Re: [SOLVED] using sleep to schedule a task: my alarm clock didn't work

Well do you have terminal output of a potential error? This could have a wide variety of causes, depending on the device mplayer plays back to that could've been busy and are you sure that only your screen was locked? It's not going to work anymore if your system suspends.

There's stuff like rtcwake which will wake up your computer even if it has entered suspend.

Offline

#4 2019-01-22 08:33:40

artiljerija1914
Member
Registered: 2019-01-06
Posts: 20

Re: [SOLVED] using sleep to schedule a task: my alarm clock didn't work

Mplayer returned as if everything worked as it should. But I'm not sure my screen was only locked. If system was suspended, could have mplayer returned normal output?

[myname@mypc ~]$ sleep 5h && mplayer alarm.mp3

MPlayer SVN-r38101 (C) 2000-2018 MPlayer Team
225 audio & 464 video codecs
do_connect: could not connect to socket
connect: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing alarm.mp3.
libavformat version 58.20.100 (external)
Mismatching header version 58.12.100
Audio only file format detected.
Load subtitles in ./
==========================================================================
Opening audio decoder: [mpg123] MPEG 1.0/2.0/2.5 layers I, II, III
AUDIO: 48000 Hz, 2 ch, s16le, 192.0 kbit/12.50% (ratio: 24000->192000)
Selected audio codec: [mpg123] afm: mpg123 (MPEG 1.0/2.0/2.5 layers I, II, III)
==========================================================================
[AO OSS] audio_setup: Can't open audio device /dev/dsp: No such file or directory
AO: [alsa] 48000Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
A:   0.0 (00.0) of 2370.0 (39:30.0) ??,?%


Exiting... (End of file)

Offline

#5 2019-01-22 08:45:10

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,680

Re: [SOLVED] using sleep to schedule a task: my alarm clock didn't work

If the system was in S3, sleep would not have progressed at all and also the computer does nothing.
You want to use rtcwake as V1del suggested - it'll send your system to S3, wake it up at a specified time and if you combine it w/ a brief sleep (few seconds to allow the sound system to be initialized for sure) and playback

Warning: this will suspend your system immediately and wake you at 6:30. Don't be confused by the output, the RTC is probably in UTC.

sudo rtcwake -m mem --time "`date -d "06:30 tomorrow" +%s`" && sleep 5 && mplayer alarm.mp3

Pro-Tip: drink a lot of water before going to bed. You'll wake up in time …

Offline

#6 2019-01-22 09:45:10

artiljerija1914
Member
Registered: 2019-01-06
Posts: 20

Re: [SOLVED] using sleep to schedule a task: my alarm clock didn't work

Thanks a lot for the spoonfeed smile I will try with rtcwake tonight, it will probably work. Also the water thing is a good idea, I could've went with that for starters...

Offline

#7 2019-01-22 11:06:00

Docbroke
Member
From: India
Registered: 2015-06-13
Posts: 1,475

Re: [SOLVED] using sleep to schedule a task: my alarm clock didn't work

seth wrote:

Pro-Tip: drink a lot of water before going to bed. You'll wake up in time …

or wake twice, once in the middle of the night and then much later.

Offline

#8 2019-01-22 11:16:46

ugjka
Member
From: Latvia
Registered: 2014-04-01
Posts: 1,962
Website

Re: [SOLVED] using sleep to schedule a task: my alarm clock didn't work

Just don't wake up in micturated bed tongue

Offline

#9 2019-01-22 22:22:29

artiljerija1914
Member
Registered: 2019-01-06
Posts: 20

Re: [SOLVED] using sleep to schedule a task: my alarm clock didn't work

Hey Seth the command you wrote me doesn't work as it should. When mplayer starts it doesn't manage to play the file. When I use it on it's own it plays it without a problem. I also tried allowing more time for the sound system to initialize and it doesn't change anything. A difference in the mplayer output tho is that when I run it by itself, it returns the following:
Starting playback...
A:  13.2 (13.2) of 2370.0 (39:30.0)  0.6%
And when I run it with rtcwake:
Starting playback...
A:   0.0 (00.0) of 2370.0 (39:30.0) ??,?%
Exiting... (End of file)

Offline

#10 2019-01-22 22:27:10

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,680

Re: [SOLVED] using sleep to schedule a task: my alarm clock didn't work

What if you play a file from /tmp?
Also try "mplayer -v" for more details.

Offline

#11 2019-01-22 22:37:45

artiljerija1914
Member
Registered: 2019-01-06
Posts: 20

Re: [SOLVED] using sleep to schedule a task: my alarm clock didn't work

Just tried it... Doesn't work. When I think about it, it acted the same way after the sleep command hmm
Could mplayer be broken?

Offline

#12 2019-01-22 22:42:39

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,680

Re: [SOLVED] using sleep to schedule a task: my alarm clock didn't work

Can you use mplayer after resuming from S3 at all? If so (and actually in general)

seth wrote:

try "mplayer -v" for more details.

Some resource might be missing.
Do you wakeup to a locked session and use pulseaudio?
There's also a bunch of other mp3 players (eg. mpg123, doesn't use libva)

Offline

#13 2019-01-22 22:52:04

artiljerija1914
Member
Registered: 2019-01-06
Posts: 20

Re: [SOLVED] using sleep to schedule a task: my alarm clock didn't work

It wakes up as it should, I have pulseaudio installed.

Tho I just noticed mplayer -v also returns this:
vo: x11 uninit called but X11 not initialized..

Offline

#14 2019-01-22 22:57:22

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,680

Re: [SOLVED] using sleep to schedule a task: my alarm clock didn't work

That's probably not the problem since you don't need a display server to play audio.
Are you maybe using gnome on wayland?

"It wakes up as it should" doesn't really answer my questions, but i'd get PA out of the equation.

Offline

#15 2019-01-22 23:04:47

artiljerija1914
Member
Registered: 2019-01-06
Posts: 20

Re: [SOLVED] using sleep to schedule a task: my alarm clock didn't work

Sorry, what I meant was it doesn't wake up locked, if that's what you were asking. I'm running KDE on Xorg.
I looked up the error, there's all sorts of things but couldn't find something that applies to my current problem.

Offline

#16 2019-01-22 23:09:59

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 78,680

Re: [SOLVED] using sleep to schedule a task: my alarm clock didn't work

Are you running this from an interactive shell (konsole) or some cronjob, systemd timer, …?
Stop the pulseaudio daemon…

Offline

#17 2019-01-22 23:14:20

artiljerija1914
Member
Registered: 2019-01-06
Posts: 20

Re: [SOLVED] using sleep to schedule a task: my alarm clock didn't work

I'm running it from konsole. I think I will just go with mpg123, since I tested it now and it works just fine... Thanks a lot for the help btw, very much appreciated!

Offline

#18 2019-01-22 23:37:49

2ManyDogs
Forum Fellow
Registered: 2012-01-15
Posts: 4,648

Re: [SOLVED] using sleep to schedule a task: my alarm clock didn't work

Please remember to mark your thread [SOLVED] (edit the title of your first post).

Offline

Board footer

Powered by FluxBB