adding systray
This commit is contained in:
parent
aaa21aff21
commit
b693e71e5f
4 changed files with 813 additions and 677 deletions
1305
Cargo.lock
generated
1305
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -18,7 +18,7 @@ tracing-subscriber = { version = "0.3.18", features = ["fmt", "std", "chrono", "
|
||||||
ron = "0.8.1"
|
ron = "0.8.1"
|
||||||
dirs = "5.0.1"
|
dirs = "5.0.1"
|
||||||
tokio = "1.41.1"
|
tokio = "1.41.1"
|
||||||
crisp = { git = "https://git.tfcconnection.org/chris/crisp", version = "0.1.3" }
|
# crisp = { git = "https://git.tfcconnection.org/chris/crisp", version = "0.1.3" }
|
||||||
iced_layershell = "0.13.0"
|
iced_layershell = "0.13.0"
|
||||||
chrono = "0.4.39"
|
chrono = "0.4.39"
|
||||||
sysinfo = "0.35.0"
|
sysinfo = "0.35.0"
|
||||||
|
|
|
||||||
46
flake.lock
generated
46
flake.lock
generated
|
|
@ -6,11 +6,11 @@
|
||||||
"rust-analyzer-src": "rust-analyzer-src"
|
"rust-analyzer-src": "rust-analyzer-src"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1735281280,
|
"lastModified": 1751006353,
|
||||||
"narHash": "sha256-FgW6NkzbGlmNeY0lywjvXgrZD+UPS/+848kI30Yaup0=",
|
"narHash": "sha256-icKFXb83uv2ezRCfuq5G8QSwCuaoLywLljSL+UGmPPI=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "fenix",
|
"repo": "fenix",
|
||||||
"rev": "3915fd69e1a2827209f3a1080cb8bcca48d11fa7",
|
"rev": "b37f026b49ecb295a448c96bcbb0c174c14fc91b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -42,11 +42,11 @@
|
||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1733346208,
|
"lastModified": 1745925850,
|
||||||
"narHash": "sha256-a4WZp1xQkrnA4BbnKrzJNr+dYoQr5Xneh2syJoddFyE=",
|
"narHash": "sha256-cyAAMal0aPrlb1NgzMxZqeN1mAJ2pJseDhm2m6Um8T0=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "naersk",
|
"repo": "naersk",
|
||||||
"rev": "378614f37a6bee5a3f2ef4f825a73d948d3ae921",
|
"rev": "38bc60bbc157ae266d4a0c96671c6c742ee17a5f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -57,11 +57,11 @@
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1734649271,
|
"lastModified": 1750776420,
|
||||||
"narHash": "sha256-4EVBRhOjMDuGtMaofAIqzJbg4Ql7Ai0PSeuVZTHjyKQ=",
|
"narHash": "sha256-/CG+w0o0oJ5itVklOoLbdn2dGB0wbZVOoDm4np6w09A=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "d70bd19e0a38ad4790d3913bf08fcbfc9eeca507",
|
"rev": "30a61f056ac492e3b7cdcb69c1e6abdcf00e39cf",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -73,23 +73,27 @@
|
||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 0,
|
"lastModified": 1750898778,
|
||||||
"narHash": "sha256-Qn3nPMSopRQJgmvHzVqPcE3I03zJyl8cSbgnnltfFDY=",
|
"narHash": "sha256-DXI7+SKDlTyA+C4zp0LoIywQ+BfdH5m4nkuxbWgV4UU=",
|
||||||
"path": "/nix/store/avxvalb7xf8x4avmrbcvn1vr5yy46kxs-source",
|
"owner": "NixOS",
|
||||||
"type": "path"
|
"repo": "nixpkgs",
|
||||||
|
"rev": "322d8a3c6940039f7cff179a8b09c5d7ca06359d",
|
||||||
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"id": "nixpkgs",
|
"owner": "NixOS",
|
||||||
"type": "indirect"
|
"ref": "nixpkgs-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs_3": {
|
"nixpkgs_3": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1735291276,
|
"lastModified": 1750776420,
|
||||||
"narHash": "sha256-NYVcA06+blsLG6wpAbSPTCyLvxD/92Hy4vlY9WxFI1M=",
|
"narHash": "sha256-/CG+w0o0oJ5itVklOoLbdn2dGB0wbZVOoDm4np6w09A=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "634fd46801442d760e09493a794c4f15db2d0cbb",
|
"rev": "30a61f056ac492e3b7cdcb69c1e6abdcf00e39cf",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -110,11 +114,11 @@
|
||||||
"rust-analyzer-src": {
|
"rust-analyzer-src": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1735227773,
|
"lastModified": 1750871759,
|
||||||
"narHash": "sha256-eYkxxU3Bqr7uLMKXOIb9BGlaD0W/I2pI6bh1SIuPZH4=",
|
"narHash": "sha256-hMNZXMtlhfjQdu1F4Fa/UFiMoXdZag4cider2R9a648=",
|
||||||
"owner": "rust-lang",
|
"owner": "rust-lang",
|
||||||
"repo": "rust-analyzer",
|
"repo": "rust-analyzer",
|
||||||
"rev": "1ce4de2585cb9802c4d5a99d1a904b11fdba9501",
|
"rev": "317542c1e4a3ec3467d21d1c25f6a43b80d83e7d",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
137
src/main.rs
137
src/main.rs
|
|
@ -9,11 +9,12 @@ use freedesktop_icons::lookup;
|
||||||
use hyprland::data::{Client, Workspace, Workspaces};
|
use hyprland::data::{Client, Workspace, Workspaces};
|
||||||
use hyprland::event_listener::{self, AsyncEventListener};
|
use hyprland::event_listener::{self, AsyncEventListener};
|
||||||
use hyprland::shared::{HyprData, HyprDataActiveOptional, HyprDataVec};
|
use hyprland::shared::{HyprData, HyprDataActiveOptional, HyprDataVec};
|
||||||
|
use iced::alignment::Vertical;
|
||||||
use iced::font::Weight;
|
use iced::font::Weight;
|
||||||
use iced::futures::SinkExt;
|
use iced::futures::SinkExt;
|
||||||
use iced::stream;
|
|
||||||
use iced::widget::image::Handle;
|
use iced::widget::image::Handle;
|
||||||
use iced::widget::{button, container, horizontal_space, image, row, svg, text};
|
use iced::widget::{button, container, horizontal_space, image, row, svg, text, Button};
|
||||||
|
use iced::{stream, ContentFit};
|
||||||
use iced::{
|
use iced::{
|
||||||
time, Background, Border, Color, Element, Event, Font, Length, Shadow, Subscription, Task,
|
time, Background, Border, Color, Element, Event, Font, Length, Shadow, Subscription, Task,
|
||||||
Vector,
|
Vector,
|
||||||
|
|
@ -87,7 +88,8 @@ struct Panel {
|
||||||
active_window: String,
|
active_window: String,
|
||||||
active_window_icon_svg: Option<svg::Handle>,
|
active_window_icon_svg: Option<svg::Handle>,
|
||||||
active_window_icon_raster: Option<Handle>,
|
active_window_icon_raster: Option<Handle>,
|
||||||
system_tray: Option<SystemTray>,
|
system_tray_svg: Option<Vec<svg::Handle>>,
|
||||||
|
system_tray_raster: Option<Vec<Handle>>,
|
||||||
apps: Vec<String>,
|
apps: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,7 +144,8 @@ impl Panel {
|
||||||
active_window_icon_svg,
|
active_window_icon_svg,
|
||||||
active_window_icon_raster,
|
active_window_icon_raster,
|
||||||
battery,
|
battery,
|
||||||
system_tray: None,
|
system_tray_svg: None,
|
||||||
|
system_tray_raster: None,
|
||||||
};
|
};
|
||||||
|
|
||||||
let sys_task = Task::perform(add_sys_tray(), |m| m);
|
let sys_task = Task::perform(add_sys_tray(), |m| m);
|
||||||
|
|
@ -194,7 +197,7 @@ impl Panel {
|
||||||
Message::SizeChange(_) => todo!(),
|
Message::SizeChange(_) => todo!(),
|
||||||
Message::VirtualKeyboardPressed { time, key } => todo!(),
|
Message::VirtualKeyboardPressed { time, key } => todo!(),
|
||||||
Message::IcedEvent(event) => {
|
Message::IcedEvent(event) => {
|
||||||
debug!(?event)
|
// debug!(?event)
|
||||||
}
|
}
|
||||||
Message::WorkspaceChange(workspaces) => {
|
Message::WorkspaceChange(workspaces) => {
|
||||||
// debug!(?workspaces);
|
// debug!(?workspaces);
|
||||||
|
|
@ -231,7 +234,32 @@ impl Panel {
|
||||||
}
|
}
|
||||||
Message::AddSystemTray(system_tray) => {
|
Message::AddSystemTray(system_tray) => {
|
||||||
debug!(?system_tray);
|
debug!(?system_tray);
|
||||||
self.system_tray = Some(system_tray);
|
let mut raster_vec = vec![];
|
||||||
|
let mut svg_vec = vec![];
|
||||||
|
for item in system_tray.items.into_values() {
|
||||||
|
if let Some(icon) = item.0.icon_name {
|
||||||
|
let icon_path = PathBuf::from(icon.clone());
|
||||||
|
if icon_path.exists() {
|
||||||
|
debug!(?icon_path);
|
||||||
|
raster_vec.push(image::Handle::from_path(icon_path))
|
||||||
|
} else if let Some(icon) = lookup(&icon)
|
||||||
|
.with_theme("Papirus-Dark")
|
||||||
|
.force_svg()
|
||||||
|
.with_size(16)
|
||||||
|
.find()
|
||||||
|
{
|
||||||
|
svg_vec.push(svg::Handle::from_path(icon));
|
||||||
|
} else if let Some(icons) = item.0.icon_pixmap {
|
||||||
|
for icon in icons {
|
||||||
|
raster_vec.push(image::Handle::from_bytes(icon.pixels));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
raster_vec.push( image::Handle::from("/home/chris/pics/wojaks/reddit_the_xenomorph_s bigass wojak folder/Chads/ChristianChad.png"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
self.system_tray_svg = Some(svg_vec);
|
||||||
|
self.system_tray_raster = Some(raster_vec);
|
||||||
}
|
}
|
||||||
Message::None => {}
|
Message::None => {}
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
|
|
@ -338,27 +366,30 @@ impl Panel {
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|w| w.name != "special:special")
|
.filter(|w| w.name != "special:special")
|
||||||
.map(|w| {
|
.map(|w| {
|
||||||
text!("{}", {
|
container(
|
||||||
match w.id {
|
text!("{}", {
|
||||||
1 => "".to_owned(),
|
match w.id {
|
||||||
2 => "".to_owned(),
|
1 => "".to_owned(),
|
||||||
3 => "".to_owned(),
|
2 => "".to_owned(),
|
||||||
4 => "".to_owned(),
|
3 => "".to_owned(),
|
||||||
5 => "".to_owned(),
|
4 => "".to_owned(),
|
||||||
6 => "".to_owned(),
|
5 => "".to_owned(),
|
||||||
7 => "".to_owned(),
|
6 => "".to_owned(),
|
||||||
8 => "".to_owned(),
|
7 => "".to_owned(),
|
||||||
9 => "".to_owned(),
|
8 => "".to_owned(),
|
||||||
_ => w.name.clone(),
|
9 => "".to_owned(),
|
||||||
}
|
_ => w.name.clone(),
|
||||||
})
|
}
|
||||||
.color({
|
})
|
||||||
if w.id == self.active_workspace {
|
.color({
|
||||||
Color::parse("#ff6ac1").unwrap()
|
if w.id == self.active_workspace {
|
||||||
} else {
|
Color::parse("#ff6ac1").unwrap()
|
||||||
Color::parse("#57c7ff").unwrap()
|
} else {
|
||||||
}
|
Color::parse("#57c7ff").unwrap()
|
||||||
})
|
}
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
.center(Length::Shrink)
|
||||||
.into()
|
.into()
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
@ -375,7 +406,11 @@ impl Panel {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
if let Some(handle) = &self.active_window_icon_svg {
|
if let Some(handle) = &self.active_window_icon_svg {
|
||||||
icon = svg(handle.clone()).width(16).height(16).into();
|
icon = svg(handle.clone())
|
||||||
|
.width(16)
|
||||||
|
.height(16)
|
||||||
|
.content_fit(ContentFit::Fill)
|
||||||
|
.into();
|
||||||
} else {
|
} else {
|
||||||
if let Some(handle) = &self.active_window_icon_raster {
|
if let Some(handle) = &self.active_window_icon_raster {
|
||||||
icon = image(handle.clone()).width(16).height(16).into();
|
icon = image(handle.clone()).width(16).height(16).into();
|
||||||
|
|
@ -383,7 +418,7 @@ impl Panel {
|
||||||
icon = image("/home/chris/pics/wojaks/reddit_the_xenomorph_s bigass wojak folder/Chads/ChristianChad.png").width(16).height(16).into();
|
icon = image("/home/chris/pics/wojaks/reddit_the_xenomorph_s bigass wojak folder/Chads/ChristianChad.png").width(16).height(16).into();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let icon = container(icon).center(Length::Shrink).padding(4);
|
let icon = container(icon).center(Length::Shrink).padding([2, 4]);
|
||||||
|
|
||||||
let window = text!("{}", self.active_window).color(Color::parse("#57c7ff").unwrap());
|
let window = text!("{}", self.active_window).color(Color::parse("#57c7ff").unwrap());
|
||||||
let disk = text!("{}", self.disk).color(Color::parse("#ff9f43").unwrap());
|
let disk = text!("{}", self.disk).color(Color::parse("#ff9f43").unwrap());
|
||||||
|
|
@ -415,13 +450,47 @@ impl Panel {
|
||||||
|
|
||||||
let spacer = text!(" | ");
|
let spacer = text!(" | ");
|
||||||
|
|
||||||
// let sys_tray = vec![button()]
|
let mut sys_tray_buttons: Vec<Element<Message>> = vec![];
|
||||||
|
|
||||||
|
if let Some(sys_tray) = &self.system_tray_svg {
|
||||||
|
for item in sys_tray.iter() {
|
||||||
|
sys_tray_buttons.push(
|
||||||
|
svg(item.clone())
|
||||||
|
.width(16)
|
||||||
|
.height(16)
|
||||||
|
.content_fit(ContentFit::Fill)
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(sys_tray) = &self.system_tray_raster {
|
||||||
|
for item in sys_tray.iter() {
|
||||||
|
sys_tray_buttons.push(
|
||||||
|
image(item)
|
||||||
|
.width(16)
|
||||||
|
.height(16)
|
||||||
|
.content_fit(ContentFit::Fill)
|
||||||
|
.into(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let row = row!(
|
let row = row!(
|
||||||
container(row!(workspaces, icon, window, horizontal_space()).spacing(10)),
|
container(row!(workspaces, icon, window, horizontal_space()).spacing(10)),
|
||||||
container(clock),
|
container(clock),
|
||||||
container(row!(horizontal_space(), disk, cpu, mem, battery).spacing(5)),
|
container(
|
||||||
spacer,
|
row!(
|
||||||
|
horizontal_space(),
|
||||||
|
disk,
|
||||||
|
cpu,
|
||||||
|
mem,
|
||||||
|
battery,
|
||||||
|
spacer,
|
||||||
|
row(sys_tray_buttons).spacing(5)
|
||||||
|
)
|
||||||
|
.spacing(5)
|
||||||
|
),
|
||||||
)
|
)
|
||||||
.spacing(5)
|
.spacing(5)
|
||||||
.padding([0, 20]);
|
.padding([0, 20]);
|
||||||
|
|
@ -534,12 +603,16 @@ struct SystemTray {
|
||||||
impl SystemTray {
|
impl SystemTray {
|
||||||
async fn new() -> Result<Self> {
|
async fn new() -> Result<Self> {
|
||||||
let client = system_tray::client::Client::new().await.into_diagnostic()?;
|
let client = system_tray::client::Client::new().await.into_diagnostic()?;
|
||||||
|
let _ = tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
|
||||||
|
let receiver = client.subscribe();
|
||||||
|
let rec_length = receiver.len();
|
||||||
let items = client.items();
|
let items = client.items();
|
||||||
let items = items
|
let items = items
|
||||||
.lock()
|
.lock()
|
||||||
.map_err(|_| SystemTrayError::SomeError)
|
.map_err(|_| SystemTrayError::SomeError)
|
||||||
.into_diagnostic()?
|
.into_diagnostic()?
|
||||||
.clone();
|
.clone();
|
||||||
|
debug!(?items);
|
||||||
Ok(Self { client, items })
|
Ok(Self { client, items })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue