]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
feature: display status with a different shape depending on the status (#17728)
authorJiehong <email@majiehong.com>
Wed, 20 Jan 2021 14:52:35 +0000 (15:52 +0100)
committerLennart Poettering <lennart@poettering.net>
Fri, 22 Jan 2021 19:45:43 +0000 (20:45 +0100)
man/systemctl.xml
src/basic/locale-util.c
src/basic/locale-util.h
src/basic/unit-def.c
src/basic/unit-def.h
src/systemctl/systemctl-list-dependencies.c
src/systemctl/systemctl-show.c
src/test/test-locale-util.c

index f316fb5eb836d57315aa4004fa14ba91987cffb2..d82f956fa8999b1f176035945dda1ef1e417da54 100644 (file)
@@ -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
index 4c81cb94401ab1e1a9f5f57a869eecc4d9b79e2f..f58e0348ba76d77084904c5e4c7e2c05fe60f612 100644 (file)
@@ -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",             /* ✓ */
index 2d672e2f95952a9281c1b371922cadbaf645c413..37bc3b7490ed9a424213b41d95d1f0e99ec269b4 100644 (file)
@@ -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,
index 145399c9639cc16cfabeea0c8037cde1fa054db4..bb4fa1ec6bf31daf0368475e12579309c0f3fe82 100644 (file)
@@ -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;
+            }
+}
index 8535fbe06231a02fa889b0fd505d18f55abd18d2..d6fc0c0379fbef41d6ab6d9497048ca9fb537807 100644 (file)
@@ -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);
index 821998eb4fc7146c89043d830260e3ce4ebbb2b0..fbb81d90fa2fa3196a6e0053c2277ae395f7c494 100644 (file)
@@ -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);
index db3a3bd40aa9fc8667ab91c06c1588192d2d8299..ab66977a7afdbedb0221430aa8c82c5b87f9329c 100644 (file)
@@ -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);
         }
 
index 62f82200a0b3e0f4f888a5259bee1bfe28828c03..972423e2fa2856ffd825f22c702156c2f9f36398 100644 (file)
@@ -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);