From b08c98f0f1f0ab88d806caa59f87ea3d9682753f Mon Sep 17 00:00:00 2001 From: id3v1669 Date: Sun, 7 Jul 2024 03:54:34 +0800 Subject: [PATCH] add changes from pr #245 commit: 3cd0d1757d21a4a5dda52a2b0ce88f068d3a801c && docs changes --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- Cargo.toml | 1 + INSTALL.md | 4 ++-- README.md | 21 +++++++++------------ contrib/PKGBUILD | 2 +- docs/swhkd-keys.5.scd | 7 ++++--- docs/swhkd.1.scd | 12 ++++++++---- docs/swhkd.5.scd | 7 ++++--- docs/swhks.1.scd | 7 ++++--- swhkd/src/daemon.rs | 24 +++++++++++++++++------- 10 files changed, 51 insertions(+), 36 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 8d445a3..a43f81a 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -3,7 +3,7 @@ name: Bug report about: swhkd bugs title: "" labels: bug -assignees: angelofallars, Shinyzenith, EdenQwQ +assignees: id3v1669 --- **Version Information:** diff --git a/Cargo.toml b/Cargo.toml index 4cd253d..99ac81c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ members = [ "swhkd", "swhks" ] +resolver = "2" [profile.release] lto = true # Enable Link Time Optimization diff --git a/INSTALL.md b/INSTALL.md index a6d104f..280d909 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -7,7 +7,7 @@ We have packaged `swhkd-git`. `swhkd-bin` has been packaged separately by a user Basic installation and autorun on NixOS ```nix # Add inputs to your flake - inputs.swhkd.url = "github:waycrate/swhkd"; + inputs.swhkd.url = "github:id3v1669/swhkd"; inputs.swhkd.inputs.nixpkgs.follows = "nixpkgs"; ... # Add package to your configuration @@ -62,7 +62,7 @@ After that add 'swhks &' to autorun of your desktop enviroment or window manager # Compiling: -- `git clone https://github.com/waycrate/swhkd;cd swhkd` +- `git clone https://github.com/id3v1669/swhkd;cd swhkd` - `make setup` - `make clean` - `make` diff --git a/README.md b/README.md index 7bc5855..04ca606 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,14 @@

- SWHKD + SWHKD

A next-generation hotkey daemon for Wayland/X11 written in Rust.

- + - - - + + +

@@ -65,10 +65,10 @@ All supported key and modifier names are listed in `man 5 swhkd-keys`. ### To autostart `swhkd` you can do one of two things 1. Add the commands from the ["Running" - section](https://github.com/waycrate/swhkd#running) to your window managers + section](https://github.com/id3v1669/swhkd#running) to your window managers configuration file. 1. Enable the [service - file](https://github.com/waycrate/swhkd/tree/main/contrib/init) for your + file](https://github.com/id3v1669/swhkd/tree/master/contrib/init) for your respective init system. Currently, only systemd and OpenRC service files exist and more will be added soon including Runit. @@ -92,10 +92,7 @@ So yes, you're safe! ## Contributors - - + + -## Supporters: - -1. [@CluelessTechnologist](https://github.com/CluelessTechnologist) diff --git a/contrib/PKGBUILD b/contrib/PKGBUILD index db0f4e1..99350e1 100644 --- a/contrib/PKGBUILD +++ b/contrib/PKGBUILD @@ -7,7 +7,7 @@ pkgname="${_pkgname}-git" pkgver=1.2.1.r17.g022466e pkgrel=1 arch=("x86_64") -url="https://github.com/waycrate/swhkd" +url="https://github.com/id3v1669/swhkd" pkgdesc="A display server independent hotkey daemon inspired by sxhkd." license=("BSD") depends=("polkit") diff --git a/docs/swhkd-keys.5.scd b/docs/swhkd-keys.5.scd index 76bb849..82bc3b3 100644 --- a/docs/swhkd-keys.5.scd +++ b/docs/swhkd-keys.5.scd @@ -1,4 +1,4 @@ -swhkd(5) "github.com/waycrate/swhkd" "File Formats Manual" +swhkd(5) "github.com/id3v1669/swhkd" "File Formats Manual" # NAME @@ -166,8 +166,9 @@ swhkd - Hotkey daemon inspired by sxhkd written in Rust # AUTHORS -Maintained by Shinyzenith , EdenQwQ , and Angelo Fallaria . -For more information about development, see . +Created by Shinyzenith , EdenQwQ , and Angelo Fallaria . +Maintained by id3v1669 as original repo looks unmaintained for now. +For more information about development, see . # SEE ALSO diff --git a/docs/swhkd.1.scd b/docs/swhkd.1.scd index 8b3f3dc..e4a99b4 100644 --- a/docs/swhkd.1.scd +++ b/docs/swhkd.1.scd @@ -1,4 +1,4 @@ -swhkd(1) "github.com/shinyzenith/swhkd" "General Commands Manual" +swhkd(1) "github.com/id3v1669/swhkd" "General Commands Manual" # NAME @@ -38,9 +38,12 @@ More about the config file syntax in `swhkd(5)` *-d*, *--debug* Enable debug mode. -*-D, --device* +*-D, --device* Manually set the keyboard devices to use. Can occur multiple times. +*-I, --ignoredevice* + Manually set the keyboard devices to ignore. Can occur multiple times. + # SIGNALS - Reload config file: `sudo pkill -HUP swhkd` @@ -49,8 +52,9 @@ More about the config file syntax in `swhkd(5)` # AUTHORS -Maintained by Shinyzenith , EdenQwQ , and Angelo Fallaria . -For more information about development, see . +Created by Shinyzenith , EdenQwQ , and Angelo Fallaria . +Maintained by id3v1669 as original repo looks unmaintained for now. +For more information about development, see . # SEE ALSO diff --git a/docs/swhkd.5.scd b/docs/swhkd.5.scd index 47fc42b..e1771c9 100644 --- a/docs/swhkd.5.scd +++ b/docs/swhkd.5.scd @@ -1,4 +1,4 @@ -swhkd(5) "github.com/waycrate/swhkd" "File Formats Manual" +swhkd(5) "github.com/id3v1669/swhkd" "File Formats Manual" # NAME @@ -106,8 +106,9 @@ endmode ``` # AUTHORS -Maintained by Shinyzenith , EdenQwQ , and Angelo Fallaria . -For more information about development, see . +Created by Shinyzenith , EdenQwQ , and Angelo Fallaria . +Maintained by id3v1669 as original repo looks unmaintained for now. +For more information about development, see . # SEE ALSO diff --git a/docs/swhks.1.scd b/docs/swhks.1.scd index 4bcd640..574bc52 100644 --- a/docs/swhks.1.scd +++ b/docs/swhks.1.scd @@ -1,4 +1,4 @@ -swhks(1) "github.com/shinyzenith/swhkd" "General Commands Manual" +swhks(1) "github.com/id3v1669/swhkd" "General Commands Manual" # NAME @@ -27,8 +27,9 @@ swhks - Server for swhkd, used to run user level commands over IPC. # AUTHORS -Maintained by Shinyzenith , EdenQwQ , and Angelo Fallaria . -For more information about development, see . +Created by Shinyzenith , EdenQwQ , and Angelo Fallaria . +Maintained by id3v1669 as original repo looks unmaintained for now. +For more information about development, see . # SEE ALSO diff --git a/swhkd/src/daemon.rs b/swhkd/src/daemon.rs index 12788b0..e263f0c 100644 --- a/swhkd/src/daemon.rs +++ b/swhkd/src/daemon.rs @@ -64,6 +64,10 @@ struct Args { /// Take a list of devices from the user #[arg(short = 'D', long, num_args = 0.., value_delimiter = ' ')] device: Vec, + + /// Take a list of devices to ignore from the user + #[arg(short = 'I', long, num_args = 0.., value_delimiter = ' ')] + ignoredevice: Vec, } #[tokio::main] @@ -118,16 +122,22 @@ async fn main() -> Result<(), Box> { let mut modes = load_config(); let mut mode_stack: Vec = vec![0]; - let arg_devices: Vec = args.device; + let arg_add_devices = args.device; + let arg_ignore_devices = args.ignoredevice; + + let to_add = + |dev: &Device| arg_add_devices.contains(&dev.name().unwrap_or("[unknown]").to_string()); + let to_ignore = + |dev: &Device| arg_ignore_devices.contains(&dev.name().unwrap_or("[unknown]").to_string()); let keyboard_devices: Vec<_> = { - if arg_devices.is_empty() { + if arg_add_devices.is_empty() { log::trace!("Attempting to find all keyboard file descriptors."); - evdev::enumerate().filter(|(_, dev)| check_device_is_keyboard(dev)).collect() - } else { evdev::enumerate() - .filter(|(_, dev)| arg_devices.contains(&dev.name().unwrap_or("").to_string())) + .filter(|(_, dev)| !to_ignore(dev) && check_device_is_keyboard(dev)) .collect() + } else { + evdev::enumerate().filter(|(_, dev)| !to_ignore(dev) && to_add(dev)).collect() } }; @@ -279,8 +289,8 @@ async fn main() -> Result<(), Box> { }, Ok(device) => device }; - let name = device.name().unwrap_or("[unknown]").to_string(); - if arg_devices.contains(&name) || check_device_is_keyboard(&device) { + if !to_ignore(&device) && (to_add(&device) || check_device_is_keyboard(&device)) { + let name = device.name().unwrap_or("[unknown]"); log::info!("Device '{}' at '{}' added.", name, node); let _ = device.grab(); keyboard_states.insert(node.to_string(), KeyboardState::new());