What's everyone working on this week (22/2020)?

New week, new Rust! What are you folks up to?

A global_shortcut library.

Basically it allows you to:

// establish an async connection to X11 display in $DISPLAY
let connection = connect(None).expect("Could not get DISPLAY");
// register a global shortcut
let mut shortcut = GlobalShortcut::new(&connection, "Ctrl+Shift+F2".try_into()?);
// run the connection in the background
let _task = smol::Task::spawn(async move { connection.await }); 
// this future will resolve when the shortcut is triggered
shortcut.activation().await;

The registered global shortcuts are able to grab the keys even when the application doesn't have the focus.
I have something working, even if I'm not done implementing the struct that allows you to choose your shortcut and so have to hardcode the keys I want :smiley:.
Also, it only works with X11 at the moment, even if adding Windows looks possible (but I don't have a windows for development). Wayland looks tougher, though.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.