mirror of
https://github.com/ErikReider/SwayNotificationCenter.git
synced 2024-09-11 15:56:04 +03:00
slider: expand cmd with predefined pattern
This commit is contained in:
parent
f454780453
commit
dc08f11f8b
@ -76,12 +76,23 @@ namespace SwayNotificationCenter.Widgets {
|
||||
show_all ();
|
||||
}
|
||||
|
||||
public string expand_cmd (string cmd, string regex, string value) {
|
||||
try {
|
||||
Regex _regx = new Regex (Regex.escape_string (regex));
|
||||
return _regx.replace_literal (cmd, -1, 0, value);
|
||||
} catch (Error e) {
|
||||
warning ("failed to expand cmd: %s\n", e.message);
|
||||
return cmd;
|
||||
}
|
||||
}
|
||||
|
||||
public async void queue_set (double value) {
|
||||
if (cmd_ing)
|
||||
return;
|
||||
|
||||
cmd_ing = true;
|
||||
yield Functions.execute_command (cmd_setter + " " + value.to_string (), {}, null);
|
||||
var cmd = expand_cmd (cmd_setter, "$value", value.to_string ());
|
||||
yield Functions.execute_command (cmd, {}, null);
|
||||
|
||||
cmd_ing = false;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user