From 2b34f3a30f48114e9f256d198afc8abfbabae8b6 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 23 May 2019 10:13:49 +0200 Subject: [PATCH] refactor: parse args before app creation --- src/client.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/client.cpp b/src/client.cpp index 114b0d28..f5d65e07 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1,7 +1,7 @@ #include "client.hpp" +#include #include #include -#include #include "util/clara.hpp" #include "util/json.hpp" @@ -229,15 +229,6 @@ void waybar::Client::bindInterfaces() { } int waybar::Client::main(int argc, char *argv[]) { - gtk_app = Gtk::Application::create(argc, argv, "fr.arouillard.waybar"); - gdk_display = Gdk::Display::get_default(); - if (!gdk_display) { - throw std::runtime_error("Can't find display"); - } - if (!GDK_IS_WAYLAND_DISPLAY(gdk_display->gobj())) { - throw std::runtime_error("Bar need to run under Wayland"); - } - wl_display = gdk_wayland_display_get_wl_display(gdk_display->gobj()); bool show_help = false; bool show_version = false; std::string config; @@ -268,6 +259,15 @@ int waybar::Client::main(int argc, char *argv[]) { if (!log_level.empty()) { spdlog::set_level(spdlog::level::from_str(log_level)); } + gtk_app = Gtk::Application::create(argc, argv, "fr.arouillard.waybar"); + gdk_display = Gdk::Display::get_default(); + if (!gdk_display) { + throw std::runtime_error("Can't find display"); + } + if (!GDK_IS_WAYLAND_DISPLAY(gdk_display->gobj())) { + throw std::runtime_error("Bar need to run under Wayland"); + } + wl_display = gdk_wayland_display_get_wl_display(gdk_display->gobj()); setupConfigs(config, style); setupConfig(); setupCss();