From 31f7fbba33d0a72a584ed03c555ac8534bd24698 Mon Sep 17 00:00:00 2001 From: Alberto Fanjul Date: Sun, 20 Nov 2022 11:47:35 +0100 Subject: [PATCH] Set custom ctl names --- src/ctl/ctl-cli.c | 2 +- src/ctl/ctl.h | 9 ++++----- src/ctl/sinkctl.c | 6 ++++++ src/ctl/wifictl.c | 7 +++++++ 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/ctl/ctl-cli.c b/src/ctl/ctl-cli.c index 15ce621..ba56dc8 100644 --- a/src/ctl/ctl-cli.c +++ b/src/ctl/ctl-cli.c @@ -697,7 +697,7 @@ int cli_init(sd_bus *bus, const struct cli_cmd *cmds) read_history(get_history_filename()); rl_end_of_history(0, 0); - rl_set_prompt(CLI_PROMPT); + rl_set_prompt(get_cli_prompt()); printf("\r"); rl_on_new_line(); rl_redisplay(); diff --git a/src/ctl/ctl.h b/src/ctl/ctl.h index 69b0db8..cb8855f 100644 --- a/src/ctl/ctl.h +++ b/src/ctl/ctl.h @@ -17,6 +17,9 @@ * along with MiracleCast; If not, see . */ +#ifndef CTL_CTL_H +#define CTL_CTL_H + #include #include #include @@ -34,9 +37,6 @@ #include #include -#ifndef CTL_CTL_H -#define CTL_CTL_H - struct ctl_wifi; struct ctl_link; struct ctl_peer; @@ -203,8 +203,6 @@ void cli_command_printf(const char *fmt, ...); #define CLI_BOLDGRAY "\x1B[1;30m" #define CLI_BOLDWHITE "\x1B[1;37m" -#define CLI_PROMPT CLI_BLUE "[miraclectl] # " CLI_DEFAULT - struct cli_cmd { const char *cmd; const char *args; @@ -231,6 +229,7 @@ extern unsigned int wfd_supported_res_cea; extern unsigned int wfd_supported_res_vesa; extern unsigned int wfd_supported_res_hh; +char* get_cli_prompt(); int cli_init(sd_bus *bus, const struct cli_cmd *cmds); void cli_destroy(void); int cli_run(void); diff --git a/src/ctl/sinkctl.c b/src/ctl/sinkctl.c index 8f0e0c8..e1335df 100644 --- a/src/ctl/sinkctl.c +++ b/src/ctl/sinkctl.c @@ -51,6 +51,8 @@ #define HISTORY_FILENAME ".miracle-sink.history" +#define CLI_PROMPT CLI_BLUE "[sinkctl] # " CLI_DEFAULT + static sd_bus *bus; static struct ctl_wifi *wifi; static struct ctl_sink *sink; @@ -87,6 +89,10 @@ struct ctl_wifi *get_wifi() return wifi; } +char* get_cli_prompt() +{ + return CLI_PROMPT; +} /* * get history filename diff --git a/src/ctl/wifictl.c b/src/ctl/wifictl.c index c53d4af..5447554 100644 --- a/src/ctl/wifictl.c +++ b/src/ctl/wifictl.c @@ -38,11 +38,18 @@ #define HISTORY_FILENAME ".miracle-wifi.history" +#define CLI_PROMPT CLI_BLUE "[wifictl] # " CLI_DEFAULT + static sd_bus *bus; static struct ctl_wifi *wifi; static struct ctl_link *selected_link; +char* get_cli_prompt() +{ + return CLI_PROMPT; +} + /* * get history filename */