GithubHelp home page GithubHelp logo

hyprland-community / hyprland-rs Goto Github PK

View Code? Open in Web Editor NEW
205.0 4.0 43.0 713 KB

An unofficial rust wrapper for hyprland's IPC [maintainers=@yavko,@cyrinux]

License: Other

Rust 99.26% Nix 0.74%
hyprland ipc rust hyprland-ipc socket

hyprland-rs's People

Contributors

bksalman avatar c0h2r avatar cyrinux avatar danhandrea avatar dependabot[bot] avatar diniamo avatar exit91 avatar flick0 avatar fufexan avatar gustash avatar h3rmt avatar herlev avatar horriblename avatar jakestanger avatar jarkz avatar jbaker0 avatar llwwns avatar mendess avatar nikolay avatar nooneyy avatar realervolker1 avatar sij1nk avatar szabgab avatar teevik avatar thrombe avatar tukanoidd avatar usersv4 avatar walter-neils avatar yavko avatar ysekka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

hyprland-rs's Issues

Can't dispatch ToggleFloating event on newly open window

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);
    }
}

Add instance support

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

Panic from workspace event listener

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.

`Client::get_active()` doesn't work

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 printed from rust-gdb.]
[edit: just in case, here's an asciinema recording]

Contributor guide

Someone needs to document how to add stuff to Hyprland-rs because it's pretty convoluted

Serialization issue with latest hyprland

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)?;

ToggleSpecialWorkspace dispatcher does not take any arguments

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.

Missing hyprctl hyprpapr functionality

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

Release 0.3 alpha

Hey,
Can you please cut a release ?
I would like to release my toy using the lib with some master feature ;)
Thanks!

Reduce amount of `.clone()`ing

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()

Latest release is broken

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.

Testers needed!

I need testers to sort out all the bugs before I release 0.3 onto crates.io, help would be greatly appreciated!

Create issue forms

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.

Wrong window_class in WindowEventData using the window change handler

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

Key Bindings

I've already started on this, should be out soon?

Switch to fixed dependency versions

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

Stuff to do to clean up codebase

stuff:

  • wipe out doc-comment, and replace with paste (paste is already used in some places, plus its cleaner)
  • use more iterators, this project was made before I knew about most iterator functions
  • #186
  • #68
  • #90
  • #186

more stuff can be added, this is just what I have so far :p

[Event]: urgent

What is the name of the event

urgent

PLEASE MAKE AN ISSUE!!
The event was: urgent>>aaab6c6c5090

[Event]: urgent

What is the name of the event

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.

Stable API

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.

`0.3.1` release

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:

  • Add all layout dispatchers #35
  • Add minimize event
  • Add group dispatchers

Add all Master and Dwindle dispatchers

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.

License

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.