Page 1 of 2

Command to play sound through speakers when headphones on ?

Posted: Mon Mar 25, 2019 1:00 am
by bartszu
Command to play sound through speakers when headphones on ?

Re: Command to play sound through speakers when headphones on ?

Posted: Mon Mar 25, 2019 5:35 am
by rene
Likely impossible, with output paths switched in hardware when inserting a headphone.

Re: Command to play sound through speakers when headphones on ?

Posted: Mon Mar 25, 2019 12:27 pm
by Flemur
bartszu wrote:
Mon Mar 25, 2019 1:00 am
Command to play sound through speakers when headphones on ?
I get it set up with qasmixer (not installed by default): Set "Auto-Mute Mode" (on lower-left of GUI, *if* it's present) to "Disabled".
qasmixer.jpg
qasmixer.jpg (3.04 KiB) Viewed 407 times

Re: Command to play sound through speakers when headphones on ?

Posted: Mon Mar 25, 2019 8:03 pm
by bartszu
Must be possible Mixx can do it. So there must be command for that.

Re: Command to play sound through speakers when headphones on ?

Posted: Mon Mar 25, 2019 8:21 pm
by bartszu
Ok lets make it simpler :)
Alarm Clock for LM able to play sound thru speakers while headphones on ???
Very simple feature every clock on Android has.

Re: Command to play sound through speakers when headphones on ?

Posted: Mon Mar 25, 2019 8:22 pm
by MrEen
It's probably something like pacmd set-sink-port 1 analog-output-lineout or pacmd set-sink-port 1 analog-output-speakers depending what you mean by speakers. Are they built-in, or connected to the Line out port? The number 1 is for the card number involved. Yours may be 0 or higher than 1. The output of aplay -l will give you your card numbers.

Re: Command to play sound through speakers when headphones on ?

Posted: Mon Mar 25, 2019 8:26 pm
by MrEen
Oh, you want to just play a sound to the port. Give me a few minutes and I might find something.

Re: Command to play sound through speakers when headphones on ?

Posted: Mon Mar 25, 2019 8:28 pm
by bartszu
Yes I want bloody aplay to play sound to port.
How to make aplay or anything to do that ???

Re: Command to play sound through speakers when headphones on ?

Posted: Mon Mar 25, 2019 8:31 pm
by bartszu
aplay -l gives me some random drop.
I have one card only one sound card.
Now if I have Bluetooth or headphones on I don't want my alarm to be played on them.

Re: Command to play sound through speakers when headphones on ?

Posted: Mon Mar 25, 2019 8:46 pm
by MrEen
bartszu wrote:
Mon Mar 25, 2019 8:31 pm
aplay -l gives me some random drop.
I have one card only one sound card.
Now if I have Bluetooth or headphones on I don't want my alarm to be played on them.
It's a little too involved for me to figure out at this time, but it is something I'm interested in trying to figure out. I'll let you know if I come up with anything.

It may be too much work for me to find and understand so I can't make any guarantees.

Re: Command to play sound through speakers when headphones on ?

Posted: Mon Mar 25, 2019 9:10 pm
by bartszu
I am going thru your web site, you know tons more about that then me.
This is annoying Linux still needs tons of development.
Don't tell me there is no Alarm Clock for Linux capable of doing that ???

You see problem atm is that I use headphones now but my active port is still: active port: <analog-output-speaker>

Code: Select all

barts@Mint ~ $ pacmd list-sinks
1 sink(s) available.
  * index: 0
	name: <alsa_output.pci-0000_00_08.0.analog-stereo>
	driver: <module-alsa-card.c>
	flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: RUNNING
	suspend cause: 
	priority: 9959
	volume: front-left: 29491 /  45% / -20.81 dB,   front-right: 29491 /  45% / -20.81 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: no
	current latency: 21.61 ms
	max request: 4 KiB
	max rewind: 64 KiB
	monitor source: 0
	sample spec: s16le 2ch 44100Hz
	channel map: front-left,front-right
	             Stereo
	used by: 5
	linked by: 5
	configured latency: 26.00 ms; range is 26.00 .. 371.52 ms
	card: 0 <alsa_card.pci-0000_00_08.0>
	module: 6
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "92HD73C1X5 Analog"
		alsa.id = "92HD73C1X5 Analog"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "0"
		alsa.card_name = "HDA NVidia"
		alsa.long_card_name = "HDA NVidia at 0xf0b80000 irq 17"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:00:08.0"
		sysfs.path = "/devices/pci0000:00/0000:00:08.0/sound/card0"
		device.bus = "pci"
		device.vendor.id = "10de"
		device.vendor.name = "NVIDIA Corporation"
		device.product.id = "0ac0"
		device.product.name = "MCP79 High Definition Audio"
		device.form_factor = "internal"
		device.string = "front:0"
		device.buffering.buffer_size = "65536"
		device.buffering.fragment_size = "32768"
		device.access_mode = "mmap+timer"
		device.profile.name = "analog-stereo"
		device.profile.description = "Analog Stereo"
		device.description = "Built-in Audio Analog Stereo"
		alsa.mixer_name = "IDT 92HD73C1X5"
		alsa.components = "HDA:111d7675,10280271,00100103 HDA:10de0007,10280271,00100100"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	ports:
		analog-output-speaker: Speakers (priority 10000, latency offset 0 usec, available: unknown)
			properties:
				device.icon_name = "audio-speakers"
		analog-output-headphones: Headphones (priority 9000, latency offset 0 usec, available: unknown)
			properties:
				device.icon_name = "audio-headphones"
	active port: <analog-output-speaker>
barts@Mint ~ $ 


Re: Command to play sound through speakers when headphones on ?

Posted: Mon Mar 25, 2019 9:16 pm
by bartszu
Selection_195.jpg
This thing would allow me to run script.
Actually simple "sleep 8h" would allow me to run script.
But what to put to my script ??

I guess I am working now on development of Linux Alarm clocks now .........LOL..../°)
Might actually write them request on GitHub /°)

Re: Command to play sound through speakers when headphones on ?

Posted: Mon Mar 25, 2019 9:38 pm
by MrEen
bartszu wrote:
Mon Mar 25, 2019 9:10 pm
I am going thru your web site, you know tons more about that then me.
This is annoying Linux still needs tons of development.
Don't tell me there is no Alarm Clock for Linux capable of doing that ???

You see problem atm is that I use headphones now but my active port is still: active port: <analog-output-speaker>

Code: Select all

barts@Mint ~ $ pacmd list-sinks
1 sink(s) available.
  * index: 0
	name: <alsa_output.pci-0000_00_08.0.analog-stereo>
	driver: <module-alsa-card.c>
	flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY DYNAMIC_LATENCY
	state: RUNNING
	suspend cause: 
	priority: 9959
	volume: front-left: 29491 /  45% / -20.81 dB,   front-right: 29491 /  45% / -20.81 dB
	        balance 0.00
	base volume: 65536 / 100% / 0.00 dB
	volume steps: 65537
	muted: no
	current latency: 21.61 ms
	max request: 4 KiB
	max rewind: 64 KiB
	monitor source: 0
	sample spec: s16le 2ch 44100Hz
	channel map: front-left,front-right
	             Stereo
	used by: 5
	linked by: 5
	configured latency: 26.00 ms; range is 26.00 .. 371.52 ms
	card: 0 <alsa_card.pci-0000_00_08.0>
	module: 6
	properties:
		alsa.resolution_bits = "16"
		device.api = "alsa"
		device.class = "sound"
		alsa.class = "generic"
		alsa.subclass = "generic-mix"
		alsa.name = "92HD73C1X5 Analog"
		alsa.id = "92HD73C1X5 Analog"
		alsa.subdevice = "0"
		alsa.subdevice_name = "subdevice #0"
		alsa.device = "0"
		alsa.card = "0"
		alsa.card_name = "HDA NVidia"
		alsa.long_card_name = "HDA NVidia at 0xf0b80000 irq 17"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:00:08.0"
		sysfs.path = "/devices/pci0000:00/0000:00:08.0/sound/card0"
		device.bus = "pci"
		device.vendor.id = "10de"
		device.vendor.name = "NVIDIA Corporation"
		device.product.id = "0ac0"
		device.product.name = "MCP79 High Definition Audio"
		device.form_factor = "internal"
		device.string = "front:0"
		device.buffering.buffer_size = "65536"
		device.buffering.fragment_size = "32768"
		device.access_mode = "mmap+timer"
		device.profile.name = "analog-stereo"
		device.profile.description = "Analog Stereo"
		device.description = "Built-in Audio Analog Stereo"
		alsa.mixer_name = "IDT 92HD73C1X5"
		alsa.components = "HDA:111d7675,10280271,00100103 HDA:10de0007,10280271,00100100"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	ports:
		analog-output-speaker: Speakers (priority 10000, latency offset 0 usec, available: unknown)
			properties:
				device.icon_name = "audio-speakers"
		analog-output-headphones: Headphones (priority 9000, latency offset 0 usec, available: unknown)
			properties:
				device.icon_name = "audio-headphones"
	active port: <analog-output-speaker>
barts@Mint ~ $ 

That usually means you have a jack detection and/or pin config issue. You're actually lucky sound is working right now.

I believe what you want is possible, but I'm not certain we can get there without either a script of hundreds of lines or causing issues with currently playing sounds. The issue with currently playing sounds is most likely to be the biggest stumbling block. But I am going to try to figure it out. The agonizing part is the lack of simple-to-understand documentation.

Re: Command to play sound through speakers when headphones on ?

Posted: Mon Mar 25, 2019 9:45 pm
by bartszu
No documentation again, well what a surprise.
So I guess we are in try it yourself game :°)

Re: Command to play sound through speakers when headphones on ?

Posted: Mon Mar 25, 2019 9:48 pm
by bartszu
pacmd set-sink-port 0 analog-output-headphones

This change my output to headphones.
But this:

pacmd set-sink-port 0 analog-output-speakers && audacious example.mp3

Resets it to analog-output-speakers, but because headphones pin is in, sound plays thru them.

Re: Command to play sound through speakers when headphones on ?

Posted: Mon Mar 25, 2019 9:57 pm
by MrEen
bartszu wrote:
Mon Mar 25, 2019 9:48 pm
pacmd set-sink-port 0 analog-output-headphones

This change my output to headphones.
But this:

pacmd set-sink-port 0 analog-output-speakers && audacious example.mp3

Resets it to analog-output-speakers, but because headphones pin is in, sound plays thru them.
Hmmm, that's interesting. Did the sound ALSO play through the speakers?

I found this app, indicator-sound-switcher, that might very well lead to being able to create what you're looking for. On the Issues tab, there a report about new sounds playing to the old port, so I'm thinking this might lead to the right solution.

I've got to head to bed in a few minutes, but I'll try to spend some time on it tomorrow.

Re: Command to play sound through speakers when headphones on ?

Posted: Mon Mar 25, 2019 10:12 pm
by bartszu
MrEen wrote:
Mon Mar 25, 2019 9:57 pm

Hmmm, that's interesting. Did the sound ALSO play through the speakers?
N0 !

Re: Command to play sound through speakers when headphones on ?

Posted: Tue Mar 26, 2019 4:52 pm
by MrEen
Well, I'm afraid this is still over my head. That switcher script I linked to above has THOUSANDS of lines of code to make a simple little switcher.

It might be possible to get sox or paplay to do something, but it'll probably be the weekend before I can get a good idea on the feasibility of using those to accomplish what you want.

You might want to consider using a visual notification instead. notify-send -t 0 "Timer expired" "Your time is up!" in the command field would work. The -t 0 will make the notification stay on the screen until you click on it.

Re: Command to play sound through speakers when headphones on ?

Posted: Tue Mar 26, 2019 8:54 pm
by bartszu
MrEen wrote:
Tue Mar 26, 2019 4:52 pm
You might want to consider using a visual notification instead. notify-send -t 0 "Timer expired" "Your time is up!" in the command field would work. The -t 0 will make the notification stay on the screen until you click on it.
Cool thing actually :°)

Re: Command to play sound through speakers when headphones on ?

Posted: Tue Mar 26, 2019 9:06 pm
by bartszu
OMG I sorted it, it works :°)))))