0001-Fix-killing-gjs.patch 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. From 1553374b9c5db3db8232738dc8fa747684b070d1 Mon Sep 17 00:00:00 2001
  2. From: =?UTF-8?q?Ball=C3=B3=20Gy=C3=B6rgy?= <ballogyor@gmail.com>
  3. Date: Fri, 30 Apr 2021 15:58:22 +0200
  4. Subject: [PATCH] Fix killing gjs
  5. ---
  6. src/gnome-screensaver.c | 22 +++++++++++-----------
  7. src/gs-listener-dbus.c | 29 ++++++++++++-----------------
  8. 2 files changed, 23 insertions(+), 28 deletions(-)
  9. diff --git a/src/gnome-screensaver.c b/src/gnome-screensaver.c
  10. index d2ccae3..96a7d49 100644
  11. --- a/src/gnome-screensaver.c
  12. +++ b/src/gnome-screensaver.c
  13. @@ -82,17 +82,17 @@ main (int argc,
  14. exit (1);
  15. }
  16. - gchar** env_vars = g_get_environ(); // Get our list of environment variables
  17. - gchar* desktop = g_environ_getenv(env_vars, "XDG_CURRENT_DESKTOP"); // Get the current desktop value
  18. -
  19. - if (desktop != NULL) { // Got a value
  20. - if (!g_str_has_prefix(desktop, "Budgie")) { // Does not start with Budgie
  21. - g_message("Not running under Budgie, exiting.");
  22. - exit(1);
  23. - }
  24. - }
  25. -
  26. - g_strfreev(env_vars); // Free our environment variables
  27. + if (g_find_program_in_path("pkill") != NULL) { // Have pkill
  28. + g_spawn_command_line_sync("pkill -9 -f '/usr/bin/gjs /usr/share/gnome-shell/org.gnome.ScreenSaver'",
  29. + NULL,
  30. + NULL,
  31. + NULL,
  32. + &error);
  33. + if (error) {
  34. + g_warning("Failed to kill gjs: %s", error->message);
  35. + g_error_free (error);
  36. + }
  37. + }
  38. gs_debug_init (debug, FALSE);
  39. gs_debug ("initializing budgie-screensaver %s", VERSION);
  40. diff --git a/src/gs-listener-dbus.c b/src/gs-listener-dbus.c
  41. index 124d83a..f667127 100644
  42. --- a/src/gs-listener-dbus.c
  43. +++ b/src/gs-listener-dbus.c
  44. @@ -1334,6 +1334,14 @@ gs_listener_acquire (GSListener *listener,
  45. _("not connected to the message bus"));
  46. return FALSE;
  47. }
  48. + if (screensaver_is_running (listener->priv->connection)) {
  49. + g_set_error (error,
  50. + GS_LISTENER_ERROR,
  51. + GS_LISTENER_ERROR_ACQUISITION_FAILURE,
  52. + "%s",
  53. + _("screensaver already running in this session"));
  54. + return FALSE;
  55. + }
  56. dbus_error_init (&buserror);
  57. @@ -1345,23 +1353,10 @@ gs_listener_acquire (GSListener *listener,
  58. return FALSE;
  59. }
  60. - if (g_find_program_in_path("pkill") != NULL) { // Have pkill
  61. - char *argv[5];
  62. - argv[0] = "pkill";
  63. - argv[1] = "-9";
  64. - argv[2] = "-f";
  65. - argv[3] = "'/usr/bin/gjs /usr/share/gnome-shell/org.gnome.ScreenSaver'";
  66. - argv[4] = NULL;
  67. -
  68. - g_autoptr(GError) error = NULL;
  69. - gboolean kill_ret = g_spawn_sync(NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL, NULL, &error);
  70. -
  71. - if (!kill_ret) {
  72. - g_warning("Failed to kill gjs: %s", error->message);
  73. - }
  74. - }
  75. -
  76. - res = dbus_bus_request_name (listener->priv->connection, GS_SERVICE, DBUS_NAME_FLAG_REPLACE_EXISTING, &buserror);
  77. + res = dbus_bus_request_name (listener->priv->connection,
  78. + GS_SERVICE,
  79. + DBUS_NAME_FLAG_DO_NOT_QUEUE | DBUS_NAME_FLAG_ALLOW_REPLACEMENT,
  80. + &buserror);
  81. if (dbus_error_is_set (&buserror)) {
  82. g_set_error (error,
  83. GS_LISTENER_ERROR,
  84. --
  85. 2.31.1