summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorGravatar An Ko2016-02-16 00:01:05 +0000
committerGravatar An Ko2016-02-16 00:01:05 +0000
commit5f73713f5bc7a9081054bfc2a6c9b36f766498af (patch)
tree632923aaf45cf5af22918cc2d35ce31515b5bbca
parent09f581eb3c07945254df69a0060692317795b9c0 (diff)
downloadxkbcat-5f73713f5bc7a9081054bfc2a6c9b36f766498af.tar.gz
xkbcat-5f73713f5bc7a9081054bfc2a6c9b36f766498af.zip
Remove "-time": instead recommend an external tool
Undoing my unnecessary feature creep.
-rw-r--r--readme.markdown12
-rw-r--r--xkbcat.c17
2 files changed, 12 insertions, 17 deletions
diff --git a/readme.markdown b/readme.markdown
index 0d167c4..81471e1 100644
--- a/readme.markdown
+++ b/readme.markdown
@@ -44,7 +44,6 @@ Flags you can pass (all optional):
- `-delay <nanosec>`: delay between polls to the keyboard (default `10000000`;
that's 100ms)
- `-up`: also prepend key-ups (default: don't)
- - `-time`: also append epoch timestamps (default: don't)
- `-help`: print usage hints and exit
Then just type as you would usually. Interrupt signal (`C-c`) to end.
@@ -55,12 +54,17 @@ If you like spying on people (ethically, of course), [`xspy`][1] or
[`logkeys`][2] might be better for you. They use the modifier keys to infer
what was actually typed, so it's easier to read what's happening.
+If you want to add timestamps to each line for logging purposes, I recommend
+piping to the [moreutils package][3]'s `ts`. [These answers][4] feature
+various other tools good for the purpose.
+
## License
-[ISC][3].
+[ISC][5].
[1]: http://www.freshports.org/security/xspy/
[2]: http://code.google.com/p/logkeys/
-[3]: http://opensource.org/licenses/ISC
-[Chi]: http://en.wikipedia.org/wiki/Chi's_Sweet_Home
+[3]: http://joeyh.name/code/moreutils/
+[4]: http://stackoverflow.com/questions/21564/is-there-a-unix-utility-to-prepend-timestamps-to-lines-of-text
+[5]: http://opensource.org/licenses/ISC
diff --git a/xkbcat.c b/xkbcat.c
index 0143a3d..c993364 100644
--- a/xkbcat.c
+++ b/xkbcat.c
@@ -11,7 +11,6 @@
const char * DEFAULT_DISPLAY = ":0";
const int DEFAULT_DELAY = 10000000;
const bool DEFAULT_PRINT_UP = false;
-const bool DEFAULT_PRINT_TIME = false;
typedef char KbBuffer[32];
@@ -24,14 +23,12 @@ static inline bool keyState(KbBuffer b, int key) {
int printUsage() {
printf("\
-USAGE: xkbcat [-display <display>] [-delay <nanosec>] [-up] [-time]\n\
+USAGE: xkbcat [-display <display>] [-delay <nanosec>] [-up]\n\
display target X display (default %s)\n\
delay polling frequency; nanoseconds (default %d)\n\
- up also print key-ups (default %s)\n\
- time also print timestamps (default %s)\n",
+ up also print key-ups (default %s)\n",
DEFAULT_DISPLAY, DEFAULT_DELAY,
- (DEFAULT_PRINT_UP ? "yes" : "no"),
- (DEFAULT_PRINT_TIME ? "yes" : "no") );
+ (DEFAULT_PRINT_UP ? "yes" : "no") );
exit(0);
}
@@ -40,7 +37,6 @@ int main(int argc, char * argv[]) {
const char * hostname = DEFAULT_DISPLAY;
int delay = DEFAULT_DELAY;
bool printKeyUps = DEFAULT_PRINT_UP;
- bool printTimes = DEFAULT_PRINT_TIME;
// Get arguments
for (int i = 1; i < argc; i++) {
@@ -48,7 +44,6 @@ int main(int argc, char * argv[]) {
else if (!strcmp(argv[i], "-display")) hostname = argv[++i];
else if (!strcmp(argv[i], "-delay")) delay = atoi(argv[++i]);
else if (!strcmp(argv[i], "-up")) printKeyUps = true;
- else if (!strcmp(argv[i], "-time")) printTimes = true;
else { printf("Unexpected argument `%s`\n", argv[i]); printUsage(); }
}
@@ -71,8 +66,6 @@ int main(int argc, char * argv[]) {
while (1) { // Forever
XQueryKeymap(disp, *keys); // Fetch changed keys
- long timestamp = 0;
- if (printTimes) timestamp = (long)time(NULL);
for (int keyCode = 0; keyCode < sizeof(KbBuffer) * 8; keyCode++) {
bool stateBefore = keyState(*oldKeys, keyCode),
@@ -87,9 +80,7 @@ int main(int argc, char * argv[]) {
if (NULL == str) continue;
if (printKeyUps) printf("%s ", (stateNow ? "+" : "-"));
- printf("%s", str);
- if (printTimes) printf(" %ld", timestamp);
- printf("\n");
+ printf("%s\n", str);
}
}
// Make sure the data is sent right away if it's being written to a