Compare commits

..

8 Commits

Author SHA1 Message Date
Carter Li 736d5316cc Merge pull request #705 from fastfetch-cli/dev
Release v2.7.1
2024-01-30 19:25:55 +08:00
李通洲 efe42a2c7d GPU: fix a copy-paste error 2024-01-30 18:54:26 +08:00
李通洲 ee07755139 Release: v2.7.1 2024-01-30 18:45:56 +08:00
李通洲 3d924eeadd Merge remote-tracking branch 'upstream/master' into dev 2024-01-30 18:27:24 +08:00
李通洲 aaa091f23b Terminal (Linux): fix segfault 2024-01-30 15:22:26 +08:00
李通洲 53cd1e5378 DateTime: print timezone info; simplify code 2024-01-29 22:01:54 +08:00
李通洲 3747683f0d GPU: add vendor code of QTI & MTK 2024-01-29 21:49:42 +08:00
李通洲 59c1e3d8c5 Platform: detect real path of exe path 2024-01-28 10:45:21 +08:00
7 changed files with 78 additions and 72 deletions
+8
View File
@@ -1,3 +1,11 @@
# 2.7.1
Features:
* Config presets in app folder now work with symlinks
Bugfixes:
* Fix a possible segfault when detecting terminal (Terminal, Linux)
# 2.7.0
Features:
+1 -1
View File
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url
project(fastfetch
VERSION 2.7.0
VERSION 2.7.1
LANGUAGES C
DESCRIPTION "Fast neofetch-like system information tool"
HOMEPAGE_URL "https://github.com/fastfetch-cli/fastfetch"
+6
View File
@@ -6,6 +6,8 @@ const char* FF_GPU_VENDOR_NAME_APPLE = "Apple";
const char* FF_GPU_VENDOR_NAME_AMD = "AMD";
const char* FF_GPU_VENDOR_NAME_INTEL = "Intel";
const char* FF_GPU_VENDOR_NAME_NVIDIA = "NVIDIA";
const char* FF_GPU_VENDOR_NAME_QUALCOMM = "Qualcomm";
const char* FF_GPU_VENDOR_NAME_MTK = "MTK";
const char* FF_GPU_VENDOR_NAME_VMWARE = "VMware";
const char* FF_GPU_VENDOR_NAME_PARALLEL = "Parallel";
const char* FF_GPU_VENDOR_NAME_MICROSOFT = "Microsoft";
@@ -33,6 +35,10 @@ const char* ffGetGPUVendorString(unsigned vendorId)
return FF_GPU_VENDOR_NAME_INTEL;
else if(arrayContains((const unsigned[]) {0x0955, 0x10de, 0x12d2}, vendorId, 3))
return FF_GPU_VENDOR_NAME_NVIDIA;
else if(arrayContains((const unsigned[]) {0x5143}, vendorId, 1))
return FF_GPU_VENDOR_NAME_QUALCOMM;
else if(arrayContains((const unsigned[]) {0x14c3}, vendorId, 1))
return FF_GPU_VENDOR_NAME_MTK;
else if(arrayContains((const unsigned[]) {0x15ad}, vendorId, 1))
return FF_GPU_VENDOR_NAME_VMWARE;
else if(arrayContains((const unsigned[]) {0x1af4}, vendorId, 1))
@@ -312,7 +312,11 @@ static pid_t getTerminalInfo(FFTerminalResult* result, pid_t pid)
static bool getTerminalInfoByPidEnv(FFTerminalResult* result, const char* pidEnv)
{
pid_t pid = (pid_t) strtol(getenv(pidEnv), NULL, 10);
const char* envStr = getenv(pidEnv);
if (envStr == NULL)
return false;
pid_t pid = (pid_t) strtol(envStr, NULL, 10);
result->pid = (uint32_t) pid;
char name[256];
if (getProcessNameAndPpid(pid, name, (pid_t*) &result->ppid, NULL) == NULL)
+37 -63
View File
@@ -9,7 +9,7 @@
#pragma GCC diagnostic ignored "-Wformat" // warning: unknown conversion type character 'F' in format
#define FF_DATETIME_DISPLAY_NAME "Date & Time"
#define FF_DATETIME_NUM_FORMAT_ARGS 20
#define FF_DATETIME_NUM_FORMAT_ARGS 22
typedef struct FFDateTimeResult
{
@@ -17,23 +17,25 @@ typedef struct FFDateTimeResult
uint16_t year; //2022
uint8_t yearShort; //22
uint8_t month; //2
FFstrbuf monthPretty; //02
FFstrbuf monthName; //February
FFstrbuf monthNameShort; //Feb
char monthPretty[FASTFETCH_STRBUF_DEFAULT_ALLOC]; //02
char monthName[FASTFETCH_STRBUF_DEFAULT_ALLOC]; //February
char monthNameShort[FASTFETCH_STRBUF_DEFAULT_ALLOC]; //Feb
uint8_t week; //8
FFstrbuf weekday; //Monday
FFstrbuf weekdayShort; //Mon
char weekday[FASTFETCH_STRBUF_DEFAULT_ALLOC]; //Monday
char weekdayShort[FASTFETCH_STRBUF_DEFAULT_ALLOC]; //Mon
uint16_t dayInYear; //52
uint8_t dayInMonth; //21
uint8_t dayInWeek; //1
uint8_t hour; //15
FFstrbuf hourPretty; //15
char hourPretty[FASTFETCH_STRBUF_DEFAULT_ALLOC]; //15
uint8_t hour12; //3
FFstrbuf hour12Pretty; //03
char hour12Pretty[FASTFETCH_STRBUF_DEFAULT_ALLOC]; //03
uint8_t minute; //18
FFstrbuf minutePretty; //18
char minutePretty[FASTFETCH_STRBUF_DEFAULT_ALLOC]; //18
uint8_t second; //37
FFstrbuf secondPretty; //37
char secondPretty[FASTFETCH_STRBUF_DEFAULT_ALLOC]; //37
char offsetFromUtc[FASTFETCH_STRBUF_DEFAULT_ALLOC];
char timezoneName[FASTFETCH_STRBUF_DEFAULT_ALLOC];
} FFDateTimeResult;
void ffPrintDateTimeFormat(struct tm* tm, const FFModuleArgs* moduleArgs)
@@ -43,80 +45,50 @@ void ffPrintDateTimeFormat(struct tm* tm, const FFModuleArgs* moduleArgs)
result.year = (uint16_t) (tm->tm_year + 1900);
result.yearShort = (uint8_t) (result.year % 100);
result.month = (uint8_t) (tm->tm_mon + 1);
ffStrbufInitA(&result.monthPretty, FASTFETCH_STRBUF_DEFAULT_ALLOC);
result.monthPretty.length = (uint32_t) strftime(result.monthPretty.chars, ffStrbufGetFree(&result.monthPretty), "%m", tm);
ffStrbufInitA(&result.monthName, FASTFETCH_STRBUF_DEFAULT_ALLOC);
result.monthName.length = (uint32_t) strftime(result.monthName.chars, ffStrbufGetFree(&result.monthName), "%B", tm);
ffStrbufInitA(&result.monthNameShort, FASTFETCH_STRBUF_DEFAULT_ALLOC);
result.monthNameShort.length = (uint32_t) strftime(result.monthNameShort.chars, ffStrbufGetFree(&result.monthNameShort), "%b", tm);
strftime(result.monthPretty, sizeof(result.monthPretty), "%m", tm);
strftime(result.monthName, sizeof(result.monthName), "%B", tm);
strftime(result.monthNameShort, sizeof(result.monthNameShort), "%b", tm);
result.week = (uint8_t) (tm->tm_yday / 7 + 1);
ffStrbufInitA(&result.weekday, FASTFETCH_STRBUF_DEFAULT_ALLOC);
result.weekday.length = (uint32_t) strftime(result.weekday.chars, ffStrbufGetFree(&result.weekday), "%A", tm);
ffStrbufInitA(&result.weekdayShort, FASTFETCH_STRBUF_DEFAULT_ALLOC);
result.weekdayShort.length = (uint32_t) strftime(result.weekdayShort.chars, ffStrbufGetFree(&result.weekdayShort), "%a", tm);
strftime(result.weekday, sizeof(result.weekday), "%A", tm);
strftime(result.weekdayShort, sizeof(result.weekdayShort), "%a", tm);
result.dayInYear = (uint8_t) (tm->tm_yday + 1);
result.dayInMonth = (uint8_t) tm->tm_mday;
result.dayInWeek = tm->tm_wday == 0 ? 7 : (uint8_t) tm->tm_wday;
result.hour = (uint8_t) tm->tm_hour;
ffStrbufInitA(&result.hourPretty, FASTFETCH_STRBUF_DEFAULT_ALLOC);
result.hourPretty.length = (uint32_t) strftime(result.hourPretty.chars, ffStrbufGetFree(&result.hourPretty), "%H", tm);
strftime(result.hourPretty, sizeof(result.hourPretty), "%H", tm);
result.hour12 = (uint8_t) (result.hour % 12);
ffStrbufInitA(&result.hour12Pretty, FASTFETCH_STRBUF_DEFAULT_ALLOC);
result.hour12Pretty.length = (uint32_t) strftime(result.hour12Pretty.chars, ffStrbufGetFree(&result.hour12Pretty), "%I", tm);
strftime(result.hour12Pretty, sizeof(result.hour12Pretty), "%I", tm);
result.minute = (uint8_t) tm->tm_min;
ffStrbufInitA(&result.minutePretty, FASTFETCH_STRBUF_DEFAULT_ALLOC);
result.minutePretty.length = (uint32_t) strftime(result.minutePretty.chars, ffStrbufGetFree(&result.minutePretty), "%M", tm);
strftime(result.minutePretty, sizeof(result.minutePretty), "%M", tm);
result.second = (uint8_t) tm->tm_sec;
ffStrbufInitA(&result.secondPretty, FASTFETCH_STRBUF_DEFAULT_ALLOC);
result.secondPretty.length = (uint32_t) strftime(result.secondPretty.chars, ffStrbufGetFree(&result.secondPretty), "%S", tm);
strftime(result.secondPretty, sizeof(result.secondPretty), "%S", tm);
strftime(result.offsetFromUtc, sizeof(result.offsetFromUtc), "%z", tm);
strftime(result.timezoneName, sizeof(result.timezoneName), "%Z", tm);
ffPrintFormat(FF_DATETIME_DISPLAY_NAME, 0, moduleArgs, FF_DATETIME_NUM_FORMAT_ARGS, (FFformatarg[]) {
{FF_FORMAT_ARG_TYPE_UINT16, &result.year}, // 1
{FF_FORMAT_ARG_TYPE_UINT8, &result.yearShort}, // 2
{FF_FORMAT_ARG_TYPE_UINT8, &result.month}, // 3
{FF_FORMAT_ARG_TYPE_STRBUF, &result.monthPretty}, // 4
{FF_FORMAT_ARG_TYPE_STRBUF, &result.monthName}, // 5
{FF_FORMAT_ARG_TYPE_STRBUF, &result.monthNameShort}, // 6
{FF_FORMAT_ARG_TYPE_STRING, result.monthPretty}, // 4
{FF_FORMAT_ARG_TYPE_STRING, result.monthName}, // 5
{FF_FORMAT_ARG_TYPE_STRING, result.monthNameShort}, // 6
{FF_FORMAT_ARG_TYPE_UINT8, &result.week}, // 7
{FF_FORMAT_ARG_TYPE_STRBUF, &result.weekday}, // 8
{FF_FORMAT_ARG_TYPE_STRBUF, &result.weekdayShort}, // 9
{FF_FORMAT_ARG_TYPE_STRING, result.weekday}, // 8
{FF_FORMAT_ARG_TYPE_STRING, result.weekdayShort}, // 9
{FF_FORMAT_ARG_TYPE_UINT16, &result.dayInYear}, // 10
{FF_FORMAT_ARG_TYPE_UINT8, &result.dayInMonth}, // 11
{FF_FORMAT_ARG_TYPE_UINT8, &result.dayInWeek}, // 12
{FF_FORMAT_ARG_TYPE_UINT8, &result.hour}, // 13
{FF_FORMAT_ARG_TYPE_STRBUF, &result.hourPretty}, // 14
{FF_FORMAT_ARG_TYPE_STRING, result.hourPretty}, // 14
{FF_FORMAT_ARG_TYPE_UINT8, &result.hour12}, // 15
{FF_FORMAT_ARG_TYPE_STRBUF, &result.hour12Pretty}, // 16
{FF_FORMAT_ARG_TYPE_STRING, result.hour12Pretty}, // 16
{FF_FORMAT_ARG_TYPE_UINT8, &result.minute}, // 17
{FF_FORMAT_ARG_TYPE_STRBUF, &result.minutePretty}, // 18
{FF_FORMAT_ARG_TYPE_STRING, result.minutePretty}, // 18
{FF_FORMAT_ARG_TYPE_UINT8, &result.second}, // 19
{FF_FORMAT_ARG_TYPE_STRBUF, &result.secondPretty} // 20
{FF_FORMAT_ARG_TYPE_STRING, result.secondPretty}, // 20
{FF_FORMAT_ARG_TYPE_STRING, result.offsetFromUtc}, // 21
{FF_FORMAT_ARG_TYPE_STRING, result.timezoneName}, // 22
});
ffStrbufDestroy(&result.hour12Pretty);
ffStrbufDestroy(&result.hourPretty);
ffStrbufDestroy(&result.minutePretty);
ffStrbufDestroy(&result.monthName);
ffStrbufDestroy(&result.monthNameShort);
ffStrbufDestroy(&result.monthPretty);
ffStrbufDestroy(&result.secondPretty);
ffStrbufDestroy(&result.weekday);
ffStrbufDestroy(&result.weekdayShort);
}
void ffPrintDateTime(FFDateTimeOptions* options)
@@ -205,7 +177,9 @@ void ffPrintDateTimeHelpFormat(void)
"minute",
"minute with leading zero",
"second",
"second with leading zero"
"second with leading zero",
"offset from UTC in the ISO 8601 format",
"locale-dependent timezone name or abbreviation",
});
}
+13 -7
View File
@@ -17,17 +17,17 @@
static void getExePath(FFPlatform* platform)
{
FFstrbuf* const exePath = &platform->exePath;
ffStrbufEnsureFree(exePath, PATH_MAX);
char exePath[PATH_MAX + 1];
#ifdef __linux__
ssize_t exePathLen = readlink("/proc/self/exe", exePath->chars, exePath->allocated - 1);
ssize_t exePathLen = readlink("/proc/self/exe", exePath, sizeof(exePath) - 1);
exePath[exePathLen] = '\0';
#elif defined(__APPLE__)
int exePathLen = proc_pidpath((int) getpid(), exePath->chars, exePath->allocated);
int exePathLen = proc_pidpath((int) getpid(), exePath, sizeof(exePath));
#elif defined(__FreeBSD__)
size_t exePathLen = exePath->allocated;
size_t exePathLen = sizeof(exePath);
if(sysctl(
(int[]){CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, (int) getpid()}, 4,
exePath->chars, &exePathLen,
exePath, &exePathLen,
NULL, 0
) < 0)
exePathLen = 0;
@@ -35,7 +35,13 @@ static void getExePath(FFPlatform* platform)
exePathLen--; // remove terminating NUL
#endif
if (exePathLen > 0)
exePath->length = (uint32_t) exePathLen;
{
ffStrbufEnsureFree(&platform->exePath, PATH_MAX);
if (realpath(platform->exePath.chars, exePath))
ffStrbufRecalculateLength(&platform->exePath);
else
ffStrbufSetNS(&platform->exePath, (uint32_t) exePathLen, exePath);
}
}
static void platformPathAddEnv(FFlist* dirs, const char* env)
+8
View File
@@ -18,6 +18,14 @@ static void getExePath(FFPlatform* platform)
DWORD exePathWLen = GetModuleFileNameW(NULL, exePathW, MAX_PATH);
if (exePathWLen == 0 && exePathWLen >= MAX_PATH) return;
FF_AUTO_CLOSE_FD HANDLE hPath = CreateFileW(exePathW, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (hPath != INVALID_HANDLE_VALUE)
{
DWORD len = GetFinalPathNameByHandleW(hPath, exePathW, MAX_PATH, FILE_NAME_OPENED);
if (len > 0 && len < MAX_PATH)
exePathWLen = len;
}
ffStrbufSetNWS(&platform->exePath, exePathWLen, exePathW);
if (ffStrbufStartsWithS(&platform->exePath, "\\\\?\\"))
ffStrbufSubstrAfter(&platform->exePath, 3);