From 40ecfcd1f19c2e29029a76a232fa56339438442a Mon Sep 17 00:00:00 2001 From: Dave Davenport Date: Sun, 12 Jun 2022 17:49:04 +0200 Subject: [PATCH] [Script] Print list of user scripts in -h --- include/modes/script.h | 6 ++++++ source/modes/script.c | 9 +++++++++ source/rofi.c | 3 +++ 3 files changed, 18 insertions(+) diff --git a/include/modes/script.h b/include/modes/script.h index 3436e796..ed53387e 100644 --- a/include/modes/script.h +++ b/include/modes/script.h @@ -64,5 +64,11 @@ void script_mode_gather_user_scripts(void); * Cleanup memory allocated by `script_mode_gather_user_scripts` */ void script_mode_cleanup(void); +/** + * @param is_term if printed to terminal + * + * List the user scripts found. + */ +void script_user_list(gboolean is_term); /**@}*/ #endif // ROFI_MODE_SCRIPT_H diff --git a/source/modes/script.c b/source/modes/script.c index 643127cc..abcb445f 100644 --- a/source/modes/script.c +++ b/source/modes/script.c @@ -552,3 +552,12 @@ gboolean script_mode_is_valid(const char *token) { } return strchr(token, ':') != NULL; } + +void script_user_list(gboolean is_term) { + + for (unsigned int i = 0; i < num_scripts; i++) { + printf(" • %s%s%s (%s)\n", is_term ? (color_bold) : "", + user_scripts[i].name, is_term ? color_reset : "", + user_scripts[i].path); + } +} diff --git a/source/rofi.c b/source/rofi.c index 096d85d7..69058d1a 100644 --- a/source/rofi.c +++ b/source/rofi.c @@ -327,6 +327,9 @@ static void help(G_GNUC_UNUSED int argc, char **argv) { printf("Detected modes:\n"); print_list_of_modes(is_term); printf("\n"); + printf("Detected user scripts:\n"); + script_user_list(is_term); + printf("\n"); printf("Compile time options:\n"); #ifdef WINDOW_MODE printf("\t• window %senabled%s\n", is_term ? color_green : "",