diff --git a/extra/service/legiond/legiond.c b/extra/service/legiond/legiond.c index fca0d13..f848afc 100644 --- a/extra/service/legiond/legiond.c +++ b/extra/service/legiond/legiond.c @@ -2,6 +2,7 @@ #include "modules/parseconf.h" #include "modules/setapply.h" #include "modules/powerstate.h" +#include "modules/output.h" LEGIOND_CONFIG config; @@ -25,14 +26,14 @@ void term_handler(int signum) void timer_handler() { - printf("---set_all start---\n"); + pretty("set_all start"); set_all(get_powerstate(), &config); if (delayed) delayed = 0; triggered = true; - printf("---set_all end----\n"); + pretty("set_all end"); } void set_timer(struct itimerspec *its, long delay_s, long delay_ns, @@ -116,14 +117,14 @@ int main() delayed = delay; } } else if (ret[0] == 'B' && triggered == true) { - printf("---set_cpu start---\n"); + pretty("set_cpu start"); set_cpu(get_powerstate(), &config); - printf("---set_cpu end-----\n"); + pretty("set_cpu end"); } else if (ret[0] == 'R') { - printf("---config reload start---\n"); + pretty("config reload start"); parseconf(&config); set_all(get_powerstate(), &config); - printf("---config reload end-----\n"); + pretty("config reload end"); } else { printf("do nothing\n"); } diff --git a/extra/service/legiond/modules/output.c b/extra/service/legiond/modules/output.c new file mode 100644 index 0000000..3be92c6 --- /dev/null +++ b/extra/service/legiond/modules/output.c @@ -0,0 +1,20 @@ +#include "output.h" +#include +#include + +void pretty(char *msg) +{ + int len = strlen(msg); + len = len > 30 ? len : 30; + printf("\033[1m"); + for (int i = 0; i < len / 2; i++) { + putchar('-'); + } + printf("%s", msg); + for (int i = 0; i < len / 2; i++) { + putchar('-'); + } + printf("\033[m"); + + putchar('\n'); +} diff --git a/extra/service/legiond/modules/output.h b/extra/service/legiond/modules/output.h new file mode 100644 index 0000000..2b91f44 --- /dev/null +++ b/extra/service/legiond/modules/output.h @@ -0,0 +1,6 @@ +#ifndef OUTPUT_H_ +#define OUTPUT_H_ + +void pretty(char *msg); + +#endif // OUTPUT_H_ diff --git a/extra/service/legiond/modules/powerstate.c b/extra/service/legiond/modules/powerstate.c index d12796d..a4d9b98 100644 --- a/extra/service/legiond/modules/powerstate.c +++ b/extra/service/legiond/modules/powerstate.c @@ -38,12 +38,12 @@ static POWER_STATE get_ppdstate() POWER_STATE get_powerstate() { static bool use_ppd = false; - static bool reload = false; + static bool initialize = false; POWER_STATE power_state = -1; FILE *fp; - if (!reload) { - reload = true; + if (!initialize) { + initialize = true; if (access(profile_path, F_OK)) { use_ppd = true; }