mirror of https://github.com/i3/i3lock.git
Add support for `xss-lock --transfer-sleep-lock' (#75)
Add support for `xss-lock --transfer-sleep-lock'pull/48/merge
parent
402254b575
commit
463d38fed6
18
i3lock.c
18
i3lock.c
|
@ -627,6 +627,22 @@ static void xcb_prepare_cb(EV_P_ ev_prepare *w, int revents) {
|
||||||
xcb_flush(conn);
|
xcb_flush(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Try closing logind sleep lock fd passed over from xss-lock, in case we're
|
||||||
|
* being run from there.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static void maybe_close_sleep_lock_fd(void) {
|
||||||
|
const char *sleep_lock_fd = getenv("XSS_SLEEP_LOCK_FD");
|
||||||
|
char *endptr;
|
||||||
|
if (sleep_lock_fd && *sleep_lock_fd != 0) {
|
||||||
|
long int fd = strtol(sleep_lock_fd, &endptr, 10);
|
||||||
|
if (*endptr == 0) {
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Instead of polling the X connection socket we leave this to
|
* Instead of polling the X connection socket we leave this to
|
||||||
* xcb_poll_for_event() which knows better than we can ever know.
|
* xcb_poll_for_event() which knows better than we can ever know.
|
||||||
|
@ -661,6 +677,7 @@ static void xcb_check_cb(EV_P_ ev_check *w, int revents) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case XCB_MAP_NOTIFY:
|
case XCB_MAP_NOTIFY:
|
||||||
|
maybe_close_sleep_lock_fd();
|
||||||
if (!dont_fork) {
|
if (!dont_fork) {
|
||||||
/* After the first MapNotify, we never fork again. We don’t
|
/* After the first MapNotify, we never fork again. We don’t
|
||||||
* expect to get another MapNotify, but better be sure… */
|
* expect to get another MapNotify, but better be sure… */
|
||||||
|
@ -956,6 +973,7 @@ int main(int argc, char *argv[]) {
|
||||||
if (pid == 0) {
|
if (pid == 0) {
|
||||||
/* Child */
|
/* Child */
|
||||||
close(xcb_get_file_descriptor(conn));
|
close(xcb_get_file_descriptor(conn));
|
||||||
|
maybe_close_sleep_lock_fd();
|
||||||
raise_loop(win);
|
raise_loop(win);
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue