1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-07-01 02:31:04 +02:00

feat: module hover options

Resolves #70.
This commit is contained in:
Jake Stanger 2023-04-01 13:29:40 +01:00
parent 80a414ab67
commit 102d2478a9
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
3 changed files with 33 additions and 11 deletions

View file

@ -397,12 +397,7 @@ fn setup_module_common_options(container: EventBox, common: CommonConfig) {
if let Some(script) = script {
trace!("Running on-click script: {}", event.button());
match await_sync(async { script.get_output().await }) {
Ok((OutputStream::Stderr(out), _)) => error!("{out}"),
Err(err) => error!("{err:?}"),
_ => {}
}
run_script(script);
}
Inhibit(false)
@ -420,12 +415,27 @@ fn setup_module_common_options(container: EventBox, common: CommonConfig) {
if let Some(script) = script {
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)
@ -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:?}"),
_ => {}
}
}