Skip to content

feat: Add global shortcuts - #326

Closed
tuxinal wants to merge 37 commits into
Vencord:mainfrom
tuxinal:main
Closed

feat: Add global shortcuts#326
tuxinal wants to merge 37 commits into
Vencord:mainfrom
tuxinal:main

Conversation

@tuxinal

@tuxinal tuxinal commented Jan 7, 2024

Copy link
Copy Markdown

i'm using electron's globalShortcuts api here which doesn't have a way to detect tell the difference between keyup and keydown. this means the push to talk/mute/deafen/etc actions don't really work. we'd probably have to switch to something else at some point
currently implementing venbind to use instead of electron's api

resolves #18

Comment thread src/renderer/patches/keybinds.ts Outdated
Comment thread src/renderer/patches/keybinds.ts Outdated
@tuxinal tuxinal changed the title Add global shortcuts feat: Add global shortcuts Jan 7, 2024
@tuxinal

tuxinal commented Jan 7, 2024

Copy link
Copy Markdown
Author

Okay so electron's globalShortcuts api is not at all a good fit for this. the keyup/keydown events are rather crucial for discord's functionality. and also it "consumes" inputs (i have no idea what the correct term for this is. basically if you set anything as a keybind nothing else can use it, for example if you have the tab key as push to talk tab won't do anything everywhere else).

@Vendicated

Copy link
Copy Markdown
Member

yes. as mentioned in the issue you linked and as discussed on discord, using a native library would be better. however all the current options don't seem to support wayland at all, so we will most likely have to write our own module

@D3SOX D3SOX mentioned this pull request Feb 1, 2024
@tuxinal
tuxinal force-pushed the main branch 2 times, most recently from 02803f0 to 8d3196c Compare March 8, 2024 22:05
@tuxinal tuxinal mentioned this pull request Apr 12, 2024
@klhrt

klhrt commented May 31, 2024

Copy link
Copy Markdown

Could you do a quick write-up of how this works? E.g. is vesktop --keybind 2 supposed to execute the keybind of id 2 set inside the app, or is the cli used to attach a bind to a key? It's pretty difficult for me to parse the code to figure out how to use it.

@tuxinal

tuxinal commented Jun 1, 2024

Copy link
Copy Markdown
Author

when you make a new keybind in discord asigns it an id. currently i have the id for each keybind written next to the keybind in the client.
you can use this id in the cli as: (vesktop) -- --keybind (id) (mind the two sets of dashes)
or if it's ptt you can add a keyup/keydown thing at the end of it.

Comment thread src/renderer/patches/keybinds.ts Outdated
@klhrt

klhrt commented Jul 3, 2024

Copy link
Copy Markdown

this doesn't seem to work on my setup on ubuntu with i3+x11, unless I still don't get how to use it. not sure if it's just not compatible with my setup or i'm just stupid, but if it doesn't work due to a window manager or display server problem it's something to look into.

if i set a toggle mute keybind with an arbitrary key and it gets assigned an id of 3, running vesktop --keybind 3 doesn't toggle mute.

@tuxinal

tuxinal commented Jul 4, 2024

Copy link
Copy Markdown
Author

an update seems to have borked it
you'll have to wait until i figure out how to fix it

@tuxinal

tuxinal commented Jul 15, 2024

Copy link
Copy Markdown
Author

@klhrt try this commit

@klhrt

klhrt commented Jul 15, 2024

Copy link
Copy Markdown
UnhandledPromiseRejectionWarning: Error: Script failed to execute, this normally means an error was thrown. Check the renderer console for the error.
    at node:electron/js2c/renderer_init:2:16470
    at IpcRendererInternal.<anonymous> (node:electron/js2c/renderer_init:2:10723)
    at IpcRendererInternal.emit (node:events:519:28)
    at Object.onMessage (node:electron/js2c/renderer_init:2:8837)
(node:1605447) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 33)

Whenever I run the keybind command, no response in-app and this error pops up. Not sure if the error is responsible/related though. I also don't know if it was happening in the earlier commit as I wasn't running vesktop from a terminal window.

for reference this is the resulting printout from the terminal where i run the keybind command:

~> vesktop --keybind 2
Checking for beta autoupdate feature for deb/rpm distributions
Found package-type: deb
Checking for update
~>

@Covkie

Covkie commented Jul 15, 2024

Copy link
Copy Markdown
Collaborator

@klhrt ATM the command is vesktop -- --keybind id 🥴

@klhrt

klhrt commented Jul 15, 2024

Copy link
Copy Markdown

@klhrt ATM the command is vesktop -- --keybind id 🥴

and it works! thanks

@tuxinal

tuxinal commented Aug 18, 2024

Copy link
Copy Markdown
Author

it would be nice if someone could test this commit on their system. the binary is technically built on nix and idk if that affects anything

@Covkie

Covkie commented Aug 18, 2024

Copy link
Copy Markdown
Collaborator

Can confirm X11 works! (Arch here)

@rbutera

rbutera commented Aug 27, 2024

Copy link
Copy Markdown

anyone know how hard it would be to get this to work on Hyprland?

@tuxinal

tuxinal commented Aug 27, 2024

Copy link
Copy Markdown
Author

you'd have to implement xdg-desktop-portal's GlobalShortucts api for hyprland on their portal implementation (which they might have implemented already i'm not sure)
i'm working on the wayland side of things as of right now and it's proving somewhat difficult. no one really has a complete implementation of GlobalShortcuts

@condmaker

Copy link
Copy Markdown

Doesn't appear to be working on Hyprland or wayland in general. I can't even start the instance. Here's the full stack trace if that helps:

thread '<unnamed>' panicked at src/lib.rs:16:44:
called `Result::unwrap()` on an `Err` value: Message("todo")
stack backtrace:
   0:     0x7e1f3eae23d5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3692694645b1bb6a
   1:     0x7e1f3eb0661b - core::fmt::write::h5131d80b4c69b88d
   2:     0x7e1f3eadff8f - std::io::Write::write_fmt::h1fb327a7d8b0eb36
   3:     0x7e1f3eae21ae - std::sys_common::backtrace::print::h998d75b840f75a73
   4:     0x7e1f3eae36f9 - std::panicking::default_hook::{{closure}}::h18ec7fe6a38b9da0
   5:     0x7e1f3eae349a - std::panicking::default_hook::hfb3f22c2e4075a6a
   6:     0x7e1f3eae3b93 - std::panicking::rust_panic_with_hook::h51af00bcb4660c4e
   7:     0x7e1f3eae3a74 - std::panicking::begin_panic_handler::{{closure}}::h39f76aa863fbe8ce
   8:     0x7e1f3eae2899 - std::sys_common::backtrace::__rust_end_short_backtrace::h4d10fc2251b89840
   9:     0x7e1f3eae37a7 - rust_begin_unwind
  10:     0x7e1f3e9cea13 - core::panicking::panic_fmt::h319840fcbcd912ef
  11:     0x7e1f3e9ceea6 - core::result::unwrap_failed::haccb9aaa604e1e21
  12:     0x7e1f3e9dfa8c - std::sys_common::backtrace::__rust_begin_short_backtrace::hfc2e22cd1f52e7a4
  13:     0x7e1f3e9dd1ff - core::ops::function::FnOnce::call_once{{vtable.shim}}::h3001236f03d016af
  14:     0x7e1f3eae5ecb - std::sys::pal::unix::thread::Thread::new::thread_start::h3b8e81128811868f
  15:     0x7e1fd0c4439d - <unknown>
  16:     0x7e1fd0cc949c - <unknown>
  17:                0x0 - <unknown>
[arRPC > ipc] listening at /run/user/1000/discord-ipc-0
[arRPC > websocket] listening on 6463
[arRPC > process] started
thread '<unnamed>' panicked at src/lib.rs:20:44:
called `Result::unwrap()` on an `Err` value: Message("todo")
stack backtrace:
   0:     0x7e1f3eae23d5 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h3692694645b1bb6a
   1:     0x7e1f3eb0661b - core::fmt::write::h5131d80b4c69b88d
   2:     0x7e1f3eadff8f - std::io::Write::write_fmt::h1fb327a7d8b0eb36
   3:     0x7e1f3eae21ae - std::sys_common::backtrace::print::h998d75b840f75a73
   4:     0x7e1f3eae36f9 - std::panicking::default_hook::{{closure}}::h18ec7fe6a38b9da0
   5:     0x7e1f3eae349a - std::panicking::default_hook::hfb3f22c2e4075a6a
   6:     0x7e1f3eae3b93 - std::panicking::rust_panic_with_hook::h51af00bcb4660c4e
   7:     0x7e1f3eae3a74 - std::panicking::begin_panic_handler::{{closure}}::h39f76aa863fbe8ce
   8:     0x7e1f3eae2899 - std::sys_common::backtrace::__rust_end_short_backtrace::h4d10fc2251b89840
   9:     0x7e1f3eae37a7 - rust_begin_unwind
  10:     0x7e1f3e9cea13 - core::panicking::panic_fmt::h319840fcbcd912ef
  11:     0x7e1f3e9ceea6 - core::result::unwrap_failed::haccb9aaa604e1e21
  12:     0x7e1f3e9d82bc - venbind::js::napi_register_keybind::hee504851f7cfee42
  13:     0x5c87ef3a456c - <unknown>
fatal runtime error: failed to initiate panic, error 5
[1]    79116 IOT instruction (core dumped)  RUST_BACKTRACE=full ./vesktop

@lillithrosepup

Copy link
Copy Markdown

Doesn't appear to be working on Hyprland or wayland in general. I can't even start the instance. Here's the full stack trace if that helps:
looks like venbind isnt setup for wayland yet, id just wait
https://github.com/tuxinal/venbind/blob/885e0dd7658bb2e25f1ad45f8d6581b0e330febb/src/linux.rs#L30

@tuxinal

tuxinal commented Aug 27, 2024

Copy link
Copy Markdown
Author

oh none of the wayland support stuff is pushed yet. currently venbind only supports linux x11

@OrHy3

OrHy3 commented Nov 26, 2024

Copy link
Copy Markdown

Over the weekend I started writing a C library (based on libdbus) to ease interactions with XDG GlobalShortcuts. The said library is libgsbus, it's in a very basic release state, but it's complete.
As of now it lacks documentation and a build system, but it's a single source-header files pair, the latter being commented. The project should now be ready.

If anyone is willing to test it around, it'll be greatly appreciated.

@checkraisefold

checkraisefold commented Jan 9, 2025

Copy link
Copy Markdown

As an update for anyone with the PR watched: further work on Venbind has begun to support Windows and Wayland (through xdg-desktop-portal DBus), and is underway.
See tuxinal/venbind#2, tuxinal/venbind#1

@checkraisefold

Copy link
Copy Markdown

An alternative to XDP if at all possible may need to be explored at some point for Venbind considering there is currently 3 different (2 confirmed) bugs blocking global shortcuts in KDE and Hyprland, which afaik are the only two actually usable global shortcuts XDP implementations

hyprwm/xdg-desktop-portal-hyprland#310
https://bugs.kde.org/show_bug.cgi?id=492992

@Ilwyd

Ilwyd commented Oct 30, 2025

Copy link
Copy Markdown

I've been trying to test this out but feel like I'm missing a step somewhere. Every time I launch this and check the keybinds tab in settings I see this:
image

On x11. Am I missing something?

@nixRidge

nixRidge commented Nov 1, 2025

Copy link
Copy Markdown

@Ilwyd

Am I missing something?

You might be, that's normal to see in the settings. The plugin registers the global shortcuts through your desktop environment.
As an example, this is where you'd find those settings on KDE Plasma.
bilde

@jacklollz2

Copy link
Copy Markdown

+1, looking for the keybind

@cyentw

cyentw commented Nov 21, 2025

Copy link
Copy Markdown

Clearly I'm missing something. How do you register hotkeys in Windows 11 settings?

@SIGSTACKFAULT

Copy link
Copy Markdown

Clearly I'm missing something. How do you register hotkeys in Windows 11 settings?

you don't, that concept is a linux thing. try just binding to something in discord and see if that works.

@SIGSTACKFAULT

Copy link
Copy Markdown

On x11. Am I missing something?

last time i tried this on x11 by accident it didn't work. and i don't think OP has changed anything since then

@ZeroKun265

Copy link
Copy Markdown

i don't really understand if this currently works on wayland or not? venbind says it supports wayland now but maybe support needs to be added here too?

@tuxinal

tuxinal commented Dec 9, 2025

Copy link
Copy Markdown
Author

Hello. this pull request will not currently work with discord as some of its patches are outdated and need to be fixed.
the lack of contribution is due to vesktop maintainers seemingly having no interest in actually merging this pr. i personally don't want to bother keeping things up to date if no one actually wants to merge anything or review any of the code (heck some even go as far as pretending this doesn't exist at all)

@Lonsfor

Lonsfor commented Dec 10, 2025

Copy link
Copy Markdown

hearing that they arent interested in merging is actually insane to me

@jacklollz2

Copy link
Copy Markdown

hearing that they arent interested in merging is actually insane to me

May I interest you in Equicord?

@dg4l

dg4l commented Dec 27, 2025

Copy link
Copy Markdown

hearing that they arent interested in merging is actually insane to me

almost 2 years...

@alterNERDtive

Copy link
Copy Markdown

Well, personally I don’t think it’s that insane. I have a single use case for this, muting my mic in Discord but not anywhere else. Happens … IDK, twice a year?

@moldyharriet

Copy link
Copy Markdown

I use keybinds in Discord probably 5 or 6 times every gaming session, so maybe 6x2 daily, maybe? Depending on the day. Regardless, I can't live without them.

I don't think it's the usability aspect that is frustrating here, it's the fact that @tuxinal has spent time implementing it and has created a PR, keeping it up to date with the latest versions of Vesktop for a few years, and the maintainers refuse to even look at merging it. The feature is right here, it's just being ignored, which is astonishing and must be unfathomably frustrating for tuxinal.

@nixRidge

Copy link
Copy Markdown

I can't imagine it's a widely used feature, no.
I don't know what the reason for the project maintainers not merging this is, all I know/assume is they're 1) stretched pretty thin 2) don't have a lot of time.

For what it's worth, I can still apply and use this patch perfectly fine, it still works fine in KDE Plasma. The shortcuts are registered via the DE, and I can use them as normal.
It'd be convenient if it was merged for general users to use, but I wouldn't go as far as to say it's insane that it hasn't been merged yet.

Has anyone tried to reach out to the developers to get it merged perhaps?

@geransmith

geransmith commented Dec 27, 2025 via email

Copy link
Copy Markdown

@nixRidge

Copy link
Copy Markdown

I only use voice activation myself. That's why having a toggle mute button is nice.

@moldyharriet

Copy link
Copy Markdown

Yep, I'm a voice activation guy myself. I run a toggle mute and toggle deafen button, as well as a push to mute button.

@ZeroKun265

Copy link
Copy Markdown

I play a lot of games that have built in voice chat, so I often have to mute myself there and then unmute on discord when I need to talk to everyone one

Also, I have 4 housemates, so I often need to mute to talk to them if they ask stuff

Toggle mute and deafen for me are an absolutely needed feature. I had been using hyprland for a while and therefore has a way to send shortcuts to certain apps, now that I'm back on plasma I don't, this is a needed feature for me

1 similar comment
@ZeroKun265

Copy link
Copy Markdown

I play a lot of games that have built in voice chat, so I often have to mute myself there and then unmute on discord when I need to talk to everyone one

Also, I have 4 housemates, so I often need to mute to talk to them if they ask stuff

Toggle mute and deafen for me are an absolutely needed feature. I had been using hyprland for a while and therefore has a way to send shortcuts to certain apps, now that I'm back on plasma I don't, this is a needed feature for me

@jacklollz2

Copy link
Copy Markdown

I'd like to use push-to-mute for in game VC

@Doc-4

Doc-4 commented Jan 12, 2026

Copy link
Copy Markdown

I do voice activation too, I need to be able to control whether or not the microphone is currently being used by discord without hitting hardware mute, as other applications may need it. Even if it's currently focused on another monitor, it's often not the focused application, which is why I'd need a feature like this.

@TJourney

Copy link
Copy Markdown

I exclusively use push-to-talk, have since the old days of Teamspeak2 and Ventrilo. I would consider push-to-talk to be a critical feature, the absence of it having kept me away from forks of Discord such as Vesktop.

@Mylloon

Mylloon commented Mar 3, 2026

Copy link
Copy Markdown

Should venbind be merged into libvesktop for this PR to be mergeable? Will it imply that venbind should be rewrote in C++?

@yaomtc

yaomtc commented Mar 23, 2026

Copy link
Copy Markdown

Didn't see this mentioned here: Discord has a setting to make a voice channel push-to-talk ONLY. I had to enable push to talk and add a keybind to speak in that channel, and then I discovered that it only worked while the window was focused, which brought me here.

@Damglador

Copy link
Copy Markdown

Something tells me #1238 will be merged instead. Which is lame as Electron's support for global shortcuts on Wayland is an afterthought and until Electron 41 or Electron 42 they weren't even labeled properly electron/electron#49873.

@yaomtc

yaomtc commented Apr 7, 2026

Copy link
Copy Markdown

@Damglador and that wouldn't resolve the issue of PTT-only voice channels! The only solution there is just to not use Vesktop for them, I guess.

@Ketoro

Ketoro commented Apr 8, 2026

Copy link
Copy Markdown

whats stopping this from being merged?

@Malix-Labs

Malix-Labs commented Apr 16, 2026

Copy link
Copy Markdown

#326 (comment) from @Ketoro :

whats stopping this from being merged?

#1238 being worked on

#326 (comment) from @Damglador :

Electron's support for global shortcuts on Wayland is an afterthought

It seems their API has rather stabilized.

It is still better to rely on chromium's native API when possible

@tuxinal tuxinal closed this Apr 19, 2026
@Vendicated

Copy link
Copy Markdown
Member

Indeed, Chromium's shortcut support on Wayland has really improved now, so it is a viable option and much simpler alternative to this PR. So I have decided to move forward with that instead and plan to finalise and add it in the next version of Vesktop

I really appreciate the work that has been done here but in hindsight it was never really realistic for this to be merged. I am (for the most part) the sole maintainer of Vesktop. This pr is a pretty big change that introduces a new native dependency written in Rust, which I'm not well versed with. Hence, this would add a big burden on me as I would have to actually maintain this library going forward. It's out of scope for me, especially considering there's a viable Electron-native alternative now

So unfortunately yeah this PR won't be accepted. But thank you a lot again Tuxinal, and I'm sorry for not communicating this more clearly earlier!

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

Successfully merging this pull request may close these issues.

Custom Keybinds