Add Ctl Socket, iterate on Idling daemon, update sysinfo crate, start on run menu

This commit is contained in:
jmb05
2026-10-30 16:49:21 +01:00
parent a6b601e3bd
commit 80b5cafb8c
17 changed files with 504 additions and 260 deletions

View File

@@ -62,20 +62,11 @@ pub fn build(
String::new()
};
let monitor_valid = !monitor.is_empty();
println!(
"{:?}",
monitors
.item(monitor_idx)
.unwrap()
.downcast::<gdk::Monitor>()
.unwrap()
.connector()
);
if monitor_valid {
let _ = channels
.br_tx()
.unwrap()
.send(BrightnessMessage::Request(monitor.clone()));
println!("req");
}
let volume_adjustment = Adjustment::new(60.0, 1.0, 100.0, 1.0, 5.0, 0.0);
@@ -85,7 +76,7 @@ pub fn build(
volume.imp().second_icon.set_icon_name("bluetooth-symbolic");
volume.imp().second_icon.add_child_css_class("bt-icon");
let media_tx = channels.media_tx();
let media_tx = channels.media_tx().unwrap();
let changed_progr = Rc::new(Cell::new(false));
let changed_progr_clone = changed_progr.clone();
volume.connect_value_changed(move |slider, button, _| {
@@ -97,7 +88,7 @@ pub fn build(
));
}
});
let media_tx = channels.media_tx();
let media_tx = channels.media_tx().unwrap();
volume.connect_clicked(move |slider, button, _| {
if button.is_active() {
let _ = media_tx.send(MediaCommand::Cmd(slider.value() as u8, true, false));
@@ -110,7 +101,7 @@ pub fn build(
let brightness = IconSlider::new(Some(brightness_adjustment));
brightness.imp().main_icon.set_font_icon("");
let br_tx = channels.br_tx();
let br_tx = channels.br_tx().unwrap();
brightness.connect_value_changed(clone!(
#[strong]
monitor,
@@ -128,7 +119,7 @@ pub fn build(
}
}
));
let br_tx = channels.br_tx();
let br_tx = channels.br_tx().unwrap();
brightness.connect_clicked(clone!(
#[strong]
monitor,
@@ -144,7 +135,7 @@ pub fn build(
let caffeine_button = Button::with_label("");
caffeine_button.add_css_class("caffeine");
let idle_tx = channels.idle_tx();
let idle_tx = channels.idle_tx().unwrap();
caffeine_button.connect_clicked(move |button| {
if button.has_css_class("on") {
let _ = idle_tx.send(IdleMessage::Release);
@@ -221,7 +212,7 @@ pub fn build(
let wg_button = Button::with_label("wg");
wg_button.add_css_class("vpn");
let net_tx = channels.net_tx();
let net_tx = channels.net_tx().unwrap();
wg_button.connect_clicked(move |_| {
let _ = net_tx.send(NetworkCommand::ToggleVpn(String::from("wg")));
});
@@ -328,7 +319,7 @@ pub fn build(
let netbird_rx = channels.take_netbird_rx().unwrap();
let idle_rx = channels.take_idle_rx().unwrap();
let monitor_clone = monitor.clone();
let br_tx = channels.br_tx();
let br_tx = channels.br_tx().unwrap();
glib::timeout_add_local(Duration::from_millis(100), move || {
while let Ok(command) = media_rx.try_recv() {
if let MediaCommand::Cmd(vol, mute, bt) = command {
@@ -374,7 +365,6 @@ pub fn build(
let _ =
br_tx.send(BrightnessMessage::Value(monitor_clone.clone(), 20, true));
brightness.set_value(20.0);
println!("Dimmed: {monitor_clone}");
}
caffeine_button.add_css_class("idle");
caffeine_button.remove_css_class("inhibit");
@@ -474,8 +464,12 @@ pub fn build(
vpn_button.remove_css_class("login");
}
while let Ok(stats) = stats_rx.try_recv() {
cpu_label.set_label(&format!("{}%", stats.cpu));
ram_label.set_label(&format!("{}%", stats.ram));
if let Some(cpu) = stats.cpu {
cpu_label.set_label(&format!("{}%", cpu));
}
if let Some(ram) = stats.ram {
ram_label.set_label(&format!("{}%", ram));
}
for disk in stats.disks {
if disk.0.eq("/") {
disk_label.set_label(&format!("{}%", disk.1));