mirror of
https://github.com/perk11/runwhenidle.git
synced 2026-01-08 21:27:57 -05:00
Open display before running the command so that it doesn't start execution in case X is not available.
This commit is contained in:
15
main.c
15
main.c
@@ -75,6 +75,14 @@ int main(int argc, char *argv[]) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
//Open display and initialize XScreensaverInfo for querying idle time
|
||||
Display *dpy = XOpenDisplay(NULL);
|
||||
if (!dpy) {
|
||||
fprintf(stderr, "Couldn't open an X11 display!\n");
|
||||
return 1;
|
||||
}
|
||||
XScreenSaverInfo *info = XScreenSaverAllocInfo();
|
||||
|
||||
shell_command_to_run = argv[optind];
|
||||
|
||||
// Fork a child process to run the command
|
||||
@@ -89,13 +97,6 @@ int main(int argc, char *argv[]) {
|
||||
exit(1);
|
||||
}
|
||||
|
||||
Display *dpy = XOpenDisplay(NULL);
|
||||
if (!dpy) {
|
||||
fprintf(stderr, "Couldn't open an X11 display!\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
XScreenSaverInfo *info = XScreenSaverAllocInfo();
|
||||
int polling_interval_seconds = 1;
|
||||
int sleep_time_seconds = polling_interval_seconds;
|
||||
int command_paused = 0;
|
||||
|
||||
Reference in New Issue
Block a user