Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I made this human script for something I need to do:
Code:
END key
press and hold LEFT SHIFT
PAGE UP key
release LEFT SHIFT
CONTEXT-MENU key
'm' key
'm' key
ENTER key
The final aim is to make a shell script to this script above.
I used 'xev' to show what its window received when I did the script in its window, with added comments in red. But most of this output is very strange to me. And I still need to learn how to convert "these xev happened" to "make these xev happen"
May you help me?
Below I have a xev session with the human script given inside it. There is no mouse noise in it - its cursor never passed above XEV window, and the only "mouse" action I did was to click "close" for that window.
Code:
Outer window is 0x5200001, inner window is 0x5200002
PropertyNotify event, serial 8, synthetic NO, window 0x5200001,
atom 0x27 (WM_NAME), time 1575197383, state PropertyNewValue
PropertyNotify event, serial 9, synthetic NO, window 0x5200001,
atom 0x22 (WM_COMMAND), time 1575197383, state PropertyNewValue
PropertyNotify event, serial 10, synthetic NO, window 0x5200001,
atom 0x28 (WM_NORMAL_HINTS), time 1575197383, state PropertyNewValue
CreateNotify event, serial 11, synthetic NO, window 0x5200001,
parent 0x5200001, window 0x5200002, (10,10), width 50, height 50
border_width 4, override NO
PropertyNotify event, serial 14, synthetic NO, window 0x5200001,
atom 0x127 (WM_PROTOCOLS), time 1575197383, state PropertyNewValue
MapNotify event, serial 15, synthetic NO, window 0x5200001,
event 0x5200001, window 0x5200002, override NO
ConfigureNotify event, serial 18, synthetic NO, window 0x5200001,
event 0x5200001, window 0x5200001, (0,0), width 178, height 178,
border_width 0, above 0x3244e39, override NO
PropertyNotify event, serial 18, synthetic NO, window 0x5200001,
atom 0x195 (_NET_WM_ALLOWED_ACTIONS), time 1575197384, state PropertyNewValue
PropertyNotify event, serial 18, synthetic NO, window 0x5200001,
atom 0x195 (_NET_WM_ALLOWED_ACTIONS), time 1575197384, state PropertyNewValue
ReparentNotify event, serial 18, synthetic NO, window 0x5200001,
event 0x5200001, window 0x5200001, parent 0xd4a80f,
(0,0), override NO
PropertyNotify event, serial 18, synthetic NO, window 0x5200001,
atom 0x12f (_NET_WM_DESKTOP), time 1575197384, state PropertyNewValue
PropertyNotify event, serial 18, synthetic NO, window 0x5200001,
atom 0x12f (_NET_WM_DESKTOP), time 1575197384, state PropertyNewValue
PropertyNotify event, serial 18, synthetic NO, window 0x5200001,
atom 0x12c (_NET_FRAME_EXTENTS), time 1575197384, state PropertyNewValue
ConfigureNotify event, serial 18, synthetic NO, window 0x5200001,
event 0x5200001, window 0x5200001, (1,23), width 178, height 178,
border_width 0, above 0x0, override NO
PropertyNotify event, serial 18, synthetic NO, window 0x5200001,
atom 0x158 (WM_STATE), time 1575197384, state PropertyNewValue
PropertyNotify event, serial 18, synthetic NO, window 0x5200001,
atom 0x135 (_NET_WM_STATE), time 1575197384, state PropertyNewValue
ConfigureNotify event, serial 24, synthetic YES, window 0x5200001,
event 0x5200001, window 0x5200001, (592,302), width 178, height 178,
border_width 2, above 0x0, override NO
MapNotify event, serial 24, synthetic NO, window 0x5200001,
event 0x5200001, window 0x5200001, override NO
VisibilityNotify event, serial 24, synthetic NO, window 0x5200001,
state VisibilityUnobscured
Expose event, serial 24, synthetic NO, window 0x5200001,
(0,0), width 178, height 10, count 3
Expose event, serial 24, synthetic NO, window 0x5200001,
(0,10), width 10, height 58, count 2
Expose event, serial 24, synthetic NO, window 0x5200001,
(68,10), width 110, height 58, count 1
Expose event, serial 24, synthetic NO, window 0x5200001,
(0,68), width 178, height 110, count 0
PropertyNotify event, serial 24, synthetic NO, window 0x5200001,
atom 0x135 (_NET_WM_STATE), time 1575197386, state PropertyNewValue
FocusIn event, serial 24, synthetic NO, window 0x5200001,
mode NotifyNormal, detail NotifyNonlinear
KeymapNotify event, serial 24, synthetic NO, window 0x0,
keys: 4294967197 0 0 0 16 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
PropertyNotify event, serial 24, synthetic NO, window 0x5200001,
atom 0x135 (_NET_WM_STATE), time 1575197386, state PropertyNewValue
ColormapNotify event, serial 33, synthetic NO, window 0x5200001,
colormap 0x20, new NO, state ColormapInstalled
PropertyNotify event, serial 33, synthetic NO, window 0x5200001,
atom 0x18d (_NET_WM_ICON_GEOMETRY), time 1575197406, state PropertyNewValue
PropertyNotify event, serial 34, synthetic NO, window 0x5200001,
atom 0x18d (_NET_WM_ICON_GEOMETRY), time 1575197430, state PropertyNewValue
KeyRelease event, serial 34, synthetic NO, window 0x5200001,
root 0xc9, subw 0x0, time 1575197449, (-40,384), root:(554,688),
state 0x10, keycode 36 (keysym 0xff0d, Return), same_screen YES,
XLookupString gives 1 bytes: (0d) "
"
XFilterEvent returns: False
KeyPress event, serial 37, synthetic NO, window 0x5200001,
root 0xc9, subw 0x0, time 1575201162, (-40,384), root:(554,688),
state 0x10, keycode 115 (keysym 0xff57, End), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 37, synthetic NO, window 0x5200001,
root 0xc9, subw 0x0, time 1575201258, (-40,384), root:(554,688),
state 0x10, keycode 115 (keysym 0xff57, End), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 37, synthetic NO, window 0x5200001,
root 0xc9, subw 0x0, time 1575203578, (-40,385), root:(554,689),
state 0x10, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 37, synthetic NO, window 0x5200001,
root 0xc9, subw 0x0, time 1575216681, (-40,385), root:(554,689),
state 0x11, keycode 112 (keysym 0xff55, Prior), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 37, synthetic NO, window 0x5200001,
root 0xc9, subw 0x0, time 1575216777, (-40,385), root:(554,689),
state 0x11, keycode 112 (keysym 0xff55, Prior), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 37, synthetic NO, window 0x5200001,
root 0xc9, subw 0x0, time 1575218641, (-40,385), root:(554,689),
state 0x11, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 37, synthetic NO, window 0x5200001,
root 0xc9, subw 0x0, time 1575222753, (-40,385), root:(554,689),
state 0x10, keycode 135 (keysym 0xff67, Menu), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
KeyRelease event, serial 37, synthetic NO, window 0x5200001,
root 0xc9, subw 0x0, time 1575222857, (-40,385), root:(554,689),
state 0x10, keycode 135 (keysym 0xff67, Menu), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: False
KeyPress event, serial 37, synthetic NO, window 0x5200001,
root 0xc9, subw 0x0, time 1575226305, (-40,385), root:(554,689),
state 0x10, keycode 58 (keysym 0x6d, m), same_screen YES,
XLookupString gives 1 bytes: (6d) "m"
XmbLookupString gives 1 bytes: (6d) "m"
XFilterEvent returns: False
KeyRelease event, serial 37, synthetic NO, window 0x5200001,
root 0xc9, subw 0x0, time 1575226385, (-40,385), root:(554,689),
state 0x10, keycode 58 (keysym 0x6d, m), same_screen YES,
XLookupString gives 1 bytes: (6d) "m"
XFilterEvent returns: False
KeyPress event, serial 37, synthetic NO, window 0x5200001,
root 0xc9, subw 0x0, time 1575227545, (-40,385), root:(554,689),
state 0x10, keycode 58 (keysym 0x6d, m), same_screen YES,
XLookupString gives 1 bytes: (6d) "m"
XmbLookupString gives 1 bytes: (6d) "m"
XFilterEvent returns: False
KeyRelease event, serial 37, synthetic NO, window 0x5200001,
root 0xc9, subw 0x0, time 1575227625, (-40,385), root:(554,689),
state 0x10, keycode 58 (keysym 0x6d, m), same_screen YES,
XLookupString gives 1 bytes: (6d) "m"
XFilterEvent returns: False
KeyPress event, serial 37, synthetic NO, window 0x5200001,
root 0xc9, subw 0x0, time 1575230833, (-40,385), root:(554,689),
state 0x10, keycode 36 (keysym 0xff0d, Return), same_screen YES,
XLookupString gives 1 bytes: (0d) "
"
XmbLookupString gives 1 bytes: (0d) "
"
XFilterEvent returns: False
KeyRelease event, serial 37, synthetic NO, window 0x5200001,
root 0xc9, subw 0x0, time 1575230937, (-40,385), root:(554,689),
state 0x10, keycode 36 (keysym 0xff0d, Return), same_screen YES,
XLookupString gives 1 bytes: (0d) "
"
XFilterEvent returns: False
ClientMessage event, serial 37, synthetic YES, window 0x5200001,
message_type 0x127 (WM_PROTOCOLS), format 32, message 0x125 (WM_DELETE_WINDOW)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,803
Rep:
Quote:
Originally Posted by dedec0
I made this human script for something I need to do:
That's not much to go on. Caveat: I've really only used xev for finding key codes in cases where I needed to use xmodmap(1) to interface with some oddball keyboard. Take the following with a grain of salt:
I would think that using xev as a means of detecting a keystroke would be one of the harder ways if you're looking to making an interactive graphical script. My first move would be to look at xmessage(1) or, maybe, gxmessage(1). (The latter may not be on your preferred distribution, though. I had to download it separately and compile from source.) Especially if all you need to do is pop up a window to ask for user input---like "which of these options do you want?" [click here, here, or here].
Simple(-minded) example using xmessage:
Code:
#!/bin/bash
xmessage -buttons "Brief list?":1,"Long list?":2 "View files..."
case $? in
1) ls ;;
2) ls -l ;;
*) echo "Oops! Something odd occurred (rc=$?)."
esac
There's also wish(1) but, if memory serves, you might need to be writing Tcl scripts to use that.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.