Code Monkey home page Code Monkey logo

swhkd's Introduction

SWHKD

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

SWHKD

Simple Wayland HotKey Daemon

swhkd is a display protocol-independent hotkey daemon made in Rust. swhkd uses an easy-to-use configuration system inspired by sxhkd, so you can easily add or remove hotkeys.

It also attempts to be a drop-in replacement for sxhkd, meaning your sxhkd config file is also compatible with swhkd.

Because swhkd can be used anywhere, the same swhkd config can be used across Xorg or Wayland desktops, and you can even use swhkd in a TTY.

Installation and Building

Installation and building instructions can be found here.

Running

swhks &
pkexec swhkd

Runtime signals

After opening swhkd, you can control the program through signals:

  • sudo pkill -USR1 swhkd — Pause key checking
  • sudo pkill -USR2 swhkd — Resume key checking
  • sudo pkill -HUP swhkd — Reload config file

Configuration

swhkd closely follows sxhkd syntax, so most existing sxhkd configs should be functional with swhkd.

The default configuration file is in /etc/swhkd/swhkdrc. If you don't like having to edit the file as root every single time, you can create a symlink from ~/.config/swhkd/swhkdrc to /etc/swhkd/swhkdrc.

If you use Vim, you can get swhkd config syntax highlighting with the swhkd-vim plugin. Install it in vim-plug with Plug 'waycrate/swhkd-vim'.

All supported key and modifier names are listed in man 5 swhkd-keys.

Autostart

To autostart swhkd you can do one of two things

  1. Add the commands from the "Running" section to your window managers configuration file.
  2. Enable the service file for your respective init system. Currently, only systemd and OpenRC service files exist and more will be added soon including Runit.

Security

We use a server-client model to keep you safe. The daemon (swhkd — privileged process) communicates to the server (swhks — running as non-root user) after checking for valid keybindings. Since the daemon is totally separate from the server, no other process can read your keystrokes. As for shell commands, you might be thinking that any program can send shell commands to the server and that's true! But the server runs the commands as the currently logged-in user, so no extra permissions are provided (This is essentially the same as any app on your desktop calling shell commands).

So yes, you're safe!

Support

  1. https://matrix.to/#/#waycrate-tools:matrix.org
  2. https://discord.gg/KKZRDYrRYW

Contributors

Supporters:

  1. @CluelessTechnologist

swhkd's People

Contributors

aadilshabier avatar actualdankcoder avatar ajanon avatar angelofallars avatar concurrentcrab avatar dependabot[bot] avatar edenqwq avatar epetousis avatar eskpil avatar freddylist avatar hipeople68 avatar innocentzero avatar ivandimitrov8080 avatar lavafroth avatar loiccoyle avatar mendess avatar michael-gallo avatar murlakatamenka avatar newtoallofthis123 avatar rv178 avatar samsonnagamani avatar shinyzenith avatar slidinghorn avatar thelastzombie avatar truenaho avatar tsankuanglee avatar ttwno avatar tusharxoxoxo avatar unsignedarduino avatar vainiovano avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swhkd's Issues

Permission error

Version Information:

  • Distribution Information: Linux pop-os 5.4.0-7634-generic #38~1592497129~20.04~9a1ea2e-Ubuntu SMP Fri Jun 19 22:43:37 UTC x86_64 x86_64 x86_64 GNU/Linux
  • swhkd version: swhkd 1.1.7

Describe the bug:

Running:

swhks &
pkexec swhkd

Gives me this error:

[2022-05-05T06:32:00Z TRACE swhks] Reading /tmp/swhks.pid file and checking for running instances.
[2022-05-05T06:32:00Z DEBUG swhks] Previous PID: 29406
[2022-05-05T06:32:00Z TRACE swhks] Sockfile exists, attempting to remove it.
[2022-05-05T06:32:00Z DEBUG swhks] Removed old socket file
[2022-05-05T06:32:00Z ERROR swhkd] Unable to write to /tmp/swhkd.pid: Permission denied (os error 13)

Expected behavior:

It works

To Reproduce:

  1. Download the release libc variant.
  2. Move the binaries to /usr/bin/
  3. Clone the repository.
  4. Run the Makefile's install commands manually

Load multiple config files

Add functionality for loading multiple config files. One approach I've thought is to use use statements at the start of the file, like this:

use "swhkdrc_base"

The path can be relative like the one above or something absolute:

use "~/.config/swhkd/swhkdrc_base"
use "/home/john/.config/qtile/swhkd_qtile"

Getting Config Unknown symbol at line 1. for caps lock

Version Information:

  • Distribution Information Linux 5.16.0-4-amd64 Debian 5.16.12-1 x86_64 GNU/Linux
  • swhkd version 1.1.7

Describe the bug:
I'm unable to bind command for the caps lock key, I've tried the following combinations:

  • caps_lock
  • Caps_Lock
  • capslock
  • CAPSLOCK

Expected behavior:

I expect it to work as it does for xbindkeys, my config for xbindkeys looks as following:

keystate_capslock = enable

<some-command>
  Release + c:66

Actual behavior:

When I run

swhks &
sudo pkexec swhkd -c $HOME/.config//swhkd/swhkdrc &

with swhkdrc:

CAPSLOCK
  "$XDG_CONFIG_BIN/toggle-key-layout"

I get:

Getting Config Unknown symbol at line 1. for caps lock

Additional information:

Seems caps-lock should be supported? I can see the key here:

https://github.com/waycrate/swhkd/blob/main/src/uinput.rs#L78

Update last_hotkey in daemon.rs to use Option<T>

Currently we're using a dummy hotkey to initialize the struct, this is really jank and should be a temporary solution only.

I don't have sufficient knowledge of Option<T>. Someone with the sufficient knowledge can send a patch.

XF86AudioMicMute is not supported

Version Information:

  • Distribution Information ( run uname -a ): Linux think-fedora 5.17.5-300.fc36.x86_64 #1 SMP PREEMPT Thu Apr 28 15:51:30 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
  • swhkd version ( swhkd -V ): 1.1.7

Describe the bug:
XF86AudioMicMute is not supported

Expected behavior:
Key is supported and related action is triggered on keypress.

Actual behavior:
Key is not supported, swhkd throws an error: Config Error: Error parsing config file "/home/user/.config/swhkd/swhkd.common". Unknown symbol at line 35.
Config:

(34) # system: mic toggle
(35) XF86AudioMicMute
(36)    change_volume mute_mic

To Reproduce:
Add XF86AudioMicMute anywhere in the config

Additional information:

[14:     wl_keyboard] key: serial: 938; time: 3552251; key: 198; state: 1 (pressed)
                      sym: XF86AudioMicMute (269025202), utf8: ''
[14:     wl_keyboard] key: serial: 939; time: 3552251; key: 198; state: 0 (released)
                      sym: XF86AudioMicMute (269025202), utf8: ''

Rename swhks to swhkd and current swhkd to swhkc

The name swhks cause confusion and looks like typo. In sxhkd daemon is called sxhkd and IPC is called sxhkc and I think we should follow this naming convention to stop general confusion especially for people which are coming from sxhkd.

Keypresses are send to focussed client in sway

Version Information:
Running arch linux, swhkd version 1.1.0 and sway version 1.7

Describe the bug:
When doing setup keybinds, e.g. super + p, the 'p' still gets send to the focused client. I have not tested another compositor yet.

Expected behavior:
Keybinds are captured by swhkd and only send to client when swhkd has not 'consumed' them

Actual behavior:
See above

To Reproduce:
Set up keybinds in swhkd;
Run swhkd;
Run alacritty and set focus to it;
Press one of the keybinds set up in swhkd;

Scroll_Lock key is not supported

Version Information:
Linux logic 5.17.5-arch1-1 #1 SMP PREEMPT Wed, 27 Apr 2022 20:56:11 +0000 x86_64 GNU/Linux
swhkd 1.1.7

Describe the bug:
Scroll_Lock key is not supported

Expected behavior:
swhkd do somthing when Scroll_Lock key is pressed

Actual behavior:
swhkd output

Config Error: Error parsing config file "/etc/swhkd/swhkdrc". Unknown symbol at line 29.

then exit

To Reproduce:
add Scroll_Lock key to your config

Grab keys so they don't go to a focused application

what i meant is that with sxhkd the keybindings conflict
and sxhkd is given the preference (i think that's how you spell it)
so if i press alt + a when i'm focused on pcmanfm
the keybinding will work on sxhkd but not pcmanfm

Discord message

Somehow we should provide an option to swallow keys so that they don't go to a focused application / the tty.

Hyper key not working

Version Information:
Linux xircon-legion 5.17.1-zen1-1-zen #1 ZEN SMP PREEMPT Mon, 28 Mar 2022 21:56:46 +0000 x86_64 GNU/Linux

swhkd 1.1.7

Describe the bug:
Cannot set hyper as a modifier.

Expected behavior:
Have redefined caps to be a hyper modifier, works in sxhkd.

Actual behavior:
Causes swhkd to not load.

To Reproduce:
add a shorcut e.g. hyper+d

Additional information:
Anything else you'd like us to know ?

Chords do not work

Version Information:

  • Distribution Information ( run uname -a )
    Linux xircon-w6567sz 5.16.16-zen1-1-zen #1 ZEN SMP PREEMPT Mon, 21 Mar 2022 22:59:42 +0000 x86_64 GNU/Linux
  • swhkd version ( swhkd -V )
    swhkd 1.1.7

Describe the bug:
Chords not working

super + n:  {n,p,d,x}
    {variety -n, variety -p, variety -t, variety --pause && notify-send Paused} 
[2022-03-28T13:43:13Z ERROR swhkd] Config Error: Error parsing config file "/etc/swhkd/swhkdrc". Unknown symbol at line 11.

Expected behavior:
Should work as it does in sxhkd.

Actual behavior:
See error swhkd does not load.

`any +` should be ignored when parsing config file

Version Information:

  • Distribution Information Linux logic 5.17.8-arch1-1 #1 SMP PREEMPT Mon, 16 May 2022 20:45:27 +0000 x86_64 GNU/Linux
  • swhkd version swhkd 1.2.0

Describe the bug:
in sxhkd you can do

any + F9
    /path/to/bin

and it gonna be treated as

F9
    /path/to/bin

but swhkd doesn't do that

Expected behavior:
swhkd to ignore any + when parsing config file and to treat any + F9 as F9

Actual behavior:
swhkd print

[2022-05-22T20:00:05Z ERROR swhkd] Config Error: Error parsing config file "/etc/swhkd/swhkdrc". Unknown symbol at line 2.

then exit

To Reproduce:

  1. add any + to a hot key in your config file
  2. reload swhkd config

Additional information:
see man sxhkd to know other modifiers that sxhkd support instead of waiting people to report them one by one

Better keyboard device detection for key support should be done.

Version Information:

  • Linux laptop 5.17.8-arch1-1 #1 SMP PREEMPT Mon, 16 May 2022 20:45:27 +0000 x86_64 GNU/Linux
  • swhkd 1.2.0

Describe the bug:
XF86Display, XF86Launch1 keys are not unsupported

Expected behavior:
XF86Display, XF86Launch1 keys are supported

Actual behavior:

Config Error: Error parsing config file "/home/dith/.config/swhkd/swhkdrc". Unknown symbol at line 91.
Config Error: Error parsing config file "/home/dith/.config/swhkd/swhkdrc". Unknown symbol at line 94.

Lines 91-95:

XF86Display
	xset dpms force suspend

XF86Launch1
	xset dpms force suspend

To Reproduce:
Use XF86Display or XF86Launch1 key in config.

Additional information:
From imported sxhkd config.

Upstream bug/breaking change shown after removing Cargo.lock

Version Information:

  • Distribution Information: OpenSUSE TumbleWeed
    • Linux sentient-slate.bbrouter 5.16.11-1-default #1 SMP PREEMPT Thu Feb 24 05:07:05 UTC 2022 (90630c5) x86_64 x86_64 x86_64 GNU/Linux
  • swhkd version: at commit hash ed4b266b1000099150ba00e0b552f54a1c86f658

Describe the bug:
As what rust has suggested in https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html, removing Cargo.lock is required if creating an executable. However, because we didn't remove it, we have found ourselves in deep water. uwu

Expected behavior:
This should build correctly. Even with cargo install and cargo build

Actual behavior:
Build fails:

   Compiling evdev v0.11.5
   Compiling Simple-Wayland-HotKey-Daemon v1.1.4 (/home/uncomfy/Projects/swhkd)
error[E0631]: type mismatch in function arguments
   --> src/daemon.rs:111:67
    |
111 |     let keyboard_devices: Vec<Device> = evdev::enumerate().filter(check_keyboard).collect();
    |                                                            ------ ^^^^^^^^^^^^^^ expected signature of `for<'r> fn(&'r (PathBuf, Device)) -> _`
    |                                                            |
    |                                                            required by a bound introduced by this call
...
312 | pub fn check_keyboard(device: &Device) -> bool {
    | ---------------------------------------------- found signature of `for<'r> fn(&'r Device) -> _`
    |
note: required by a bound in `std::iter::Iterator::filter`

error[E0599]: the method `collect` exists for struct `std::iter::Filter<evdev::EnumerateDevices, for<'r> fn(&'r Device) -> bool {check_keyboard}>`, but its trait bounds were not satisfied
   --> src/daemon.rs:111:83
    |
111 |       let keyboard_devices: Vec<Device> = evdev::enumerate().filter(check_keyboard).collect();
    |                                                                                     ^^^^^^^ method cannot be called on `std::iter::Filter<evdev::EnumerateDevices, for<'r> fn(&'r Device) -> bool {check_keyboard}>` due to unsatisfied trait bounds
    |
    = note: the following trait bounds were not satisfied:
            `std::iter::Filter<evdev::EnumerateDevices, for<'r> fn(&'r Device) -> bool {check_keyboard}>: tokio_stream::Stream`
            which is required by `std::iter::Filter<evdev::EnumerateDevices, for<'r> fn(&'r Device) -> bool {check_keyboard}>: StreamExt`
            `<for<'r> fn(&'r Device) -> bool {check_keyboard} as FnOnce<(&(PathBuf, Device),)>>::Output = bool`
            which is required by `std::iter::Filter<evdev::EnumerateDevices, for<'r> fn(&'r Device) -> bool {check_keyboard}>: Iterator`
            `for<'r> fn(&'r Device) -> bool {check_keyboard}: FnMut<(&(PathBuf, Device),)>`
            which is required by `std::iter::Filter<evdev::EnumerateDevices, for<'r> fn(&'r Device) -> bool {check_keyboard}>: Iterator`
            `&std::iter::Filter<evdev::EnumerateDevices, for<'r> fn(&'r Device) -> bool {check_keyboard}>: tokio_stream::Stream`
            which is required by `&std::iter::Filter<evdev::EnumerateDevices, for<'r> fn(&'r Device) -> bool {check_keyboard}>: StreamExt`
            `&mut std::iter::Filter<evdev::EnumerateDevices, for<'r> fn(&'r Device) -> bool {check_keyboard}>: tokio_stream::Stream`
            which is required by `&mut std::iter::Filter<evdev::EnumerateDevices, for<'r> fn(&'r Device) -> bool {check_keyboard}>: StreamExt`
            `std::iter::Filter<evdev::EnumerateDevices, for<'r> fn(&'r Device) -> bool {check_keyboard}>: Iterator`
            which is required by `&mut std::iter::Filter<evdev::EnumerateDevices, for<'r> fn(&'r Device) -> bool {check_keyboard}>: Iterator`

error[E0631]: type mismatch in function arguments
   --> src/daemon.rs:185:74
    |
185 |                         let keyboard_devices = evdev::enumerate().filter(check_keyboard);
    |                                                                   ------ ^^^^^^^^^^^^^^ expected signature of `for<'r> fn(&'r (PathBuf, Device)) -> _`
    |                                                                   |
    |                                                                   required by a bound introduced by this call
...
312 | pub fn check_keyboard(device: &Device) -> bool {
    | ---------------------------------------------- found signature of `for<'r> fn(&'r Device) -> _`
    |
note: required by a bound in `std::iter::Iterator::filter`

error[E0631]: type mismatch in function arguments
   --> src/daemon.rs:186:43
    |
186 |                         for mut device in keyboard_devices {
    |                                           ^^^^^^^^^^^^^^^^ expected signature of `for<'r> fn(&'r (PathBuf, Device)) -> _`
...
312 | pub fn check_keyboard(device: &Device) -> bool {
    | ---------------------------------------------- found signature of `for<'r> fn(&'r Device) -> _`
    |
    = note: required because of the requirements on the impl of `Iterator` for `std::iter::Filter<evdev::EnumerateDevices, for<'r> fn(&'r Device) -> bool {check_keyboard}>`
    = note: required because of the requirements on the impl of `IntoIterator` for `std::iter::Filter<evdev::EnumerateDevices, for<'r> fn(&'r Device) -> bool {check_keyboard}>`

error[E0599]: no method named `ungrab` found for tuple `(PathBuf, Device)` in the current scope
   --> src/daemon.rs:187:45
    |
187 | ...                   let _ = &device.ungrab();
    |                                       ^^^^^^ method not found in `(PathBuf, Device)`

error[E0631]: type mismatch in function arguments
   --> src/daemon.rs:192:74
    |
192 |                         let keyboard_devices = evdev::enumerate().filter(check_keyboard);
    |                                                                   ------ ^^^^^^^^^^^^^^ expected signature of `for<'r> fn(&'r (PathBuf, Device)) -> _`
    |                                                                   |
    |                                                                   required by a bound introduced by this call
...
312 | pub fn check_keyboard(device: &Device) -> bool {
    | ---------------------------------------------- found signature of `for<'r> fn(&'r Device) -> _`
    |
note: required by a bound in `std::iter::Iterator::filter`

error[E0631]: type mismatch in function arguments
   --> src/daemon.rs:193:43
    |
193 |                         for mut device in keyboard_devices {
    |                                           ^^^^^^^^^^^^^^^^ expected signature of `for<'r> fn(&'r (PathBuf, Device)) -> _`
...
312 | pub fn check_keyboard(device: &Device) -> bool {
    | ---------------------------------------------- found signature of `for<'r> fn(&'r Device) -> _`
    |
    = note: required because of the requirements on the impl of `Iterator` for `std::iter::Filter<evdev::EnumerateDevices, for<'r> fn(&'r Device) -> bool {check_keyboard}>`
    = note: required because of the requirements on the impl of `IntoIterator` for `std::iter::Filter<evdev::EnumerateDevices, for<'r> fn(&'r Device) -> bool {check_keyboard}>`

error[E0599]: no method named `grab` found for tuple `(PathBuf, Device)` in the current scope
   --> src/daemon.rs:194:45
    |
194 | ...                   let _ = &device.grab();
    |                                       ^^^^ method not found in `(PathBuf, Device)`

error[E0631]: type mismatch in function arguments
   --> src/daemon.rs:205:74
    |
205 |                         let keyboard_devices = evdev::enumerate().filter(check_keyboard);
    |                                                                   ------ ^^^^^^^^^^^^^^ expected signature of `for<'r> fn(&'r (PathBuf, Device)) -> _`
    |                                                                   |
    |                                                                   required by a bound introduced by this call
...
312 | pub fn check_keyboard(device: &Device) -> bool {
    | ---------------------------------------------- found signature of `for<'r> fn(&'r Device) -> _`
    |
note: required by a bound in `std::iter::Iterator::filter`

error[E0631]: type mismatch in function arguments
   --> src/daemon.rs:206:43
    |
206 |                         for mut device in keyboard_devices {
    |                                           ^^^^^^^^^^^^^^^^ expected signature of `for<'r> fn(&'r (PathBuf, Device)) -> _`
...
312 | pub fn check_keyboard(device: &Device) -> bool {
    | ---------------------------------------------- found signature of `for<'r> fn(&'r Device) -> _`
    |
    = note: required because of the requirements on the impl of `Iterator` for `std::iter::Filter<evdev::EnumerateDevices, for<'r> fn(&'r Device) -> bool {check_keyboard}>`
    = note: required because of the requirements on the impl of `IntoIterator` for `std::iter::Filter<evdev::EnumerateDevices, for<'r> fn(&'r Device) -> bool {check_keyboard}>`

error[E0599]: no method named `ungrab` found for tuple `(PathBuf, Device)` in the current scope
   --> src/daemon.rs:207:45
    |
207 | ...                   let _ = &device.ungrab();
    |                                       ^^^^^^ method not found in `(PathBuf, Device)`

Some errors have detailed explanations: E0599, E0631.
For more information about an error, try `rustc --explain E0599`.
error: could not compile `Simple-Wayland-HotKey-Daemon` due to 11 previous errors
warning: build failed, waiting for other jobs to finish...
error: build failed

To Reproduce:
Remove Cargo.lock, then run cargo build --release

Additional information:
UWU

keyboard rates on X11 are changed

Version Information:

  • uname -a :
    Linux FrameWork 5.16.12-arch1-1 #1 SMP PREEMPT Wed, 02 Mar 2022 12:22:51 +0000 x86_64 GNU/Linux
  • swhkd -V :
    swhkd 1.1.2

Describe the bug:
When on X11, the keyboard's delay and repeat rates are not respected. They get set to delay: 660 and repeat: 25.

Expected behavior:
For the keyboard rates to remain unchanged.

Actual behavior:
Keyboard rates are changed to 660 25.

To Reproduce:

$ xset r rate 300 50
$ swhks &
$ pkexec swhkd -c ~/.config/swhkd/swhkdrc
$ xset q
...
  auto repeat delay:  660    repeat rate:  25
...

swhkd doesn't start: Os Error, Function not implemented

Version Information:

  • Distribution Information ( run uname -a ):
    Linux FrameWork 5.16.11-arch1-1 #1 SMP PREEMPT Thu, 24 Feb 2022 02:18:20 +0000 x86_64 GNU/Linux
  • swhkd version ( swhkd -V )
    swhkd 1.0.0

Describe the bug:
I installed from the AUR (swhkd-git), when I try to run start the daemon I get the following error msg:

$ swhks &
$ pkexec swhkd -c ~/.config/swhkd/swhkdrc
[2022-03-02T00:49:56Z WARN  swhkd] Running swhkd as root!
Error: Os { code: 38, kind: Unsupported, message: "Function not implemented" }

Expected behavior:
The daemon to start succefully.

Actual behavior:
Daemon doesn't start and crashes.

To Reproduce:

$ paru -S swhkd
$ swhks &
$ pkexec swhkd -c ~/.config/swhkd/swhkdrc

I also tried installing straight from the github:

$ git clone https://github.com/waycrate/swhkd
$ cd swhkd
$ git rev-parse HEAD
3986dd01a31c168e91a3de038911745293dfa574
$ make setup
$ make glibc
$ sudo make install

But the same crash happens.

Configuration rules with a modifier + MEDIA_KEY not working

Version Information:
Linux fedora 5.17.12-300.fc36.x86_64 #1 SMP PREEMPT Mon May 30 16:56:53 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

swhkd 1.2.0

Describe the bug:
Rules with a combination of a modifier(ctrl,super,shift) with media keys are not working. Rules with only the media keys are working.

Expected behavior:
Rules running as expected

Actual behavior:
Nothing happens.

To Reproduce:
Define this rules in your configuration file and restart swhkd:

# works
ctrl + return
  kgx

# works
xf86audiolowervolume
  sh -c 'ydotool key 29:1 12:1 12:0 29:0'

# not working
ctrl + xf86audiolowervolume
  sh -c 'ydotool key 29:1 12:1 12:0 29:0'

# works
XF86AudioPlay
  firefox

# not working
super + shift + XF86AudioPlay
  kgx

Additional information:

Use ~/.config/swhkd/swhkd as first default config path

We can get the invoking user's name from the PKEXEC_UID like this:

nix::unistd::User::from_uid(Uid::from_raw(invoking_uid)).unwrap().unwrap().name

From there, we can then read the user's home directory with the user's name.

config.rs todo

  • convert keychord to lowercase and then parse from hashmap.
  • Ignore duplicates.
  • Add multiple keysym support ( vector ).
  • Return evdev::Key:: object in hotkey struct.

Issue with mapping commas

Version Information:

  • Linux archlinux 5.16.2-arch1-1 #1 SMP PREEMPT Thu, 20 Jan 2022 16:18:29 +0000 x86_64 GNU/Linux
  • swhkd 1.0.0

Describe the bug:

I'm trying to map commas and having some problems. The map I'm trying to write is:

super + {comma, period}
	riverctl focus-output {previous, next}

But this won't work because swhkd appears to use the ascii character (",") instead of the keysym name ("comma") in mappings, which is fine, except:

super + {,, .}
	riverctl focus-output {previous, next}

Produces the error "[2022-02-27T17:32:13Z ERROR swhkd] Config Error: Unknown symbol at line 25" which is obvious given that {,,.} is clearly a syntax error.

However, I can't find a way to escape a comma inside curly braces.

Expected behavior:

I should be able to map commas using the keysym name or have a way to map them inside braces.

Actual behavior:

Launching swhkd with either of the above mappings will produce an error.

Additional information:

Fwiw, the first rule (super + {comma, period}) works in SXHKD.

Todo: `@` and `~`

In sxhkd man page:

If @ is added at the beginning of the keysym, the command will be run on key release events, otherwise on key press events.

If ~ is added at the beginning of the keysym, the captured event will be replayed for the other clients.

In the config_devel branch, we've already implemented checking for those prefixes.
As you can see in the struct KeyBinding, there are two bool items send and on_release.
Calling .is_send() or is_on_release() method on struct KeyBinding or Hotkey returns the value respectively.

Need help to actually implement this feature to daemon.rs

brightness keys are not detected

Expected behavior:
Brightness keys are detected and respond to keybinds.

Actual behavior:
Brightness keys are not detected.

To Reproduce:
set keybinds with xf86brightnessup

Duplicate lines

2 lines are duplicate in daemon.rs at 173
Is this because some function wont work until you duplicate the first 2 items, or its just a typo?
image

Mouse cursor doesn't work

Version Information:

  • Linux yarikus-pc 5.18.3-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 09 Jun 2022 16:14:10 +0000 x86_64 GNU/Linux
  • swhkd 1.2.0

Describe the bug:
A mouse cursor doesn't work after start daemon.

Expected behavior:
I can use my mouse cursor as before.

Actual behavior:
A mouse cursor doesn't response.

To Reproduce:
swhks & pkexec swhkd

Additional information:

[yarikus@yarikus-pc ~]$ swhks & pkexec swhkd
[2] 9913
[2022-06-14T10:09:47Z TRACE swhks] Setting process umask.
[2022-06-14T10:09:47Z INFO  swhks] XDG_RUNTIME_DIR Variable is present, using it's value as default file path.
[2022-06-14T10:09:47Z TRACE swhks] Reading /run/user/1000/swhks.pid file and checking for running instances.
[2022-06-14T10:09:47Z DEBUG swhks] Previous PID: 9025
[2022-06-14T10:09:47Z ERROR swhkd] XDG_RUNTIME_DIR has not been set.
[2022-06-14T10:09:48Z WARN  swhkd] Running swhkd as root!
[2022-06-14T10:09:48Z ERROR swhkd] XDG_CONFIG_HOME has not been set.
[2022-06-14T10:09:48Z ERROR swhks] Server is already running!
[2022-06-14T10:09:49Z ERROR swhkd] XDG_RUNTIME_DIR has not been set.

if statements not working

Version Information:

  • uname -a :
    Linux FrameWork 5.16.12-arch1-1 #1 SMP PREEMPT Wed, 02 Mar 2022 12:22:51 +0000 x86_64 GNU/Linux
  • swhkd -V :
    swhkd 1.1.2

Describe the bug:
Commands with if statements don't run.

Expected behavior:
Command with if statements to work, like with sxhkd.

Actual behavior:
Commands don't run.

To Reproduce:

super+u
    dest="0";\
    [ "$dest" = "0" ] && notify-send "yay";
super+i
    dest="0";\
    if [ "$dest" = "0" ]; then; notify-send "yay"; fi;

With the above swhkdrc, super + u works but super + i doesn't. Both work with sxhkd.

modal feature missing?

Version Information:

  • linux 5.16.11-arch1-2
  • swhkd 1.1.0

Describe the bug:
sxhkd has the modal feature, e.g. (example from https://github.com/baskerville/sxhkd/blob/master/README.md )

super + o ; {e,w,m}
	{gvim,firefox,thunderbird}

swhkd doesn't seem to recognize the semicolor ;. Is this implemented yet?

Expected behavior:
Drop in replacement for sxhkd.

Actual behavior:
semicolon ; causes error.

To Reproduce:
same as above

super + o ; {e,w,m}
	{gvim,firefox,thunderbird}

Additional information:
Great project! Thank you!

dont let build.rs call an installation script

This makes it not flexible when doing installations for packaging this software.

use std::env;
use std::path::Path;
use std::process::Command;

fn main() {
    println!("cargo:rerun-if-changed=build.rs");
    let src_dir = env::var_os("CARGO_MANIFEST_DIR").unwrap();
    let src_dir = Path::new(&src_dir);
    Command::new("sh").arg("-c").arg("./install.sh").current_dir(src_dir).spawn().unwrap();  // <- remove this
}

PS: I mentioned in Discord that I talk to my friend and that using Makefile is fine and build.rs is for linking libraries or modifying build behaviour

cargo package / crates io?

Describe the bug:

Can see here a cargo.toml file in the root folder of this repo / the main project repo. However cannot seem to just cargo install ... the software like other rust packages. So is this something planned for the future?

Have tried the following on the cmdline:

⏚ θ127° [id:~/.bin] $ cargo install Swhkd
    Updating crates.io index
error: could not find `Swhkd` in registry `crates-io` with version `*`
⏚ θ127° [id:~/.bin] 101 $ cargo install swhkd
    Updating crates.io index
error: could not find `swhkd` in registry `crates-io` with version `*`
⏚ θ127° [id:~/.bin] 101 $ cargo install swhkd-git
    Updating crates.io index
error: could not find `swhkd-git` in registry `crates-io` with version `*`
⏚ θ127° [id:~/.bin] 101 $ cargo install swhkd-musl-git
    Updating crates.io index
error: could not find `swhkd-musl-git` in registry `crates-io` with version `*`
⏚ θ127° [id:~/.bin] 101 $ cargo install swhkd-bin
    Updating crates.io index
error: could not find `swhkd-bin` in registry `crates-io` with version `*`
⏚ θ127° [id:~/.bin] 101 $ cargo install swhkd-musl-bin
    Updating crates.io index
error: could not find `swhkd-musl-bin` in registry `crates-io` with version `*`
⏚ θ127° [id:~/.bin] 101 $ cargo install swhks
    Updating crates.io index
error: could not find `swhks` in registry `crates-io` with version `*`
⏚ θ127° [id:~/.bin] 101 $ 

Additional information:
Anything else you'd like us to know ?

[bug] swallow on removal.

If we set a keybind such as super + p to some shell command, start swhkd, remove the command from config file, and then send SIGHUP then swhkd still swallows super + p instead of sending p to focused application.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.