-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #237 from joshurtree/master
Expanded examples
- Loading branch information
Showing
17 changed files
with
341 additions
and
257 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/// Demonstates the use of Hyprland-rs for creating key bindings | ||
/// and using submaps | ||
/// | ||
/// Usage: cargo run --example bind | ||
|
||
use std::io::Read; | ||
use hyprland::dispatch; | ||
use hyprland::dispatch::{Dispatch, DispatchType}; | ||
use hyprland::keyword::Keyword; | ||
|
||
fn main() -> hyprland::Result<()> { | ||
Keyword::set("submap", "example")?; | ||
hyprland::bind!(SUPER, Key, "I" => ToggleFloating, None)?; | ||
hyprland::bind!(l | CTRL ALT, Key, "Delete" => Exec, "sudo reboot"); // Reboot including from lock screen | ||
hyprland::bind!(e | SUPER, Key, "C" => KillActiveWindow); // Kill all your windows | ||
Keyword::set("submap", "reset")?; | ||
|
||
dispatch!(Custom, "submap", "example")?; | ||
println!("Press enter to revert to default keymap"); | ||
let _ = std::io::stdin().read(&mut [0u8]) | ||
.expect("Crashed: Run `hyprctl dispatch submap reset` to return to default submap"); | ||
dispatch!(Custom, "submap", "reset")?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/// Demonstates the use of Hyprland-rs for asyncronous creation key bindings | ||
/// and using submaps | ||
/// | ||
/// Usage: cargo run --example bind | ||
|
||
use std::io::Read; | ||
use hyprland::dispatch; | ||
use hyprland::dispatch::{Dispatch, DispatchType}; | ||
use hyprland::keyword::Keyword; | ||
|
||
#[tokio::main(flavor = "current_thread")] | ||
async fn main() -> hyprland::Result<()> { | ||
Keyword::set_async("submap", "example").await?; | ||
hyprland::bind!(async; SUPER, Key, "I" => ToggleFloating, None).await?; | ||
hyprland::bind!(async; l | CTRL ALT, Key, "Delete" => Exec, "sudo reboot").await?; // Reboot including from lock screen | ||
hyprland::bind!(async; e | SUPER, Key, "C" => KillActiveWindow).await?; // Kill all your windows | ||
Keyword::set_async("submap", "reset").await?; | ||
|
||
dispatch!(async; Custom, "submap", "example").await?; | ||
println!("Press enter to revert to default keymap"); | ||
let _ = std::io::stdin().read(&mut [0u8]).unwrap(); | ||
dispatch!(async; Custom, "submap", "reset").await?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/// Demostrates using hyprland-rs to fetch information about clients, workspaces and monitors | ||
/// | ||
/// Usage: cargo run --example data <animations|binds|client(s)|workspace(s)|monitor(s)> | ||
/// Example: cargo run --example data client (Gets data on active client) | ||
/// Example: cargo run --example data workspaces (Gets data on all workspaces) | ||
|
||
use hyprland::data::{Animations, Binds, Client, Clients, Monitor, Monitors, Workspace, Workspaces}; | ||
use hyprland::shared::{HyprData, HyprDataActive, HyprDataActiveOptional}; | ||
fn main() -> hyprland::Result<()>{ | ||
let args: Vec<_> = std::env::args().skip(1).collect(); | ||
|
||
if args.len() == 0 { | ||
panic!("You have to specify client, workspace or monitor") | ||
} | ||
|
||
match args[0].as_str() { | ||
"client" => println!("{:#?}", Client::get_active()?), | ||
"monitor" => println!("{:#?}", Monitor::get_active()?), | ||
"workspace" => println!("{:#?}", Workspace::get_active()?), | ||
"animations" => println!("{:#?}", Animations::get()?), | ||
"binds" => println!("{:#?}", Binds::get()?), | ||
"clients" => println!("{:#?}", Clients::get()?), | ||
"monitors" => println!("{:#?}", Monitors::get()?), | ||
"workspaces" => println!("{:#?}", Workspaces::get()?), | ||
_ => println!("Specify one of client(s), monitor(s) or workspace(s)") | ||
}; | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.