pino-rs
Rust notification daemon.
git clone https://git.pi66.xyz/pino-rs
About | Files | Commits | Refs | License
add sessions to run on different sockets
Author: pixel2175
Date: 2025-05-22 22:50
commit: 5d5136c1
Stat
| M | Cargo.lock | 30 | +15 | -15 |
| M | Cargo.toml | 2 | +1 | -1 |
| M | src/main.rs | 182 | +114 | -68 |
| M | src/ui.rs | 11 | +6 | -5 |
Diff
diff --git a/Cargo.lock b/Cargo.lock
index 7490101..ea13311 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -36,15 +36,15 @@ dependencies = [
[[package]]
name = "bitflags"
-version = "2.9.0"
+version = "2.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
+checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
[[package]]
name = "cc"
-version = "1.2.17"
+version = "1.2.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a"
...
Show all
Show less
diff --git a/Cargo.lock b/Cargo.lock
index 7490101..ea13311 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -36,15 +36,15 @@ dependencies = [
[[package]]
name = "bitflags"
-version = "2.9.0"
+version = "2.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
+checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
[[package]]
name = "cc"
-version = "1.2.17"
+version = "1.2.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a"
...
diff --git a/Cargo.lock b/Cargo.lock
index 7490101..ea13311 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -36,15 +36,15 @@ dependencies = [
[[package]]
name = "bitflags"
-version = "2.9.0"
+version = "2.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
+checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967"
[[package]]
name = "cc"
-version = "1.2.17"
+version = "1.2.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1fcb57c740ae1daf453ae85f16e37396f672b039e00d9d866e07ddb24e328e3a"
+checksum = "5f4ac86a9e5bc1e2b3449ab9d7d3a6a405e3d1bb28d7b9be8614f55846ae3766"
dependencies = [
"shlex",
]
@@ -66,9 +66,9 @@ checksum = "8fd5de2a10e31b3ec3e8d75e7ccf8281ab3ee55de68f7ab6ffa9e21be8d82f22"
[[package]]
name = "crossbeam-channel"
-version = "0.5.14"
+version = "0.5.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "06ba6d68e24814cb8de6bb986db8222d3a027d15872cabc0d18817bc3c0e4471"
+checksum = "82b8f8f868b36967f9606790d1903570de9ceaf870a7bf9fbbd3016d636a2cb2"
dependencies = [
"crossbeam-utils",
]
@@ -81,9 +81,9 @@ checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
[[package]]
name = "fltk"
-version = "1.5.5"
+version = "1.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "63827b17d535827c9cdc922d6d8e0b6068084ae9d5072a4be139442012a8e6a2"
+checksum = "ecfe1d97c0be7585b46d52c1e563226a6495a993be2c72dcdd03fe79d29b1f2a"
dependencies = [
"bitflags",
"crossbeam-channel",
@@ -95,9 +95,9 @@ dependencies = [
[[package]]
name = "fltk-sys"
-version = "1.5.5"
+version = "1.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b27145d51dae768b5263277382d584a3752ffa3423dab877754266c9c080e08d"
+checksum = "de39f27a66d3ceefca611ee2db890369c6846fde4de7b5fd7cdedd9ce0c432f8"
dependencies = [
"cmake",
"cmk",
@@ -117,7 +117,7 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]]
name = "pino"
-version = "1.1.3"
+version = "1.1.4"
dependencies = [
"argh",
"fltk",
@@ -127,9 +127,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
-version = "1.0.94"
+version = "1.0.95"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
+checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778"
dependencies = [
"unicode-ident",
]
@@ -177,9 +177,9 @@ checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
[[package]]
name = "syn"
-version = "2.0.100"
+version = "2.0.101"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
+checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf"
dependencies = [
"proc-macro2",
"quote",
diff --git a/Cargo.toml b/Cargo.toml
index dc0b9c4..d86fbb7 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "pino"
-version = "1.1.3"
+version = "1.1.4"
edition = "2024"
[dependencies]
diff --git a/src/main.rs b/src/main.rs
index f15789c..abbf13d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,7 +1,7 @@
use argh::FromArgs;
use fltk::app::screen_xywh;
use serde::Deserialize;
-use std::{fs, io::Write, os::unix::net::UnixStream, path::Path};
+use std::{fs, io::Write, os::unix::net::UnixStream};
mod colors;
mod config;
@@ -34,6 +34,13 @@ struct Arg {
)]
delay: Option<u64>,
+ #[argh(
+ option,
+ short = 's',
+ description = "choice a name for new session by a special number (default = 0)"
+ )]
+ session: Option<u8>,
+
#[argh(
switch,
short = 'f',
@@ -60,46 +67,46 @@ struct Config {
#[derive(Debug, Deserialize)]
struct Screen {
- monitor: i32,
- placement: String,
- x: i32,
- y: i32,
- width: i32,
- height: i32,
- delay: u64,
+ monitor: Option<i32>,
+ placement: Option<String>,
+ x: Option<i32>,
+ y: Option<i32>,
+ width: Option<i32>,
+ height: Option<i32>,
+ delay: Option<u64>,
}
#[derive(Debug, Deserialize)]
struct Frame {
- fg_color: String,
- font_family: String,
+ fg_color: Option<String>,
+ font_family: Option<String>,
}
#[derive(Debug, Deserialize)]
struct Border {
- weight: i32,
- color: String,
- radius: i32,
+ weight: Option<i32>,
+ color: Option<String>,
+ radius: Option<i32>,
}
#[derive(Debug, Deserialize)]
struct Title {
- color: String,
- font_size: i32,
- x: i32,
- y: i32,
+ color: Option<String>,
+ font_size: Option<i32>,
+ x: Option<i32>,
+ y: Option<i32>,
}
#[derive(Debug, Deserialize)]
struct Message {
- color: String,
- font_size: i32,
- x: i32,
- y: i32,
+ color: Option<String>,
+ font_size: Option<i32>,
+ x: Option<i32>,
+ y: Option<i32>,
}
#[derive(Debug, Deserialize)]
struct Pywal {
- pywal: bool,
- background_color: String,
- border_color: String,
- title_color: String,
- message_color: String,
+ pywal: Option<bool>,
+ background_color: Option<String>,
+ border_color: Option<String>,
+ title_color: Option<String>,
+ message_color: Option<String>,
}
fn main() {
@@ -107,7 +114,7 @@ fn main() {
let args: Arg = argh::from_env();
if args.version {
- println!("v1.1.3");
+ println!("v1.1.4");
return;
}
@@ -133,8 +140,8 @@ fn main() {
let config_content = fs::read_to_string(config_file).expect("Faild ");
let config: Config = toml::from_str(&config_content).expect("Faild");
-
- if let Ok(mut stream) = UnixStream::connect("/tmp/pino-check.sock") {
+ let socket = format!("/tmp/pino-check-{}.sock", args.session.unwrap_or(0));
+ if let Ok(mut stream) = UnixStream::connect(&socket) {
stream
.write_all(
format!(
@@ -142,61 +149,100 @@ fn main() {
args.title.unwrap_or("Title".to_string()),
args.message
.unwrap_or("you didn't set the title or message".to_string()),
- args.delay.unwrap_or(config.screen.delay)
+ args.delay.unwrap_or(config.screen.delay.unwrap_or(3))
)
.as_bytes(),
)
.unwrap()
} else {
- let colors = match config.pywal.pywal {
- true => colors::pywal(
- config.pywal.background_color.to_string(),
- config.pywal.border_color.to_string(),
- config.pywal.title_color.to_string(),
- config.pywal.message_color.to_string(),
- ),
- false => (
- config.frame.fg_color,
- config.border.color,
- config.title.color,
- config.message.color,
- ),
+ let fallback = (
+ config
+ .frame
+ .fg_color
+ .clone()
+ .unwrap_or("#000000".to_string()),
+ config.border.color.clone().unwrap_or("#62777d".to_string()),
+ config.title.color.clone().unwrap_or("#b8b8b8".to_string()),
+ config
+ .message
+ .color
+ .clone()
+ .unwrap_or("#501701".to_string()),
+ );
+
+ let colors = if config.pywal.pywal.unwrap_or(false) {
+ colors::pywal(
+ config
+ .pywal
+ .background_color
+ .clone()
+ .unwrap_or_else(|| fallback.0.clone()),
+ config
+ .pywal
+ .border_color
+ .clone()
+ .unwrap_or_else(|| fallback.1.clone()),
+ config
+ .pywal
+ .title_color
+ .clone()
+ .unwrap_or_else(|| fallback.2.clone()),
+ config
+ .pywal
+ .message_color
+ .clone()
+ .unwrap_or_else(|| fallback.3.clone()),
+ )
+ } else {
+ fallback
};
- /*
- let screen = screen::get_size(
- config.screen.monitor,
- config.screen.vertical.as_str(),
- config.screen.horizontal.as_str(),
- config.screen.x,
- config.screen.y,
- config.screen.width,
- config.screen.height,
+ let (sx, sy, sw, sh) = screen_xywh(config.screen.monitor.unwrap_or(0));
+ let (ax, ay, aw, ah) = (
+ config.screen.x.unwrap_or(25),
+ config.screen.y.unwrap_or(55),
+ config.screen.width.unwrap_or(400),
+ config.screen.height.unwrap_or(60),
);
-*/
- let (sx, sy, sw, sh) = screen_xywh(config.screen.monitor);
- let screen = match config.screen.placement.as_str() {
- "top_left" => (sx + config.screen.x, sy + config.screen.y),
- "top_center" => (sx + (sw - config.screen.width) / 2, sy + config.screen.y),
- "top_right" => (sx + sw - config.screen.width - config.screen.x, sy + config.screen.y),
- "bottom_left" => (sx + config.screen.x, sy + sh - config.screen.height - config.screen.y),
- "bottom_center" => (sx + (sw - config.screen.width) / 2, sy + sh - config.screen.height - config.screen.y),
- "bottom_right" => (sx + sw - config.screen.width - config.screen.x, sy + sh - config.screen.height - config.screen.y),
- _ => (20, 30),
+ let screen = match config
+ .screen
+ .placement
+ .unwrap_or("top_center".to_string())
+ .as_str()
+ {
+ "top_left" => (sx + ax, sy + ay),
+ "top_center" => (sx + (sw - aw) / 2, sy + ay),
+ "top_right" => (sx + sw - aw - ax, sy + ay),
+ "bottom_left" => (sx + ax, sy + sh - ah - ay),
+ "bottom_center" => (sx + (sw - aw) / 2, sy + sh - ah - ay),
+ "bottom_right" => (sx + sw - aw - ax, sy + sh - ah - ay),
+ _ => (20, 30),
};
ui::ui(
- (screen.0,screen.1,config.screen.width,config.screen.height),
- config.frame.font_family,
- (config.border.weight, config.border.radius),
- (config.title.x, config.title.y, config.title.font_size),
- (config.message.x, config.message.y, config.message.font_size),
+ (screen.0, screen.1, aw, ah),
+ config.frame.font_family.unwrap_or("Monospace".to_string()),
+ (
+ config.border.weight.unwrap_or(2),
+ config.border.radius.unwrap_or(10),
+ ),
+ (
+ config.title.x.unwrap_or(5),
+ config.title.y.unwrap_or(0),
+ config.title.font_size.unwrap_or(17),
+ ),
+ (
+ config.message.x.unwrap_or(10),
+ config.message.y.unwrap_or(19),
+ config.message.font_size.unwrap_or(13),
+ ),
colors,
(
args.title.unwrap_or("Title".to_string()),
args.message
.unwrap_or("you didn't set the title or message".to_string()),
- args.delay.unwrap_or(config.screen.delay),
+ args.delay.unwrap_or(config.screen.delay.unwrap_or(5)),
),
+ socket,
);
}
}
diff --git a/src/ui.rs b/src/ui.rs
index dfc8167..bb33465 100644
--- a/src/ui.rs
+++ b/src/ui.rs
@@ -29,6 +29,7 @@ pub fn ui(
message: (i32, i32, i32),
colors: (String, String, String, String),
data: (String, String, u64),
+ socket_path: String,
) {
let app = app::App::default().load_system_fonts();
@@ -97,14 +98,14 @@ pub fn ui(
let (tx, rx) = mpsc::channel::<(String, String, u64)>();
tx.send((data.0, data.1, data.2)).unwrap();
- let socket_path = "/tmp/pino-check.sock";
- if Path::new(socket_path).exists() {
- std::fs::remove_file(socket_path).unwrap();
+ if Path::new(&socket_path).exists() {
+ std::fs::remove_file(&socket_path).unwrap();
}
+ let socket = socket_path.clone();
thread::spawn(move || {
- let listener = UnixListener::bind(socket_path).unwrap();
+ let listener = UnixListener::bind(&socket).unwrap();
for stream in listener.incoming() {
match stream {
@@ -165,7 +166,7 @@ pub fn ui(
}
}
}
- if Path::new(socket_path).exists() {
+ if Path::new(&socket_path).exists() {
std::fs::remove_file(socket_path).unwrap();
}
}