<listitem>
<para>The relative path to sysfs subsystem specifying
the root directory of a soundcard device. Usually,
- it should be set to "/class/sound/controlC$cardinfo{card}/device".
+ it should be set to "/class/sound/card$cardinfo{card}/device".
</para>
</listitem>
</varlistentry>
<listitem>
<para>The relative path to sysfs subsystem specifying
the root directory of a soundcard device. Usually,
- it should be set to "/class/sound/controlC$cardinfo{card}/device".
+ it should be set to "/class/sound/card$cardinfo{card}/device".
</para>
</listitem>
</varlistentry>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>$config{<replaceable>key</replaceable>}</option>, <option>%g{<replaceable>key</replaceable>}</option></term>
+ <listitem>
+ <para>The value of a configuration variable. See CONFIG{} for more details.</para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>%%</option></term>
<listitem>
# See 'man alsactl_init' for syntax.
# set root device directory in sysfs for soundcard for ATTR{} command
-CONFIG{sysfs_device}="/class/sound/controlC$cardinfo{card}/device"
+CONFIG{sysfs_device}="/class/sound/card$cardinfo{card}/device"
+ACCESS!="$sysfsroot$config{sysfs_device}", \
+ CONFIG{sysfs_device}="/class/sound/controlC$cardinfo{card}/device"
# test for extra commands
ENV{CMD}=="help", INCLUDE="help", GOTO="00main_end"
SUBST_ATTR,
SUBST_SYSFSROOT,
SUBST_ENV,
+ SUBST_CONFIG,
};
static const struct subst_map {
char *name;
{ .name = "attr", .fmt = 's', .type = SUBST_ATTR },
{ .name = "sysfsroot", .fmt = 'r', .type = SUBST_SYSFSROOT },
{ .name = "env", .fmt = 'E', .type = SUBST_ENV },
+ { .name = "config", .fmt = 'g', .type = SUBST_CONFIG },
{ NULL, '\0', 0 }
};
enum subst_type type;
dbg("substitute env '%s=%s'", attr, pos);
strlcat(string, pos, maxsize);
break;
+ case SUBST_CONFIG:
+ if (attr == NULL) {
+ dbg("missing attribute");
+ break;
+ }
+ pair = value_find(space, attr);
+ if (pair == NULL)
+ break;
+ strlcat(string, pair->value, maxsize);
+ break;
default:
Perror(space, "unknown substitution type=%i", type);
break;
}
if (strncasecmp(key, "ACCESS", 6) == 0) {
if (op == KEY_OP_MATCH || op == KEY_OP_NOMATCH) {
+ if (value[0] == '$') {
+ strlcpy(string, value, sizeof(string));
+ apply_format(space, string, sizeof(string));
+ if (string[0] == '/')
+ goto __access1;
+ }
if (value[0] != '/') {
strlcpy(string, space->rootdir, sizeof(string));
strlcat(string, "/", sizeof(string));
strlcat(string, value, sizeof(string));
} else {
- strlcat(string, value, sizeof(string));
+ strlcpy(string, value, sizeof(string));
}
+ apply_format(space, string, sizeof(string));
+ __access1:
count = access(string, F_OK);
- dbg("access(%s) = %i", value, count);
+ dbg("access(%s) = %i (%s)", string, count, value);
if (op == KEY_OP_MATCH && count != 0)
break;
if (op == KEY_OP_NOMATCH && count == 0)