]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
loginctl: *-status: set minimum table column width if extra info will be printed
authorMike Yuan <me@yhndnzj.com>
Tue, 10 Oct 2023 14:08:36 +0000 (22:08 +0800)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 10 Oct 2023 22:30:52 +0000 (23:30 +0100)
Follow-up for bf366954fa09070f6c3e1e630f57d20463fc5739

Before this commit, we hardcode "prefix" to the widest field
possible in the table. However, there's no guarantee that the
field would actually be used/added, so it could potentially
result in misalignment. Therefore, let's set the minimum width
of the cell to the hardcoded width too.

src/login/loginctl.c

index 8704f44dfd7989a5b9564be6c455211068a9ff00..5248135d006e033e811d8406956fdf16ead9be5e 100644 (file)
@@ -628,6 +628,7 @@ static int print_session_status_info(sd_bus *bus, const char *path) {
         if (i.scope) {
                 r = table_add_many(table,
                                    TABLE_FIELD, "Unit",
+                                   TABLE_SET_MINIMUM_WIDTH, STRLEN("Display"), /* For alignment with show_unit_cgroup */
                                    TABLE_STRING, i.scope);
                 if (r < 0)
                         return table_log_add_error(r);
@@ -732,6 +733,7 @@ static int print_user_status_info(sd_bus *bus, const char *path) {
         if (i.slice) {
                 r = table_add_many(table,
                                    TABLE_FIELD, "Unit",
+                                   TABLE_SET_MINIMUM_WIDTH, STRLEN("Sessions"), /* For alignment with show_unit_cgroup */
                                    TABLE_STRING, i.slice);
                 if (r < 0)
                         return table_log_add_error(r);
@@ -805,6 +807,7 @@ static int print_seat_status_info(sd_bus *bus, const char *path) {
         if (arg_transport == BUS_TRANSPORT_LOCAL) {
                 r = table_add_many(table,
                                    TABLE_FIELD, "Devices",
+                                   TABLE_SET_MINIMUM_WIDTH, STRLEN("Sessions"), /* For alignment with show_sysfs */
                                    TABLE_EMPTY);
                 if (r < 0)
                         return table_log_add_error(r);