You are not logged in.

#1 2017-07-07 20:49:36

Yashalta
Member
Registered: 2017-05-28
Posts: 49

(SOLVED) How to automatically switch the sound?

When I plug in my MS LifeChat LX-3000 headphones into my usb drive into notebook, I have to manually change the sound output to the headset by pavucontrol.
  And when I switch the sound manualy and try to change volume from my keyboard (on the rope) the volume remains the same.
I found this link in the wiki https://wiki.archlinux.org/index.php/Pu … on_connect
And try to test command in terminal # pactl load-module module-switch-on-connect
i have this error

i3 ~ $ sudo su
[root@PC i3]# pactl load-module module-switch-on-connect
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
[root@PC i3]# 

PS -ArchLinux wm i3

Last edited by Yashalta (2017-07-11 13:43:38)

Offline

#2 2017-07-07 22:26:49

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,779

Re: (SOLVED) How to automatically switch the sound?

Why are you running this as root? Your pulse runs as your user, so run the pactl command as your user. You've already been told this extensively here Although in your defense you might've been thrown off by the # which usually means run something as root, which is an error in the wiki article, I'm going to fix that. However please try to learn from your exchanges on the boards and if running something as root doesn't work, try it as your user/finding a solution before opening another thread.

Offline

#3 2017-07-07 23:29:41

randomguy
Member
Registered: 2007-06-19
Posts: 101

Re: (SOLVED) How to automatically switch the sound?

FYI: This exact module made pulseaudio crash for me on my work laptop (Ubuntu) when I added it to ~/.config/pulse/default.pa. Didn't investigate any further though.

Offline

#4 2017-07-07 23:50:50

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,779

Re: (SOLVED) How to automatically switch the sound?

Define "added". If you have a default.pa in ~/.config/pulse/ it overrides the configuration in /etc/pulse/default.pa so if you create a file with only that line as its content pulse won't load any other modules. Correct location to make it persistent would either way be before the if..udev detect block in /etc/pulse/default.pa (or a relevant copy of said file to the home dir path)

Offline

#5 2017-07-08 09:07:10

Yashalta
Member
Registered: 2017-05-28
Posts: 49

Re: (SOLVED) How to automatically switch the sound?

V1del wrote:

Why are you running this as root?

Jeez! Thank you for the amendment.
But, if i run command as user it is also a problem.

i3 ~ $ pactl load-module module-switch-on-connect
Failure: Module initialization failed
i3 ~ $ 

Offline

#6 2017-07-08 17:27:28

randomguy
Member
Registered: 2007-06-19
Posts: 101

Re: (SOLVED) How to automatically switch the sound?

V1del wrote:

Define "added". If you have a default.pa in ~/.config/pulse/ it overrides the configuration in /etc/pulse/default.pa so if you create a file with only that line as its content pulse won't load any other modules.

Ha, you got me. I jumped to the conclusion that the user config is loaded in addition to the one in /etc.

Yashalta, "Failure: Module initialization failed" is also printed when the module was successfully loaded before. Check your journal, it should contain a more specific error message.

Offline

#7 2017-07-10 07:57:35

Yashalta
Member
Registered: 2017-05-28
Posts: 49

Re: (SOLVED) How to automatically switch the sound?

randomguy wrote:

Yashalta, "Failure: Module initialization failed" is also printed when the module was successfully loaded before. Check your journal, it should contain a more specific error message.

1. How to open a journal?
2. And journal need to open after entering the command # pactl load-module module-switch-on-connect in the terminal?

Offline

#8 2017-07-10 08:48:25

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,779

Re: (SOLVED) How to automatically switch the sound?

https://wiki.archlinux.org/index.php/Sy … he_journal

However I don't know if a module-load failure will be logged there. Best to verify, what is the output of

pacmd list-modules | grep 'switch'

Offline

#9 2017-07-10 16:35:40

Yashalta
Member
Registered: 2017-05-28
Posts: 49

Re: (SOLVED) How to automatically switch the sound?

V1del wrote:

https://wiki.archlinux.org/index.php/Sy … he_journal
However I don't know if a module-load failure will be logged there. Best to verify, what is the output of

pacmd list-modules | grep 'switch'

Thanks for link!

i3 ~ $ pacmd list-modules | grep 'switch'
	name: <module-switch-on-port-available>
	name: <module-switch-on-connect>
		module.description = "When a sink/source is added, switch to it or conditionally switch to it"
i3 ~ $ 

  command

i3 ~ $ sudo su
[root@PC i3]# pactl load-module module-switch-on-connect
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
[root@PC i3]# 

i3 ~ $ journalctl --user
-- Logs begin at Mon 2017-07-10 12:06:22 EEST, end at Mon 2017-07-10 19:23:32 EEST. --
Jul 10 12:06:22 PC systemd[393]: Stopping Accessibility services bus...
Jul 10 12:06:22 PC systemd[393]: Stopped target Default.
Jul 10 12:06:22 PC systemd[393]: Stopping Sound Service...
Jul 10 12:06:22 PC systemd[393]: Stopping D-Bus User Message Bus...
Jul 10 12:06:22 PC systemd[393]: Stopping Virtual filesystem service...
Jul 10 12:06:22 PC systemd[393]: Stopped D-Bus User Message Bus.
Jul 10 12:06:22 PC systemd[393]: Stopped Sound Service.
Jul 10 12:06:22 PC systemd[393]: Stopped Virtual filesystem service.
Jul 10 12:06:22 PC systemd[393]: Stopped Accessibility services bus.
Jul 10 12:06:22 PC systemd[393]: Stopped target Basic System.
Jul 10 12:06:22 PC systemd[393]: Stopped target Timers.
Jul 10 12:06:22 PC systemd[393]: Stopped target Paths.
Jul 10 12:06:22 PC systemd[393]: Stopped target Sockets.
Jul 10 12:06:22 PC systemd[393]: Closed GnuPG cryptographic agent and passphrase cache (access for web browsers).
Jul 10 12:06:22 PC systemd[393]: Closed GnuPG cryptographic agent and passphrase cache.
Jul 10 12:06:22 PC systemd[393]: Closed GnuPG network certificate management daemon.
Jul 10 12:06:22 PC systemd[393]: Closed GnuPG cryptographic agent and passphrase cache (restricted).
Jul 10 12:06:22 PC systemd[393]: Closed Sound System.
Jul 10 12:06:22 PC systemd[393]: Closed GnuPG cryptographic agent (ssh-agent emulation).
Jul 10 12:06:22 PC systemd[393]: Closed D-Bus User Message Bus Socket.
Jul 10 12:06:22 PC systemd[393]: Reached target Shutdown.
Jul 10 12:06:22 PC systemd[393]: Starting Exit the Session...
Jul 10 12:06:22 PC systemd[393]: Received SIGRTMIN+24 from PID 32656 (kill).
Jul 10 12:06:22 PC systemd[394]: pam_unix(systemd-user:session): session closed for user i3
-- Reboot --
Jul 10 19:07:33 PC systemd[394]: Listening on GnuPG cryptographic agent (ssh-agent emulation).
Jul 10 19:07:33 PC systemd[394]: Reached target Timers.
Jul 10 19:07:33 PC systemd[394]: Listening on GnuPG cryptographic agent and passphrase cache (access for web browsers).
Jul 10 19:07:33 PC systemd[394]: Listening on GnuPG cryptographic agent and passphrase cache (restricted).
Jul 10 19:07:33 PC systemd[394]: Starting D-Bus User Message Bus Socket.
Jul 10 19:07:33 PC systemd[394]: Listening on GnuPG network certificate management daemon.
Jul 10 19:07:33 PC systemd[394]: Reached target Paths.
Jul 10 19:07:33 PC systemd[394]: Listening on GnuPG cryptographic agent and passphrase cache.
Jul 10 19:07:33 PC systemd[394]: Listening on Sound System.
Jul 10 19:07:33 PC systemd[394]: Listening on D-Bus User Message Bus Socket.
Jul 10 19:07:33 PC systemd[394]: Reached target Sockets.
Jul 10 19:07:33 PC systemd[394]: Reached target Basic System.
Jul 10 19:07:33 PC systemd[394]: Reached target Default.
Jul 10 19:07:33 PC systemd[394]: Startup finished in 43ms.
Jul 10 19:07:33 PC systemd[394]: Started D-Bus User Message Bus.
Jul 10 19:07:33 PC dbus-daemon[417]: Successfully activated service 'org.freedesktop.systemd1'
Jul 10 19:07:33 PC dbus-daemon[417]: Activating service name='org.freedesktop.Notifications'
Jul 10 19:07:33 PC dbus-daemon[417]: Successfully activated service 'org.freedesktop.Notifications'
Jul 10 19:07:33 PC org.freedesktop.Notifications[417]: Name Lost. Is Another notification daemon running?
Jul 10 19:07:33 PC org.freedesktop.Notifications[417]: no dunstrc found -> skipping
Jul 10 19:07:34 PC dbus-daemon[417]: Activating via systemd: service name='org.gtk.vfs.Daemon' unit='gvfs-daemon.service'
Jul 10 19:07:34 PC systemd[394]: Starting Virtual filesystem service...
Jul 10 19:07:34 PC dbus-daemon[417]: Successfully activated service 'org.gtk.vfs.Daemon'
Jul 10 19:07:34 PC systemd[394]: Started Virtual filesystem service.
Jul 10 19:07:34 PC dbus-daemon[417]: Activating via systemd: service name='org.a11y.Bus' unit='at-spi-dbus-bus.service'
Jul 10 19:07:34 PC systemd[394]: Starting Accessibility services bus...
Jul 10 19:07:34 PC dbus-daemon[417]: Successfully activated service 'org.a11y.Bus'
Jul 10 19:07:34 PC systemd[394]: Started Accessibility services bus.
Jul 10 19:07:34 PC at-spi-bus-launcher[635]: Activating service name='org.a11y.atspi.Registry'
Jul 10 19:07:34 PC dbus-daemon[417]: Activating service name='org.xfce.Xfconf'
Jul 10 19:07:34 PC dbus-daemon[417]: Successfully activated service 'org.xfce.Xfconf'
Jul 10 19:07:34 PC at-spi-bus-launcher[635]: Successfully activated service 'org.a11y.atspi.Registry'
Jul 10 19:07:34 PC org.a11y.atspi.Registry[648]: SpiRegistry daemon is running with well-known name - org.a11y.atspi.Registry
Jul 10 19:07:34 PC pkexec[725]: pam_unix(polkit-1:session): session opened for user root by (uid=1000)
Jul 10 19:07:36 PC systemd[394]: Starting Sound Service...
Jul 10 19:07:36 PC systemd[394]: Started Sound Service.
Jul 10 19:23:31 PC dbus-daemon[417]: Activating via systemd: service name='org.gtk.vfs.UDisks2VolumeMonitor' unit='gvfs-udisks2-volume-monitor.
Jul 10 19:23:31 PC systemd[394]: Starting Virtual filesystem service - disk device monitor...
Jul 10 19:23:31 PC dbus-daemon[417]: Successfully activated service 'org.gtk.vfs.UDisks2VolumeMonitor'
Jul 10 19:23:31 PC systemd[394]: Started Virtual filesystem service - disk device monitor.
Jul 10 19:23:31 PC dbus-daemon[417]: Activating via systemd: service name='org.gtk.vfs.MTPVolumeMonitor' unit='gvfs-mtp-volume-monitor.service'
Jul 10 19:23:31 PC systemd[394]: Starting Virtual filesystem service - Media Transfer Protocol monitor...
Jul 10 19:23:31 PC dbus-daemon[417]: Successfully activated service 'org.gtk.vfs.MTPVolumeMonitor'
Jul 10 19:23:31 PC systemd[394]: Started Virtual filesystem service - Media Transfer Protocol monitor.
Jul 10 19:23:31 PC dbus-daemon[417]: Activating via systemd: service name='org.gtk.vfs.GPhoto2VolumeMonitor' unit='gvfs-gphoto2-volume-monitor.
Jul 10 19:23:31 PC systemd[394]: Starting Virtual filesystem service - digital camera monitor...
Jul 10 19:23:31 PC dbus-daemon[417]: Successfully activated service 'org.gtk.vfs.GPhoto2VolumeMonitor'
Jul 10 19:23:31 PC systemd[394]: Started Virtual filesystem service - digital camera monitor.
Jul 10 19:23:31 PC dbus-daemon[417]: Activating via systemd: service name='org.gtk.vfs.Metadata' unit='gvfs-metadata.service'
Jul 10 19:23:31 PC systemd[394]: Starting Virtual filesystem metadata service...
Jul 10 19:23:31 PC dbus-daemon[417]: Successfully activated service 'org.gtk.vfs.Metadata'
Jul 10 19:23:31 PC systemd[394]: Started Virtual filesystem metadata service.
Jul 10 19:23:32 PC dbus-daemon[417]: Activating service name='org.freedesktop.thumbnails.Thumbnailer1'
Jul 10 19:23:32 PC dbus-daemon[417]: Successfully activated service 'org.freedesktop.thumbnails.Thumbnailer1'
 ESCOD
Jul 10 19:23:31 PC systemd[394]: Starting Virtual filesystem service - disk device monitor...
Jul 10 19:23:31 PC dbus-daemon[417]: Successfully activated service 'org.gtk.vfs.UDisks2VolumeMonitor'
Jul 10 19:23:31 PC systemd[394]: Started Virtual filesystem service - disk device monitor.
Jul 10 19:23:31 PC dbus-daemon[417]: Activating via systemd: service name='org.gtk.vfs.MTPVolumeMonitor' unit='gvfs-mtp-volume-monitor.service'
Jul 10 19:23:31 PC systemd[394]: Starting Virtual filesystem service - Media Transfer Protocol monitor...
Jul 10 19:23:31 PC dbus-daemon[417]: Successfully activated service 'org.gtk.vfs.MTPVolumeMonitor'
Jul 10 19:23:31 PC systemd[394]: Started Virtual filesystem service - Media Transfer Protocol monitor.
Jul 10 19:23:31 PC dbus-daemon[417]: Activating via systemd: service name='org.gtk.vfs.GPhoto2VolumeMonitor' unit='gvfs-gphoto2-volume-monitor.
Jul 10 19:23:31 PC systemd[394]: Starting Virtual filesystem service - digital camera monitor...
Jul 10 19:23:31 PC dbus-daemon[417]: Successfully activated service 'org.gtk.vfs.GPhoto2VolumeMonitor'
Jul 10 19:23:31 PC systemd[394]: Started Virtual filesystem service - digital camera monitor.
Jul 10 19:23:31 PC dbus-daemon[417]: Activating via systemd: service name='org.gtk.vfs.Metadata' unit='gvfs-metadata.service'
Jul 10 19:23:31 PC systemd[394]: Starting Virtual filesystem metadata service...
Jul 10 19:23:31 PC dbus-daemon[417]: Successfully activated service 'org.gtk.vfs.Metadata'
Jul 10 19:23:31 PC systemd[394]: Started Virtual filesystem metadata service.
Jul 10 19:23:32 PC dbus-daemon[417]: Activating service name='org.freedesktop.thumbnails.Thumbnailer1'
Jul 10 19:23:32 PC dbus-daemon[417]: Successfully activated service 'org.freedesktop.thumbnails.Thumbnailer1'
 ESCOD
Jul 10 19:23:31 PC systemd[394]: Starting Virtual filesystem service - disk device monitor...
Jul 10 19:23:31 PC dbus-daemon[417]: Successfully activated service 'org.gtk.vfs.UDisks2VolumeMonitor'
Jul 10 19:23:31 PC systemd[394]: Started Virtual filesystem service - disk device monitor.
Jul 10 19:23:31 PC dbus-daemon[417]: Activating via systemd: service name='org.gtk.vfs.MTPVolumeMonitor' unit='gvfs-mtp-volume-monitor.service'
Jul 10 19:23:31 PC systemd[394]: Starting Virtual filesystem service - Media Transfer Protocol monitor...
Jul 10 19:23:31 PC dbus-daemon[417]: Successfully activated service 'org.gtk.vfs.MTPVolumeMonitor'
Jul 10 19:23:31 PC systemd[394]: Started Virtual filesystem service - Media Transfer Protocol monitor.
Jul 10 19:23:31 PC dbus-daemon[417]: Activating via systemd: service name='org.gtk.vfs.GPhoto2VolumeMonitor' unit='gvfs-gphoto2-volume-monitor.
Jul 10 19:23:31 PC systemd[394]: Starting Virtual filesystem service - digital camera monitor...
Jul 10 19:23:31 PC dbus-daemon[417]: Successfully activated service 'org.gtk.vfs.GPhoto2VolumeMonitor'
Jul 10 19:23:31 PC systemd[394]: Started Virtual filesystem service - digital camera monitor.
Jul 10 19:23:31 PC dbus-daemon[417]: Activating via systemd: service name='org.gtk.vfs.Metadata' unit='gvfs-metadata.service'
Jul 10 19:23:31 PC systemd[394]: Starting Virtual filesystem metadata service...
Jul 10 19:23:31 PC dbus-daemon[417]: Successfully activated service 'org.gtk.vfs.Metadata'
Jul 10 19:23:31 PC systemd[394]: Started Virtual filesystem metadata service.
Jul 10 19:23:32 PC dbus-daemon[417]: Activating service name='org.freedesktop.thumbnails.Thumbnailer1'
Jul 10 19:23:32 PC dbus-daemon[417]: Successfully activated service 'org.freedesktop.thumbnails.Thumbnailer1'
lines 64-80/80 (END)
 

 i3 ~ $ journalctl --user -u myunit.service
-- No entries --
i3 ~ $ 
 
i3 ~ $ journalctl --user --user-unit myunit.service
-- No entries --
i3 ~ $ 

Offline

#10 2017-07-10 17:05:37

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,779

Re: (SOLVED) How to automatically switch the sound?

Again, for the nth time DO NOT EVER run anything pulseaudio related as root it wont ever fix anything.  The fact that pacmd lists that module shows that it has been loaded, so it should be ready to go. Does it not work? What happens if you unplug/plug your headset? If it still doesn't switch, try to add

load-module module-switch-on-connect

before the if..udev-detect block in your /etc/pulse/default.pa instead of wherever you have added it now. And those journal invocations are obviously bogus, the service you want information on is unsurprisingly called pulseaudio and not "myunit".

Offline

#11 2017-07-10 17:15:07

tom.ty89
Member
Registered: 2012-11-15
Posts: 897

Re: (SOLVED) How to automatically switch the sound?

ugh sudo su...perhaps you want to know there's sudo -s and sudo -i?

But please just stop running pulseaudio or any of its utilities as root. Especially in your case you are trying to get more info from possible logs triggered by the module initialization failure.

In your case "myunit.servive" should pulseaudio.service.

Offline

#12 2017-07-10 19:13:20

Yashalta
Member
Registered: 2017-05-28
Posts: 49

Re: (SOLVED) How to automatically switch the sound?

tom.ty89 wrote:

ugh sudo su...perhaps you want to know there's sudo -s and sudo -i?

But please just stop running pulseaudio or any of its utilities as root. Especially in your case you are trying to get more info from possible logs triggered by the module initialization failure.

In your case "myunit.servive" should pulseaudio.service.

I probably do something wrong?!?

i3 ~ $ sudo systemctl status | grep pulseaudio
[sudo] password for i3: 
           │   │ ├─pulseaudio.service
           │   │ │ └─840 /usr/bin/pulseaudio --daemonize=no
           │     ├─29297 grep pulseaudio
i3 ~ $ sudo systemctl disable pulseaudio
Failed to disable unit: Unit file pulseaudio.service does not exist.
i3 ~ $ sudo systemctl disable pulseaudio.service
Failed to disable unit: Unit file pulseaudio.service does not exist.
i3 ~ $ sudo systemctl stop pulseaudio
Failed to stop pulseaudio.service: Unit pulseaudio.service not loaded.
i3 ~ $ sudo systemctl stop pulseaudio.service
Failed to stop pulseaudio.service: Unit pulseaudio.service not loaded.
i3 ~ $ 

Offline

#13 2017-07-10 20:13:39

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,779

Re: (SOLVED) How to automatically switch the sound?

Read the article I linked to, from top to bottom instead of just the paragraph. Pulseaudio is an user service it runs as your user you have to use systemctl --user . And the service is running that isn't the problem here. Please try to remain on topic, you learning about what user services are has nothing to do with the actual problem.

The module is loaded and should be working, what happens if you unplug and plug your headset now?

Offline

#14 2017-07-11 13:42:37

Yashalta
Member
Registered: 2017-05-28
Posts: 49

Re: (SOLVED) How to automatically switch the sound?

V1del wrote:

Read the article I linked to, from top to bottom instead of just the paragraph. Pulseaudio is an user service it runs as your user you have to use systemctl --user . And the service is running that isn't the problem here. Please try to remain on topic, you learning about what user services are has nothing to do with the actual problem.

I will read your link carefully, thank you!

V1del wrote:

The module is loaded and should be working, what happens if you unplug and plug your headset now?

Yes, it really works! I did not understand how it was fixed, but now it works! smile

Offline

#15 2017-07-11 13:52:35

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 21,779

Re: (SOLVED) How to automatically switch the sound?

One of your invocations of pactl (after you stopped doing them as root) was successful, you should've seen something like

i3 ~ $ pactl load-module module-switch-on-connect
20 #This number can differ, it tells you what index the module was loaded with

at least once. Afterwards, as randomguy pointed out, it will tell you that the load fails because the module was already loaded and it makes no sense to load it multiple times. If you want to make this persistent (so that you don't have to run pactl everytime) you can add

load-module module-switch-on-connect

to your /etc/pulse/default.pa

Offline

#16 2017-07-11 19:07:39

Yashalta
Member
Registered: 2017-05-28
Posts: 49

Re: (SOLVED) How to automatically switch the sound?

ok, thanks!

Offline

Board footer

Powered by FluxBB