You are not logged in.

#1 2010-04-19 05:55:09

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,358

[SOLVED] Fake XF86Audio-related keystrokes?

Hi all,

I'd like to get all my players to rely on the same keystrokes. The XF86AudioPlay/XF86AudioNext etc. etc. keystrokes seem to be exactly what I want, but simulating those keystrokes (since I don't have those keys on my keyboard) doesn't seem possible without 'gotchas'.

The current methods I've found are:-

xdotool key XF86AudioPlay
echo 'KeyStrPress XF86AudioPlay KeyStrRelease XF86AudioPlay' | xmacroplay :0
xte 'keydown XF86AudioPlay' 'keyup XF86AudioPlay'
xvkbd -text "\[XF86AudioPlay]\r"

All of them work (from the xdotool, xmacro, xautomation, and xvkbd packages respectively) but don't work in conjunction with xbindkeys bindings. Basically, when I put them in under Super-C (my preferred keybinding for playing), they don't take any effect, unless I press Super-C very quickly (basically just tapping).

The primary problem seems to be that when I hold the Super key down, those commands issue Super-XF86AudioPlay rather than just XF86AudioPlay. xdotool actually has a --clearmodifiers option for that, but it doesn't seem to make things better.

Any other solutions for what I'm trying to do (bind Super-C to issue XF86AudioPlay because my keyboard does not have music buttons)? Currently my Super-C is bound with xbindkeys to 'mpc toggle' which works, but only for mpd.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#2 2010-10-20 12:56:00

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,358

Re: [SOLVED] Fake XF86Audio-related keystrokes?

Really old bump. Been working around by hard-coding mpc, but I just got a new external speaker with buttons I'd like to use.

Same question still, anyway to emulate XF86AudioPlay (or any of the XF86Audio keys) with a Super-related combo?


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#3 2010-10-20 13:10:40

Stebalien
Member
Registered: 2010-04-27
Posts: 1,239
Website

Re: [SOLVED] Fake XF86Audio-related keystrokes?

This works for me:

echo 'KeyStrRelease Mod4 KeyStrRelease c KeyStrPress XF86AudioPlay KeyStrRelease XF86AudioPlay' | xmacroplay :0

Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C

Offline

#4 2010-10-20 16:17:37

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,358

Re: [SOLVED] Fake XF86Audio-related keystrokes?

Doesn't work all the time here, similar to previously I've found that it only works if I 'tap' the keys really fast.

When running xbindkeys -v, I notice the times when it works it looks like this:-

Key press !
e.xkey.keycode=19
e.xkey.state=80
"echo 'KeyStrRelease Mod4 KeyStrRelease Mod2 KeyStrRelease 0 KeyStrPress XF86AudioMute KeyStrRelease XF86AudioMute KeyStrRelease Mod4 KeyStrRelease 0' | xmacroplay :0"
    m:0x40 + c:19
    Mod4 + 0
got screen 0 for window 15a
Start program with fork+exec call
Key release !
e.xkey.keycode=133
e.xkey.state=80
Key release !
e.xkey.keycode=19
e.xkey.state=16
XTest for server ":0.0" is version 2.2.

KeyStrRelease: Mod4
KeyStrRelease: Mod2
KeyStrRelease: 0
KeyStrPress: XF86AudioMute
KeyStrRelease: XF86AudioMute
KeyStrRelease: Mod4
KeyStrRelease: 0
Unknown tag: 0
xmacroplay: pointer and keyboard released. 
Key press !
e.xkey.keycode=19
e.xkey.state=80
"echo 'KeyStrRelease Mod4 KeyStrRelease Mod2 KeyStrRelease 0 KeyStrPress XF86AudioMute KeyStrRelease XF86AudioMute KeyStrRelease Mod4 KeyStrRelease 0' | xmacroplay :0"
    m:0x40 + c:19
    Mod4 + 0
got screen 0 for window 15a
Start program with fork+exec call
XTest for server ":0.0" is version 2.2.

KeyStrRelease: Mod4
KeyStrRelease: Mod2
KeyStrRelease: 0
KeyStrPress: XF86AudioMute
KeyStrRelease: XF86AudioMute
KeyStrRelease: Mod4
KeyStrRelease: 0
Unknown tag: 0
xmacroplay: pointer and keyboard released. 
Key release !
e.xkey.keycode=19
e.xkey.state=80

Looks like a race condition.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#5 2010-10-20 19:32:56

Stebalien
Member
Registered: 2010-04-27
Posts: 1,239
Website

Re: [SOLVED] Fake XF86Audio-related keystrokes?

Ugly, dirty, terrible, horrific, Not Safe for Human Consumption HACK:

echo 'KeyStrRelease Super_L KeyStrRelease c' | xmacroplay :0; xmodmap -e 'remove Mod4 = Super_L'; echo 'KeyStrPress XF86AudioPlay KeyStrRelease XF86AudioPlay' | xmacroplay :0; xmodmap -e 'add Mod4 = Super_L'

Steven [ web : git ]
GPG:  327B 20CE 21EA 68CF A7748675 7C92 3221 5899 410C

Offline

#6 2010-10-20 23:24:01

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,358

Re: [SOLVED] Fake XF86Audio-related keystrokes?

Damn cool. That works. So hacky though. Thanks much, sir.


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

#7 2010-10-22 01:23:45

ngoonee
Forum Fellow
From: Between Thailand and Singapore
Registered: 2009-03-17
Posts: 7,358

Re: [SOLVED] Fake XF86Audio-related keystrokes?

Slight addition, the code you've posted works just fine, but I can double tap (for example) Super-minus to continually lower volume. This is what I have, modified:-

echo 'KeyStrRelease Super_L KeyStrRelease minus' | xmacroplay :0; xmodmap -e 'remove Mod4 = Super_L'; echo 'KeyStrPress XF86AudioLowerVolume KeyStrRelease XF86AudioLowerVolume' | xmacroplay :0; xmodmap -e 'add Mod4 = Super_L'; echo 'KeyStrPress Super_L' | xmacroplay :0

The issue with that is if you tap Super-Minus really fast (such that you release before the last KeyStrPress executes you're left with a permanently held down state for Super_L (which can confuse you if your keys start doing what you don't expect them to). Just pressing Super_L again makes this go away though.

Time to update the wiki....

EDIT: and its up http://wiki.archlinux.org/index.php/Xbi … media_keys Thanks Stebalien for your invaluable help.

Last edited by ngoonee (2010-10-22 01:44:09)


Allan-Volunteer on the (topic being discussed) mailn lists. You never get the people who matters attention on the forums.
jasonwryan-Installing Arch is a measure of your literacy. Maintaining Arch is a measure of your diligence. Contributing to Arch is a measure of your competence.
Griemak-Bleeding edge, not bleeding flat. Edge denotes falls will occur from time to time. Bring your own parachute.

Offline

Board footer

Powered by FluxBB