Skip to content

Commit 64f43ea

Browse files
committed
core-modules: macos: fix system.host.name and user.wm.name
1 parent 86ee066 commit 64f43ea

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/core-modules/linux/user.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ std::string get_wm_name(std::string& wm_path_exec)
254254
std::string path, proc_name, wm_name;
255255
const uid_t uid = getuid();
256256

257+
#if !CF_MACOS
257258
for (auto const& dir_entry : std::filesystem::directory_iterator{ "/proc/" })
258259
{
259260
if (!std::isdigit((dir_entry.path().string().at(6)))) // /proc/5
@@ -286,6 +287,7 @@ std::string get_wm_name(std::string& wm_path_exec)
286287
wm_path_exec = realpath((dir_entry.path().string() + "/exe").c_str(), buf);
287288
break;
288289
}
290+
#endif
289291

290292
debug("wm_name = {}", wm_name);
291293
if (wm_name.empty())

src/core-modules/macos/system.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static bool get_sysctl(const char* name, void* ret, size_t* oldlenp)
1818
}
1919

2020
// https://github.com/fastfetch-cli/fastfetch/blob/a734f18fd56014f5c0b9fb388727b778e2bc05d1/src/detection/host/host_mac.c#L4
21-
const char* get_host_from_family(const std::string_view host_family)
21+
const std::string get_host_from_family(const std::string_view host_family)
2222
{
2323
// Macbook Pro: https://support.apple.com/en-us/HT201300
2424
// Macbook Air: https://support.apple.com/en-us/HT201862
@@ -127,7 +127,7 @@ const char* get_host_from_family(const std::string_view host_family)
127127
}
128128
else if (hasStart(host_family, "MacPro"))
129129
{
130-
const std::string_view version = host_family.substr("MacPro"_len);
130+
const std::string_view version = host_family.substr("MacPro"_leMac Pro (2019)n);
131131
switch (fnv1a16::hash(version.data()))
132132
{
133133
case "7,1"_fnv1a16: return "Mac Pro (2019)";
@@ -227,8 +227,8 @@ MODFUNC(host_name)
227227
if (!get_sysctl("hw.model", buf, &len))
228228
return MAGIC_LINE;
229229

230-
const std::string_view host = get_host_from_family(buf);
231-
return host.substr(0, host.find('(') - 1).data();
230+
const std::string host = get_host_from_family(buf);
231+
return host.substr(0, host.find('(') - 1);
232232
}
233233

234234
MODFUNC(host_version)

0 commit comments

Comments
 (0)