# Something like udev for regular users?

## Geralt

Hi,

I want to run some scripts under my regular user when I attach/detach some devices (currently they're all usb soundcards and I want to switch the default soundcard). For a system-wide policy udev and its rules would be the perfect tool, however I'm wondering if I can accomplish something like that on a per-user basis. Do you know if it's possible to run udev (or something like udev) as a non-root user to do that?

I don't think it's a permission problem because I'm allowed to run "udevadm monitor --environment" as a non-root user.

Thanks,

Geralt.

----------

## irbanur

You could map the soundcards to the group "audio" and then add your user(s) to that group:

http://reactivated.net/writing_udev_rules.html#ownership

----------

## VoidMage

Pulseaudio handles that by combination of udev ACL rules and consolekit.

----------

## Geralt

 *VoidMage wrote:*   

> Pulseaudio handles that by combination of udev ACL rules and consolekit.

 

Sounds promising, can you elaborate?

----------

## VoidMage

It's 70-acl.rules on udev side and consolekit part is usually handled

by a part of your desktop environment (if not, it may require a bit of tinkering).

As for pulseaudio, preferred (by upstream) mode of working is user daemon,

but actual configuration may require more work - the topic is broad

and there's an well established group of pulseaudio haters (personally, I'm indifferent).

----------

## Geralt

Now I'm unsure if you misunderstand my problem. It's not that I can't access my soundcards, that works just fine. What I want is to automatically switch the default soundcard in pulseaudio (as you said it runs as a user daemon) when I attach/detach one of my usb soundcards. This is currently not possible within pulseaudio itself, therefore I was looking for a way to do it myself. And I was thinking that something like udev (that listens for changes in my hardware configuration) would be suited to the job, that would listen for my soundcards and when one is (un-)plugged execute a shellscript (like udev can do), i.e. I don't want to manage the device nodes, all I want to do is to monitor the devices and execute a shell script.

Thanks,

Geralt.

----------

