Code Monkey home page Code Monkey logo

wayland-push-to-talk-fix's Introduction

wayland-push-to-talk-fix

This fixes the inability to use push to talk in Discord when running Wayland

NOTE: by default the left Meta (Windows) key is used for push to talk. In order to use a different key, see the configuration section below.

Requirements

Nothing special.

  • C++ compiler & Make
  • libevdev
  • libxdo (Debian/Ubuntu: libxdo-dev, Fedora/Centos: libxdo-devel)

Approach

Read specific key events via evdev (needs sudo) and then pass them to libxdo to inject key presses to X apps.

Configuration

The command supports three command line args.

  • -v: verbose mode, logs all keystrokes
  • -k: keycode to listen for. Full list.
  • -n: keycode to send to discord. Full list (ignore leading XKB_KEY_).
  • You can use mouse buttons as well for both options, you can determine the correct keycode for -k using evtest. The correct keycode for -n will be in the form of MOUSE<num> and you can use xev to determine <num> for the particular button press that you are interested in.

Installation

Manual run

make
sudo ./push-to-talk /dev/input/by-id/<device-id> &

Autostart

First edit the push-to-talk.desktop file and replace /dev/input/by-id/<device-id> with your device path. Then:

make
sudo make install

# to allow you access `/dev/input` devices without root
sudo usermod -aG input <your username>

Then just log out and log in. A process named push-to-talk should be running (visible in any process monitor).

License

MIT

wayland-push-to-talk-fix's People

Contributors

effective-light avatar rush avatar selfref avatar yorickvp 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

Watchers

 avatar  avatar  avatar  avatar

wayland-push-to-talk-fix's Issues

undefined reference to `libevdev_new_from_fd'

On Ubuntu 22.04.1.

Install dependencies:

wayland-push-to-talk-fix$ sudo apt install libevdev-dev libxdo-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
libevdev-dev is already the newest version (1.12.1+dfsg-1).
libxdo-dev is already the newest version (1:3.20160805.1-4).
0 upgraded, 0 newly installed, 0 to remove and 8 not upgraded.

Attempt build:

wayland-push-to-talk-fix$ make
g++ -Os -levdev  -levdev -lxdo  push-to-talk.cpp   -o push-to-talk
/usr/bin/ld: /tmp/ccGcaImP.o: in function `main':
push-to-talk.cpp:(.text.startup+0xa4): undefined reference to `libevdev_new_from_fd'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0xc7): undefined reference to `libevdev_get_name'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0xee): undefined reference to `libevdev_get_id_product'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0xfc): undefined reference to `libevdev_get_id_vendor'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0x10a): undefined reference to `libevdev_get_id_bustype'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0x144): undefined reference to `libevdev_has_event_code'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0x164): undefined reference to `xdo_new'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0x19d): undefined reference to `libevdev_next_event'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0x1d0): undefined reference to `xdo_send_keysequence_window_down'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0x1d7): undefined reference to `xdo_send_keysequence_window_up'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0x1e1): undefined reference to `xdo_free'
/usr/bin/ld: push-to-talk.cpp:(.text.startup+0x1eb): undefined reference to `libevdev_free'
collect2: error: ld returned 1 exit status
make: *** [<builtin>: push-to-talk] Error 1

Toolchain versions:

wayland-push-to-talk-fix$ g++ --version
g++ (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

wayland-push-to-talk-fix$ /usr/bin/ld --version
GNU ld (GNU Binutils for Ubuntu) 2.38
Copyright (C) 2022 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.

This on Arch with KDE Plasma 6.1 not working anymore

Hey, so this was working very well for me before I stupidly upgraded to KDE Plasma 6.1.

The app now runs and looks like it's working the same way (even with Debugging mode) but when I get into discord, it's not sending anything to it. It also worked for mumble before, and not now.

I did get a popup now from KWIN / KDE that didn't happen before asking to Share input with the remote window. I opted to allow sharing, and it didn't change anything. I also tried not allowing it later, then allowing it, and remembering. Doesn't seem to impact it.

I uninstalled and rebuilt wayland-push-to-talk-fix, no errors anywhere, just doesn't seem to be able to have permission or know what scope to do what it did in 6.1.

I can confirm that the app is indeed capturing out of Window events just fine, its just not sending translated new ones or maybe it is, and other windows can't read it.

Any help is appreciated!

/usr/bin/push-to-talk /dev/input/by-id/usb-ROCCAT_ROCCAT_Kone_XP-event-mouse -k BTN_SIDE -n MOUSE8

Support for Flatpak

Is there a way to make this work with the flatpak version of Discord too?

Error: DISPLAY environment variable is empty

What I typed: sudo push-to-talk -k KEY_SCROLLLOCK -n Scroll_Lock /dev/input/by-id/usb-Glorious_Series_One_PRO_Wireless_000000000000-if01-event-kbd &

Using openSUSE tumbleweed

Input device name: "Glorious Series One PRO Wireless Keyboard"
Input device ID: bus 0x3 vendor 0x258a product 0x2031
Error: DISPLAY environment variable is empty. Is there an Xorg or other X server running? You can try setting 'export DISPLAY=:0' and trying again.
Failed to initialize xdo lib

KDE6 remote control requested

Everything worked fine for a long time, but now when using this program, immediately after pressing the necessary button outside of Discord, KDE displays the message "Remote control requested". If I press "share" to allow remote control, the confirmation window closes, but the key stop being transmitted, so nothing works.

I hope this is just a temporary bug that will be fixed in the next KDE update.

My system: EndeavourOS, KDE plasma 6.1.0, Wayland, Linux Kernel: 6.9.6

Using Mouse Keys Instead of Keyboard Keys

It's probably more common to use keyboards instead of mouse keys for push-to-talk. but I do have a mouse with the extra keys on the side. I know they are bound to forward and back as I use the forward key for PTT on X11. I don't know much about the Linux key code system and was wondering if it was possible to use a mouse instead? I have the Logitech G900 for reference.

I tried with the forward key from the key code links but I only got a "This device is not capable of sending this key code" message.

How do I get the device ID?

Sorry, this is a bit of a noob question. I've looked it up and can't find a way to get the device-id of my microphone. Is this what the device-id is referring to or is it something else?

Thanks

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.