mirror of
https://github.com/systemd/systemd.git
synced 2025-03-19 22:50:17 +03:00
feature: display status with a different shape depending on the status (#17728)
This commit is contained in:
parent
95457dc13c
commit
9ae5fed64e
@ -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)
|
||||
</programlisting>
|
||||
|
||||
<para>The dot ("●") uses color on supported terminals to summarize the unit state at a glance. White
|
||||
indicates an <literal>inactive</literal> or <literal>deactivating</literal> state. Red indicates a
|
||||
<literal>failed</literal> or <literal>error</literal> state and green indicates an
|
||||
<literal>active</literal>, <literal>reloading</literal> or <literal>activating</literal> state.
|
||||
<para>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: <literal>inactive</literal> or
|
||||
<literal>maintenance</literal> is a white circle ("○"), <literal>active</literal> is a green dot ("●"),
|
||||
<literal>deactivating</literal> is a white dot, <literal>failed</literal> or <literal>error</literal> is
|
||||
a red cross ("×"), and <literal>reloading</literal> is a green clockwise circle arrow ("↻").
|
||||
</para>
|
||||
|
||||
<para>The "Loaded:" line in the output will show <literal>loaded</literal> if the unit has been loaded into
|
||||
|
@ -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", /* ✓ */
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#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);
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user