Skip to content
Snippets Groups Projects
Commit 6763a956 authored by Jiří Kalvoda's avatar Jiří Kalvoda
Browse files

Wrappers: Exec: Set button and modifiers

parent 2cebdc6c
No related branches found
No related tags found
No related merge requests found
......@@ -40,8 +40,33 @@ abstract partial class StatusBar
if(section.Contains("_color"))
module = new WrapperColor(module, section.Mandatory("_color").AsColor());
if(section.Contains("_exec"))
module = new WrapperExec(module, section.Mandatory("_exec").AsString(), MouseButton.Left, 0);
foreach(var opt in section)
{
MouseButton? button = null;
Modifiers modifiers = 0;
if(opt.KeyAsValue().Tokens()[0] == "_exec")
{
opt.Use();
foreach(var t in opt.KeyAsValue().Tokens()[1..])
{
void setButton(MouseButton _button)
{
if(button != null)
throw new ConfigMistake(t, "Duplicit button definition.");
button = _button;
}
if(t=="left") setButton(MouseButton.Left); else
if(t=="right") setButton(MouseButton.Right); else
if(t=="middle") setButton(MouseButton.Middle); else
if(t=="ctrl" || t=="control") modifiers |= Modifiers.Control; else
if(t=="shift") modifiers |= Modifiers.Shift; else
if(t=="alt") modifiers |= Modifiers.Alt; else
if(t=="super" || t=="win" || t=="windows") modifiers |= Modifiers.Super; else
throw new ConfigMistake(t, $"No such modifiers or mouse key \"{t.AsString()}\".");
}
module = new WrapperExec(module, opt.AsString(), button ?? MouseButton.Left, modifiers);
}
}
module.Init(parrent, section);
return module;
......
......@@ -306,6 +306,11 @@ _default_color = red
# <color>
# Set color if module don't set any
#exec [KEY (left (default)/right/middle)] [MODIFIERS (shift/ctlr/alt/super) ...]
_exec right super shift = osdc "Super+Shift+Right pressed"
# <string>
# Command to run
# Parsers:
# ========
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment