LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-10-2022, 11:28 PM   #1
slac-in-the-box
Member
 
Registered: Mar 2010
Location: oregon
Distribution: slackware64-15.0 / slarm64-current
Posts: 783
Blog Entries: 1

Rep: Reputation: 432Reputation: 432Reputation: 432Reputation: 432Reputation: 432
program to prevent standby mode on speakers that can't disable it themselves


Howdy LQ:

Yep, I bought some speakers, and they don't do what I want: wake me up. I frequently use my linux laptop as an alarm clock, with a simple command like
Code:
sleep 300m && ffplay alarm.flac
I change my alarm.flac to different songs I feel like waking up to. The problem is my laptop speakers are not always loud enough to wake me up.

So I bought something that looked good in the picture: The Marshall Action II. I didn't need rechargeable or portable; just something that plugged in, and can use an aux cord. These speakers do both, as well as bluetooth. But by the time 300 minutes have elapsed, the speakers go into standby mode, and don't play my alarm. In fact, I think it only takes ten minutes or so, and the only way to wake the speakers up, is to touch them: manually turning the volume knob. So needless to say, I am disappointed. I found out that Marshall provides no way to disable this feature, and apprently it was created to "save power" in the EU.

Thus, I've been contemplating a program that can do the following:

Every nine minutes (so a cron job is in order), check and see if sound is already going to the speaker, and if not, send a sound that the speaker detects but not my ears.

So the cron part is easy, and the playing some low frequency sound shouldn't be too difficult. But what would be the most efficient way to check for output sound? I thought about searching for processes of what I play sounds with the most, such as ffplay, moc, ogg, etc., but there are just too many options, so I figure there must be something lower level.

Like if I were to open pamixer, and check output, I see the green bar moving when there is activity. Is there a command-line equivalent that would return "zero" for no output, and some number for whatever it was at when the command was executed?

Just asking this question made me check in /proc, and I just discovered that this returns "closed" when there's no sound, but it is dependent on knowing which sound card is in use:

Code:
cat /proc/asound/card1/pcm0p/sub0/status
Haha... that will work, but now I want to post this anyways
 
Old 10-11-2022, 11:51 AM   #2
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,286
Blog Entries: 24

Rep: Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238Reputation: 4238
Sometimes just formulating the question for others can lead to a solution, as it apparently did here!

Glad you figured it out and thanks for sharing the experience with the rest of us! It never occurred to me that speakers might have a "screensaver" mode, or powersaver in this case. How annoying...

Last edited by astrogeek; 10-11-2022 at 11:55 AM.
 
Old 10-12-2022, 11:22 AM   #3
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,829

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Quote:
Originally Posted by astrogeek View Post
Sometimes just formulating the question for others can lead to a solution, as it apparently did here!
Heh! I can't remember how many times that doing a sanity check on a question before posting it resulted in an AHA! moment.
 
Old 06-03-2023, 06:58 AM   #4
baiyibai
LQ Newbie
 
Registered: Jun 2023
Posts: 2

Rep: Reputation: 0
Thank you slac-in-the-box for posting about this problem, I also encountered it.

I wrote some scripts and posted them on my GitLab which solve this problem also.
https://gitlab.com/baiyibai/bybs-kno...ive_audio.adoc

Thank you for inspiring me to learn systemd today!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
plugging in headphones or speakers doesn't disable my laptop's built in speakers moljac024 Linux - Software 14 07-13-2017 08:01 AM
disable sleep mode, away mode standby, etc. ZiGz Linux - General 4 06-19-2016 01:15 PM
How can i prevent the gnome task bar icons from rearranging themselves when i reboot? Stevithen Debian 1 04-10-2010 05:10 PM
Printers disable by themselves OOsorio Linux - Newbie 4 05-16-2008 06:16 AM
disable standby mode? wimva Linux - Newbie 7 09-23-2003 09:06 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration