mirror of
https://github.com/swaywm/sway.git
synced 2024-11-11 21:14:10 +01:00
Merge pull request #2226 from emersion/swaylock-daemonize-after-lock
swaylock: daemonize after locking
This commit is contained in:
commit
6595d07ec7
@ -23,6 +23,7 @@ struct swaylock_args {
|
|||||||
uint32_t color;
|
uint32_t color;
|
||||||
enum background_mode mode;
|
enum background_mode mode;
|
||||||
bool show_indicator;
|
bool show_indicator;
|
||||||
|
bool daemonize;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct swaylock_password {
|
struct swaylock_password {
|
||||||
|
@ -38,6 +38,7 @@ static void daemonize() {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
|
setsid();
|
||||||
close(fds[0]);
|
close(fds[0]);
|
||||||
int devnull = open("/dev/null", O_RDWR);
|
int devnull = open("/dev/null", O_RDWR);
|
||||||
dup2(STDOUT_FILENO, devnull);
|
dup2(STDOUT_FILENO, devnull);
|
||||||
@ -406,7 +407,7 @@ int main(int argc, char **argv) {
|
|||||||
" -v, --version Show the version number and quit.\n"
|
" -v, --version Show the version number and quit.\n"
|
||||||
" -i, --image [<output>:]<path> Display the given image.\n"
|
" -i, --image [<output>:]<path> Display the given image.\n"
|
||||||
" -u, --no-unlock-indicator Disable the unlock indicator.\n"
|
" -u, --no-unlock-indicator Disable the unlock indicator.\n"
|
||||||
" -f, --daemonize Detach from the controlling terminal.\n";
|
" -f, --daemonize Detach from the controlling terminal after locking.\n";
|
||||||
|
|
||||||
state.args = (struct swaylock_args){
|
state.args = (struct swaylock_args){
|
||||||
.mode = BACKGROUND_MODE_SOLID_COLOR,
|
.mode = BACKGROUND_MODE_SOLID_COLOR,
|
||||||
@ -454,7 +455,7 @@ int main(int argc, char **argv) {
|
|||||||
state.args.show_indicator = false;
|
state.args.show_indicator = false;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
daemonize();
|
state.args.daemonize = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s", usage);
|
fprintf(stderr, "%s", usage);
|
||||||
@ -510,6 +511,11 @@ int main(int argc, char **argv) {
|
|||||||
create_layer_surface(surface);
|
create_layer_surface(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (state.args.daemonize) {
|
||||||
|
wl_display_roundtrip(state.display);
|
||||||
|
daemonize();
|
||||||
|
}
|
||||||
|
|
||||||
state.run_display = true;
|
state.run_display = true;
|
||||||
while (wl_display_dispatch(state.display) != -1 && state.run_display) {
|
while (wl_display_dispatch(state.display) != -1 && state.run_display) {
|
||||||
// This space intentionally left blank
|
// This space intentionally left blank
|
||||||
|
@ -37,6 +37,9 @@ Locks your Wayland session.
|
|||||||
*-u, --no-unlock-indicator*
|
*-u, --no-unlock-indicator*
|
||||||
Disable the unlock indicator.
|
Disable the unlock indicator.
|
||||||
|
|
||||||
|
*-f, --daemonize*
|
||||||
|
Detach from the controlling terminal after locking.
|
||||||
|
|
||||||
*-v, --version*
|
*-v, --version*
|
||||||
Show the version number and quit.
|
Show the version number and quit.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user