Change exit menu

This commit is contained in:
BitHeaven 2023-05-28 10:36:59 +05:00
parent 071d28fc5e
commit 81176dd138
3 changed files with 20 additions and 19 deletions

BIN
dwm

Binary file not shown.

37
dwm.c
View File

@ -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;
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;
}
if (strcmp(buf, "yes\n") == 0) {
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);
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;
}
}
}
Monitor *

BIN
dwm.o

Binary file not shown.