Compare commits
4 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 4895333ff1 | |||
| 9bf4c44aa2 | |||
| 27f8cc3ab8 | |||
| 95353bb8d6 |
12 changed files with 2343 additions and 9 deletions
19
.direnv/bin/nix-direnv-reload
Executable file
19
.direnv/bin/nix-direnv-reload
Executable file
|
|
@ -0,0 +1,19 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
if [[ ! -d "/home/benag/.nix-config/configuration/modules/dots/wayland_panel" ]]; then
|
||||||
|
echo "Cannot find source directory; Did you move it?"
|
||||||
|
echo "(Looking for "/home/benag/.nix-config/configuration/modules/dots/wayland_panel")"
|
||||||
|
echo 'Cannot force reload with this script - use "direnv reload" manually and then try again'
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# rebuild the cache forcefully
|
||||||
|
_nix_direnv_force_reload=1 direnv exec "/home/benag/.nix-config/configuration/modules/dots/wayland_panel" true
|
||||||
|
|
||||||
|
# Update the mtime for .envrc.
|
||||||
|
# This will cause direnv to reload again - but without re-building.
|
||||||
|
touch "/home/benag/.nix-config/configuration/modules/dots/wayland_panel/.envrc"
|
||||||
|
|
||||||
|
# Also update the timestamp of whatever profile_rc we have.
|
||||||
|
# This makes sure that we know we are up to date.
|
||||||
|
touch -r "/home/benag/.nix-config/configuration/modules/dots/wayland_panel/.envrc" "/home/benag/.nix-config/configuration/modules/dots/wayland_panel/.direnv"/*.rc
|
||||||
1
.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa
Symbolic link
1
.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa
Symbolic link
|
|
@ -0,0 +1 @@
|
||||||
|
/nix/store/19sic4f4w000jj6fscbhz98zaib4f4ml-nix-shell-env
|
||||||
2221
.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc
Normal file
2221
.direnv/flake-profile-a5d5b61aa8a61b7d9d765e1daf971a9a578f1cfa.rc
Normal file
File diff suppressed because it is too large
Load diff
11
Cargo.lock
generated
11
Cargo.lock
generated
|
|
@ -1787,6 +1787,16 @@ dependencies = [
|
||||||
"jni-sys",
|
"jni-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "niri-ipc"
|
||||||
|
version = "25.11.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "12bd9eb4e437f5282ce853cf66837658379cb537b4b6bae687da59246005329a"
|
||||||
|
dependencies = [
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-traits"
|
name = "num-traits"
|
||||||
version = "0.2.19"
|
version = "0.2.19"
|
||||||
|
|
@ -3310,6 +3320,7 @@ dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"iced",
|
"iced",
|
||||||
"iced_layershell",
|
"iced_layershell",
|
||||||
|
"niri-ipc",
|
||||||
"tokio",
|
"tokio",
|
||||||
"winit",
|
"winit",
|
||||||
"zbus",
|
"zbus",
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ edition = "2024"
|
||||||
chrono = "0.4.44"
|
chrono = "0.4.44"
|
||||||
iced = { version = "0.14.0", default-features = false, features = ["wgpu", "wayland", "tokio"] }
|
iced = { version = "0.14.0", default-features = false, features = ["wgpu", "wayland", "tokio"] }
|
||||||
iced_layershell = { version = "0.15.0", default-features = false }
|
iced_layershell = { version = "0.15.0", default-features = false }
|
||||||
|
niri-ipc = "25.11.0"
|
||||||
tokio = { version = "1.50.0", features = ["time"] }
|
tokio = { version = "1.50.0", features = ["time"] }
|
||||||
winit = { version = "0.30.12", default-features = false, features = ["wayland"] }
|
winit = { version = "0.30.12", default-features = false, features = ["wayland"] }
|
||||||
zbus = "5.14.0"
|
zbus = "5.14.0"
|
||||||
|
|
|
||||||
12
flake.lock
generated
12
flake.lock
generated
|
|
@ -2,11 +2,11 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1773579282,
|
"lastModified": 1773821835,
|
||||||
"narHash": "sha256-LWvZj9Bvm1EuoO6zbX4yjZebwnZNfeTbmCJGS7RGQ3Y=",
|
"narHash": "sha256-TJ3lSQtW0E2JrznGVm8hOQGVpXjJyXY2guAxku2O9A4=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "5a88de74db0e948139be4b46f9a94d64aa11391c",
|
"rev": "b40629efe5d6ec48dd1efba650c797ddbd39ace0",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -29,11 +29,11 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1773630837,
|
"lastModified": 1773975983,
|
||||||
"narHash": "sha256-zJhgAGnbVKeBMJOb9ctZm4BGS/Rnrz+5lfSXTVah4HQ=",
|
"narHash": "sha256-zrRVwdfhDdohANqEhzY/ydeza6EXEi8AG6cyMRNYT9Q=",
|
||||||
"owner": "oxalica",
|
"owner": "oxalica",
|
||||||
"repo": "rust-overlay",
|
"repo": "rust-overlay",
|
||||||
"rev": "f600ea449c7b5bb596fa1cf21c871cc5b9e31316",
|
"rev": "cc80954a95f6f356c303ed9f08d0b63ca86216ac",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,7 @@
|
||||||
]
|
]
|
||||||
++ runtimeLibs;
|
++ runtimeLibs;
|
||||||
|
|
||||||
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath runtimeLibs;
|
LD_LIBRARY_PATH = "/run/opengl-driver/lib:${pkgs.lib.makeLibraryPath runtimeLibs}";
|
||||||
VK_ICD_FILENAMES = "${pkgs.mesa}/share/vulkan/icd.d/intel_icd.x86_64.json";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
use crate::widget::{Message, PanelWidget};
|
use crate::widget::{Message, PanelWidget};
|
||||||
use crate::widgets::battery::BatteryWidget;
|
use crate::widgets::battery::BatteryWidget;
|
||||||
use crate::widgets::clock::ClockWidget;
|
use crate::widgets::clock::ClockWidget;
|
||||||
|
use crate::widgets::focused_window::FocusedWindowWidget;
|
||||||
use crate::widgets::powerbutton::ShutdownWidget;
|
use crate::widgets::powerbutton::ShutdownWidget;
|
||||||
use crate::widgets::spacer::Spacer;
|
use crate::widgets::spacer::Spacer;
|
||||||
|
|
||||||
use iced::Color;
|
use iced::Color;
|
||||||
use iced::Element;
|
use iced::Element;
|
||||||
use iced::Subscription;
|
use iced::Subscription;
|
||||||
|
|
@ -24,6 +24,7 @@ impl App {
|
||||||
Box::new(ShutdownWidget::new()),
|
Box::new(ShutdownWidget::new()),
|
||||||
Box::new(Spacer::new(iced::Length::Fill)),
|
Box::new(Spacer::new(iced::Length::Fill)),
|
||||||
Box::new(BatteryWidget::new()),
|
Box::new(BatteryWidget::new()),
|
||||||
|
Box::new(FocusedWindowWidget::new()),
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,3 +25,4 @@ pub fn main() -> Result<(), iced_layershell::Error> {
|
||||||
})
|
})
|
||||||
.run()
|
.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,4 +20,5 @@ pub enum Message {
|
||||||
Battery(Option<f64>),
|
Battery(Option<f64>),
|
||||||
Time,
|
Time,
|
||||||
ShutdownEvent(ShutdownEvents),
|
ShutdownEvent(ShutdownEvents),
|
||||||
|
FocusChanged(Option<u64>),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
78
src/widgets/focused_window.rs
Normal file
78
src/widgets/focused_window.rs
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
use iced::{Subscription, Task, futures::SinkExt};
|
||||||
|
use niri_ipc::{Event, Request, socket::Socket};
|
||||||
|
|
||||||
|
use crate::widget::{Message, PanelWidget};
|
||||||
|
|
||||||
|
pub struct FocusedWindowWidget {
|
||||||
|
focused_window: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl FocusedWindowWidget {
|
||||||
|
pub fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
focused_window: "dsadsadsadas".into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PanelWidget for FocusedWindowWidget {
|
||||||
|
fn update(&mut self, message: &Message) -> iced::Task<Message> {
|
||||||
|
let Message::FocusChanged(i) = message else {
|
||||||
|
return Task::none();
|
||||||
|
};
|
||||||
|
|
||||||
|
self.focused_window = match i {
|
||||||
|
Some(id) => id.to_string(),
|
||||||
|
None => "None".into(),
|
||||||
|
};
|
||||||
|
|
||||||
|
Task::none()
|
||||||
|
}
|
||||||
|
|
||||||
|
//ain't gonna lie, I got no idea wth is going on here, the issue was that, smth smth channel
|
||||||
|
//not filled, it was not working properly
|
||||||
|
//this is entirely vibecoded
|
||||||
|
fn subscribe(&self) -> Subscription<Message> {
|
||||||
|
Subscription::run_with("niri-focus-watcher", |_| {
|
||||||
|
iced::stream::channel(16, async |mut tx| {
|
||||||
|
let (btx, brx) = std::sync::mpsc::channel::<Message>();
|
||||||
|
|
||||||
|
std::thread::spawn(move || {
|
||||||
|
let mut socket = Socket::connect().expect("failed to connect");
|
||||||
|
let _ = socket.send(Request::EventStream).expect("failed to send");
|
||||||
|
let mut read_event = socket.read_events();
|
||||||
|
loop {
|
||||||
|
match read_event() {
|
||||||
|
Ok(Event::WindowFocusChanged { id }) => {
|
||||||
|
if btx.send(Message::FocusChanged(id)).is_err() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("{e}");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
loop {
|
||||||
|
match brx.try_recv() {
|
||||||
|
Ok(msg) => {
|
||||||
|
let _ = tx.send(msg).await;
|
||||||
|
}
|
||||||
|
Err(std::sync::mpsc::TryRecvError::Empty) => {
|
||||||
|
tokio::time::sleep(std::time::Duration::from_millis(10)).await;
|
||||||
|
}
|
||||||
|
Err(std::sync::mpsc::TryRecvError::Disconnected) => break,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
fn view(&self, _id: iced::window::Id) -> iced::Element<'_, Message> {
|
||||||
|
iced::widget::text!("{}", self.focused_window).into()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
pub mod battery;
|
pub mod battery;
|
||||||
pub mod clock;
|
pub mod clock;
|
||||||
|
pub mod focused_window;
|
||||||
pub mod powerbutton;
|
pub mod powerbutton;
|
||||||
pub mod spacer;
|
pub mod spacer;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue