An unofficial rust wrapper for hyprland's IPC [maintainer=@yavko]

Overview

Hyprland-rs

Crates.io Crates.io Crates.io docs.rs Hyprland Discord

An unofficial rust wrapper for Hyprland's IPC

Disclaimer

If something doesn't work, doesn't matter what, make sure you are on the latest commit of Hyprland before making an issue!

Getting started!

Let's get started with Hyprland-rs!

Adding to your project

Add the code below to the dependencies section of your Cargo.toml file!

hyprland = "0.3.2"

Master version

If Hyprland-rs is broken (or other reason) and is taking too long for a release to come out, you can use the master branch in Cargo (will not allow the crate to be published to crates.io):

hyprland = { git = "https://github.com/hyprland-community/hyprland-rs", branch = "master" }

What this crate provides

This crate provides 6 modules (+1 for shared things)

  • data for getting information on the compositor
  • event_listener which provides the EventListener struct for listening for events
  • dispatch for calling dispatchers
  • keyword for dealing with config option (aka keywords)
  • config::binds for changing binds (in future config might have config generation)
  • ctl for calling hyprctl commands

Example Usage

Check the examples in the src/bin/ directory

Comments
  • fix: read all Hyprland socket data returned

    fix: read all Hyprland socket data returned

    Without this fix, when I got a lot of windows open / clients, this lead to a truncated JSON.

    fix: https://github.com/cyrinux/hyprland-autoname-workspaces/issues/8

    opened by cyrinux 8
  • Panic from workspace event listener

    Panic from workspace event listener

    Hey, I'm integrating this library into ironbar for https://github.com/JakeStanger/ironbar/issues/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.

    bug 
    opened by JakeStanger 6
  • `0.3.1` release

    `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:

    • [x] Add all layout dispatchers #35
    • [x] Add minimize event
    • [x] Add group dispatchers
    opened by yavko 5
  • Create issue forms

    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.

    documentation 
    opened by yavko 4
  • fix: some others Client struct fixes, this fix grouped mode and monitor

    fix: some others Client struct fixes, this fix grouped mode and monitor

    • grouped take a Vec<Box
      >
    • and looks like monitor can be -1 now
    • in prevention, we will allow fullscreenmode to be negative too

    fix: https://github.com/cyrinux/hyprland-autoname-workspaces/issues/21

    opened by cyrinux 3
  • WorkspaceType::Named values over 99 will turn into 10

    WorkspaceType::Named values over 99 will turn into 10

    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

    opened by JustSimplyKyle 3
  • ToggleSpecialWorkspace dispatcher does not take any arguments

    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.

    bug enhancement 
    opened by mhats 2
  • Optimize for smaller build-size

    Optimize for smaller build-size

    Added

    [profile.release]
    opt-level = "z"
    strip = true
    lto = true
    

    To Cargo.toml which reduces the total size of target/release from ~200MB+ to ~139MB.

    opened by vars1ty 2
  • Add all Master and Dwindle 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.

    enhancement good first issue 
    opened by yavko 1
  • Implement `Error` for `HyprError`

    Implement `Error` for `HyprError`

    Small edit to impl Error for HyprError, this lets you use it together with crates like anyhow, for example:

    fn main() -> anyhow::Result<()> {
        let workspaces = Workspaces::get()?;
    
        dbg!(workspaces);
    
        Ok(())
    }
    
    
    opened by teevik 1
  • fix: client struct use more signed integer

    fix: client struct use more signed integer

    It Looks like in recent hyprland, client struct change. Some data are now a i8. fix: https://github.com/cyrinux/hyprland-autoname-workspaces/issues/17

    opened by cyrinux 0
  • Reduce amount of clones

    Reduce amount of clones

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

    enhancement 
    opened by yavko 2
Releases(0.3.2)
  • 0.3.2(Apr 19, 2023)

    Literally just adds new stuff lol, also adds new silent feature which will get rid of error messages in STDERR ;)

    Full Changelog: https://github.com/hyprland-community/hyprland-rs/compare/0.3.1...0.3.2

    Source code(tar.gz)
    Source code(zip)
  • 0.3.1(Apr 1, 2023)

    0.3.1 The "I forgot to add these" update!!!

    New stuff I can remember

    since this was supposed to come out a month ago

    • Added hyprctl commands
    • Add layout dispatchers, new ones, and custom dispatcher (kind needed now cuz of plugins)
    • Add support for getting all animations, and binds (yeah take that @NotAShelf)
    • Add support for different async runtimes (Yes, no more bloat tokio if you so please)

    Fixes

    • Fix broken types (Some types changed, and sometimes I was just dumb)
    • Add support for infinitely (theoretically) long responses from socket

    Auto generated

    What's Changed

    • Fix a bug of MoveWorkspaceToMonitor dispatcher by @llwwns in https://github.com/hyprland-community/hyprland-rs/pull/30
    • Added iter functions to data structures by @tukanoidd in https://github.com/hyprland-community/hyprland-rs/pull/34
    • fix: read all Hyprland socket data returned by @cyrinux in https://github.com/hyprland-community/hyprland-rs/pull/36
    • fix: client struct use more signed integer by @cyrinux in https://github.com/hyprland-community/hyprland-rs/pull/37
    • fix: some others Client struct fixes, this fix grouped mode and monitor by @cyrinux in https://github.com/hyprland-community/hyprland-rs/pull/38

    New Contributors

    • @llwwns made their first contribution in https://github.com/hyprland-community/hyprland-rs/pull/30
    • @tukanoidd made their first contribution in https://github.com/hyprland-community/hyprland-rs/pull/34

    Full Changelog: https://github.com/hyprland-community/hyprland-rs/compare/0.3.0...0.3.1

    Source code(tar.gz)
    Source code(zip)
  • 0.3.0(Jan 28, 2023)

    Hyprland-rs 0.3.0 release!

    This release revamps a lot of things so make sure to read the migration guide!

    Overview of API changes

    Data fetchers have been revamped with a new struct based syntax! New dispatchers, and new struct based syntax! New listeners! New system for setting binds! New macro abstractions for setting binds, and calling dispatchers! And way more!!

    Overview of internal changes

    Event listener has been revamped with macros! Data fetchers have been revamped with macros!

    Generated from pull requests

    What's Changed

    • Make Option of ActiveWindow public by @herlev in https://github.com/hyprland-community/hyprland-rs/pull/7
    • typo lol by @horriblename in https://github.com/hyprland-community/hyprland-rs/pull/6
    • fix typo by @flick0 in https://github.com/hyprland-community/hyprland-rs/pull/11
    • Implement Error for HyprError by @teevik in https://github.com/hyprland-community/hyprland-rs/pull/16
    • feat: add fullscreen field to window by @cyrinux in https://github.com/hyprland-community/hyprland-rs/pull/19
    • feat: add renameworkspace dispatcher by @cyrinux in https://github.com/hyprland-community/hyprland-rs/pull/18
    • Add CI by @yavko in https://github.com/hyprland-community/hyprland-rs/pull/21
    • Make multiple item fetchers iterators by @yavko in https://github.com/hyprland-community/hyprland-rs/pull/25
    • feat(dispatcher): add focus urgent or last window by @cyrinux in https://github.com/hyprland-community/hyprland-rs/pull/24

    New Contributors

    • @herlev made their first contribution in https://github.com/hyprland-community/hyprland-rs/pull/7
    • @horriblename made their first contribution in https://github.com/hyprland-community/hyprland-rs/pull/6
    • @flick0 made their first contribution in https://github.com/hyprland-community/hyprland-rs/pull/11
    • @teevik made their first contribution in https://github.com/hyprland-community/hyprland-rs/pull/16
    • @cyrinux made their first contribution in https://github.com/hyprland-community/hyprland-rs/pull/19

    Full Changelog: https://github.com/hyprland-community/hyprland-rs/compare/0.2.4...0.3.0

    Source code(tar.gz)
    Source code(zip)
  • 0.3.0-alpha.0(Jan 17, 2023)

    Hyprland-rs 0.3 alpha release 0

    This release revamps a lot of things so make sure to read the migration guide!

    Overview of API changes

    Data fetchers have been revamped with a new struct based syntax! New dispatchers, and new struct based syntax! New listeners! New system for setting binds! New macro abstractions for setting binds, and calling dispatchers!

    Overview of internal changes

    Event listener has been revamped with macros! Data fetchers have been revamped with macros!

    Generated from pull requests

    What's Changed

    • Make Option of ActiveWindow public by @herlev in https://github.com/hyprland-community/hyprland-rs/pull/7
    • typo lol by @horriblename in https://github.com/hyprland-community/hyprland-rs/pull/6
    • fix typo by @flick0 in https://github.com/hyprland-community/hyprland-rs/pull/11
    • Implement Error for HyprError by @teevik in https://github.com/hyprland-community/hyprland-rs/pull/16
    • feat: add fullscreen field to window by @cyrinux in https://github.com/hyprland-community/hyprland-rs/pull/19
    • feat: add renameworkspace dispatcher by @cyrinux in https://github.com/hyprland-community/hyprland-rs/pull/18
    • Add CI by @yavko in https://github.com/hyprland-community/hyprland-rs/pull/21

    New Contributors

    • @herlev made their first contribution in https://github.com/hyprland-community/hyprland-rs/pull/7
    • @horriblename made their first contribution in https://github.com/hyprland-community/hyprland-rs/pull/6
    • @flick0 made their first contribution in https://github.com/hyprland-community/hyprland-rs/pull/11
    • @teevik made their first contribution in https://github.com/hyprland-community/hyprland-rs/pull/16
    • @cyrinux made their first contribution in https://github.com/hyprland-community/hyprland-rs/pull/19
    • @yavko made their first contribution in https://github.com/hyprland-community/hyprland-rs/pull/21

    Full Changelog: https://github.com/hyprland-community/hyprland-rs/compare/0.2.4...0.3.0-alpha.0

    Source code(tar.gz)
    Source code(zip)
  • 0.2.4(Aug 18, 2022)

  • 0.2.3(Aug 18, 2022)

    This version changes the buffer size for reading the IPC socket, and most importantly adds new Special workspace handling to get rid of those pesky PANICS! How to get around breaking changes! when using WorkspaceId, instead use WorkspaceType!

    // New Version!
    WorkspaceType::Regular(5);
    WorkspaceType::Special;
    
    // Old Version!
    5_u8;
    panic!("Special workspaces caused panics!");
    

    What's Changed

    • Optimize for smaller build-size by @dev11n in https://github.com/yavko/hyprland-rs/pull/1

    New Contributors

    • @dev11n made their first contribution in https://github.com/yavko/hyprland-rs/pull/1

    Full Changelog: https://github.com/yavko/hyprland-rs/compare/0.2.2...0.2.3

    Source code(tar.gz)
    Source code(zip)
  • 0.2.2(Aug 13, 2022)

    Fixes a bug where active window didn't work when the activewindow value was empty, also changes the internals if some helper functions that used activewindow.

    Full Changelog: https://github.com/yavko/hyprland-rs/compare/0.2.1...0.2.2

    Source code(tar.gz)
    Source code(zip)
  • 0.2.1(Aug 12, 2022)

    This release only changes things in the backend, should make writing blocking code faster, and not dependent on tokio!

    Full Changelog: https://github.com/yavko/hyprland-rs/compare/0.2.0...0.2.1

    Source code(tar.gz)
    Source code(zip)
  • 0.2.0(Aug 12, 2022)

    Added support for getting version data Added support for getting keyword information Added support for setcursor as a dispatcher Added mutable state to the EventListener Added more async versions of functions And more...

    Full Changelog: https://github.com/yavko/hyprland-rs/compare/2f382d5..6e0045b

    Source code(tar.gz)
    Source code(zip)
Owner
Hyprland Community
Unofficial place for Hyprland related projects to be stored!
Hyprland Community
A ranger-like flake.lock viewer [maintainer=@figsoda]

nix-melt A ranger-like flake.lock viewer Usage nix run github:nix-community/nix-melt Usage: nix-melt [OPTIONS] [PATH] Arguments: [PATH] Path to th

Nix community projects 120 Jun 28, 2023
TUI monitor handler for Hyprland [maintainer=@Degra02]

MonitorMaestro Tired of fiddling with Hyprland configs? Monitor Maestro lets you switch between monitor layouts in a snap! This Rust-powered TUI app l

Hyprland Community 11 Jun 27, 2024
More than safe rust abstractions over rytm-sys, an unofficial SDK for writing software for Analog Rytm running on firmware 1.70.

rytm-rs More than safe rust abstractions over rytm-sys, an unofficial SDK for writing software for Analog Rytm running on firmware 1.70. On top of CC

Ali Somay 5 Dec 22, 2023
Boursorama / BoursoBank unofficial API and CLI

Bourso CLI This app aims to be a simple CLI powered by Bourso API to log in to your BoursoBank/Boursorama account and achieve some basic tasks. The fi

Azerpas 4 Nov 20, 2023
A low-level ncurses wrapper for Rust

ncurses-rs This is a very thin wrapper around the ncurses TUI lib. NOTE: The ncurses lib is terribly unsafe and ncurses-rs is only the lightest wrappe

Jeaye Wilkerson 628 Jan 7, 2023
argmax is a library that allows Rust applications to avoid Argument list too long errors (E2BIG) by providing a std::process::Command wrapper with a

argmax argmax is a library that allows Rust applications to avoid Argument list too long errors (E2BIG) by providing a std::process::Command wrapper w

David Peter 22 Nov 20, 2022
Wrapper around atspi-code to provide higher-level at-spi Rust bindings

atspi Wrapper around atspi-codegen to provide higher-level at-spi Rust bindings. Contributions Take a look at our atspi-codegen crate, and try inpleme

Odilia 3 Feb 7, 2022
Shared memory - A Rust wrapper around native shared memory for Linux and Windows

shared_memory A crate that allows you to share memory between processes. This crate provides lightweight wrappers around shared memory APIs in an OS a

elast0ny 274 Dec 29, 2022
Idiomatic inotify wrapper for the Rust programming language

inotify-rs Idiomatic inotify wrapper for the Rust programming language. extern crate inotify; use std::env; use inotify::{ EventMask, Watch

Hanno Braun 220 Dec 26, 2022
Rust wrapper for gphoto2 (mirror of https://git.maxicarlos.de/maxicarlos08/gphoto2-rs)

GPhoto2-rs Rust bindings to libgphoto2 What about gphoto-rs? I know about the other crate (gphoto and gphoto2-sys which was created by @dcuddeback, bu

Maxicarlos08 14 Dec 29, 2022
Plain Rust wrapper of Ableton Link's C 11 extension

rusty_link rusty_link is a Rust wrapper of abl_link, which is a C 11 extension for Ableton Link, provided by Ableton. This library attempts to be most

anzbert 7 Jan 7, 2023
Python wrapper for Rust's httparse HTTP parser

httparse Python wrapper for Rust's httparse. See this project on GitHub. Example from httparse import RequestParser parser = RequestParser() buff =

Adrian Garcia Badaracco 41 Dec 22, 2022
Python wrapper around reth db. Written in Rust.

reth-db-py Bare-bones Python package allowing you to interact with the Reth DB via Python. Written with Rust and Pyo3. This python wrapper can access

gibz 44 Jul 3, 2023
Simple OpenAI CLI wrapper written in Rust, feat. configurable prompts and models

Quick Start git clone https://github.com/ryantinder/ask-rs cd ask cargo install --path . Example ask tell me about the Lockheed Martin SR71 >> The Loc

Ryan Tinder 3 Aug 9, 2023
A safe and idiomatic wrapper over shared memory APIs in rust with proper cleanups.

shmem-bind A safe and idiomatic wrapper over shared memory APIs in rust with proper cleanups. Quick start: check the message-passing example for bette

ArshiA Akhavan 3 Apr 6, 2024
ddi is a wrapper for dd. It takes all the same arguments, and all it really does is call dd in the background

ddi A safer dd Introduction If you ever used dd, the GNU coreutil that lets you copy data from one file to another, then you may have encountered a ty

Tomás Ralph 80 Sep 8, 2022
A small CLI wrapper for authenticating with SSH keys from Hashicorp Vault

vaultssh A small CLI wrapper for authenticating with SSH keys from Hashicorp Vault vaultssh is a small CLI wrapper for automatically fetching and usin

Joshua Gilman 50 Dec 10, 2022
A newtype wrapper that causes Debug impls to skip a field.

debug-ignore This library contains DebugIgnore, a newtype wrapper that causes a field to be skipped while printing out Debug output. Examples use debu

Rain 15 Sep 22, 2022
🌌⭐cosmo is a wrapper for Git essentially, allowing you to compress multiple commands into one

❯ Cosmo Git tooling of the future New feature: Cosmo hooks! Click here for more info! ❯ ?? Features Config files (with defaults!) Fast Easy to use Fri

Jack 1 Oct 31, 2021