notification daemon
git clone https://git.lucas.co/cce-notifier.git
Refactor and adapt widgets to use UiContext and scale factor
Cargo.lock | 26 +++++++++++++-------------
Cargo.toml | 2 +-
Makefile | 2 +-
src/main.rs | 28 ++++++++++++++--------------
4 files changed, 29 insertions(+), 29 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index 358fa0a..e770970 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -311,19 +311,7 @@ dependencies = [
]
[[package]]
-name = "cfg-if"
-version = "1.0.4"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
-
-[[package]]
-name = "cfg_aliases"
-version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
-
-[[package]]
-name = "clear-notification-daemon"
+name = "cce-notification-daemon"
version = "0.1.0"
dependencies = [
"bytemuck",
@@ -343,6 +331,18 @@ dependencies = [
"zbus",
]
+[[package]]
+name = "cfg-if"
+version = "1.0.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
+
+[[package]]
+name = "cfg_aliases"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "613afe47fcd5fac7ccf1db93babcb082c5994d996f20b8b159f2ad1658eb5724"
+
[[package]]
name = "clear-ui"
version = "0.1.0"
diff --git a/Cargo.toml b/Cargo.toml
index b75d161..aea5706 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,5 +1,5 @@
[package]
-name = "clear-notification-daemon"
+name = "cce-notification-daemon"
version = "0.1.0"
edition = "2021"
diff --git a/Makefile b/Makefile
index 0fd32b6..a2c8fa4 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ build:
install: build
mkdir -p ~/.local/bin
- install -m 755 target/release/clear-notification-daemon ~/.local/bin/clear-notification-daemon
+ install -m 755 target/release/cce-notification-daemon ~/.local/bin/cce-notification-daemon
run:
cargo run
diff --git a/src/main.rs b/src/main.rs
index b16e790..d3c7429 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -156,7 +156,7 @@ impl NotificationApp {
surface.set_buffer_scale(scale as i32);
let window = xdg_shell_state.create_window(surface.clone(), WindowDecorations::None, qh);
window.set_title("Notification");
- window.set_app_id("clear-notification-daemon");
+ window.set_app_id("cce-notification-daemon");
window.set_min_size(Some(((width as f64 / scale) as u32, (height as f64 / scale) as u32)));
window.set_max_size(Some(((width as f64 / scale) as u32, (height as f64 / scale) as u32)));
window.commit();
@@ -328,7 +328,7 @@ impl NotificationApp {
let bounds = TextBounds { left: 0, top: 0, right: w as i32, bottom: h as i32 };
let areas: Vec<TextArea> = self.text_items.iter().map(|ti| TextArea {
buffer: &ti.buffer,
- left: ti.x, top: ti.y, scale: 1.0, bounds,
+ left: ti.x.round(), top: ti.y.round(), scale: 1.0, bounds,
default_color: ti.color,
custom_glyphs: &[],
}).collect();
@@ -407,7 +407,7 @@ impl NotificationApp {
}
fn play_bell_if_configured() {
- let config_path = "/home/lsgalante/.config/ccec/config.toml";
+ let config_path = "/home/lsgalante/.config/cce/config.toml";
let content = std::fs::read_to_string(config_path).unwrap_or_default();
let mut in_section = false;
@@ -429,18 +429,18 @@ fn play_bell_if_configured() {
}
if bell_enabled {
- println!("[clear-notification-daemon] Playing notification bell sound...");
+ println!("[cce-notification-daemon] Playing notification bell sound...");
if let Err(e) = std::process::Command::new("pw-play")
.arg("/usr/share/sounds/freedesktop/stereo/bell.oga")
.spawn()
{
- eprintln!("[clear-notification-daemon] Failed to spawn pw-play: {}", e);
+ eprintln!("[cce-notification-daemon] Failed to spawn pw-play: {}", e);
}
}
}
fn read_duration_if_configured() -> u64 {
- let config_path = "/home/lsgalante/.config/ccec/config.toml";
+ let config_path = "/home/lsgalante/.config/cce/config.toml";
let content = std::fs::read_to_string(config_path).unwrap_or_default();
let mut in_section = false;
@@ -465,7 +465,7 @@ fn read_duration_if_configured() -> u64 {
}
fn read_opacity_if_configured() -> f32 {
- let config_path = "/home/lsgalante/.config/ccec/config.toml";
+ let config_path = "/home/lsgalante/.config/cce/config.toml";
let content = std::fs::read_to_string(config_path).unwrap_or_default();
let mut in_section = false;
@@ -780,7 +780,7 @@ impl AppState {
let opacity = read_opacity_if_configured();
if self.state.is_none() {
- println!("[clear-notification-daemon] Opening notification window: {} - {}", summary, body);
+ println!("[cce-notification-daemon] Opening notification window: {} - {}", summary, body);
let scale = clear_ui::wayland::detect_scale_factor(&self.output_state);
let pw = (360.0 * scale) as u32;
let ph = (100.0 * scale) as u32;
@@ -805,7 +805,7 @@ impl AppState {
state.needs_rebuild = true;
self.state = Some(state);
} else if let Some(ref mut state) = self.state {
- println!("[clear-notification-daemon] Updating active notification window: {} - {}", summary, body);
+ println!("[cce-notification-daemon] Updating active notification window: {} - {}", summary, body);
state.app_name = app_name;
state.summary = summary;
state.body = body;
@@ -824,7 +824,7 @@ impl AppState {
}
UserEvent::CloseNotification { notification_id } => {
if notification_id == self.current_id {
- println!("[clear-notification-daemon] Closing notification window (ID: {})...", notification_id);
+ println!("[cce-notification-daemon] Closing notification window (ID: {})...", notification_id);
self.state = None; // Dropping the window and resources
self.redraw = true;
}
@@ -873,7 +873,7 @@ impl DbusInterface {
async fn get_server_information(&self) -> (String, String, String, String) {
(
- "clear-notification-daemon".to_string(),
+ "cce-notification-daemon".to_string(),
"CCEC Project".to_string(),
"0.1.0".to_string(),
"1.2".to_string(),
@@ -998,7 +998,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.await
.expect("Failed to build D-Bus connection");
- println!("[clear-notification-daemon] D-Bus listener registered. Running...");
+ println!("[cce-notification-daemon] D-Bus listener registered. Running...");
// Keep background runtime alive
loop {
@@ -1040,10 +1040,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
}
}).unwrap();
- println!("[clear-notification-daemon] Wayland event loop starting...");
+ println!("[cce-notification-daemon] Wayland event loop starting...");
loop {
if let Err(err) = event_loop.dispatch(std::time::Duration::from_millis(16), &mut app) {
- eprintln!("[clear-notification-daemon] Event loop error (exiting): {:?}", err);
+ eprintln!("[cce-notification-daemon] Event loop error (exiting): {:?}", err);
break;
}
if app.exit {