implemented library calls instead of cli calls
Release / Build and Release (push) Has been cancelled

This commit is contained in:
2026-04-01 12:23:04 +02:00
parent f640f116ec
commit 2ce5aceae0
21 changed files with 1874 additions and 424 deletions
+19 -3
View File
@@ -2,14 +2,16 @@ use crate::config::Config;
use crate::modules::WaybarModule;
use crate::output::WaybarOutput;
use crate::state::SharedState;
use crate::utils::run_command;
use anyhow::Result;
use anyhow::{Result, anyhow};
use std::env;
use std::io::{Read, Write};
use std::os::unix::net::UnixStream;
pub struct GameModule;
impl WaybarModule for GameModule {
fn run(&self, config: &Config, _state: &SharedState, _args: &[&str]) -> Result<WaybarOutput> {
let is_gamemode = run_command("hyprctl", &["getoption", "animations:enabled", "-j"])
let is_gamemode = hyprland_ipc("j/getoption animations:enabled")
.map(|stdout| stdout.contains("\"int\": 0"))
.unwrap_or(false);
@@ -30,3 +32,17 @@ impl WaybarModule for GameModule {
}
}
}
fn hyprland_ipc(cmd: &str) -> Result<String> {
let signature = env::var("HYPRLAND_INSTANCE_SIGNATURE")
.map_err(|_| anyhow!("HYPRLAND_INSTANCE_SIGNATURE not set"))?;
let path = format!("/tmp/hypr/{}/.socket.sock", signature);
let mut stream = UnixStream::connect(path)?;
stream.write_all(cmd.as_bytes())?;
let mut response = String::new();
stream.read_to_string(&mut response)?;
Ok(response)
}