battery
This commit is contained in:
44
dim_plugins/battery/src/lib.rs
Normal file
44
dim_plugins/battery/src/lib.rs
Normal file
@@ -0,0 +1,44 @@
|
||||
use std::fmt::Write;
|
||||
use dim_sdk::{plugin_info, DimPlugin};
|
||||
use std::fs::read_to_string;
|
||||
|
||||
plugin_info!(
|
||||
Plug, // Your main global structs name that implements `DimPlugin`
|
||||
"battery", // Plugin name
|
||||
"0.0.0", // Plugin Version (leave empty for none)
|
||||
"GPLv3" // Plugin license (leave empty for none)
|
||||
);
|
||||
|
||||
struct Plug {
|
||||
}
|
||||
|
||||
impl Plug {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl DimPlugin for Plug {
|
||||
fn init(&mut self) {
|
||||
}
|
||||
fn poll(&mut self, f: &mut dim_sdk::CBuffer) -> dim_sdk::Result<()> {
|
||||
let contents = read_to_string("/home/xomf/battery_test")?;
|
||||
let cleaned_contents: String = contents.chars().filter(|c| c.is_digit(10)).collect();
|
||||
|
||||
write!(f, "Battery: {}%", cleaned_contents)?;
|
||||
Ok(())
|
||||
}
|
||||
fn pre_reload(&mut self) {
|
||||
}
|
||||
fn post_reload(&mut self) {
|
||||
|
||||
}
|
||||
fn free(&mut self) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user