]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
hostnamectl: make the distribution name a pretty clickable link if we can
authorLennart Poettering <lennart@poettering.net>
Thu, 19 Apr 2018 15:52:51 +0000 (17:52 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 19 Apr 2018 16:04:26 +0000 (18:04 +0200)
src/hostname/hostnamectl.c

index cebc7742bf6f8a7a9a6ba27f1c506070d586b125..2cc9324ff3ad63b04d705a85e6c3cc37a67310e8 100644 (file)
@@ -20,6 +20,7 @@
 #include "bus-util.h"
 #include "hostname-util.h"
 #include "spawn-polkit-agent.h"
+#include "terminal-util.h"
 #include "util.h"
 #include "verbs.h"
 
@@ -44,6 +45,7 @@ typedef struct StatusInfo {
         const char *os_cpe_name;
         const char *virtualization;
         const char *architecture;
+        const char *home_url;
 } StatusInfo;
 
 static void print_status_info(StatusInfo *i) {
@@ -87,8 +89,17 @@ static void print_status_info(StatusInfo *i) {
         if (!isempty(i->virtualization))
                 printf("    Virtualization: %s\n", i->virtualization);
 
-        if (!isempty(i->os_pretty_name))
-                printf("  Operating System: %s\n", i->os_pretty_name);
+        if (!isempty(i->os_pretty_name)) {
+                _cleanup_free_ char *formatted = NULL;
+                const char *t = i->os_pretty_name;
+
+                if (i->home_url) {
+                        if (terminal_urlify(i->home_url, i->os_pretty_name, &formatted) >= 0)
+                                t = formatted;
+                }
+
+                printf("  Operating System: %s\n", t);
+        }
 
         if (!isempty(i->os_cpe_name))
                 printf("       CPE OS Name: %s\n", i->os_cpe_name);
@@ -141,6 +152,7 @@ static int show_all_names(sd_bus *bus, sd_bus_error *error) {
                 { "KernelRelease",             "s", NULL, offsetof(StatusInfo, kernel_release)  },
                 { "OperatingSystemPrettyName", "s", NULL, offsetof(StatusInfo, os_pretty_name)  },
                 { "OperatingSystemCPEName",    "s", NULL, offsetof(StatusInfo, os_cpe_name)     },
+                { "HomeURL",                   "s", NULL, offsetof(StatusInfo, home_url)        },
                 {}
         };