mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-01 18:51:04 +02:00
refactor: swap out some code for existing macros
This commit is contained in:
parent
ad97550583
commit
012762e102
5 changed files with 41 additions and 54 deletions
|
@ -1,9 +1,8 @@
|
|||
use crate::clients::music::{self, MusicClient, PlayerState, PlayerUpdate, Status, Track};
|
||||
use crate::config::CommonConfig;
|
||||
use crate::error::ERR_CHANNEL_SEND;
|
||||
use crate::modules::{Module, ModuleInfo, ModuleUpdateEvent, ModuleWidget, WidgetContext};
|
||||
use crate::popup::Popup;
|
||||
use crate::try_send;
|
||||
use crate::{send_async, try_send};
|
||||
use color_eyre::Result;
|
||||
use dirs::{audio_dir, home_dir};
|
||||
use glib::Continue;
|
||||
|
@ -202,14 +201,9 @@ impl Module<Button> for MusicModule {
|
|||
display_string,
|
||||
};
|
||||
|
||||
tx.send(ModuleUpdateEvent::Update(Some(update)))
|
||||
.await
|
||||
.expect(ERR_CHANNEL_SEND);
|
||||
send_async!(tx, ModuleUpdateEvent::Update(Some(update)));
|
||||
}
|
||||
None => tx
|
||||
.send(ModuleUpdateEvent::Update(None))
|
||||
.await
|
||||
.expect(ERR_CHANNEL_SEND),
|
||||
None => send_async!(tx, ModuleUpdateEvent::Update(None)),
|
||||
},
|
||||
PlayerUpdate::Disconnect => break,
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ use serde::Deserialize;
|
|||
use tokio::spawn;
|
||||
use tokio::sync::mpsc::{Receiver, Sender};
|
||||
use tracing::error;
|
||||
use crate::try_send;
|
||||
|
||||
#[derive(Debug, Deserialize, Clone)]
|
||||
pub struct ScriptModule {
|
||||
|
@ -63,8 +64,8 @@ impl Module<Label> for ScriptModule {
|
|||
spawn(async move {
|
||||
script.run(move |(out, _)| match out {
|
||||
OutputStream::Stdout(stdout) => {
|
||||
tx.try_send(ModuleUpdateEvent::Update(stdout))
|
||||
.expect("Failed to send stdout"); }
|
||||
try_send!(tx, ModuleUpdateEvent::Update(stdout));
|
||||
},
|
||||
OutputStream::Stderr(stderr) => {
|
||||
error!("{:?}", Report::msg(stderr)
|
||||
.wrap_err("Watched script error:")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue