diff --git a/src/main.cpp b/src/main.cpp index 28a7e19..2696d6c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -47,26 +47,27 @@ fn GetDate() -> string { } fn main() -> int { + using WeatherOutput = Weather::WeatherOutput; + const Config& config = Config::getInstance(); - - if (config.getNowPlaying().getEnabled()) - fmt::println("{}", GetNowPlaying()); - - fmt::println("Hello {}!", config.getGeneral().getName()); - fmt::println("Installed RAM: {:.2f}", BytesToGiB {GetMemInfo()}); - fmt::println("Today is: {}", GetDate()); - - Weather::WeatherOutput json = config.getWeather().getWeatherInfo(); + WeatherOutput json = config.getWeather().getWeatherInfo(); const long temp = std::lround(json.main.temp); const string townName = json.name; + const char* version = GetOSVersion(); + const string name = config.getGeneral().getName(); + const bool nowPlayingEnabled = config.getNowPlaying().getEnabled(); + + fmt::println("Hello {}!", name); + fmt::println("Today is: {}", GetDate()); fmt::println("It is {}°F in {}", temp, townName); - - const char* version = GetOSVersion(); - + fmt::println("Installed RAM: {:.2f}", BytesToGiB {GetMemInfo()}); fmt::println("{}", version); + if (nowPlayingEnabled) + fmt::println("{}", GetNowPlaying()); + delete[] version; delete &config; diff --git a/src/os/macos/bridge.mm b/src/os/macos/bridge.mm index c9a6b03..8760aca 100644 --- a/src/os/macos/bridge.mm +++ b/src/os/macos/bridge.mm @@ -67,10 +67,17 @@ using MRMediaRemoteGetNowPlayingInfoFunction = void (*)( NSOperatingSystemVersion osVersion = [processInfo operatingSystemVersion]; - NSString* version = [NSString stringWithFormat:@"%ld.%ld.%ld", - osVersion.majorVersion, - osVersion.minorVersion, - osVersion.patchVersion]; + NSString* version; + if (osVersion.patchVersion == 0) { + version = [NSString stringWithFormat:@"%ld.%ld", + osVersion.majorVersion, + osVersion.minorVersion]; + } else { + version = [NSString stringWithFormat:@"%ld.%ld.%ld", + osVersion.majorVersion, + osVersion.minorVersion, + osVersion.patchVersion]; + } // Dictionary to map macOS versions to their respective names NSDictionary* versionNames =