How can I log a keyboard hit via shell script? My aim is to log the number of keyboard hits of a login session on my Ubuntu system.
Note: I do not want to log the keystrokes itself, only the number of hits. So in the end it says:
94853 hits today.
|
|
Monitoring in X11 (Graphical Desktop) Session OnlyIn you're using the XInput layer (you probably are, if you're running a modern X) then
Note that when you pipe You can fairly easily start your script as one of the login scripts in your desktop environment or from your Monitoring System-wide (All Sessions, Even Text Mode)Alternatively, if you want to monitor all keystrokes on the system, not just those in your X11 session, you can use the
If you go this way, you'll have to figure out when your sessions start and end some way (e.g., peterph's dbus suggestion). |
||||
|
|
|
As Derobert mentioned, Additionally, you would miss anything typed on virtual consoles - for that I'm afraid you'd need to write a kernel module, that would export its statistics somewhere in |
|||||||||||||
|