You are not logged in.

#1 2015-03-10 09:51:55

zabrielza
Member
Registered: 2015-03-02
Posts: 125

Trying to disable a Udev rule. Deleting it is not working.

I am trying to configure my sound. I have a usb sound card I want it to be default.

I followed the procedure as described here .

So, my default soundcard was my usb soundcard!

But, did this,

Hot-plugging a USB sound card
The following udev rule can be used to automatically make a USB sound card the primary output device when the card is plugged in. To do so, create the following file with the specified contents and.
/etc/udev/rules.d/00-local.rules
KERNEL=="pcmC[D0-9cp]*", ACTION=="add", PROGRAM="/usr/bin/sh -c 'K=%k; K=$${K#pcmC}; K=$${K%%D*}; echo defaults.ctl.card $$K > /etc/asound.conf; echo defaults.pcm.card $$K >>/etc/asound.conf'"
KERNEL=="pcmC[D0-9cp]*", ACTION=="remove", PROGRAM="/usr/bin/sh -c 'echo defaults.ctl.card 0 > /etc/asound.conf; echo defaults.pcm.card 0 >>/etc/asound.conf'"
For information regarding loading udev rules see the following: Udev#Loading_new_rules

But it was a mistake.. So, I wanted to correct this. I deleted this file.

rm -rf /etc/udev/rules.d/00-local.rules

after that, as mentioned here

udevadm control --reload
udevadm trigger

After reboot, I was having again the file

/etc/asound.conf

which is created after the rule is triggered.

So, what can i Do ?

Offline

#2 2015-03-10 19:17:16

mychris
Member
From: Munich
Registered: 2012-09-15
Posts: 68

Re: Trying to disable a Udev rule. Deleting it is not working.

What do you mean by "again"?
Did you delete the file (/etc/asound.conf), rebooted and then it has been created or again?

Offline

#3 2015-03-11 04:07:40

frank604
Member
From: BC, Canada
Registered: 2011-04-20
Posts: 1,212

Re: Trying to disable a Udev rule. Deleting it is not working.

That udev rule doesn't delete /etc/asound.conf so just deleting the udev rule will still have whatever modified /etc/asound.conf still there.  /etc/asound.conf is there by default when you install alsa.  That file contains what devices to use for audio output so that udev rule was just modifying /etc/asound.conf to automatically set usb audio as default when a usb audio device gets plugged in.

Is there still an issue?

Offline

#4 2015-03-14 16:21:00

zabrielza
Member
Registered: 2015-03-02
Posts: 125

Re: Trying to disable a Udev rule. Deleting it is not working.

mychris wrote:

What do you mean by "again"?
Did you delete the file (/etc/asound.conf), rebooted and then it has been created or again?

Very sorry for my late reply. Firstly, when i started configuring sound asound.conf did not exist. I configured correctly my usb soundcard to be default and after that i created the rule. After reboot,

asound.conf

was created and usb sound card was not default soundcard. I deleted the rule file as described before and i deleted the asound.conf file. All my configuration I had done was at file

/etc/modprobe.d/alsa-base.conf
options snd_usb_audio index=0 nrpacks=1
options snd_hda_intel index=1

So, now I have this file as before and my usb soundcard is not my default.

frank604 wrote:

That udev rule doesn't delete /etc/asound.conf so just deleting the udev rule will still have whatever modified /etc/asound.conf still there.  /etc/asound.conf is there by default when you install alsa.  That file contains what devices to use for audio output so that udev rule was just modifying /etc/asound.conf to automatically set usb audio as default when a usb audio device gets plugged in.

Is there still an issue?

Yes, still an issue! How can i disable a udev rule? Apparently deleting the file is not the proper way, right? On my fresh install of arch linux /etc/asound.conf did not exist as i mentioned above. Can you guide me to the right direction to solve my problem?

Offline

#5 2015-03-16 06:02:22

zabrielza
Member
Registered: 2015-03-02
Posts: 125

Re: Trying to disable a Udev rule. Deleting it is not working.

Ok, right now i have this issue. When i Have unplugged the usb soundcard my default soundcard is my hdmi port of HDA-intel:

0 [HDMI    ]: HDA-Intel - HDA ATI HDMI
                       HDA ATI HDMI at 0xfdffc000 irq 27
1 [SB         ]: HDA-Intel - HDA ATI SB
                       HDA ATI SB at 0xfe024000 irq 16

I have deleted

/etc/modprobe.d/alsa-base.conf

. So, when i plug in my usb soundcard nothing changes. But after reboot my usb soundcard is my default. When another reboot takes place then the usb soundcard is gone again.

Question: Do you think that this is a udev issue or alsa configuration? How can I understand how to fix that?

Offline

#6 2015-03-16 13:10:38

Alad
Wiki Admin/IRC Op
From: Bagelstan
Registered: 2014-05-04
Posts: 2,413
Website

Re: Trying to disable a Udev rule. Deleting it is not working.

Hot-plugging a USB sound card
The following udev rule can be used to automatically make a USB sound card the primary output device when the card is plugged in. To do so, create the following file with the specified contents and.
/etc/udev/rules.d/00-local.rules
KERNEL=="pcmC[D0-9cp]*", ACTION=="add", PROGRAM="/usr/bin/sh -c 'K=%k; K=$${K#pcmC}; K=$${K%%D*}; echo defaults.ctl.card $$K > /etc/asound.conf; echo defaults.pcm.card $$K >>/etc/asound.conf'"
KERNEL=="pcmC[D0-9cp]*", ACTION=="remove", PROGRAM="/usr/bin/sh -c 'echo defaults.ctl.card 0 > /etc/asound.conf; echo defaults.pcm.card 0 >>/etc/asound.conf'"
For information regarding loading udev rules see the following: Udev#Loading_new_rules

This is horrid. Truly horrid.

You've already deleted the udev rule; if the previous ALSA configuration is still restored, it may be done so by systemd: https://wiki.archlinux.org/index.php/Ad … nd_Systemd


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby

Offline

#7 2015-03-16 13:15:18

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

Re: Trying to disable a Udev rule. Deleting it is not working.

Your alsa-base.conf should remain, it's what defines the card order at boot, otherwise it's going to be random. If the /etc/asound.conf returns it might be beneficial to post its contents to verify if it still contains the stuff the udev rule adds into it or if there is something else now

Last edited by V1del (2015-03-16 13:19:32)

Offline

#8 2015-03-16 16:04:35

zabrielza
Member
Registered: 2015-03-02
Posts: 125

Re: Trying to disable a Udev rule. Deleting it is not working.

Alad wrote:

Hot-plugging a USB sound card
The following udev rule can be used to automatically make a USB sound card the primary output device when the card is plugged in. To do so, create the following file with the specified contents and.
/etc/udev/rules.d/00-local.rules
KERNEL=="pcmC[D0-9cp]*", ACTION=="add", PROGRAM="/usr/bin/sh -c 'K=%k; K=$${K#pcmC}; K=$${K%%D*}; echo defaults.ctl.card $$K > /etc/asound.conf; echo defaults.pcm.card $$K >>/etc/asound.conf'"
KERNEL=="pcmC[D0-9cp]*", ACTION=="remove", PROGRAM="/usr/bin/sh -c 'echo defaults.ctl.card 0 > /etc/asound.conf; echo defaults.pcm.card 0 >>/etc/asound.conf'"
For information regarding loading udev rules see the following: Udev#Loading_new_rules

This is horrid. Truly horrid.

You've already deleted the udev rule; if the previous ALSA configuration is still restored, it may be done so by systemd: https://wiki.archlinux.org/index.php/Ad … nd_Systemd


Yes I 've already deleted the udev rule. Was that wrong? What should I do instead?
About the alsa configuration what do you mean if is still restored ? The output of the

cat /var/lib/alsa/asound.state 

command is too long. Where should i Look in there?

Offline

#9 2015-03-16 16:07:15

zabrielza
Member
Registered: 2015-03-02
Posts: 125

Re: Trying to disable a Udev rule. Deleting it is not working.

V1del wrote:

Your alsa-base.conf should remain, it's what defines the card order at boot, otherwise it's going to be random. If the /etc/asound.conf returns it might be beneficial to post its contents to verify if it still contains the stuff the udev rule adds into it or if there is something else now

Ok,

 /etc/modprobe.d/alsa-base.conf

will remain.

/etc/asound.conf

does not return. Is it possible to know if it's a rule problem or wrong alsa-configuration?

Offline

#10 2015-03-16 16:25:20

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

Re: Trying to disable a Udev rule. Deleting it is not working.

if the asound.conf doesn't return, the rule is out of the question because it's all it does.  I doubt that ALSA state contains any information on which card is the default or isn't, so leave that out for now. And right now I don't really know what your problem is anymore. Does it work now? Maybe you'll have to unmute some mixers in alsamixer if you don't hear any sound

Last edited by V1del (2015-03-16 16:26:23)

Offline

#11 2015-03-16 18:45:12

MoonSwan
Member
From: Great White North
Registered: 2008-01-23
Posts: 881

Re: Trying to disable a Udev rule. Deleting it is not working.

I may be mis-understanding your problem, zabrielza, so please correct me if I am off base here.

You have 2 soundcards, yes?  One is a HDA Intel on-board and the other is your USB card.  You want the USB card to be the default all the time, correct?  If that is true then I suggest using this little part of the Alsa Wiki article to set your default card: https://wiki.archlinux.org/index.php/Ad … sound_card  I have used that part of the wiki successfully to set my default card, as I also have two sound cards, and I've had few issues since then. 

As I said when I began this post, I may be wrong here so please say so if I am.  You might also want to start over and re-state exactly what your goal is because I see some posters are confused about what it is you're trying to accomplish.

Offline

#12 2015-03-16 19:18:28

zabrielza
Member
Registered: 2015-03-02
Posts: 125

Re: Trying to disable a Udev rule. Deleting it is not working.

V1del wrote:

if the asound.conf doesn't return, the rule is out of the question because it's all it does.  I doubt that ALSA state contains any information on which card is the default or isn't, so leave that out for now. And right now I don't really know what your problem is anymore. Does it work now? Maybe you'll have to unmute some mixers in alsamixer if you don't hear any sound


My problem is what I wrote above:

. So, when i plug in my usb soundcard nothing changes. But after reboot my usb soundcard is my default. When another reboot takes place then the usb soundcard is gone again.

I do not have this file

 /etc/asound.conf

so as you say the udev rule is not active. ( I would like to know if deleting a udev rule is the right way to cancel-disable it) Does this mean that my problem is alsa configuration?

Offline

#13 2015-03-16 19:35:05

zabrielza
Member
Registered: 2015-03-02
Posts: 125

Re: Trying to disable a Udev rule. Deleting it is not working.

MoonSwan wrote:

I may be mis-understanding your problem, zabrielza, so please correct me if I am off base here.

You have 2 soundcards, yes?  One is a HDA Intel on-board and the other is your USB card.  You want the USB card to be the default all the time, correct?  If that is true then I suggest using this little part of the Alsa Wiki article to set your default card: https://wiki.archlinux.org/index.php/Ad … sound_card  I have used that part of the wiki successfully to set my default card, as I also have two sound cards, and I've had few issues since then. 

As I said when I began this post, I may be wrong here so please say so if I am.  You might also want to start over and re-state exactly what your goal is because I see some posters are confused about what it is you're trying to accomplish.

Yes you are right. You described my situation perfectly.  Firstly I started this topic to learn/know How should i disable correctly udev rules. It turns out that my udev rule is disabled. I have this file

 /etc/modprobe.d/alsa-base.conf

configured correctly. Before I create the rule I had sound correctly but I never followed this.

Select the default PCM via environment variable

In your configuration file, preferably global, add:

pcm.!default {
    type plug
    slave.pcm {
        @func getenv
        vars [ ALSAPCM ]
        default "hw:Audigy2"
    }
}

You need to replace the default line with the name of your card (in the example is Audigy2). You can get the names with aplay -l or you can also use PCMs like surround51. But if you need to use the microphone it is a good idea to select full-duplex PCM as default.

Now you can start programs selecting the sound card just changing the environment variable ALSAPCM. It works fine for all program that do not allow to select the card, for the others ensure you keep the default card. For example, assuming you wrote a downmix PCM called mix51to20 you can use it with mplayer using the commandline ALSAPCM=mix51to20 mplayer example_6_channel.wav

Instead of using new variables, you could set one of those mentioned in default global configuration.

/usr/share/alsa/alsa.conf

Variable name # Definition
ALSA_CARD # pcm.default pcm.hw pcm.plughw ctl.sysdefault ctl.hw rawmidi.default rawmidi.hw hwdep.hw
ALSA_CTL_CARD # ctl.sysdefault ctl.hw
ALSA_HWDEP_CARD # hwdep.default hwdep.hw
ALSA_HWDEP_DEVICE # hwdep.default hwdep.hw
ALSA_PCM_CARD # pcm.default pcm.hw pcm.plughw
ALSA_PCM_DEVICE # pcm.hw pcm.plughw
ALSA_RAWMIDI_CARD # rawmidi.default rawmidi.hw
ALSA_RAWMIDI_DEVICE # rawmidi.default rawmidi.hw

Note: Pay attention to default addressing type.

So, Should I try it now? Do I have to reset alsa-installation first ( I do not know how to do this ) or not?

Offline

#14 2015-03-16 19:46:39

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: Trying to disable a Udev rule. Deleting it is not working.

Just follow the steps in the link MoonSwan posted and stop spamming the thread with question about what you should try: try it first, see what happens, if it doesn't work, investigate and recheck against the wiki.

This has nothing to do with disabling or deleting a udev rule.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#15 2015-03-16 21:38:20

zabrielza
Member
Registered: 2015-03-02
Posts: 125

Re: Trying to disable a Udev rule. Deleting it is not working.

jasonwryan wrote:

Just follow the steps in the link MoonSwan posted and stop spamming the thread with question about what you should try: try it first, see what happens, if it doesn't work, investigate and recheck against the wiki.

This has nothing to do with disabling or deleting a udev rule.

Well, I tried MoonSwan's suggestion. I had already created the

/etc/modprobe.d/alsa-base.conf

. So, I tried several things. I added to this file this:

pcm.!default {
    type plug
    slave.pcm {
        @func getenv
        vars [ ALSAPCM ]
        default "hw:CODEC"
    }
}

After reboot snd-usb-audio was not there.

cat /proc/asound/modules
0 snd_hda_intel
1 snd_hda_intel

After that I tried creating

/etc/asound.conf

with the following content

pcm.!default {
    type hw
    card Audio
}

ctl.!default {
    type hw
    card Audio
}

And also I removed /etc/modprobe.d/alsa-base.conf. So, After 1 reboot Usb sound card was default. YEAH. BUT at the second reboot again, snd-usb-audio module is not started.

After that I recreated /etc/modprobe.d/alsa-base.conf . After reboot snd-usb-audio is not started.

As you can See I have tried several things. Any suggestion?

Offline

Board footer

Powered by FluxBB