Skip to content

Commit

Permalink
add changes from pr waycrate#245 commit: 3cd0d17 && docs changes
Browse files Browse the repository at this point in the history
  • Loading branch information
id3v1669 committed Jul 6, 2024
1 parent 7717d8a commit b08c98f
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 36 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Bug report
about: swhkd bugs
title: ""
labels: bug
assignees: angelofallars, Shinyzenith, EdenQwQ
assignees: id3v1669
---

**Version Information:**
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ members = [
"swhkd",
"swhks"
]
resolver = "2"

[profile.release]
lto = true # Enable Link Time Optimization
Expand Down
4 changes: 2 additions & 2 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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`
Expand Down
21 changes: 9 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<p align=center>
<img src="https://git.sr.ht/~shinyzenith/swhkd/blob/main/assets/swhkd.png" alt=SWHKD width=60%>
<img src="https://github.com/id3v1669/id3v1669/assets/swhkd.png" alt=SWHKD width=60%>

<p align="center">A next-generation hotkey daemon for Wayland/X11 written in <a href="https://www.rust-lang.org/">Rust</a>.</p>

<p align="center">
<a href="./LICENSE.md"><img src="https://img.shields.io/github/license/waycrate/swhkd?style=flat-square&logo=appveyor"></a>
<a href="./LICENSE.md"><img src="https://img.shields.io/github/license/id3v1669/swhkd?style=flat-square&logo=appveyor"></a>
<img src="https://img.shields.io/badge/cargo-v1.2.1-green?style=flat-square&logo=appveyor">
<img src="https://img.shields.io/github/issues/waycrate/swhkd?style=flat-square&logo=appveyor">
<img src="https://img.shields.io/github/forks/waycrate/swhkd?style=flat-square&logo=appveyor">
<img src="https://img.shields.io/github/stars/waycrate/swhkd?style=flat-square&logo=appveyor">
<img src="https://img.shields.io/github/issues/id3v1669/swhkd?style=flat-square&logo=appveyor">
<img src="https://img.shields.io/github/forks/id3v1669/swhkd?style=flat-square&logo=appveyor">
<img src="https://img.shields.io/github/stars/id3v1669/swhkd?style=flat-square&logo=appveyor">
</p>
</p>

Expand Down Expand Up @@ -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.

Expand All @@ -92,10 +92,7 @@ So yes, you're safe!

## Contributors

<a href="https://github.com/Shinyzenith/swhkd/graphs/contributors">
<img src="https://contrib.rocks/image?repo=waycrate/swhkd" />
<a href="https://github.com/id3v1669/swhkd/graphs/contributors">
<img src="https://contrib.rocks/image?repo=id3v1669/swhkd" />
</a>

## Supporters:

1. [@CluelessTechnologist](https://github.com/CluelessTechnologist)
2 changes: 1 addition & 1 deletion contrib/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
7 changes: 4 additions & 3 deletions docs/swhkd-keys.5.scd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
swhkd(5) "github.com/waycrate/swhkd" "File Formats Manual"
swhkd(5) "github.com/id3v1669/swhkd" "File Formats Manual"

# NAME

Expand Down Expand Up @@ -166,8 +166,9 @@ swhkd - Hotkey daemon inspired by sxhkd written in Rust

# AUTHORS

Maintained by Shinyzenith <[email protected]>, EdenQwQ <[email protected]>, and Angelo Fallaria <[email protected]>.
For more information about development, see <https://github.com/waycrate/swhkd>.
Created by Shinyzenith <[email protected]>, EdenQwQ <[email protected]>, and Angelo Fallaria <[email protected]>.
Maintained by id3v1669 <[email protected]> as original repo looks unmaintained for now.
For more information about development, see <https://github.com/id3v1669/swhkd>.

# SEE ALSO

Expand Down
12 changes: 8 additions & 4 deletions docs/swhkd.1.scd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
swhkd(1) "github.com/shinyzenith/swhkd" "General Commands Manual"
swhkd(1) "github.com/id3v1669/swhkd" "General Commands Manual"

# NAME

Expand Down Expand Up @@ -38,9 +38,12 @@ More about the config file syntax in `swhkd(5)`
*-d*, *--debug*
Enable debug mode.

*-D, --device* <DEVICE_NAME>
*-D, --device* <DEVICE_NAMES>
Manually set the keyboard devices to use. Can occur multiple times.

*-I, --ignoredevice* <DEVICE_NAMES>
Manually set the keyboard devices to ignore. Can occur multiple times.

# SIGNALS

- Reload config file: `sudo pkill -HUP swhkd`
Expand All @@ -49,8 +52,9 @@ More about the config file syntax in `swhkd(5)`

# AUTHORS

Maintained by Shinyzenith <[email protected]>, EdenQwQ <[email protected]>, and Angelo Fallaria <[email protected]>.
For more information about development, see <https://github.com/waycrate/swhkd>.
Created by Shinyzenith <[email protected]>, EdenQwQ <[email protected]>, and Angelo Fallaria <[email protected]>.
Maintained by id3v1669 <[email protected]> as original repo looks unmaintained for now.
For more information about development, see <https://github.com/id3v1669/swhkd>.

# SEE ALSO

Expand Down
7 changes: 4 additions & 3 deletions docs/swhkd.5.scd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
swhkd(5) "github.com/waycrate/swhkd" "File Formats Manual"
swhkd(5) "github.com/id3v1669/swhkd" "File Formats Manual"

# NAME

Expand Down Expand Up @@ -106,8 +106,9 @@ endmode
```
# AUTHORS

Maintained by Shinyzenith <[email protected]>, EdenQwQ <[email protected]>, and Angelo Fallaria <[email protected]>.
For more information about development, see <https://github.com/waycrate/swhkd>.
Created by Shinyzenith <[email protected]>, EdenQwQ <[email protected]>, and Angelo Fallaria <[email protected]>.
Maintained by id3v1669 <[email protected]> as original repo looks unmaintained for now.
For more information about development, see <https://github.com/id3v1669/swhkd>.

# SEE ALSO

Expand Down
7 changes: 4 additions & 3 deletions docs/swhks.1.scd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
swhks(1) "github.com/shinyzenith/swhkd" "General Commands Manual"
swhks(1) "github.com/id3v1669/swhkd" "General Commands Manual"

# NAME

Expand Down Expand Up @@ -27,8 +27,9 @@ swhks - Server for swhkd, used to run user level commands over IPC.

# AUTHORS

Maintained by Shinyzenith <[email protected]>, EdenQwQ <[email protected]>, and Angelo Fallaria <[email protected]>.
For more information about development, see <https://github.com/waycrate/swhks>.
Created by Shinyzenith <[email protected]>, EdenQwQ <[email protected]>, and Angelo Fallaria <[email protected]>.
Maintained by id3v1669 <[email protected]> as original repo looks unmaintained for now.
For more information about development, see <https://github.com/id3v1669/swhks>.

# SEE ALSO

Expand Down
24 changes: 17 additions & 7 deletions swhkd/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String>,

/// Take a list of devices to ignore from the user
#[arg(short = 'I', long, num_args = 0.., value_delimiter = ' ')]
ignoredevice: Vec<String>,
}

#[tokio::main]
Expand Down Expand Up @@ -118,16 +122,22 @@ async fn main() -> Result<(), Box<dyn Error>> {

let mut modes = load_config();
let mut mode_stack: Vec<usize> = vec![0];
let arg_devices: Vec<String> = 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()
}
};

Expand Down Expand Up @@ -279,8 +289,8 @@ async fn main() -> Result<(), Box<dyn Error>> {
},
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());
Expand Down

0 comments on commit b08c98f

Please sign in to comment.