Jump to content

Setting up a second keyboard as a soundboard on linux

Hello i have been trying to setup a second keyboard as a soundboard in manjaro for the past two days but i can't figure it out.

What i have tried is using actkbd to detect the keypresses only on the second keyboard and then running the play command from sox to try and play sound like this:

30:::play /soundboard/sound.mp3

But when trying this i get the error:

ALSA lib pcm_dmix.c:1089:(snd_pcm_dmix_open) unable to open slave

First i tought it was a problem with it running in root so i changed the command to:

30:::sudo -u roy play /soundboard/message.mp3

But with this the exact same error occurred. On which I have been stuck, when I run 'play /soundboard/sound.mp3' manually in my terminal it works without any problems. I have also tried other sound playing libraries but they are giving me the same error as the one above. Trying it with a small piece of python also didn't fix the problem : /. I hope someone here knows a potential solution to the problem I am having, and is able to help me / try to help me with it.

 

Greetings,

Roy

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, Sheerpython said:

That's a really old project (the last commit is from 6 years ago and the readme mentions Linux 2.6), I wouldn't really trust it. Also running audio operations as root or with sudo (even when sudoing as a regular user) is ultra sketchy, avoid it. If you must use a dedicated daemon try this instead, at least it's actively maintained.

 

What version of Manjaro are you using? Most desktop environments have a pretty good shortcut manager bundled with them, try using that instead.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

Thank you for responding : )

I am running Manjaro 18.1.5 and I have just tried running sxhkd which i got to play sound when pressing a key. The problem with this daemon is that it doesn't work keyboard specific. It's listening on both keyboards and i can't find a way to make it listen to just one. I also looked at the build in shortcut manager but that also doesn't seem to support it. Did i possibly miss something at the sxhkd deamon?

Link to comment
Share on other sites

Link to post
Share on other sites

45 minutes ago, Sheerpython said:

Thank you for responding : )

I am running Manjaro 18.1.5 and I have just tried running sxhkd which i got to play sound when pressing a key. The problem with this daemon is that it doesn't work keyboard specific. It's listening on both keyboards and i can't find a way to make it listen to just one. I also looked at the build in shortcut manager but that also doesn't seem to support it. Did i possibly miss something at the sxhkd deamon?

You could try a custom mapping using xmodmap and bind all keys on the second keyboard to unused unicode symbols, then map those symbols to the shortcuts you want. I think sxhkd can't tell the difference between the two keyboards because it uses symbols rather than keycodes but this workaround should allow you to use it anyway.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

15 hours ago, Sauron said:

You could try a custom mapping using xmodmap and bind all keys on the second keyboard to unused unicode symbols, then map those symbols to the shortcuts you want. I think sxhkd can't tell the difference between the two keyboards because it uses symbols rather than keycodes but this workaround should allow you to use it anyway.

I looked at the post you send me and i think you meant XKB instead of xmodmap but the question that i currently have is, is there a way i can just put the second keyboard in russian or chinese? (Something I will never use)

Link to comment
Share on other sites

Link to post
Share on other sites

9 hours ago, Sheerpython said:

the question that i currently have is, is there a way i can just put the second keyboard in russian or chinese? (Something I will never use)

...maybe? I mean in theory sure, I don't know if there's a program that lets you do it automatically though. You could use XKB (I did mean that and not xmodmap) and use a python script to generate the correct bindings. Maybe there are premade mappings you can copy, all you'd have to to would be to change the regex to match your device.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

Use xinput to list devices, on manjaro you need to install xorg-xinput, then do setxkbmap -device xinput_device_id ru

That will set it to russian but you can get a keymap list with localectl list-x11-keymap-layouts

 

autokey(aur) has a gui and can run scripts /  commands on key input.

system.exec_command("command")

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×