added 2 plugins

This commit is contained in:
2024-06-16 11:53:43 -04:00
parent f55279b7ef
commit ca71830262
10 changed files with 346 additions and 5 deletions

View File

@@ -0,0 +1,13 @@
[package]
name = "clock"
version = "0.1.0"
edition = "2021"
[lib]
crate-type=["cdylib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
chrono = "0.4.38"
dim_sdk = {path="../../sdk/rust/"}
lazy_static = "1.4.0"

View File

@@ -0,0 +1,15 @@
# Must match package name in Cargo.toml
PLUGIN_NAME=clock
build: $(PLUGIN_DIR)/$(PLUGIN_NAME).dim
$(PLUGIN_DIR)/$(PLUGIN_NAME).dim: $(OBJECT_DIR)/$(PLUGIN_NAME)/debug/lib$(PLUGIN_NAME).so
cp $(OBJECT_DIR)/$(PLUGIN_NAME)/debug/lib$(PLUGIN_NAME).so $(PLUGIN_DIR)/$(PLUGIN_NAME).dim
$(OBJECT_DIR)/$(PLUGIN_NAME)/debug/lib$(PLUGIN_NAME).so:
mkdir -p $(OBJECT_DIR)/$(PLUGIN_NAME)
cargo build --target-dir $(OBJECT_DIR)/$(PLUGIN_NAME)

View File

@@ -0,0 +1,45 @@
use std::fmt::Write;
use chrono::prelude::*;
use dim_sdk::{plugin_info, DimPlugin};
plugin_info!(
Plug, // Your main global structs name that implements `DimPlugin`
"Clock", // 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 local: DateTime<Local> = Local::now();
let formatted_time = local.format("%H:%M (%Y-%m-%d)").to_string();
write!(f, "Time: {}", formatted_time)?;
Ok(())
}
fn pre_reload(&mut self) {
}
fn post_reload(&mut self) {
}
fn free(&mut self) {
}
}

View File

@@ -0,0 +1,13 @@
[package]
name = "counter"
version = "0.1.0"
edition = "2021"
[lib]
crate-type=["cdylib"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
chrono = "0.4.38"
dim_sdk = {path="../../sdk/rust/"}
lazy_static = "1.4.0"

View File

@@ -0,0 +1,15 @@
# Must match package name in Cargo.toml
PLUGIN_NAME=counter
build: $(PLUGIN_DIR)/$(PLUGIN_NAME).dim
$(PLUGIN_DIR)/$(PLUGIN_NAME).dim: $(OBJECT_DIR)/$(PLUGIN_NAME)/debug/lib$(PLUGIN_NAME).so
cp $(OBJECT_DIR)/$(PLUGIN_NAME)/debug/lib$(PLUGIN_NAME).so $(PLUGIN_DIR)/$(PLUGIN_NAME).dim
$(OBJECT_DIR)/$(PLUGIN_NAME)/debug/lib$(PLUGIN_NAME).so:
mkdir -p $(OBJECT_DIR)/$(PLUGIN_NAME)
cargo build --target-dir $(OBJECT_DIR)/$(PLUGIN_NAME)

View File

@@ -0,0 +1,45 @@
use std::fmt::Write;
use dim_sdk::{plugin_info, DimPlugin};
use chrono::{NaiveDate, Local};
plugin_info!(
Plug, // Your main global structs name that implements `DimPlugin`
"counter", // 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 start_date = NaiveDate::from_ymd_opt(2024, 3, 8).expect("Invalid date");
let current_date = Local::now().date_naive();
let duration = current_date.signed_duration_since(start_date);
write!(f, "{} days <3", duration.num_days())?;
Ok(())
}
fn pre_reload(&mut self) {
}
fn post_reload(&mut self) {
}
fn free(&mut self) {
}
}

View File

@@ -9,4 +9,4 @@ crate-type=["cdylib"]
[dependencies]
dim_sdk = {path="../../sdk/rust/"}
lazy_static = "1.4.0"
lazy_static = "1.4.0"