12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- From 1553374b9c5db3db8232738dc8fa747684b070d1 Mon Sep 17 00:00:00 2001
- From: =?UTF-8?q?Ball=C3=B3=20Gy=C3=B6rgy?= <ballogyor@gmail.com>
- Date: Fri, 30 Apr 2021 15:58:22 +0200
- Subject: [PATCH] Fix killing gjs
- ---
- src/gnome-screensaver.c | 22 +++++++++++-----------
- src/gs-listener-dbus.c | 29 ++++++++++++-----------------
- 2 files changed, 23 insertions(+), 28 deletions(-)
- diff --git a/src/gnome-screensaver.c b/src/gnome-screensaver.c
- index d2ccae3..96a7d49 100644
- --- a/src/gnome-screensaver.c
- +++ b/src/gnome-screensaver.c
- @@ -82,17 +82,17 @@ main (int argc,
- exit (1);
- }
-
- - gchar** env_vars = g_get_environ(); // Get our list of environment variables
- - gchar* desktop = g_environ_getenv(env_vars, "XDG_CURRENT_DESKTOP"); // Get the current desktop value
- -
- - if (desktop != NULL) { // Got a value
- - if (!g_str_has_prefix(desktop, "Budgie")) { // Does not start with Budgie
- - g_message("Not running under Budgie, exiting.");
- - exit(1);
- - }
- - }
- -
- - g_strfreev(env_vars); // Free our environment variables
- + if (g_find_program_in_path("pkill") != NULL) { // Have pkill
- + g_spawn_command_line_sync("pkill -9 -f '/usr/bin/gjs /usr/share/gnome-shell/org.gnome.ScreenSaver'",
- + NULL,
- + NULL,
- + NULL,
- + &error);
- + if (error) {
- + g_warning("Failed to kill gjs: %s", error->message);
- + g_error_free (error);
- + }
- + }
-
- gs_debug_init (debug, FALSE);
- gs_debug ("initializing budgie-screensaver %s", VERSION);
- diff --git a/src/gs-listener-dbus.c b/src/gs-listener-dbus.c
- index 124d83a..f667127 100644
- --- a/src/gs-listener-dbus.c
- +++ b/src/gs-listener-dbus.c
- @@ -1334,6 +1334,14 @@ gs_listener_acquire (GSListener *listener,
- _("not connected to the message bus"));
- return FALSE;
- }
- + if (screensaver_is_running (listener->priv->connection)) {
- + g_set_error (error,
- + GS_LISTENER_ERROR,
- + GS_LISTENER_ERROR_ACQUISITION_FAILURE,
- + "%s",
- + _("screensaver already running in this session"));
- + return FALSE;
- + }
-
- dbus_error_init (&buserror);
-
- @@ -1345,23 +1353,10 @@ gs_listener_acquire (GSListener *listener,
- return FALSE;
- }
-
- - if (g_find_program_in_path("pkill") != NULL) { // Have pkill
- - char *argv[5];
- - argv[0] = "pkill";
- - argv[1] = "-9";
- - argv[2] = "-f";
- - argv[3] = "'/usr/bin/gjs /usr/share/gnome-shell/org.gnome.ScreenSaver'";
- - argv[4] = NULL;
- -
- - g_autoptr(GError) error = NULL;
- - gboolean kill_ret = g_spawn_sync(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL, NULL, &error);
- -
- - if (!kill_ret) {
- - g_warning("Failed to kill gjs: %s", error->message);
- - }
- - }
- -
- - res = dbus_bus_request_name (listener->priv->connection, GS_SERVICE, DBUS_NAME_FLAG_REPLACE_EXISTING, &buserror);
- + res = dbus_bus_request_name (listener->priv->connection,
- + GS_SERVICE,
- + DBUS_NAME_FLAG_DO_NOT_QUEUE | DBUS_NAME_FLAG_ALLOW_REPLACEMENT,
- + &buserror);
- if (dbus_error_is_set (&buserror)) {
- g_set_error (error,
- GS_LISTENER_ERROR,
- --
- 2.31.1
|