Skip to content

Commit a665655

Browse files
committed
ydotoold: check $DISPLAY env before invoking xinput
1 parent 55ba139 commit a665655

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

Daemon/ydotoold.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -356,18 +356,20 @@ int main(int argc, char **argv) {
356356

357357
const char *xinput_path = "/usr/bin/xinput";
358358

359-
if (stat(xinput_path, &sbuf) == 0) {
360-
pid_t npid = vfork();
361-
362-
if (npid == 0) {
363-
execl(xinput_path, "xinput", "--set-prop", "pointer:ydotoold virtual device", "libinput Accel Profile Enabled", "0,", "1", NULL);
364-
perror("failed to run xinput command");
365-
_exit(2);
366-
} else if (npid == -1) {
367-
perror("failed to fork");
359+
if (getenv("DISPLAY")) {
360+
if (stat(xinput_path, &sbuf) == 0) {
361+
pid_t npid = vfork();
362+
363+
if (npid == 0) {
364+
execl(xinput_path, "xinput", "--set-prop", "pointer:ydotoold virtual device", "libinput Accel Profile Enabled", "0,", "1", NULL);
365+
perror("failed to run xinput command");
366+
_exit(2);
367+
} else if (npid == -1) {
368+
perror("failed to fork");
369+
}
370+
} else {
371+
printf("xinput command not found in `%s', not disabling mouser pointer acceleration", xinput_path);
368372
}
369-
} else {
370-
printf("xinput command not found in `%s', not disabling mouser pointer acceleration", xinput_path);
371373
}
372374

373375
puts("READY");

0 commit comments

Comments
 (0)