Migrate socket2 path resolution to bread-utils::hypr
hyprland_socket2_path() duplicated the same HYPRLAND_INSTANCE_SIGNATURE + XDG_RUNTIME_DIR resolution breadbox and breadclip had for socket1 — now shared via bread_utils::hypr::socket_path (path dependency for now, see the TODO in Cargo.toml). Builds and all 16 existing tests pass.
This commit is contained in:
parent
ddbc9e63d3
commit
13863836bc
3 changed files with 13 additions and 7 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
|
@ -20,11 +20,21 @@ version = "2.13.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8"
|
checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bread-utils"
|
||||||
|
version = "0.2.3"
|
||||||
|
dependencies = [
|
||||||
|
"dirs",
|
||||||
|
"serde",
|
||||||
|
"serde_json",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "breadmon"
|
name = "breadmon"
|
||||||
version = "0.1.1"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
|
"bread-utils",
|
||||||
"crossterm",
|
"crossterm",
|
||||||
"dirs",
|
"dirs",
|
||||||
"futures",
|
"futures",
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,8 @@ toml = "0.8"
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
dirs = "5"
|
dirs = "5"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
|
# TODO(owner): switch to tag-pinned git dependency once bread-utils is merged and tagged, matching the bread-theme pattern
|
||||||
|
bread-utils = { path = "../bread-ecosystem-fix-worktree/bread-utils" }
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = "thin"
|
lto = "thin"
|
||||||
|
|
|
||||||
|
|
@ -24,12 +24,6 @@ use tokio::{
|
||||||
|
|
||||||
use ui::{AppState, StatusLevel};
|
use ui::{AppState, StatusLevel};
|
||||||
|
|
||||||
fn hyprland_socket2_path() -> Option<String> {
|
|
||||||
let instance = std::env::var("HYPRLAND_INSTANCE_SIGNATURE").ok()?;
|
|
||||||
let runtime = std::env::var("XDG_RUNTIME_DIR").unwrap_or_else(|_| "/run/user/1000".into());
|
|
||||||
Some(format!("{}/hypr/{}/.socket2.sock", runtime, instance))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
enum AppEvent {
|
enum AppEvent {
|
||||||
Key(crossterm::event::KeyEvent),
|
Key(crossterm::event::KeyEvent),
|
||||||
|
|
@ -104,7 +98,7 @@ async fn run(
|
||||||
// Hyprland socket hotplug listener
|
// Hyprland socket hotplug listener
|
||||||
let tx_hotplug = tx.clone();
|
let tx_hotplug = tx.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
if let Some(sig) = hyprland_socket2_path() {
|
if let Some(sig) = bread_utils::hypr::socket_path(bread_utils::hypr::Socket::Events) {
|
||||||
if let Ok(mut stream) = tokio::net::UnixStream::connect(&sig).await {
|
if let Ok(mut stream) = tokio::net::UnixStream::connect(&sig).await {
|
||||||
use tokio::io::AsyncBufReadExt;
|
use tokio::io::AsyncBufReadExt;
|
||||||
let reader = tokio::io::BufReader::new(&mut stream);
|
let reader = tokio::io::BufReader::new(&mut stream);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue