Browse Source

Merge pull request #8528 from Anatzum/patch-1

Use kioclient for MoveItemToTrash on KDE
Cheng Zhao 8 years ago
parent
commit
7265a0c1b4
1 changed files with 14 additions and 1 deletions
  1. 14 1
      atom/common/platform_util_linux.cc

+ 14 - 1
atom/common/platform_util_linux.cc

@@ -7,7 +7,9 @@
 #include <stdio.h>
 
 #include "base/cancelable_callback.h"
+#include "base/environment.h"
 #include "base/files/file_util.h"
+#include "base/nix/xdg_util.h"
 #include "base/process/kill.h"
 #include "base/process/launch.h"
 #include "url/gurl.h"
@@ -100,7 +102,18 @@ bool MoveItemToTrash(const base::FilePath& full_path) {
   if (getenv(ELECTRON_TRASH) != NULL) {
     trash = getenv(ELECTRON_TRASH);
   } else {
-    trash = ELECTRON_DEFAULT_TRASH;
+    // Determine desktop environment and set accordingly.
+    std::unique_ptr<base::Environment> env(base::Environment::Create());
+    base::nix::DesktopEnvironment desktop_env(
+        base::nix::GetDesktopEnvironment(env.get()));
+    if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE4 ||
+        desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE5) {
+      trash = "kioclient5";
+    } else if (desktop_env == base::nix::DESKTOP_ENVIRONMENT_KDE3) {
+      trash = "kioclient";
+    } else {
+      trash = ELECTRON_DEFAULT_TRASH;
+    }
   }
 
   std::vector<std::string> argv;