Commit graph

7 commits

Author SHA1 Message Date
Jaroslav Kysela
15970ebf7f ucm: add support for ControlEnum in ControlExists condition
Condition {
  Type ControlExists
  Control "name='Capture Input'"
  ControlEnum "Headphone Mic"
}

The result is true if the control exists, it is the enumerated
type and has the item with the ControlEnum text (name).

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-29 09:34:09 +01:00
Jaroslav Kysela
6eb4f8a724 ucm: conditions - fix the wrong string/substring match
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-28 19:54:52 +01:00
Jaroslav Kysela
a0b00a954e ucm: add possibility to keep order of childs for If blocks
Because of the nature of the structured parser, it is not guaranteed
that the order of the parsed tree is equal to the lines in the source.

Add possibility to insert the If results before or after the selected
identifier like:

SectionDevice."Speaker" {
  ...
}

If.1 {
	Condition { ... }
	Before.SectionDevice "Speaker"
	True { ... }
}
If.2 {
	Condition { ... }
	After.SectionDevice "Speaker"
	True { ... }
}

If the "After" or "Before" identifiers are not found, the result is added
after the last entry in the block.

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 17:21:20 +01:00
Jaroslav Kysela
1b14643384 ucm: add If.Condition.RegexMatch
If.1 {
	Condition {
		Type RegexMatch
		String "something to match"
		Regex ".*(thing)"
	}
	...
}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
7ccaa08693 ucm: evaluate nested If blocks also in True/False blocks
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
b7d74c6977 ucm: add If.Condition.String to match strings and substrings
Case insensitive string match:

If.1 {
	Condition {
		Type String
		String1 "aa"
		String2 "bb"
	}
	True {
		...
	}
}

Substring is present (case sensitive):

If.1 {
	Condition {
		Type String
		Haystack "White Horse"
		Needle "Horse"
	}
	True {
		...
	}
}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:40 +01:00
Jaroslav Kysela
8a36e38dc4 ucm: add If condition block
The syntax is simple:

If./any-if-identificator/ {
  Condition {
    Type /type_here/
    /optional defines/
  }
  True {
    /block used when condition is evaluated as true/
  }
  False {
    /block used when condition is evaluated as false/
  }
}

The Type "ControlExists" is implemented:

Condition {
  Type ControlExists
  Device "hw:${CardId}"
  Control "iface=CARD,name='Headphone Jack'"
}

Signed-off-by: Jaroslav Kysela <perex@perex.cz>
2019-11-14 15:00:37 +01:00