Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hyper key not working #103

Open
xircon opened this issue Apr 2, 2022 · 13 comments
Open

Hyper key not working #103

xircon opened this issue Apr 2, 2022 · 13 comments
Assignees
Labels
Bug Something isn't working Enhancement New feature or request

Comments

@xircon
Copy link

xircon commented Apr 2, 2022

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 ?

@xircon xircon added the Bug Something isn't working label Apr 2, 2022
@Shinyzenith
Copy link
Member

Hi, thank you for the verbose report. Would you mind expanding on what the hyper key is? I'm not particularly familiar with that.

@xircon
Copy link
Author

xircon commented Apr 3, 2022

It is an additional modifier, so I now have Super, Alt, Control and Hyper. You can use xmodmap to do this on x11, but on wayland I used this:

https://ibnishak.github.io/blog/post/caps-to-hyper/

So in sxhkd you can use:

hyper+d
    <your-command-here>

Press and hold caps lock - press d.

I can define hyper in my sway config and it works:

set $mod3 Mod3
#######################
# Hyper key bindings: #
#######################

    bindsym $mod3+b exec --no-startup-id killall -SIGUSR1 waybar
    bindsym $mod3+n exec swaync-client -t -sw
    bindsym $mod3+s exec ~/.local/bin/grimm
    bindsym $mod3+u exec ~/scripts/ups.sh 

All of which function as expected.

For a full history of additional modifiers, search for space-cadet keyboards on lisp machines (spot the emacs user 😄).

:edit:
To get caps lock, I use:

input type:keyboard {
      		    xkb_layout "gb"
		    xkb_options shift:both_capslock # <<<<<<<<<<<<<<
		    }

Press both shifts to toggle caps lock.

@Shinyzenith
Copy link
Member

OK I will get someone to look into this. I currently can't work on it due to my deteriorating health.

@xircon
Copy link
Author

xircon commented Apr 7, 2022

No problems, I completely understand, I am an old crip, easier and quicker to list what isn't wrong with me 🤣

@simonwiles
Copy link

I was experimenting with migrating from sxhkd, but this is a show-stopper for me. With my existing sxhkd config:

hyper + f
  jumpapp firefox

...

I get:

[2022-08-19T00:09:53Z ERROR swhkd] Config Error: Error parsing config file "/etc/swhkd/swhkdrc". Unknown symbol at line 1.

99% of what I use sxhkd for is mapping commands to hyper combinations, fwiw.

@Shinyzenith
Copy link
Member

patches are always welcome

@Shinyzenith Shinyzenith added the Enhancement New feature or request label Aug 23, 2022
@ajanon
Copy link
Collaborator

ajanon commented Sep 15, 2022

What is the difference between

hyper + f
  jumpapp firefox

and

capslock + f
  jumpapp firefox

in your case? If I understand correctly, this is exactly what you want: map the caps lock physical key to a command (which is what it means for swhkd).

swhkd reads input at a lower level than X11 libraries, so your custom rebind (with xmodmap, setxbkmap or any other) should not impact it in any way. (please correct me if I am wrong @angelofallars @EdenQwQ @Shinyzenith)

I think you should even be able to keep your custom config in X or wayland and both swhkd binds and your custom mappings should work together.

@simonwiles
Copy link

@ajanon -- thank you for the suggestion. With just:

capslock + f
  jumpapp firefox

I just get:

[... ERROR swhkd] Config Error: Error parsing config file "/etc/swhkd/swhkdrc". Invalid modifier at line 1.

This is similar to sxhkd, which why capslock has to be mapped to the hyper modifier first.

@xircon
Copy link
Author

xircon commented Sep 15, 2022

Yup, caps lock is not a "modifier" I get exactly the same. You can however use the hyper modifier in sway, so that is the route I took.

@Shinyzenith
Copy link
Member

swhkd reads input at a lower level than X11 libraries, so your custom rebind

@ajanon You are correct!

@redxtech
Copy link

does that mean that there's no way to get binds with the hyper mod key working in swhkd?

@samsonnagamani
Copy link
Contributor

I found the code to do with the "hyper" mod key, while trying to make the "alt graph" key work. It may be considered a breaking change. I've managed to get it working with the "alt gr" key so I'm assuming it would work with the "hyper" key, however I don't have a keyboard with the "hyper" key.

Also by "hyper" key I'm assuming you mean the "right logo/windows" button found on larger keyboards.

There are 2 main steps to get the hyper key working.

  1. Add "Hyper" in the "Modifier" enum in config.rs
pub enum Modifier {
    Super,
    Hyper,
    Alt,
    Control,
    Shift,
    Any,
}
  1. Map "RIGHTMETA" key to the "Hyper" Modifer enum in the "modifiers_map" hashmap located in daemon.rs
    let modifiers_map: HashMap<Key, config::Modifier> = HashMap::from([
        (Key::KEY_LEFTMETA, config::Modifier::Super),
        (Key::KEY_RIGHTMETA, config::Modifier::Hyper),
        (Key::KEY_LEFTALT, config::Modifier::Alt),
        (Key::KEY_RIGHTALT, config::Modifier::Alt),
        (Key::KEY_LEFTCTRL, config::Modifier::Control),
        (Key::KEY_RIGHTCTRL, config::Modifier::Control),
        (Key::KEY_LEFTSHIFT, config::Modifier::Shift),
        (Key::KEY_RIGHTSHIFT, config::Modifier::Shift),
    ]);

Again, I can't test whether this will work since I don't have that key available on my keyboard

@Shinyzenith
Copy link
Member

@samsonnagamani Thanks for the patch! If anyone can test it and get it working, I'd be more than happy to merge and support this usecase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Enhancement New feature or request
Development

No branches or pull requests

9 participants