pino-rs
Rust notification daemon.
git clone https://git.pi66.xyz/pino-rs
About | Files | Commits | Refs | License
remove the bloated screen placement file
Author: pixel
Date: 2025-05-03 13:09
commit: 893371c1
Stat
| M | src/config.rs | 6 | +4 | -2 |
| M | src/main.rs | 22 | +16 | -6 |
| D | src/screen.rs | 47 | +0 | -47 |
Diff
diff --git a/src/config.rs b/src/config.rs
index 8f26304..34b2cdd 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -21,9 +21,11 @@ pub fn generate_config(config_path: PathBuf) {
b"[screen]
monitor = 0 # Set the monitor using index
+# Placment:
+# top_left | top_center | top_right
+# bottom_left | bottom_center | bottom_right
-horizontal = "left" #[right] | [left]
-vertical = "top" # [top] | [bottom]
+placement = "top_left"
x = 25 # X access palcement
y = 55 # Y access palcement
diff --git a/src/main.rs b/src/main.rs
index 0a3198f..756adb7 100644
...
Show all
Show less
diff --git a/src/config.rs b/src/config.rs
index 8f26304..34b2cdd 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -21,9 +21,11 @@ pub fn generate_config(config_path: PathBuf) {
b"[screen]
monitor = 0 # Set the monitor using index
+# Placment:
+# top_left | top_center | top_right
+# bottom_left | bottom_center | bottom_right
-horizontal = "left" #[right] | [left]
-vertical = "top" # [top] | [bottom]
+placement = "top_left"
x = 25 # X access palcement
y = 55 # Y access palcement
diff --git a/src/main.rs b/src/main.rs
index 0a3198f..756adb7 100644
...
diff --git a/src/config.rs b/src/config.rs
index 8f26304..34b2cdd 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -21,9 +21,11 @@ pub fn generate_config(config_path: PathBuf) {
b"[screen]
monitor = 0 # Set the monitor using index
+# Placment:
+# top_left | top_center | top_right
+# bottom_left | bottom_center | bottom_right
-horizontal = "left" #[right] | [left]
-vertical = "top" # [top] | [bottom]
+placement = "top_left"
x = 25 # X access palcement
y = 55 # Y access palcement
diff --git a/src/main.rs b/src/main.rs
index 0a3198f..756adb7 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,11 +1,11 @@
use argh::FromArgs;
+use fltk::app::screen_xywh;
use serde::Deserialize;
use std::{fs, io::Write, os::unix::net::UnixStream, path::Path};
use utils::is_running;
mod colors;
mod config;
-mod screen;
mod ui;
mod utils;
@@ -62,9 +62,8 @@ struct Config {
#[derive(Debug, Deserialize)]
struct Screen {
- monitor: usize,
- horizontal: String,
- vertical: String,
+ monitor: i32,
+ placement: String,
x: i32,
y: i32,
width: i32,
@@ -166,6 +165,7 @@ fn main() {
),
};
+ /*
let screen = screen::get_size(
config.screen.monitor,
config.screen.vertical.as_str(),
@@ -175,9 +175,19 @@ fn main() {
config.screen.width,
config.screen.height,
);
-
+*/
+ 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),
+ };
ui::ui(
- screen,
+ (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),
diff --git a/src/screen.rs b/src/screen.rs
deleted file mode 100644
index c47efcb..0000000
--- a/src/screen.rs
+++ /dev/null
@@ -1,47 +0,0 @@
-use fltk::app;
-
-pub fn get_size(
- monitor: usize,
- v: &str,
- h: &str,
- ax: i32,
- ay: i32,
- aw: i32,
- ah: i32,
-) -> (i32, i32, i32, i32) {
- let mut screens = vec![];
-
- for screen in 0..app::screen_count() {
- screens.push(app::screen_xywh(screen));
- }
-
- if h.to_lowercase() == "left" {
- if v.to_lowercase() == "top" {
- return (screens[monitor].0 + ax, ay + screens[monitor].1, aw, ah);
- } else if v.to_lowercase() == "bottom" {
- return (
- screens[monitor].0 + ax,
- screens[monitor].1 + screens[monitor].3 - ah - ay,
- aw,
- ah,
- );
- }
- } else if h.to_lowercase() == "right" {
- if v.to_lowercase() == "top" {
- return (
- screens[monitor].0 + screens[monitor].2 - aw - ax,
- screens[monitor].1 + ay,
- aw,
- ah,
- );
- } else if v.to_lowercase() == "bottom" {
- return (
- screens[monitor].0 + screens[monitor].2 - aw - ax,
- screens[monitor].1 + screens[monitor].3 - ah - ay,
- aw,
- ah,
- );
- }
- }
- (0, 0, 100, 100)
-}