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

[Feature Request] Command execution #9

Open
pushqrdx opened this issue Oct 3, 2021 · 10 comments
Open

[Feature Request] Command execution #9

pushqrdx opened this issue Oct 3, 2021 · 10 comments

Comments

@pushqrdx
Copy link

pushqrdx commented Oct 3, 2021

I would like to use this as a replacement for xbindkeys but for this, there has to be a way to execute commands, any chance to have this functionality?

@samvel1024
Copy link
Owner

Hi @pushqrdx and thanks for your request.

Have you considered using another alternative for command execution other than xbindkeys. For example, I am using i3wm and it gives command execution capability right out of the box. I believe alternatives should exist for gnome,kde,etc. as well.

@pushqrdx
Copy link
Author

pushqrdx commented Oct 4, 2021

@samvel1024 using the window manager hotkeys means that you run into the issue where media keys don't work if a context menu is open, also media keys steal focus from current window for a split second everytime you press them. however if we handle hotkeys at a level lower than X these issues will not happen

@samvel1024
Copy link
Owner

Hmm, that sounds reasonable.

One possible solution that I use is the following.

Pick a key that you're not going to use (or you don't have on your keyboard). Let's say F13.
Now use KBCT to map any key/keycombo to F13. Use another tool to perform arbitrary command execution on F13.

This is obviously not a clean solution, but I use this in my setup and it more or less works.

@pushqrdx
Copy link
Author

pushqrdx commented Oct 7, 2021

@samvel1024 wouldn't that just result in the same issues with X, a context menu grabs the keyboard so if you are handling keyboard events on X level no shortcuts will work there, also if you handle any events on X level it will steal focus from active window

@samvel1024
Copy link
Owner

Well, as a result KBCT will intercept any of that shortcut that you intended to map to a command, if I understand correctly.

@pushqrdx
Copy link
Author

pushqrdx commented Oct 8, 2021

@samvel1024 yeah this is what i meant by using KBCT as a xbindkeys alternative (which is in your readme already), so i'll be able to create hotkeys that execute commands independent of display server, and side track the issues of handling hotkeys on Xorg level. I can't think of a scenario where i would want KBCT to execute a command AND ALSO pass the keys around, i expect that if for instance i hit VolumeDown and i have that bound in KBCT it will execute amixer set Master 5%- and eat the VolumeDown keyevent

@samvel1024
Copy link
Owner

Yeah, for that very reason this is also in the readme 😃

*However, KBCT is not a tool that can be used to configure macros or arbitrary command execution on a key press. Also note that KBCT requires sudo access.

To be honest, I don't think I see a lot of value in putting efforts towards command execution to kbct. But I will accept a PR if someone wants to work on this feature.

@yunmikun2
Copy link
Contributor

@pushqrdx, another reason why it may be not the best idea, is that when you run something via a tool such a kbct, it will be run as root (for kbct is required to be run as root). It may have some unintended implications, like, when you try to run something session-related from different user (playerctl as example, or anything related to pulseaudio which has a daemon run in user-unit).

There is another project that attempts to do what you want, though.

@pushqrdx
Copy link
Author

pushqrdx commented Oct 11, 2021

@yunmikun2 no i just add my user account to the input group and run as normal user, playerctl works just fine (using hkd) So to be clear i already have a working solution to my problem with hkd, but i thought KBCT would be a bit nicer with added feature of key remapping and allow for hijacking the event instead of passing it through like hkd does

@timcharper
Copy link

If you're on gnome, I recommend the excellent run-or-raise

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants