1

im on raperry pi 3b running defult 32bit os. Im trying to record the bluetooth inputs from my headset similar to the read command.to bind that code i get from that to another command to do stuff like pausing and playing music with playerctl.

i tried xev however im using ssh and any attempt on using stuff like MobaXterm dont work

Amir Ahmed
  • 13
  • 2

1 Answers1

0

You can use the command btmon to see live inputs. If you want to write inputs to a file, you can use btmon --write <path-to-file>, and if you want to read it you can use btmon --read <path-to-file>. It should come installed with bluez.

However, it seems that you want to capture keypresses of a pause/play button, similar to one that you would find on a keyboard. For that, the keybind is XF86AudioPause and XF86AudioPlay. For more information, check the Arch Wiki about Xbindings, as well as all the keyboard codes. If it's a keyboard code that's not part of xbindings, you can find them here.

imad.nyc
  • 57
  • 10
  • Are the keyboard codes the same a my headphones? – Amir Ahmed May 10 '23 at 18:58
  • I can't say for sure without seeing the inputs of the headphones myself, but this has been the case for every headphone I've had anecdotally. If you use `btmon`, or even `evdev` with python, you can figure out what codes are being pressed. – imad.nyc May 10 '23 at 19:02
  • so I ran evdev and got this: 201 (KEY_PAUSECD), down 201 (KEY_PAUSECD), up 200 (KEY_PLAYCD), down 200 (KEY_PLAYCD), up so how would i bind that to playerctl play and pause – Amir Ahmed May 10 '23 at 19:21
  • So looking here at the [source code] https://github.com/torvalds/linux/blob/master/include/uapi/linux/input-event-codes.h , we see that those keys have an ID attached to them, the same IDs that `evdev` gave you. You can use those character IDs to use in other programs, since raspbian, a linux distro, will recognize them. – imad.nyc May 10 '23 at 19:34
  • so in order to bind to playerctl i just write something along the lines of bind 201 playerctl pause – Amir Ahmed May 10 '23 at 19:48
  • Yup, that's how it should be. I'm not familiar with playerctl, but looking at their docs, that seems to be correct. – imad.nyc May 10 '23 at 19:58
  • I was just making sure as many other people were using bindsym which seems to not be working for me – Amir Ahmed May 10 '23 at 20:00
  • Are you perhaps trying to use `sxhkd` in combination with playerctl? That would be a different question, one that you most likely can find answers to on the internet. – imad.nyc May 10 '23 at 20:08
  • im sorry about this but Im still quite in the dark about which code I give to sxhkd. I tried KEY PAUSED / KEY PLAYED and 200 / 201. I even tried XF86Audio which also did not work in my case – Amir Ahmed May 10 '23 at 20:25
  • I'm not sure if you ARE using `sxhkd` or not. What is it you're trying to do? Your question only mentioned reading the event codes. If you need help with another thing, you should open another question so others can help too, since they're not clicking on this title as it is currently. – imad.nyc May 10 '23 at 20:28
  • i said i was trying to bind the Bluetooth code with a playerctl command to pause and play music. – Amir Ahmed May 10 '23 at 20:30
  • [https://github.com/altdesktop/playerctl](playerctl) has documentation on how to do that. I'm not sure what program you're trying to use to bind to it, you're going to have to give more info or start a new question. – imad.nyc May 10 '23 at 20:46
  • i said i was using sxhkd. what code to i use – Amir Ahmed May 10 '23 at 20:58
  • `bindsym` KEY_PLAYCD – imad.nyc May 10 '23 at 21:01
  • im so sorry about this but I get this result : -bash: bindsym: command not found. shall i open a new quesition – Amir Ahmed May 10 '23 at 21:04
  • You should. `bindsym` goes in your `sxhkdrc`, your config file most likely found in `~/.config/`. You should read the manual pages for `sxhkd`, and then if you still can't find what you're looking for, start a new question. – imad.nyc May 10 '23 at 21:10
  • im verry confused: pi@raspberrypi:~ $ bindsym -bash: bindsym: command not found – Amir Ahmed May 10 '23 at 21:13
  • Please read the [manual](https://wiki.archlinux.org/title/Sxhkd) – imad.nyc May 11 '23 at 02:26