diff --git a/man/systemctl.xml b/man/systemctl.xml index f316fb5eb83..d82f956fa89 100644 --- a/man/systemctl.xml +++ b/man/systemctl.xml @@ -230,10 +230,11 @@ Jan 12 10:46:45 example.com bluetoothd[8900]: Current Time Service could not be Jan 12 10:46:45 example.com bluetoothd[8900]: gatt-time-server: Input/output error (5) - The dot ("●") uses color on supported terminals to summarize the unit state at a glance. White - indicates an inactive or deactivating state. Red indicates a - failed or error state and green indicates an - active, reloading or activating state. + The dot ("●") uses color on supported terminals to summarize the unit state at a glance. Along with + its color, its shape varies according to its state: inactive or + maintenance is a white circle ("○"), active is a green dot ("●"), + deactivating is a white dot, failed or error is + a red cross ("×"), and reloading is a green clockwise circle arrow ("↻"). The "Loaded:" line in the output will show loaded if the unit has been loaded into diff --git a/src/basic/locale-util.c b/src/basic/locale-util.c index 4c81cb94401..f58e0348ba7 100644 --- a/src/basic/locale-util.c +++ b/src/basic/locale-util.c @@ -356,6 +356,9 @@ const char *special_glyph(SpecialGlyph code) { [SPECIAL_GLYPH_TREE_SPACE] = " ", [SPECIAL_GLYPH_TRIANGULAR_BULLET] = ">", [SPECIAL_GLYPH_BLACK_CIRCLE] = "*", + [SPECIAL_GLYPH_WHITE_CIRCLE] = "*", + [SPECIAL_GLYPH_MULTIPLICATION_SIGN] = "x", + [SPECIAL_GLYPH_CIRCLE_ARROW] = "*", [SPECIAL_GLYPH_BULLET] = "*", [SPECIAL_GLYPH_MU] = "u", [SPECIAL_GLYPH_CHECK_MARK] = "+", @@ -388,6 +391,9 @@ const char *special_glyph(SpecialGlyph code) { /* Single glyphs in both cases */ [SPECIAL_GLYPH_TRIANGULAR_BULLET] = "\342\200\243", /* ‣ */ [SPECIAL_GLYPH_BLACK_CIRCLE] = "\342\227\217", /* ● */ + [SPECIAL_GLYPH_WHITE_CIRCLE] = "\u25CB", /* ○ */ + [SPECIAL_GLYPH_MULTIPLICATION_SIGN] = "\u00D7", /* × */ + [SPECIAL_GLYPH_CIRCLE_ARROW] = "\u21BB", /* ↻ */ [SPECIAL_GLYPH_BULLET] = "\342\200\242", /* • */ [SPECIAL_GLYPH_MU] = "\316\274", /* μ (actually called: GREEK SMALL LETTER MU) */ [SPECIAL_GLYPH_CHECK_MARK] = "\342\234\223", /* ✓ */ diff --git a/src/basic/locale-util.h b/src/basic/locale-util.h index 2d672e2f959..37bc3b7490e 100644 --- a/src/basic/locale-util.h +++ b/src/basic/locale-util.h @@ -46,6 +46,9 @@ typedef enum { SPECIAL_GLYPH_TREE_SPACE, SPECIAL_GLYPH_TRIANGULAR_BULLET, SPECIAL_GLYPH_BLACK_CIRCLE, + SPECIAL_GLYPH_WHITE_CIRCLE, + SPECIAL_GLYPH_MULTIPLICATION_SIGN, + SPECIAL_GLYPH_CIRCLE_ARROW, SPECIAL_GLYPH_BULLET, SPECIAL_GLYPH_MU, SPECIAL_GLYPH_CHECK_MARK, diff --git a/src/basic/unit-def.c b/src/basic/unit-def.c index 145399c9639..bb4fa1ec6bf 100644 --- a/src/basic/unit-def.c +++ b/src/basic/unit-def.c @@ -287,3 +287,24 @@ static const char* const notify_access_table[_NOTIFY_ACCESS_MAX] = { }; DEFINE_STRING_TABLE_LOOKUP(notify_access, NotifyAccess); + +SpecialGlyph unit_active_state_to_glyph(UnitActiveState state) { + switch (state) { + case UNIT_ACTIVE: + return SPECIAL_GLYPH_BLACK_CIRCLE; + case UNIT_RELOADING: + return SPECIAL_GLYPH_CIRCLE_ARROW; + case UNIT_INACTIVE: + return SPECIAL_GLYPH_WHITE_CIRCLE; + case UNIT_FAILED: + return SPECIAL_GLYPH_MULTIPLICATION_SIGN; + case UNIT_ACTIVATING: + case UNIT_DEACTIVATING: + return SPECIAL_GLYPH_BLACK_CIRCLE; + case UNIT_MAINTENANCE: + return SPECIAL_GLYPH_WHITE_CIRCLE; + + default: + return SPECIAL_GLYPH_BLACK_CIRCLE; + } +} diff --git a/src/basic/unit-def.h b/src/basic/unit-def.h index 8535fbe0623..d6fc0c0379f 100644 --- a/src/basic/unit-def.h +++ b/src/basic/unit-def.h @@ -3,6 +3,7 @@ #include +#include "locale-util.h" #include "macro.h" /* The enum order is used to order unit jobs in the job queue @@ -304,3 +305,5 @@ UnitDependency unit_dependency_from_string(const char *s) _pure_; const char* notify_access_to_string(NotifyAccess i) _const_; NotifyAccess notify_access_from_string(const char *s) _pure_; + +SpecialGlyph unit_active_state_to_glyph(UnitActiveState state); diff --git a/src/systemctl/systemctl-list-dependencies.c b/src/systemctl/systemctl-list-dependencies.c index 821998eb4fc..fbb81d90fa2 100644 --- a/src/systemctl/systemctl-list-dependencies.c +++ b/src/systemctl/systemctl-list-dependencies.c @@ -117,7 +117,7 @@ static int list_dependencies_one( break; } - printf("%s%s%s ", on, special_glyph(SPECIAL_GLYPH_BLACK_CIRCLE), ansi_normal()); + printf("%s%s%s ", on, special_glyph(unit_active_state_to_glyph(active_state)), ansi_normal()); } r = list_dependencies_print(*c, level, branches, c[1] == NULL); diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c index db3a3bd40aa..ab66977a7af 100644 --- a/src/systemctl/systemctl-show.c +++ b/src/systemctl/systemctl-show.c @@ -314,7 +314,9 @@ static void print_status_info( format_active_state(i->active_state, &active_on, &active_off); - printf("%s%s%s %s", active_on, special_glyph(SPECIAL_GLYPH_BLACK_CIRCLE), active_off, strna(i->id)); + const SpecialGlyph glyph = unit_active_state_to_glyph(unit_active_state_from_string(i->active_state)); + + printf("%s%s%s %s", active_on, special_glyph(glyph), active_off, strna(i->id)); if (i->description && !streq_ptr(i->id, i->description)) printf(" - %s", i->description); @@ -433,7 +435,7 @@ static void print_status_info( printf("%s %s%s%s %s\n", t == i->triggered_by ? "TriggeredBy:" : " ", - on, special_glyph(SPECIAL_GLYPH_BLACK_CIRCLE), off, + on, special_glyph(unit_active_state_to_glyph(state)), off, *t); } diff --git a/src/test/test-locale-util.c b/src/test/test-locale-util.c index 62f82200a0b..972423e2fa2 100644 --- a/src/test/test-locale-util.c +++ b/src/test/test-locale-util.c @@ -101,6 +101,9 @@ static void dump_special_glyphs(void) { dump_glyph(SPECIAL_GLYPH_TREE_SPACE); dump_glyph(SPECIAL_GLYPH_TRIANGULAR_BULLET); dump_glyph(SPECIAL_GLYPH_BLACK_CIRCLE); + dump_glyph(SPECIAL_GLYPH_WHITE_CIRCLE); + dump_glyph(SPECIAL_GLYPH_MULTIPLICATION_SIGN); + dump_glyph(SPECIAL_GLYPH_CIRCLE_ARROW); dump_glyph(SPECIAL_GLYPH_BULLET); dump_glyph(SPECIAL_GLYPH_ARROW); dump_glyph(SPECIAL_GLYPH_ELLIPSIS);