Skip to content

Commit ba2636d

Browse files
authored
Merge pull request #775 from fastfetch-cli/dev
Release: v2.9.0
2 parents e897a98 + 69589f1 commit ba2636d

File tree

19 files changed

+225
-57
lines changed

19 files changed

+225
-57
lines changed

CHANGELOG.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
1-
# 2.8.10
1+
# 2.9.0
22

3-
Changes:
4-
* Use MS-DOS device name as mountFrom result, instead of useless GUID volume name (Windows, Disk)
5-
* Some adjustments to Terminal detection (Terminal, Windows)
6-
* Don't pretty print CMD
7-
* Print conhost as Windows Console
8-
* Don't detect `wininit` as Terminal
3+
Features:
4+
* Support Lxterminal version detection (Terminal, Linux)
5+
* Support weston-terminal version and font detection (TerminalFont, Linux)
6+
* Support `am` package manager detection (#771, Packages, Linux)
7+
* Support network prefix length detection for IPv6 (LocalIP)
8+
* Display all IPs when multiple IPs are assigned to the same interface (LocalIP)
9+
* Add option `--localip-show-prefix-len` to show network prefix length for both IPv4 and IPv6. Defaults to `true` (LocalIP)
10+
11+
Bugfixes:
12+
* Fix network prefix length detection when the value is greater than 24 (#773, LocalIP, Linux)
13+
* For xfce4-terminal, use system mono font if no config file is found (TerminalFont, Linux)
14+
15+
# 2.8.10
916

1017
Bugfixes:
1118
* Don't display 0.00 GHz (CPU, FreeBSD)
@@ -17,6 +24,11 @@ Bugfixes:
1724

1825
Features:
1926
* Improve stability; print more useful error message; avoid misuse (PublicIP / Weather)
27+
* Use MS-DOS device name as mountFrom result, instead of useless GUID volume name (Windows, Disk)
28+
* Some adjustments to Terminal detection (Terminal, Windows)
29+
* Don't pretty print CMD
30+
* Print conhost as Windows Console
31+
* Don't detect `wininit` as Terminal
2032

2133
Logo:
2234
* Fix color of Arco Linux

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
22

33
project(fastfetch
4-
VERSION 2.8.10
4+
VERSION 2.9.0
55
LANGUAGES C
66
DESCRIPTION "Fast neofetch-like system information tool"
77
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"

debian/changelog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
fastfetch (2.8.10) jammy; urgency=medium
2+
3+
* Update to 2.8.10
4+
5+
-- Carter Li <[email protected]> Mon, 25 Mar 2024 15:01:53 +0800
6+
17
fastfetch (2.8.9) jammy; urgency=medium
28

39
* Update to 2.8.9

debian/files

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
fastfetch_2.8.9_source.buildinfo universe/utils optional
1+
fastfetch_2.8.10_source.buildinfo universe/utils optional

doc/json_schema.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1438,6 +1438,11 @@
14381438
"type": "boolean",
14391439
"default": false
14401440
},
1441+
"showPrefixLen": {
1442+
"description": "Show network prefix length (/N)",
1443+
"type": "boolean",
1444+
"default": true
1445+
},
14411446
"compact": {
14421447
"description": "Show all IPs in one line",
14431448
"type": "boolean",

src/data/help.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,15 @@
12611261
"default": false
12621262
}
12631263
},
1264+
{
1265+
"long": "localip-show-prefix-len",
1266+
"desc": "Show network prefix length (/N) in local ip module",
1267+
"arg": {
1268+
"type": "bool",
1269+
"optional": true,
1270+
"default": true
1271+
}
1272+
},
12641273
{
12651274
"long": "localip-name-prefix",
12661275
"desc": "Show interfaces with given interface name prefix only",

src/detection/localip/localip_linux.c

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,12 @@ static void addNewIp(FFlist* list, const char* name, const char* addr, int type,
4040
switch (type)
4141
{
4242
case AF_INET:
43-
ffStrbufSetS(&ip->ipv4, addr);
43+
if (ip->ipv4.length) ffStrbufAppendC(&ip->ipv4, ',');
44+
ffStrbufAppendS(&ip->ipv4, addr);
4445
break;
4546
case AF_INET6:
46-
ffStrbufSetS(&ip->ipv6, addr);
47+
if (ip->ipv6.length) ffStrbufAppendC(&ip->ipv6, ',');
48+
ffStrbufAppendS(&ip->ipv6, addr);
4749
break;
4850
case -1:
4951
ffStrbufSetS(&ip->mac, addr);
@@ -83,12 +85,15 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
8385
char addressBuffer[INET_ADDRSTRLEN + 4];
8486
inet_ntop(AF_INET, &ipv4->sin_addr, addressBuffer, INET_ADDRSTRLEN);
8587

86-
struct sockaddr_in* netmask = (struct sockaddr_in*) ifa->ifa_netmask;
87-
int cidr = __builtin_popcount(inet_netof(netmask->sin_addr));
88-
if (cidr != 0)
88+
if (options->showType & FF_LOCALIP_TYPE_PREFIX_LEN_BIT)
8989
{
90-
size_t len = strlen(addressBuffer);
91-
snprintf(addressBuffer + len, 4, "/%d", cidr);
90+
struct sockaddr_in* netmask = (struct sockaddr_in*) ifa->ifa_netmask;
91+
int cidr = __builtin_popcount(netmask->sin_addr.s_addr);
92+
if (cidr != 0)
93+
{
94+
size_t len = strlen(addressBuffer);
95+
snprintf(addressBuffer + len, 4, "/%d", cidr);
96+
}
9297
}
9398

9499
addNewIp(results, ifa->ifa_name, addressBuffer, AF_INET, isDefaultRoute);
@@ -99,8 +104,23 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
99104
continue;
100105

101106
struct sockaddr_in6* ipv6 = (struct sockaddr_in6 *)ifa->ifa_addr;
102-
char addressBuffer[INET6_ADDRSTRLEN];
107+
char addressBuffer[INET6_ADDRSTRLEN + 4];
103108
inet_ntop(AF_INET6, &ipv6->sin6_addr, addressBuffer, INET6_ADDRSTRLEN);
109+
110+
if (options->showType & FF_LOCALIP_TYPE_PREFIX_LEN_BIT)
111+
{
112+
struct sockaddr_in6* netmask = (struct sockaddr_in6*) ifa->ifa_netmask;
113+
int cidr = 0;
114+
static_assert(sizeof(netmask->sin6_addr) % sizeof(uint64_t) == 0, "");
115+
for (uint32_t i = 0; i < sizeof(netmask->sin6_addr) / sizeof(uint64_t); ++i)
116+
cidr += __builtin_popcountll(((uint64_t*) &netmask->sin6_addr)[i]);
117+
if (cidr != 0)
118+
{
119+
size_t len = strlen(addressBuffer);
120+
snprintf(addressBuffer + len, 4, "/%d", cidr);
121+
}
122+
}
123+
104124
addNewIp(results, ifa->ifa_name, addressBuffer, AF_INET6, isDefaultRoute);
105125
}
106126
#if defined(__FreeBSD__) || defined(__APPLE__)

src/detection/localip/localip_windows.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "util/windows/unicode.h"
77
#include "localip.h"
88

9-
static void addNewIp(FFlist* list, const char* name, const char* value, int type, bool newIp, bool defaultRoute)
9+
static void addNewIp(FFlist* list, const char* name, const char* addr, int type, bool newIp, bool defaultRoute)
1010
{
1111
FFLocalIpResult* ip = NULL;
1212

@@ -27,13 +27,15 @@ static void addNewIp(FFlist* list, const char* name, const char* value, int type
2727
switch (type)
2828
{
2929
case AF_INET:
30-
ffStrbufSetS(&ip->ipv4, value);
30+
if (ip->ipv4.length) ffStrbufAppendC(&ip->ipv4, ',');
31+
ffStrbufAppendS(&ip->ipv4, addr);
3132
break;
3233
case AF_INET6:
33-
ffStrbufSetS(&ip->ipv6, value);
34+
if (ip->ipv6.length) ffStrbufAppendC(&ip->ipv6, ',');
35+
ffStrbufAppendS(&ip->ipv6, addr);
3436
break;
3537
case -1:
36-
ffStrbufSetS(&ip->mac, value);
38+
ffStrbufSetS(&ip->mac, addr);
3739
break;
3840
}
3941
}
@@ -108,7 +110,7 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
108110
char addressBuffer[INET_ADDRSTRLEN + 4];
109111
inet_ntop(AF_INET, &ipv4->sin_addr, addressBuffer, INET_ADDRSTRLEN);
110112

111-
if (ifa->OnLinkPrefixLength)
113+
if ((options->showType & FF_LOCALIP_TYPE_PREFIX_LEN_BIT) && ifa->OnLinkPrefixLength)
112114
{
113115
size_t len = strlen(addressBuffer);
114116
snprintf(addressBuffer + len, 4, "/%u", (unsigned) ifa->OnLinkPrefixLength);
@@ -120,8 +122,15 @@ const char* ffDetectLocalIps(const FFLocalIpOptions* options, FFlist* results)
120122
else if (ifa->Address.lpSockaddr->sa_family == AF_INET6)
121123
{
122124
SOCKADDR_IN6* ipv6 = (SOCKADDR_IN6*) ifa->Address.lpSockaddr;
123-
char addressBuffer[INET6_ADDRSTRLEN];
125+
char addressBuffer[INET6_ADDRSTRLEN + 4];
124126
inet_ntop(AF_INET6, &ipv6->sin6_addr, addressBuffer, INET6_ADDRSTRLEN);
127+
128+
if ((options->showType & FF_LOCALIP_TYPE_PREFIX_LEN_BIT) && ifa->OnLinkPrefixLength)
129+
{
130+
size_t len = strlen(addressBuffer);
131+
snprintf(addressBuffer + len, 4, "/%u", (unsigned) ifa->OnLinkPrefixLength);
132+
}
133+
125134
addNewIp(results, name, addressBuffer, AF_INET6, newIp, isDefaultRoute);
126135
newIp = false;
127136
}

src/detection/packages/packages.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
typedef struct FFPackagesResult
66
{
7+
uint32_t am;
78
uint32_t apk;
89
uint32_t brew;
910
uint32_t brewCask;

src/detection/packages/packages_linux.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,43 @@ static uint32_t getRpmFromLibrpm(void)
253253

254254
#endif //FF_HAVE_RPM
255255

256+
static uint32_t getAM(FFstrbuf* baseDir)
257+
{
258+
// #771
259+
uint32_t baseDirLength = baseDir->length;
260+
261+
ffStrbufAppendS(baseDir, "/opt");
262+
uint32_t optDirLength = baseDir->length;
263+
264+
uint32_t result = 0;
265+
266+
ffStrbufAppendS(baseDir, "/am/APP-MANAGER");
267+
if (ffPathExists(baseDir->chars, FF_PATHTYPE_FILE))
268+
{
269+
++result; // `am` itself is counted as a package too
270+
ffStrbufSubstrBefore(baseDir, optDirLength);
271+
FF_AUTO_CLOSE_DIR DIR* dirp = opendir(baseDir->chars);
272+
if(dirp)
273+
{
274+
struct dirent *entry;
275+
while ((entry = readdir(dirp)) != NULL)
276+
{
277+
if (entry->d_name[0] == '.') continue;
278+
if (entry->d_type == DT_DIR)
279+
{
280+
ffStrbufAppendF(baseDir, "/%s/AM-updater", entry->d_name);
281+
if (ffPathExists(baseDir->chars, FF_PATHTYPE_FILE))
282+
++result;
283+
ffStrbufSubstrBefore(baseDir, optDirLength);
284+
}
285+
}
286+
}
287+
}
288+
289+
ffStrbufSubstrBefore(baseDir, baseDirLength);
290+
return result;
291+
}
292+
256293
static void getPackageCounts(FFstrbuf* baseDir, FFPackagesResult* packageCounts, FFPackagesOptions* options)
257294
{
258295
if (!(options->disabled & FF_PACKAGES_FLAG_APK_BIT)) packageCounts->apk += getNumStrings(baseDir, "/lib/apk/db/installed", "C:Q");
@@ -277,6 +314,7 @@ static void getPackageCounts(FFstrbuf* baseDir, FFPackagesResult* packageCounts,
277314
}
278315
if (!(options->disabled & FF_PACKAGES_FLAG_PALUDIS_BIT)) packageCounts->paludis += countFilesRecursive(baseDir, "/var/db/paludis/repositories", "environment.bz2");
279316
if (!(options->disabled & FF_PACKAGES_FLAG_OPKG_BIT)) packageCounts->opkg += getNumStrings(baseDir, "/usr/lib/opkg/status", "Package:"); // openwrt
317+
if (!(options->disabled & FF_PACKAGES_FLAG_AM_BIT)) packageCounts->am = getAM(baseDir);
280318
}
281319

282320
static void getPackageCountsRegular(FFstrbuf* baseDir, FFPackagesResult* packageCounts, FFPackagesOptions* options)

0 commit comments

Comments
 (0)