Experimental command socket support

Introduces "start-or-kill" and "toggle-visible" commands. How the
command socket is used will likely change soon.
This commit is contained in:
Kenny Levinsen
2019-08-27 15:09:19 +02:00
parent 1cadf43d49
commit 6deffa91bb
6 changed files with 169 additions and 59 deletions
+3 -2
View File
@@ -2,6 +2,7 @@ use crate::buffer::Buffer;
use crate::color::Color;
use crate::draw::{draw_bar, draw_box, Font, ROBOTO_REGULAR};
use crate::modules::module::{Input, ModuleImpl};
use crate::cmd::Cmd;
use std::sync::mpsc::Sender;
use std::sync::{Arc, Mutex};
@@ -129,7 +130,7 @@ impl UpowerBattery {
})
}
pub fn new(listener: Sender<bool>) -> Result<Self, ::std::io::Error> {
pub fn new(listener: Sender<Cmd>) -> Result<Self, ::std::io::Error> {
let d = UpowerBattery::from_device("BAT0")?;
let path = d.device_path.clone();
let inner = d.inner.clone();
@@ -175,7 +176,7 @@ impl UpowerBattery {
inner.state = state;
inner.capacity = capacity;
inner.dirty = true;
listener.send(true).unwrap();
listener.send(Cmd::Draw).unwrap();
}
}
});