hyprland-community / hyprland-rs Goto Github PK
View Code? Open in Web Editor NEWAn unofficial rust wrapper for hyprland's IPC [maintainers=@yavko,@cyrinux]
License: Other
An unofficial rust wrapper for hyprland's IPC [maintainers=@yavko,@cyrinux]
License: Other
It's pretty badly implemented and used by nobody. If you have an issue with this, please make it vocal. For next release, a warning will appear when used!!
Version 0.3.10 breaks because of pr #108, It changes monitor to a u64 which is incorrect since that value can actually be -1. It should instead be a i64. This should be reversed and the release yanked. Some of my project started breaking because of this issue.
activespecial
monitoraddedv2
event_listener.add_workspace_added_handler(move |workspace, state| {
dbg!(&workspace);
});
Yeah. weird.
It seems like it only reads the first two digits, since if I'm at workspace 161, it would output 16
hyprwm/Hyprland#557
I think this is what caused the current IPC panic when a new window is created
It's been more than a month, so it's time for a new release, if anyone wants small changes please request here, so they can be seen in next stable release. Thanks!
To-do:
First of all, thanks a lot for this project!
The hyprland dispatcher togglespecialworkspace takes an optional argument for specifying the name of the special workspace. The ToggleSpecialWorkspace in dispatch.rs does not seem to have any way of specifying the workspace name.
Please let me now if I am missing something.
I don't see a way to interact with hyprpaper through this library. Would love to see a module like ctl::paper
, or perhaps some of the socket functionality (like write_to_socket
) made public to allow users to make direct calls to hyprctl
I've already started on this, should be out soon?
I wrote a lot of this codebase not knowing much on ownership, and now the codebase is riddled with .clone()
s. This issue exists to track the process of me reducing the usage of .clone()
ignoregrouplock
Was doing a cargo license
check and noticed the license of hyprland-rs.
As far as I'm aware, the GPL license would require all programs that use hyprland-rs to be GPL'd.
If this is intended, can a short notice be added to the README? Many existing projects use more permissive licenses and some none at all. As far as I'm aware, it's possible to use a GPL-compatible license but the work as a whole would be GPL'd.
configreloaded
lockgroups
Someone needs to document how to add stuff to Hyprland-rs because it's pretty convoluted
I forgot to add them as they weren't on main page in wiki, anyways they are around like 20, but its easy to add dispatchers, so if someone wants to do it before I get to it, go ahead.
urgent
PLEASE MAKE AN ISSUE!!
The event was: urgent>>aaab6c6c5090
We need to do this quickly, since issues like #59 will happen again. Also, we need to add Dependabot to actually update them for us.
EDIT: We can ignore popular crates like tokio or serde that are on 1.*
cuz of semver
Pretty self-explanatory, this will be done to make it easier, and standardize issues for like adding dispatchers as an example. I want this to be integrated with 0.3.1
to make it easier to report missing dispatchers.
Should reduce the amount of clones required to use Hyprland-rs
windowtitle>>555ef349f500
Hello, using the window change handler and moving focus to firefox with this video opened https://www.youtube.com/watch?v=aUiazUxP0j8 gives the wrong window_class and window_title:
Some(
WindowEventData {
window_class: "firefox,GrapheneOS: first impressions, stumbling blocks",
window_title: " and opinions - YouTube — Mozilla Firefox",
window_address: Address(
"597b290",
),
},
)
This is the code:
use hyprland::event_listener::EventListener;
fn main() -> hyprland::Result<()> {
let mut event_listener = EventListener::new();
event_listener.add_active_window_change_handler(|data| println!("{data:#?}"));
event_listener.start_listener()
}
Cargo.toml
:
[package]
name = "hyprlandtest"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
hyprland = { git = "https://github.com/hyprland-community/hyprland-rs", branch = "master" }
Output from hyprctl clients
:
Window 597b290 -> GrapheneOS: first impressions, stumbling blocks, and opinions - YouTube — Mozilla Firefox:
mapped: 1
hidden: 0
at: 22,22
size: 931,1006
workspace: 1 (1: )
floating: 0
monitor: 0
class: firefox
title: GrapheneOS: first impressions, stumbling blocks, and opinions - YouTube — Mozilla Firefox
initialClass: firefox
initialTitle: Mozilla Firefox
pid: 1883
xwayland: 0
pinned: 0
fullscreen: 0
fullscreenmode: 0
fakefullscreen: 0
grouped: 0
swallowing: 0
screencast>>1,0
This event was triggered by launching OBS.
Tracker for progress in the migration guide
In https://wiki.hyprland.org/Configuring/Dispatchers/
you may call pin using a specified window, similar to togglefloating
However, TogglePin does not allow specifying a window in the same way.
Hi,
Using hyprland-workspaces and trying to get active workspace I get a panic!
Sample command:
hyprland-workspaces DP-1
[{"active":false,"class":"workspace-button w1","id":1,"name":"1"}]
thread 'main' panicked at 'Error parsing data whith serde: expected value at line 1 column 1', /home/patrik/.cargo/registry/src/github.com-1ecc6299db9ec823/hyprland-0.3.3/src/event_listener/mutable.rs:53:31
Could the data structure have changed/optionals to cause the serde parser to panic?
let data = call_hyprctl_data_cmd(DataCommands::ActiveWorkspace);
let deserialized: Workspace = serde_json::from_str(&data)?;
Calling the method with an active window present results in smth like that:
[src/main.rs:210] Client::get_active() = Err(
SerdeError(
Error("data did not match any variant of untagged enum Aux", line: 0, column: 0),
),
)
And when there's none, everything works fine:
[src/main.rs:210] Client::get_active() = Ok(
None,
)
Attempts at debugging showed that the problem is with trying to deserialize json into ActiveWindow
. Maybe it'd be easier to manually check if the result [edit: of the ipc call] is empty instead of doing that proxy struct thingy?
In case of inability to replicate: I'm on NixOS, and hyprctl version
says
hyprctl version
Hyprland, built from branch at commit v0.30.0 ().
Tag: ?
flags: (if any)
debug
Also, if I manually feed serde
with an output of hyprctl activewindow -j
, it is able to parse the output into structs provided by the crate.
[edit: Also^2: the data
variable right before parsing looks fine when print
ed from rust-gdb
.]
[edit: just in case, here's an asciinema recording]
renameworkspace
work in progress
configreloaded
Instead of calling get_something()
It should be
let workspaces = Workspaces::get();
Hey, I'm integrating this library into ironbar for JakeStanger/ironbar#18 and I've hit a bug:
When creating and switching to a new workspace, the event listener receives the added event and the change event. It appears when you then open a program (in this case kitty
) it panics.
This can be reproduced simply by starting the program, using hyperctl dispatch workspace 4
(or the number of any workspace that does not currently exist), and then opening a window in the new workspace.
Minimal code to reproduce:
let mut event_listener = EventListener::new();
event_listener.add_workspace_added_handler(|id| println!("workspace added: {id:?}"));
event_listener.add_workspace_destroy_handler(|id| println!("workspace removed: {id:?}"));
event_listener.add_workspace_change_handler(|id| println!("workspace changed to {id:?}"));
event_listener.start_listener().await.unwrap();
Stdout and the relevant part of the backtrace:
workspace changed to Regular(2)
workspace changed to Regular(1)
workspace changed to Regular(3)
workspace changed to Regular(1)
workspace changed to Regular(3)
workspace added: Regular(4)
workspace changed to Regular(4)
The application panicked (crashed).
Message: something has went down -[]-
Location: /home/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/hyprland-0.2.4/src/event_listener/shared.rs:228
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⋮ 7 frames hidden ⋮
8: hyprland::event_listener::shared::event_parser::h59e666c08b605020
at /home/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/hyprland-0.2.4/src/event_listener/shared.rs:228
9: hyprland::event_listener::immutable::EventListener::start_listener::{{closure}}::h8810f2076f1a9397
at /home/jake/.cargo/registry/src/github.com-1ecc6299db9ec823/hyprland-0.2.4/src/event_listener/immutable.rs:260
10: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h1c521f9b23072b06
at /rustc/a55dd71d5fb0ec5a6a3a9e8c27b2127ba491ce52/library/core/src/future/mod.rs:91
11: ironbar::clients::hyprland::HyprlandEventClient::new::{{closure}}::h70a2c01650c455c5
at /home/jake/Programming/ironbar/src/clients/hyprland.rs:25
12: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hdb2b9da00f74bf77
The line that's crashing is here:
https://github.com/yavko/hyprland-rs/blob/0f1b676924d9a614278f2a7e3bf4284369de64e1/src/event_listener/shared.rs#L228
It looks like perhaps there's another event being received after those two that is unsupported?
Hyprland version: hyprland-git r1728.7a775c0-1
Library version: 0.2.4
As an aside, it'd probably be better to return an Err
rather than panic in the library, so binaries can control how to handle the error.
If it's possible, I would also like to use address instead of title, but that's on you
I need testers to sort out all the bugs before I release 0.3
onto crates.io, help would be greatly appreciated!
Trying to dispatch a ToggleFloating
event on a window_open_handler
event listener does not float the newly open window.
I'm trying to use the data.window_address
to make sure only the newly open window gets floated, but this does nothing to the window. If I call DispatchType::ToggleFloating
with None
instead, the new window gets floated, but I want more predictable behavior when doing so.
Below is the code I'm using, which can be used to replicate this issue:
use hyprland::{
dispatch::{Dispatch, DispatchType, WindowIdentifier},
event_listener::{EventListener, WindowOpenEvent},
Result,
};
#[tokio::main]
async fn main() -> Result<()> {
let mut listener = EventListener::new();
listener.add_window_open_handler(|data| float_window(&data));
listener.start_listener_async().await
}
fn float_window(data: &WindowOpenEvent) {
let window_address = data.window_address.clone();
println!("Window Address: {}", window_address);
if let Err(err) = Dispatch::call(DispatchType::ToggleFloating(Some(
WindowIdentifier::Address(window_address),
))) {
println!("Error: {:#?}", err);
}
}
Hey,
Can you please cut a release ?
I would like to release my toy using the lib with some master feature ;)
Thanks!
Not really used, plus derive_more
has formatting
I have an idea on how to do this without breaking api. Ex. Clients::instance(<id>).get()
Instead, can be used to create a socket ex. HyprlandCommandSocket::new_with_instance(<id>)
, which will be required to be taken by all hyprland-rs methods
The API has been unstable for a while, so I'm proposing 0.4
be the final release before 1.0
. 0.4 will only exist to be a transitioning period for all the big API changes I have planned.
async-fn in traits now supported !!! https://blog.rust-lang.org/2023/12/28/Rust-1.75.0.html
urgent
Full log from ironbar
:
A unknown event was passed into Hyprland-rs
PLEASE MAKE AN ISSUE!!
The event was: urgent>>55fc37dad5d0
I believe this got triggered after clicking a link in discord, which was opened in Firefox.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.