Change exit menu
This commit is contained in:
parent
071d28fc5e
commit
81176dd138
39
dwm.c
39
dwm.c
|
@ -1573,26 +1573,27 @@ quit(const Arg *arg)
|
|||
void
|
||||
quitprompt(const Arg *arg)
|
||||
{
|
||||
FILE *pp = popen("echo \"no\nrestart\nyes\" | dmenu -i -sb red -p \"Quit DWM?\"", "r");
|
||||
if(pp != NULL) {
|
||||
char buf[1024];
|
||||
if (fgets(buf, sizeof(buf), pp) == NULL) {
|
||||
fprintf(stderr, "Quitprompt: Error reading pipe!\n");
|
||||
return;
|
||||
}
|
||||
if (strcmp(buf, "yes\n") == 0) {
|
||||
pclose(pp);
|
||||
restart = 0;
|
||||
quit(NULL);
|
||||
} else if (strcmp(buf, "restart\n") == 0) {
|
||||
pclose(pp);
|
||||
restart = 1;
|
||||
quit(NULL);
|
||||
} else if (strcmp(buf, "no\n") == 0) {
|
||||
pclose(pp);
|
||||
return;
|
||||
}
|
||||
FILE *pp = popen("echo \"lock\nrestart\nexit\nreboot\nshutdown\" | dmenu -i -sb red -p \"exit:\"", "r");
|
||||
|
||||
char buf[16];
|
||||
|
||||
if(pp == NULL || fscanf(pp, "%15[a-zA-Z -]", buf) == EOF) {
|
||||
fputs("Quitprompt: Error reading pipe!", stderr);
|
||||
goto close_streams;
|
||||
}
|
||||
|
||||
int sysret;
|
||||
|
||||
if(strcmp(buf, "lock") == 0) sysret = system("slock");
|
||||
else if(strcmp(buf, "restart") == 0) quit(&(const Arg){1});
|
||||
else if(strcmp(buf, "exit") == 0) quit(&(const Arg){0});
|
||||
else if(strcmp(buf, "reboot") == 0) sysret = system("systemctl reboot");
|
||||
else if(strcmp(buf, "shutdown") == 0) sysret = system("systemctl poweroff -i");
|
||||
|
||||
if(sysret);
|
||||
|
||||
close_streams:
|
||||
pclose(pp);
|
||||
}
|
||||
|
||||
Monitor *
|
||||
|
|
Loading…
Reference in New Issue