@@ -296,4 +296,6 @@ For information on the `Script` type, and embedding scripts in strings, see [her
|
|||||||
| `on_click_right` | `Script [oneshot]` | `null` | Runs the script when the module is right clicked. |
|
| `on_click_right` | `Script [oneshot]` | `null` | Runs the script when the module is right clicked. |
|
||||||
| `on_scroll_up` | `Script [oneshot]` | `null` | Runs the script when the module is scroll up on. |
|
| `on_scroll_up` | `Script [oneshot]` | `null` | Runs the script when the module is scroll up on. |
|
||||||
| `on_scroll_down` | `Script [oneshot]` | `null` | Runs the script when the module is scrolled down on. |
|
| `on_scroll_down` | `Script [oneshot]` | `null` | Runs the script when the module is scrolled down on. |
|
||||||
|
| `on_mouse_enter` | `Script [oneshot]` | `null` | Runs the script when the module is hovered over. |
|
||||||
|
| `on_mouse_exit` | `Script [oneshot]` | `null` | Runs the script when the module is no longer hovered over. |
|
||||||
| `tooltip` | `string` | `null` | Shows this text on hover. Supports embedding scripts between `{{double braces}}`. |
|
| `tooltip` | `string` | `null` | Shows this text on hover. Supports embedding scripts between `{{double braces}}`. |
|
||||||
|
|||||||
40
src/bar.rs
40
src/bar.rs
@@ -397,12 +397,7 @@ fn setup_module_common_options(container: EventBox, common: CommonConfig) {
|
|||||||
|
|
||||||
if let Some(script) = script {
|
if let Some(script) = script {
|
||||||
trace!("Running on-click script: {}", event.button());
|
trace!("Running on-click script: {}", event.button());
|
||||||
|
run_script(script);
|
||||||
match await_sync(async { script.get_output().await }) {
|
|
||||||
Ok((OutputStream::Stderr(out), _)) => error!("{out}"),
|
|
||||||
Err(err) => error!("{err:?}"),
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Inhibit(false)
|
Inhibit(false)
|
||||||
@@ -420,12 +415,27 @@ fn setup_module_common_options(container: EventBox, common: CommonConfig) {
|
|||||||
|
|
||||||
if let Some(script) = script {
|
if let Some(script) = script {
|
||||||
trace!("Running on-scroll script: {}", event.direction());
|
trace!("Running on-scroll script: {}", event.direction());
|
||||||
|
run_script(script);
|
||||||
match await_sync(async { script.get_output().await }) {
|
|
||||||
Ok((OutputStream::Stderr(out), _)) => error!("{out}"),
|
|
||||||
Err(err) => error!("{err:?}"),
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Inhibit(false)
|
||||||
|
});
|
||||||
|
|
||||||
|
let mouse_enter_script = common.on_mouse_enter.map(Script::new_polling);
|
||||||
|
container.connect_enter_notify_event(move |_, _| {
|
||||||
|
if let Some(ref script) = mouse_enter_script {
|
||||||
|
trace!("Running enter script");
|
||||||
|
run_script(script);
|
||||||
|
}
|
||||||
|
|
||||||
|
Inhibit(false)
|
||||||
|
});
|
||||||
|
|
||||||
|
let mouse_exit_script = common.on_mouse_exit.map(Script::new_polling);
|
||||||
|
container.connect_leave_notify_event(move |_, _| {
|
||||||
|
if let Some(ref script) = mouse_exit_script {
|
||||||
|
trace!("Running exit script");
|
||||||
|
run_script(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
Inhibit(false)
|
Inhibit(false)
|
||||||
@@ -438,3 +448,11 @@ fn setup_module_common_options(container: EventBox, common: CommonConfig) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn run_script(script: &Script) {
|
||||||
|
match await_sync(async { script.get_output().await }) {
|
||||||
|
Ok((OutputStream::Stderr(out), _)) => error!("{out}"),
|
||||||
|
Err(err) => error!("{err:?}"),
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ pub struct CommonConfig {
|
|||||||
pub on_click_middle: Option<ScriptInput>,
|
pub on_click_middle: Option<ScriptInput>,
|
||||||
pub on_scroll_up: Option<ScriptInput>,
|
pub on_scroll_up: Option<ScriptInput>,
|
||||||
pub on_scroll_down: Option<ScriptInput>,
|
pub on_scroll_down: Option<ScriptInput>,
|
||||||
|
pub on_mouse_enter: Option<ScriptInput>,
|
||||||
|
pub on_mouse_exit: Option<ScriptInput>,
|
||||||
|
|
||||||
pub tooltip: Option<String>,
|
pub tooltip: Option<String>,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user