Compile the code with
g++ foo.c -o XFakeKey `pkg-config --libs --cflags x11 xtst`
then start xev, switch to another terminal, run
sleep 5; ./XFakeKey Alt_L Left
switch back to xev and you'll get
KeyPress event, serial 30, synthetic NO, window 0x9e00001,
root 0xb7, subw 0x0, time 11060756, (620,384), root:(686,436),
state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 30, synthetic NO, window 0x9e00001,
root 0xb7, subw 0x0, time 11060758, (620,384), root:(686,436),
state 0x8, keycode 113 (keysym 0xff51, Left), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 30, synthetic NO, window 0x9e00001,
root 0xb7, subw 0x0, time 11060758, (620,384), root:(686,436),
state 0x8, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 30, synthetic NO, window 0x9e00001,
root 0xb7, subw 0x0, time 11060758, (620,384), root:(686,436),
state 0x0, keycode 113 (keysym 0xff51, Left), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
Compile the code with
g++ foo.c -o XFakeKey `pkg-config --libs --cflags x11 xtst`
then start xev, switch to another terminal, run
sleep 5; ./XFakeKey Alt_L Left
switch back to xev and you'll get
KeyPress event, serial 30, synthetic NO, window 0x9e00001,
root 0xb7, subw 0x0, time 11060756, (620,384), root:(686,436),
state 0x0, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 30, synthetic NO, window 0x9e00001,
root 0xb7, subw 0x0, time 11060758, (620,384), root:(686,436),
state 0x8, keycode 113 (keysym 0xff51, Left), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 30, synthetic NO, window 0x9e00001,
root 0xb7, subw 0x0, time 11060758, (620,384), root:(686,436),
state 0x8, keycode 64 (keysym 0xffe9, Alt_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 30, synthetic NO, window 0x9e00001,
root 0xb7, subw 0x0, time 11060758, (620,384), root:(686,436),
state 0x0, keycode 113 (keysym 0xff51, Left), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
and the hud will trigger