[alsa-devel] Per-host .asoundrc on shared $HOME

Mark Hills mark at xwax.org
Tue Apr 23 22:41:27 CEST 2013


There is a very old thread [1] on alsa-user on this topic which seems to 
go through some yucky solutions. I have the same use case, and post some 
findings here.

Since pre-2003 alsa-lib calls wordexp(3) on the filenames. I am using the 
patch below in /usr/share/alsa/alsa.conf

It follows a precedent set by other files such as .Xdefaults-hostname.

I'd submit a patch, except there seems to be no guarantee that HOSTNAME is 
in the environment (on Slackware it is explicitly set in /etc/profile.) 
Without it I can only see a bash local variable.

>From the old thread I imagine this function (or at least this mail) would 
be useful to others.

Would it be better to patch the C code to provide a token (eg. '\h') that 
is substituted by the hostname? Or is it enough to assume that HOSTNAME 
would be set?

I didn't consider short vs. long hostnames, I suppose $HOSTNAME gives the 
user/admin some control over this.

This:

  ~/.asoundrc-$(hostname -s)

may work, but I don't see that forking a process is an option.

[1] http://thread.gmane.org/gmane.linux.alsa.user/27532/focus=27542

-- 
Mark


--- alsa.conf.orig	2013-04-23 21:22:45.105454493 +0100
+++ alsa.conf	2013-04-23 21:16:41.707053308 +0100
@@ -17,6 +17,7 @@
 			}
 			"/etc/asound.conf"
 			"~/.asoundrc"
+			"~/.asoundrc-$HOSTNAME"
 		]
 		errors false
 	}




More information about the Alsa-devel mailing list