This commit is contained in:
Mars 2024-06-21 03:15:01 -04:00
commit b09839ff6a
Signed by: pupbrained
GPG key ID: 0FF5B8826803F895
289 changed files with 57 additions and 43596 deletions

View file

@ -6,6 +6,7 @@
#include "config/config.h"
#include "os/os.h"
using std::future;
using std::string;
struct BytesToGiB {
@ -27,10 +28,10 @@ struct fmt::formatter<BytesToGiB> : formatter<double> {
}
};
fn GetDate() -> string {
fn GetDate() -> std::string {
const std::tm localTime = fmt::localtime(time(nullptr));
string date = fmt::format("{:%e}", localTime);
std::string date = fmt::format("{:%e}", localTime);
if (!date.empty() && std::isspace(date.front()))
date.erase(date.begin());
@ -57,29 +58,28 @@ fn main() -> int {
auto nowPlayingEnabledFuture =
std::async(std::launch::async, [&config]() { return config.now_playing.get().enabled; });
auto dateFuture = std::async(std::launch::async, GetDate);
auto memInfoFuture = std::async(std::launch::async, GetMemInfo);
future<string> dateFuture = std::async(std::launch::async, GetDate);
future<u64> memInfoFuture = std::async(std::launch::async, GetMemInfo);
WeatherOutput json = weatherFuture.get();
const long temp = std::lround(json.main.temp);
const std::string townName = json.name;
const WeatherOutput json = weatherFuture.get();
const i64 temp = std::lround(json.main.temp);
const string townName = json.name;
const char* version = osVersionFuture.get();
const std::string name = config.general.value().name.get();
const bool nowPlayingEnabled = nowPlayingEnabledFuture.get();
const char* version = osVersionFuture.get();
const string date = dateFuture.get();
const std::string name = config.general.get().name.get();
const u64 mem = memInfoFuture.get();
fmt::println("Hello {}!", name);
fmt::println("Today is: {}", dateFuture.get());
fmt::println("Today is: {}", date);
fmt::println("It is {}°F in {}", temp, townName);
fmt::println("Installed RAM: {:.2f} GiB", BytesToGiB(memInfoFuture.get()));
fmt::println("Installed RAM: {:.2f} GiB", BytesToGiB(mem));
fmt::println("{}", version);
if (nowPlayingEnabled) {
if (nowPlayingEnabled)
fmt::println("{}", GetNowPlaying());
}
delete[] version;
return 0;
delete &config;
}