1. what
This commit is contained in:
parent
9b155fd8db
commit
e7372afa2f
22
meson.build
22
meson.build
|
@ -79,14 +79,24 @@ foreach file : source_file_names
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
dependency('fmt'),
|
dependency('fmt', include_type: 'system', static: true),
|
||||||
dependency('libcurl'),
|
dependency('libcurl', include_type: 'system', static: true),
|
||||||
dependency('tomlplusplus'),
|
dependency('yyjson', include_type: 'system', static: true),
|
||||||
dependency('yyjson'),
|
dependency(
|
||||||
dependency('ftxui', modules: ['ftxui::screen', 'ftxui::dom', 'ftxui::component']),
|
'ftxui',
|
||||||
dependency('reflectcpp'),
|
modules: ['ftxui::screen', 'ftxui::dom', 'ftxui::component'],
|
||||||
|
include_type: 'system',
|
||||||
|
static: true,
|
||||||
|
),
|
||||||
|
dependency('reflectcpp', include_type: 'system', static: true),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if host_machine.system() == 'windows'
|
||||||
|
deps += cpp.find_library('tomlplusplus', static: true, dirs: 'C:/msys64/usr/lib')
|
||||||
|
else
|
||||||
|
deps += dependency('tomlplusplus', static: true)
|
||||||
|
endif
|
||||||
|
|
||||||
if host_machine.system() == 'darwin'
|
if host_machine.system() == 'darwin'
|
||||||
deps += dependency('Foundation')
|
deps += dependency('Foundation')
|
||||||
deps += dependency('MediaPlayer')
|
deps += dependency('MediaPlayer')
|
||||||
|
|
|
@ -35,7 +35,7 @@ fn Config::getInstance() -> Config {
|
||||||
const Result<Config> result = rfl::toml::load<Config>(configPath.string());
|
const Result<Config> result = rfl::toml::load<Config>(configPath.string());
|
||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
ERROR_LOG("Failed to load config file: {}", result.error()->what());
|
ERROR_LOG("Failed to load config file: {}", result.error().what());
|
||||||
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ namespace {
|
||||||
|
|
||||||
rfl::Result<WeatherOutput> result = rfl::json::read<WeatherOutput>(content);
|
rfl::Result<WeatherOutput> result = rfl::json::read<WeatherOutput>(content);
|
||||||
if (!result)
|
if (!result)
|
||||||
return std::unexpected(result.error()->what());
|
return std::unexpected(result.error().what());
|
||||||
|
|
||||||
DEBUG_LOG("Successfully read from cache file.");
|
DEBUG_LOG("Successfully read from cache file.");
|
||||||
return *result;
|
return *result;
|
||||||
|
@ -117,7 +117,7 @@ namespace {
|
||||||
|
|
||||||
rfl::Result<WeatherOutput> output = rfl::json::read<WeatherOutput>(responseBuffer);
|
rfl::Result<WeatherOutput> output = rfl::json::read<WeatherOutput>(responseBuffer);
|
||||||
if (!output)
|
if (!output)
|
||||||
return std::unexpected(output.error()->what());
|
return std::unexpected(output.error().what());
|
||||||
|
|
||||||
return *output;
|
return *output;
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,13 +74,16 @@ namespace {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn GetMemInfo() -> u64 {
|
fn GetMemInfo() -> expected<u64, string> {
|
||||||
u64 mem = 0;
|
u64 mem = 0;
|
||||||
GetPhysicallyInstalledSystemMemory(&mem);
|
|
||||||
|
if (!GetPhysicallyInstalledSystemMemory(&mem))
|
||||||
|
return std::unexpected("Failed to get physical system memory.");
|
||||||
|
|
||||||
return mem * 1024;
|
return mem * 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn GetNowPlaying() -> string {
|
fn GetNowPlaying() -> expected<string, NowPlayingError> {
|
||||||
using namespace winrt::Windows::Media::Control;
|
using namespace winrt::Windows::Media::Control;
|
||||||
using namespace winrt::Windows::Foundation;
|
using namespace winrt::Windows::Foundation;
|
||||||
|
|
||||||
|
@ -102,14 +105,11 @@ fn GetNowPlaying() -> string {
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we reach this point, there is no current session
|
// If we reach this point, there is no current session
|
||||||
return "";
|
return std::unexpected(NowPlayingError { NowPlayingCode::NoActivePlayer });
|
||||||
} catch (const winrt::hresult_error& e) {
|
} catch (const winrt::hresult_error& e) { return std::unexpected(NowPlayingError { e }); }
|
||||||
ERROR_LOG("Error: {}", to_string(e.message()));
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn GetOSVersion() -> string {
|
fn GetOSVersion() -> expected<string, string> {
|
||||||
string productName =
|
string productName =
|
||||||
GetRegistryValue(HKEY_LOCAL_MACHINE, R"(SOFTWARE\Microsoft\Windows NT\CurrentVersion)", "ProductName");
|
GetRegistryValue(HKEY_LOCAL_MACHINE, R"(SOFTWARE\Microsoft\Windows NT\CurrentVersion)", "ProductName");
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ fn GetOSVersion() -> string {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return std::unexpected("Failed to get OS version.");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn GetHost() -> string {
|
fn GetHost() -> string {
|
||||||
|
@ -195,13 +195,13 @@ fn GetWindowManager() -> string {
|
||||||
return windowManager;
|
return windowManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn GetDesktopEnvironment() -> string {
|
fn GetDesktopEnvironment() -> optional<string> {
|
||||||
// Get version information from registry
|
// Get version information from registry
|
||||||
const string buildStr =
|
const string buildStr =
|
||||||
GetRegistryValue(HKEY_LOCAL_MACHINE, R"(SOFTWARE\Microsoft\Windows NT\CurrentVersion)", "CurrentBuildNumber");
|
GetRegistryValue(HKEY_LOCAL_MACHINE, R"(SOFTWARE\Microsoft\Windows NT\CurrentVersion)", "CurrentBuildNumber");
|
||||||
|
|
||||||
if (buildStr.empty())
|
if (buildStr.empty())
|
||||||
return "Unknown";
|
return std::nullopt;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const i32 build = stoi(buildStr);
|
const i32 build = stoi(buildStr);
|
||||||
|
@ -234,7 +234,7 @@ fn GetDesktopEnvironment() -> string {
|
||||||
|
|
||||||
// Older versions
|
// Older versions
|
||||||
return "Classic";
|
return "Classic";
|
||||||
} catch (...) { return "Unknown"; }
|
} catch (...) { return std::nullopt; }
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3,7 +3,14 @@
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#ifdef __WIN32__
|
||||||
|
#include <winrt/base.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
#include <sdbus-c++/sdbus-c++.h>
|
#include <sdbus-c++/sdbus-c++.h>
|
||||||
|
|
Loading…
Reference in a new issue