File tree 2 files changed +17
-7
lines changed
2 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,7 @@ const Bar::bar_mode_map Bar::PRESET_MODES = { //
61
61
62
62
const std::string_view Bar::MODE_DEFAULT = " default" ;
63
63
const std::string_view Bar::MODE_INVISIBLE = " invisible" ;
64
+ const std::string_view DEFAULT_BAR_ID = " bar-0" ;
64
65
65
66
#ifdef HAVE_GTK_LAYER_SHELL
66
67
struct GLSSurfaceImpl : public BarSurface , public sigc ::trackable {
@@ -556,7 +557,14 @@ waybar::Bar::Bar(struct waybar_output* w_output, const Json::Value& w_config)
556
557
if (auto id = config[" id" ]; id.isString ()) {
557
558
bar_id = id.asString ();
558
559
}
559
- _ipc_client = std::make_unique<BarIpcClient>(*this );
560
+ if (bar_id.empty ()) {
561
+ bar_id = DEFAULT_BAR_ID;
562
+ }
563
+ try {
564
+ _ipc_client = std::make_unique<BarIpcClient>(*this );
565
+ } catch (const std::exception & exc) {
566
+ spdlog::warn (" Failed to open bar ipc connection: {}" , exc.what ());
567
+ }
560
568
}
561
569
#endif
562
570
Original file line number Diff line number Diff line change 3
3
#include < fmt/ostream.h>
4
4
#include < spdlog/spdlog.h>
5
5
6
+ #include < stdexcept>
7
+
6
8
#include " bar.hpp"
7
9
#include " modules/sway/ipc/ipc.hpp"
8
10
@@ -47,13 +49,13 @@ struct swaybar_config parseConfig(const Json::Value& payload) {
47
49
}
48
50
49
51
void BarIpcClient::onInitialConfig (const struct Ipc ::ipc_response& res) {
50
- try {
51
- auto payload = parser_.parse (res.payload );
52
- auto config = parseConfig (payload);
53
- onConfigUpdate (config);
54
- } catch (const std::exception & e) {
55
- spdlog::error (" BarIpcClient::onInitialConfig {}" , e.what ());
52
+ auto payload = parser_.parse (res.payload );
53
+ if (auto success = payload.get (" success" , true ); !success.asBool ()) {
54
+ auto err = payload.get (" error" , " Unknown error" );
55
+ throw std::runtime_error (err.asString ());
56
56
}
57
+ auto config = parseConfig (payload);
58
+ onConfigUpdate (config);
57
59
}
58
60
59
61
void BarIpcClient::onIpcEvent (const struct Ipc ::ipc_response& res) {
You can’t perform that action at this time.
0 commit comments