mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2025-02-20 11:43:27 +08:00
LocalIp: add option --localip-name-prefix
eg: --localip-name-prefix en
This commit is contained in:
parent
6e3a329d3b
commit
f324794f54
@ -184,6 +184,7 @@ __fastfetch_completion()
|
||||
"--localip-show-ipv4"
|
||||
"--localip-show-ipv6"
|
||||
"--localip-show-loop"
|
||||
"--localip-name-prefix"
|
||||
"--escape-bedrock"
|
||||
"--pipe"
|
||||
"--title-fqdn"
|
||||
|
@ -238,6 +238,7 @@ static void defaultConfig(FFinstance* instance)
|
||||
instance->config.localIpShowIpV4 = true;
|
||||
instance->config.localIpShowIpV6 = false;
|
||||
instance->config.localIpShowLoop = false;
|
||||
ffStrbufInit(&instance->config.localIpNamePrefix);
|
||||
|
||||
instance->config.publicIpTimeout = 0;
|
||||
|
||||
|
@ -101,6 +101,7 @@ Module specific options:
|
||||
--localip-show-ipv4 <?value>: Show ipv4 addresses in local ip module. Default is true
|
||||
--localip-show-ipv6 <?value>: Show ipv6 addresses in local ip module. Default is false
|
||||
--localip-show-loop <?value>: Show loop back addresses (127.0.0.1) in local ip module. Default is false
|
||||
--localip-name-prefix <str>: Show ips with given name prefix only. Default is empty
|
||||
--public-ip-timeout: Time in milliseconds to wait for the public ip server to respond. Default is disabled (0)
|
||||
--player-name: The name of the player to use
|
||||
--gl <value>: Sets the opengl context creation library to use. Must be auto, egl, glx or osmesa. Default is auto
|
||||
|
@ -1277,6 +1277,8 @@ static void parseOption(FFinstance* instance, FFdata* data, const char* key, con
|
||||
instance->config.localIpShowIpV6 = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--localip-show-loop") == 0)
|
||||
instance->config.localIpShowLoop = optionParseBoolean(value);
|
||||
else if(strcasecmp(key, "--localip-name-prefix") == 0)
|
||||
optionParseString(key, value, &instance->config.localIpNamePrefix);
|
||||
else if(strcasecmp(key, "--os-file") == 0)
|
||||
optionParseString(key, value, &instance->config.osFile);
|
||||
else if(strcasecmp(key, "--player-name") == 0)
|
||||
|
@ -170,6 +170,7 @@ typedef struct FFconfig
|
||||
bool localIpShowLoop;
|
||||
bool localIpShowIpV4;
|
||||
bool localIpShowIpV6;
|
||||
FFstrbuf localIpNamePrefix;
|
||||
|
||||
uint32_t publicIpTimeout;
|
||||
|
||||
|
@ -62,6 +62,9 @@ void ffPrintLocalIp(FFinstance* instance)
|
||||
if (strncmp(ifa->ifa_name, "lo", 2) == 0 && (ifa->ifa_name[2] == '\0' || isdigit(ifa->ifa_name[2])) && !instance->config.localIpShowLoop)
|
||||
continue;
|
||||
|
||||
if (instance->config.localIpNamePrefix.length && strncmp(ifa->ifa_name, instance->config.localIpNamePrefix.chars, instance->config.localIpNamePrefix.length) != 0)
|
||||
continue;
|
||||
|
||||
if (ifa->ifa_addr->sa_family == AF_INET) { // check it is IP4
|
||||
// is a valid IP4 Address
|
||||
if (!instance->config.localIpShowIpV4)
|
||||
|
Loading…
x
Reference in New Issue
Block a user