birdwm

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 1f08eefc59b2d32899b5bb7c84be3865a9098a89
parent 4c6dc552ae0431688018f96f120fe2152bbd075b
Author: grouse <bdmfegys@duck.com>
Date:   Fri,  2 Feb 2024 01:42:36 -0500

rename TEST in exitdwm.c to RESTARTER_SCRIPT

Diffstat:
Mexitdwm.c | 152+++++++++++++++++++++++++++++++++++--------------------------------------------
1 file changed, 68 insertions(+), 84 deletions(-)

diff --git a/exitdwm.c b/exitdwm.c @@ -1,95 +1,79 @@ -# include <stdio.h> -# include <string.h> +#include <stdio.h> +#include <string.h> -void exitdwm () -{ -# if \ - defined S_LOCK || \ - defined S_RESTART_DWM || \ - defined S_OFFSCREEN || \ - defined S_TEST || \ - defined S_EXIT || \ - defined S_REBOOT || \ - defined S_SHUTDOWN || \ - defined S_LOCK_ICON || \ - defined S_RESTART_DWM_ICON || \ - defined S_OFFSCREEN_ICON || \ - defined S_EXIT_ICON || \ - defined S_TEST_ICON || \ - defined S_REBOOT_ICON || \ - defined S_SHUTDOWN_ICON || \ - defined S_FORMAT || \ - defined S_FORMAT_CLEAR -# error (conflicting macro names) -# endif +void exitdwm() { +#if defined S_LOCK || defined S_RESTART_DWM || defined S_OFFSCREEN || \ + defined S_RESTARTER_SCRIPT || defined S_EXIT || defined S_REBOOT || \ + defined S_SHUTDOWN || defined S_LOCK_ICON || defined S_RESTART_DWM_ICON || \ + defined S_OFFSCREEN_ICON || defined S_EXIT_ICON || \ + defined S_RESTARTER_SCRIPT_ICON || defined S_REBOOT_ICON || \ + defined S_SHUTDOWN_ICON || defined S_FORMAT || defined S_FORMAT_CLEAR +#error(conflicting macro names) +#endif -# define S_LOCK "Lock" -# define S_RESTART_DWM "restart birdwm" -# define S_OFFSCREEN "Off-screen" -# define S_TEST "Restarter Script" -# define S_EXIT "Exit" -# define S_REBOOT "Reboot" -# define S_SHUTDOWN "Shutdown" -# define S_LOCK_ICON "\uf023" // <= FontAwesome icons -# define S_RESTART_DWM_ICON "\uf01e" -# define S_OFFSCREEN_ICON "\uf108" -# define S_EXIT_ICON "\uf2f5" -# define S_TEST_ICON "\uf0c9" -# define S_REBOOT_ICON "\uf021" -# define S_SHUTDOWN_ICON "\uf011" +#define S_LOCK "Lock" +#define S_RESTART_DWM "restart birdwm" +#define S_OFFSCREEN "Off-screen" +#define S_RESTARTER_SCRIPT "Restarter Script" +#define S_EXIT "Exit" +#define S_REBOOT "Reboot" +#define S_SHUTDOWN "Shutdown" +#define S_LOCK_ICON "\uf023" // <= FontAwesome icons +#define S_RESTART_DWM_ICON "\uf01e" +#define S_OFFSCREEN_ICON "\uf108" +#define S_EXIT_ICON "\uf2f5" +#define S_RESTARTER_SCRIPT_ICON "\uf0c9" +#define S_REBOOT_ICON "\uf021" +#define S_SHUTDOWN_ICON "\uf011" -# define S_FORMAT(ACTION) S_##ACTION##_ICON " " S_##ACTION -# define S_FORMAT_CLEAR "sed 's/^..//'" +#define S_FORMAT(ACTION) S_##ACTION##_ICON " " S_##ACTION +#define S_FORMAT_CLEAR "sed 's/^..//'" - FILE * exit_menu = popen ( - "echo \"" - S_FORMAT (LOCK) "\n" - S_FORMAT (RESTART_DWM) "\n" - S_FORMAT (OFFSCREEN) "\n" - S_FORMAT (TEST) "\n" - S_FORMAT (EXIT) "\n" - S_FORMAT (REBOOT) "\n" - S_FORMAT (SHUTDOWN) - "\" | dmenu -i -p exit: | " S_FORMAT_CLEAR - , - "r" - ); + FILE *exit_menu = popen( + "echo \"" S_FORMAT(LOCK) "\n" S_FORMAT(RESTART_DWM) "\n" S_FORMAT(OFFSCREEN) "\n" S_FORMAT( + RESTARTER_SCRIPT) "\n" S_FORMAT(EXIT) "\n" S_FORMAT(REBOOT) "\n" S_FORMAT(SHUTDOWN) "\" | dmenu -i -p exit: | " S_FORMAT_CLEAR, + "r"); - char exit_action [16]; + char exit_action[16]; - if ( - exit_menu == NULL || - fscanf (exit_menu, "%15[a-zA-Z -]", exit_action) == EOF - ) { - fputs ("Error. Failure in exit_dwm.", stderr); - goto close_streams; - } + if (exit_menu == NULL || + fscanf(exit_menu, "%15[a-zA-Z -]", exit_action) == EOF) { + fputs("Error. Failure in exit_dwm.", stderr); + goto close_streams; + } - if (strcmp (exit_action, S_LOCK) == 0) system ("slock & sleep 10; xset dpms force off"); - else if (strcmp (exit_action, S_RESTART_DWM) == 0) quit (& (const Arg) {1}); - else if (strcmp (exit_action, S_OFFSCREEN) == 0) system ("sleep .5; xset dpms force off"); - else if (strcmp (exit_action, S_EXIT) == 0) quit (& (const Arg) {0}); - else if (strcmp (exit_action, S_TEST) == 0) system ("restarter"); - else if (strcmp (exit_action, S_REBOOT) == 0) system ("systemctl reboot"); - else if (strcmp (exit_action, S_SHUTDOWN) == 0) system ("systemctl poweroff -i"); + if (strcmp(exit_action, S_LOCK) == 0) + system("slock & sleep 10; xset dpms force off"); + else if (strcmp(exit_action, S_RESTART_DWM) == 0) + quit(&(const Arg){1}); + else if (strcmp(exit_action, S_OFFSCREEN) == 0) + system("sleep .5; xset dpms force off"); + else if (strcmp(exit_action, S_EXIT) == 0) + quit(&(const Arg){0}); + else if (strcmp(exit_action, S_RESTARTER_SCRIPT) == 0) + system("restarter"); + else if (strcmp(exit_action, S_REBOOT) == 0) + system("systemctl reboot"); + else if (strcmp(exit_action, S_SHUTDOWN) == 0) + system("systemctl poweroff -i"); close_streams: - pclose (exit_menu); + pclose(exit_menu); -# undef S_LOCK -# undef S_RESTART_DWM -# undef S_OFFSCREEN -# undef S_EXIT -# undef S_TEST -# undef S_REBOOT -# undef S_SHUTDOWN -# undef S_LOCK_ICON -# undef S_RESTART_DWM_ICON -# undef S_OFFSCREEN_ICON -# undef S_EXIT_ICON -# undef S_TEST_ICON -# undef S_REBOOT_ICON -# undef S_SHUTDOWN_ICON -# undef S_FORMAT -# undef S_FORMAT_CLEAR +#undef S_LOCK +#undef S_RESTART_DWM +#undef S_OFFSCREEN +#undef S_EXIT +#undef S_RESTARTER_SCRIPT +#undef S_REBOOT +#undef S_SHUTDOWN +#undef S_LOCK_ICON +#undef S_RESTART_DWM_ICON +#undef S_OFFSCREEN_ICON +#undef S_EXIT_ICON +#undef S_RESTARTER_SCRIPT_ICON +#undef S_REBOOT_ICON +#undef S_SHUTDOWN_ICON +#undef S_FORMAT +#undef S_FORMAT_CLEAR }