1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-23 21:35:11 +03:00

hostnamectl: make the distribution name a pretty clickable link if we can

This commit is contained in:
Lennart Poettering 2018-04-19 17:52:51 +02:00
parent 64928aa545
commit 87adb0db27

View 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) },
{}
};