aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2025-05-11 05:39:43 -0400
committerB. Watson <urchlay@slackware.uk>2025-05-11 05:39:43 -0400
commitfe074451e1e993a3ab1b18ac29d434a18970d344 (patch)
tree62db4ab45e0014a57e73419ee453b0cffe15eaea
parenta68d256cd2be29e63e8a2dd75522491bdab1cb75 (diff)
downloadmarsond-fe074451e1e993a3ab1b18ac29d434a18970d344.tar.gz
improve --help and debugging output.
-rw-r--r--marsond.82
-rw-r--r--marsond.c25
-rw-r--r--marsond.rst2
-rw-r--r--usage.c2
4 files changed, 19 insertions, 12 deletions
diff --git a/marsond.8 b/marsond.8
index e245dbe..02b4da5 100644
--- a/marsond.8
+++ b/marsond.8
@@ -61,7 +61,7 @@ Options can be "bundled": \fB\-vf\fP is the same as \fB\-v\fP \fB\-f\fP\&.
Amount of time in milliseconds to delay the Enter key release events.
Default: 30.
.UNINDENT
-.\" delay time for Enter key relase (default 30).
+.\" delay time for Enter key release.
.
.INDENT 0.0
.TP
diff --git a/marsond.c b/marsond.c
index 9bb7795..53b007b 100644
--- a/marsond.c
+++ b/marsond.c
@@ -83,6 +83,10 @@ void print_help(void) {
for(helpline = helptext; *helpline; helpline++)
puts(*helpline);
+
+ puts( "Compiled-in defaults:");
+ puts( " -k: " DEFAULT_KBD);
+ printf(" -d: %d\n", DEFAULT_DELAY_MS);
}
void version(void) {
@@ -276,6 +280,16 @@ void set_evbit(int outfd, int event) {
}
}
+void print_device_name(void) {
+ char name[UINPUT_MAX_NAME_SIZE];
+
+ if(ioctl(outfd, UI_GET_SYSNAME(UINPUT_MAX_NAME_SIZE), name) >= 0) {
+ debug("created virtual keyboard device: /sys/devices/virtual/input/%s/", name);
+ } else {
+ debug("created virtual keyboard device but couldn't get its name (old kernel?)");
+ }
+}
+
int main(int argc, char **argv) {
int i;
struct uinput_user_dev dev;
@@ -346,14 +360,7 @@ int main(int argc, char **argv) {
/* I was hoping the return value of this ioctl would be the
device number, but it's just 0 for no error. */
if(ioctl(outfd, UI_DEV_CREATE) >= 0) {
- if(debugging) {
- char name[UINPUT_MAX_NAME_SIZE];
- if(ioctl(outfd, UI_GET_SYSNAME(UINPUT_MAX_NAME_SIZE), name) >= 0) {
- debug("created virtual keyboard device: /sys/devices/virtual/input/%s/", name);
- } else {
- debug("created virtual keyboard device but couldn't get its name (old kernel?)");
- }
- }
+ if(debugging) print_device_name();
} else {
die("UI_DEV_CREATE failed: %s", strerror(errno));
}
@@ -383,7 +390,7 @@ int main(int argc, char **argv) {
}
if(foreground) {
- debug("got event: type %d, code %d, value %d\n",
+ debug("got event: type %d, code %d, value %d",
ev.type, ev.code, ev.value);
}
diff --git a/marsond.rst b/marsond.rst
index c304a06..2e705f6 100644
--- a/marsond.rst
+++ b/marsond.rst
@@ -47,7 +47,7 @@ Options can be "bundled": **-vf** is the same as **-v** **-f**.
Amount of time in milliseconds to delay the Enter key release events.
Default: 30.
-.. delay time for Enter key relase (default 30).
+.. delay time for Enter key release.
-f
Run in the foreground; do not detach from the terminal or become a
diff --git a/usage.c b/usage.c
index 44080f1..847cc76 100644
--- a/usage.c
+++ b/usage.c
@@ -1,5 +1,5 @@
const char *helptext[] = {
- " -d delay-ms: delay time for Enter key relase (default 30).",
+ " -d delay-ms: delay time for Enter key release.",
" -f: run in foreground, not as a daemon.",
" -k keyboard-device: keyboard device (usually under /dev/input/by-id/).",
" -p pause-ms: pause before opening keyboard/uinput devs (default 0).",