Find the answer to your Linux question:
Results 1 to 6 of 6
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    RTC alarm in bash - problem with audio volume control


    I've written an alarm in bash which uses rtcwake to wake the computer up if it is turned off and runs as a service from rc.d in order to be able to play an alarm song even if no user is logged in (I don't have automatic logging in set up).

    The problem is, I do not know how to stop the alarm. I've set it up to spy volume level using "amixer -c0 get Master" which works when it is run with sudo under a logged user in GNOME 3 but does not if the service is run during boot process.

    Even after logging in, changing the volume in GNOME does nothing - the alarm continues playing (using mpg123) and even blocks any other audio output - I cannot hear any other sounds when the alarm is playing.

    Could someone please tell me what am I doing wrong and how to correct this behaviour?

    Thank you.

  2. #2

    can you show the script? what i am wondering is, are you playing a file in a loop or something? i.e., why does the script not just end (and thus, the alarm stop) when the file (wav or whatever) is finished playing? or is it a superlong wav?

  3. #3

    yes, the file is (potentially) played in a loop. The other reason for not just playing the song until it ends is quite simple - the script turns the volume up progressively and it is essential for an alarm to provide a way of stopping itself.
    The script is perhaps executed too early?

    It is quite large though, I'm not sure you would like to familiarize yourself with the script - it contains some "echo" lines which I used for debugging purposes and the alarm format is not very elegant.
    Anyway, here it is: ( won't let me write it as a valid link with the http prefix)
    Last edited by atreyu; 10-03-2013 at 11:48 PM. Reason: linkified link on behalf of OP

  4. $spacer_open
  5. #4
    okay, yeah, that's a mammoth script! so maybe a better approach would be to ask this: when *should* the alarm stop playing? is there some programmatic way to determine this? for example, when a user logs in? should it stop automatically, or should a user have to click a button or something?

  6. #5
    My approach was to spy for the volume level using amixer and if the volume changed, kill the mpg123 process. This works if I run the script manually with sudo in GNOME but not when run as an rc.d script.

    Stopping the alarm when user logs in is not very handy - user could be already logged in (then how would the alarm know if it should stop?).

  7. #6
    are these two different processes? One that spies the volume and one that runs the alarm? do you normally start the script manually?

    can you add logging to the script so that when it runs in an rc.d script, you can capture any (helpful) info?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts