Skip to content

Commit 6d5077e

Browse files
committed
Don't activate swaync if already activated
The activate signal would be called again if another instance of swaync would start, resulting in a crash due to trying to own the dbus name
1 parent 3cb431d commit 6d5077e

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/main.vala

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ namespace SwayNotificationCenter {
88

99
static Settings self_settings;
1010

11-
public void main (string[] args) {
11+
static bool activated = false;
12+
13+
public int main (string[] args) {
1214
Gtk.init ();
1315
Adw.init ();
1416
Functions.init ();
@@ -33,23 +35,30 @@ namespace SwayNotificationCenter {
3335
case "-v":
3436
case "--version":
3537
stdout.printf ("%s\n", Constants.VERSION);
36-
return;
38+
return 0;
3739
case "-h":
3840
case "--help":
41+
print_help (args);
42+
return 0;
3943
default:
4044
print_help (args);
41-
return;
45+
return 1;
4246
}
4347
}
4448
}
4549

4650
var app = new Gtk.Application ("org.erikreider.swaync",
4751
ApplicationFlags.DEFAULT_FLAGS);
48-
app.hold ();
4952
app.activate.connect (() => {
53+
if (activated) {
54+
return;
55+
}
56+
activated = true;
5057
ConfigModel.init (config_path);
5158
Functions.load_css (style_path);
5259

60+
app.hold ();
61+
5362
swaync_daemon = new SwayncDaemon ();
5463
Bus.own_name (BusType.SESSION, "org.erikreider.swaync.cc",
5564
BusNameOwnerFlags.NONE,
@@ -64,7 +73,7 @@ namespace SwayNotificationCenter {
6473
app.add_window (swaync_daemon.noti_daemon.control_center);
6574
});
6675

67-
app.run ();
76+
return app.run ();
6877
}
6978

7079
void on_cc_bus_aquired (DBusConnection conn) {

0 commit comments

Comments
 (0)