← easystroke

Add option to not use DBus

b21e6d1a85b3e5121515dfc886c5b4fa46b2328a · Thomas Jaeger · Sep 16, 2010 01:46

+9 −3 · 1 file changed

  • main.cc +9 −3
diff --git a/main.cc b/main.cc
index 0a049b4..ebe3530 100644
--- a/main.cc
+++ b/main.cc
@@ -57,6 +57,7 @@ Grabber::XiDevice *current_dev = 0;
 std::set<guint> xinput_pressed; // TODO get rid of
 
 static bool show_gui = false;
+static bool no_dbus = false;
 
 static int argc;
 static char **argv;
@@ -1059,7 +1060,7 @@ Main::Main() : kit(0) {
 		printf(_("Couldn't open display.\n"));
 		exit(EXIT_FAILURE);
 	}
-	if (start_dbus() < 0) {
+	if (!no_dbus && start_dbus() < 0) {
 		printf(_("Easystroke is already running, showing configuration window instead.\n"));
 		send_dbus("");
 		exit(EXIT_SUCCESS);
@@ -1121,7 +1122,7 @@ void Main::usage(char *me, bool good) {
 	printf("Options:\n");
 	printf("  -c, --config-dir       Directory for config files\n");
 	printf("      --display          X Server to contact\n");
-	printf("  -x  --no-xi            Don't use the Xinput extension\n");
+	printf("  -D  --no-dbus          Don't try to register as a DBus service\n");
 	printf("  -e  --experimental     Start in experimental mode\n");
 	printf("  -g, --show-gui         Show the configuration dialog on startup\n");
 	printf("  -v, --verbose          Increase verbosity level\n");
@@ -1144,6 +1145,7 @@ std::string Main::parse_args_and_init_gtk() {
 		{"help",0,0,'h'},
 		{"version",0,0,'V'},
 		{"show-gui",0,0,'g'},
+		{"no-dbus",0,0,'D'},
 		{0,0,0,0}
 	};
 	static struct option long_opts2[] = {
@@ -1152,6 +1154,7 @@ std::string Main::parse_args_and_init_gtk() {
 		{"experimental",0,0,'e'},
 		{"show-gui",0,0,'g'},
 		{"verbose",0,0,'v'},
+		{"no-dbus",0,0,'D'},
 		{0,0,0,0}
 	};
 	std::string display;
@@ -1179,7 +1182,7 @@ std::string Main::parse_args_and_init_gtk() {
 	oldHandler = XSetErrorHandler(xErrorHandler);
 	oldIOHandler = XSetIOErrorHandler(xIOErrorHandler);
 
-	while ((opt = getopt_long(argc, argv, "c:egv", long_opts2, 0)) != -1) {
+	while ((opt = getopt_long(argc, argv, "c:egvD", long_opts2, 0)) != -1) {
 		switch (opt) {
 			case 'c':
 				config_dir = optarg;
@@ -1190,6 +1193,9 @@ std::string Main::parse_args_and_init_gtk() {
 			case 'v':
 				verbosity++;
 				break;
+			case 'D':
+				no_dbus = true;
+				break;
 			case 'd':
 			case 'n':
 			case 'g':