bleh
This commit is contained in:
parent
dff976ed0e
commit
3ebbb2b3ec
19
flake.lock
19
flake.lock
|
@ -2,27 +2,26 @@
|
|||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1718149104,
|
||||
"narHash": "sha256-Ds1QpobBX2yoUDx9ZruqVGJ/uQPgcXoYuobBguyKEh8=",
|
||||
"lastModified": 1722375055,
|
||||
"narHash": "sha256-TXtpKGKpaa7ZivMgB0y+63ZLITXPXIAzof6hqw1pqHA=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e913ae340076bbb73d9f4d3d065c2bca7caafb16",
|
||||
"rev": "d8c09e3ff18ad95f0765fdfc21f4698dea7ab670",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1708475490,
|
||||
"narHash": "sha256-g1v0TsWBQPX97ziznfJdWhgMyMGtoBFs102xSYO4syU=",
|
||||
"lastModified": 1720957393,
|
||||
"narHash": "sha256-oedh2RwpjEa+TNxhg5Je9Ch6d3W1NKi7DbRO1ziHemA=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0e74ca98a74bc7270d28838369593635a5db3260",
|
||||
"rev": "693bc46d169f5af9c992095736e82c3488bf7dbb",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -59,11 +58,11 @@
|
|||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1718271476,
|
||||
"narHash": "sha256-35hUMmFesmchb+u7heKHLG5B6c8fBOcSYo0jj0CHLes=",
|
||||
"lastModified": 1722330636,
|
||||
"narHash": "sha256-uru7JzOa33YlSRwf9sfXpJG+UAV+bnBEYMjrzKrQZFw=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "e75ba0a6bb562d2ce275db28f6a36a2e4fd81391",
|
||||
"rev": "768acdb06968e53aa1ee8de207fd955335c754b7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
22
flake.nix
22
flake.nix
|
@ -2,7 +2,7 @@
|
|||
description = "C/C++ environment";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs";
|
||||
treefmt-nix.url = "github:numtide/treefmt-nix";
|
||||
utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
@ -43,35 +43,29 @@
|
|||
];
|
||||
};
|
||||
|
||||
deps = with (
|
||||
if !stdenv.isDarwin
|
||||
then pkgs.pkgsStatic
|
||||
else pkgs # TODO: Remove when fixed on darwin
|
||||
);
|
||||
deps = with pkgs.pkgsStatic;
|
||||
[
|
||||
curl
|
||||
fmt
|
||||
glib
|
||||
libiconv
|
||||
tomlplusplus
|
||||
yyjson
|
||||
reflect-cpp
|
||||
]
|
||||
++ (
|
||||
if !stdenv.isDarwin && system == "x86_64-linux"
|
||||
then [pkgsStatic.curl]
|
||||
else [pkgs.curl]
|
||||
)
|
||||
++ linuxPkgs
|
||||
++ darwinPkgs;
|
||||
|
||||
linuxPkgs = nixpkgs.lib.optionals stdenv.isLinux (with pkgs; [
|
||||
linuxPkgs = nixpkgs.lib.optionals stdenv.isLinux (with pkgs.pkgsStatic; [
|
||||
glib
|
||||
systemdLibs
|
||||
sdbus-cpp
|
||||
valgrind
|
||||
]);
|
||||
|
||||
darwinPkgs = nixpkgs.lib.optionals stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [
|
||||
darwinPkgs = nixpkgs.lib.optionals stdenv.isDarwin (with pkgs.pkgsStatic.darwin.apple_sdk.frameworks; [
|
||||
Foundation
|
||||
MediaPlayer
|
||||
SystemConfiguration
|
||||
]);
|
||||
in
|
||||
with pkgs; {
|
||||
|
|
13
meson.build
13
meson.build
|
@ -2,7 +2,7 @@ project(
|
|||
'draconis++', 'cpp',
|
||||
version: '0.1.0',
|
||||
default_options: [
|
||||
'cpp_std=c++23',
|
||||
'cpp_std=c++20',
|
||||
'default_library=static',
|
||||
'warning_level=everything',
|
||||
'buildtype=release'
|
||||
|
@ -79,15 +79,17 @@ foreach file : source_file_names
|
|||
endforeach
|
||||
|
||||
deps = [
|
||||
dependency('fmt', static: host_machine.system() != 'darwin'),
|
||||
dependency('libcurl', static: host_machine.system() != 'darwin'),
|
||||
dependency('tomlplusplus', static: host_machine.system() != 'darwin'),
|
||||
dependency('yyjson', static: host_machine.system() != 'darwin')
|
||||
dependency('fmt'),
|
||||
dependency('libcurl'),
|
||||
dependency('tomlplusplus'),
|
||||
dependency('yyjson')
|
||||
]
|
||||
|
||||
if host_machine.system() == 'darwin'
|
||||
deps += dependency('Foundation')
|
||||
deps += dependency('MediaPlayer')
|
||||
deps += dependency('SystemConfiguration')
|
||||
deps += dependency('iconv')
|
||||
elif host_machine.system() == 'linux'
|
||||
deps += dependency('sdbus-c++')
|
||||
endif
|
||||
|
@ -97,7 +99,6 @@ link_args = []
|
|||
|
||||
if host_machine.system() == 'darwin'
|
||||
objc_args += ['-fobjc-arc']
|
||||
link_args += ['-framework', 'Foundation', '-framework', 'MediaPlayer']
|
||||
elif host_machine.system() == 'windows'
|
||||
windows_sdk_lib_dir = 'C:/Program Files (x86)/Windows Kits/10/Lib/10.0.22621.0/um/x64'
|
||||
link_args += ['-L' + windows_sdk_lib_dir, '-lwindowsapp', '-static']
|
||||
|
|
|
@ -1,26 +1,43 @@
|
|||
#include <cstdlib>
|
||||
#include <filesystem>
|
||||
#include <fmt/core.h>
|
||||
#include <string>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
using rfl::Result;
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
inline fn GetConfigPath() -> string {
|
||||
return getenv(
|
||||
#ifdef __WIN32__
|
||||
"LOCALAPPDATA"
|
||||
inline fn GetConfigPath() -> std::string {
|
||||
#ifdef _WIN32
|
||||
const char* localAppData = std::getenv("LOCALAPPDATA");
|
||||
|
||||
if (!localAppData)
|
||||
throw std::runtime_error("Environment variable LOCALAPPDATA is not set");
|
||||
|
||||
return localAppData;
|
||||
#else
|
||||
"HOME"
|
||||
const char* home = std::getenv("HOME");
|
||||
|
||||
if (!home)
|
||||
throw std::runtime_error("Environment variable HOME is not set");
|
||||
|
||||
return std::string(home) + "/.config";
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
fn Config::getInstance() -> Config {
|
||||
const string path = GetConfigPath() + "\\draconis++\\config.toml";
|
||||
const Result<Config> result = rfl::toml::load<Config>(path);
|
||||
try {
|
||||
fs::path configPath = GetConfigPath();
|
||||
configPath /= "draconis++/config.toml";
|
||||
|
||||
if (result)
|
||||
return result.value();
|
||||
const Result<Config> result = rfl::toml::load<Config>(configPath.string());
|
||||
|
||||
if (result)
|
||||
return result.value();
|
||||
|
||||
fmt::println("Failed to load config file: {}", result.error().value().what());
|
||||
} catch (const std::exception& e) { fmt::println("Error getting config path: {}", e.what()); }
|
||||
|
||||
fmt::println("Failed to load config file: {}", result.error().value().what());
|
||||
return {};
|
||||
}
|
||||
|
|
15
src/main.cpp
15
src/main.cpp
|
@ -48,7 +48,8 @@ fn main() -> i32 {
|
|||
const Config& config = Config::getInstance();
|
||||
|
||||
// Fetching weather information
|
||||
auto weatherInfo = config.weather.get().getWeatherInfo();
|
||||
auto weather = config.weather.get();
|
||||
WeatherOutput weatherInfo = weather.getWeatherInfo();
|
||||
|
||||
// Fetching OS version
|
||||
std::string osVersion = GetOSVersion();
|
||||
|
@ -69,17 +70,11 @@ fn main() -> i32 {
|
|||
fmt::println("Installed RAM: {:.2f}", BytesToGiB(memInfo));
|
||||
fmt::println("{}", osVersion);
|
||||
|
||||
if (config.weather.get().enabled) {
|
||||
const auto& [clouds, tz, visibility, main, coords, rain, snow, base, townName, weather, sys, cod, dt, id, wind] =
|
||||
weatherInfo;
|
||||
i64 temp = std::lround(main.temp);
|
||||
if (weather.enabled)
|
||||
fmt::println("It is {}°F in {}", std::lround(weatherInfo.main.temp), weatherInfo.name);
|
||||
|
||||
fmt::println("It is {}°F in {}", temp, townName);
|
||||
}
|
||||
|
||||
if (nowPlayingEnabled) {
|
||||
if (nowPlayingEnabled)
|
||||
fmt::println("{}", GetNowPlaying());
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -21,6 +21,6 @@ fn GetNowPlaying() -> string {
|
|||
return "No song playing";
|
||||
}
|
||||
|
||||
fn GetOSVersion() -> const char* { return GetMacOSVersion(); }
|
||||
fn GetOSVersion() -> string { return GetMacOSVersion(); }
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue