Google Chrome 在文件夹中显示选中文件解决方案
Tofloor
poster avatar
w_w
deepin
2017-06-08 03:16
Author
参考https://bugs.chromium.org/p/chromium/issues/detail?id=352988
中用户 abhishek...@gmail.com的解决方案,使得对chrome下载的文件选择在文件夹中显示时打开dde文件管理器并且下载的文件处于选中状态。

在/home/username/.config/google-chrome目录下建立两个文件并chmod +x
xdg-mime:
  1. #!/bin/bash
  2. if [ "$#" -eq 3 ] && [ "$1" = "query" ] && [ "$2" = "default" ] \
  3. && [ "$3" = "inode/directory" ]; then
  4.     echo "nautilus.desktop";
  5. else
  6.     /usr/bin/xdg-mime "$@";
  7. fi
Copy the Code
nautilus:
  1. #!/bin/bash
  2. if [ "$1" = "--version" ]; then
  3.     echo "GNOME nautilus 3.14.3"; else
  4.     dde-file-manager --show-item "$1"
  5. fi
Copy the Code
然后修改/usr/share/applications/google-chrome,修改三条Exec后面的命令为:
  1. sh -c "export PATH=/home/username/.config/google-chrome/fake-environment:$PATH;/usr/bin/google-chrome-stable %U"
  2. sh -c "export PATH=/home/username/.config/google-chrome/fake-environment:$PATH;/usr/bin/google-chrome-stable"
  3. sh -c "export PATH=/home/username/.config/google-chrome/fake-environment:$PATH;/usr/bin/google-chrome-stable --incognito"
Copy the Code

原理:
xdg-open没有选中的功能,但是Chrome对Nautilus打了补丁:
  1. const char kNautilusKey[] = "nautilus.desktop";
  2. const char kNautilusKeyExtended[] = "nautilus-folder-handler.desktop";
  3. const char kNautilusCmd[] = "nautilus";
  4. const char kSupportedNautilusVersion[] = "3.0.2";
Copy the Code
  1. void ShowItemInFolder(Profile* profile, const base::FilePath& full_path) {
  2.   DCHECK_CURRENTLY_ON(BrowserThread::UI);
  3.   base::PostTaskWithTraitsAndReplyWithResult(
  4.       FROM_HERE,
  5.       {base::WithBaseSyncPrimitives(), base::MayBlock(),
  6.        base::TaskPriority::USER_BLOCKING},
  7.       base::BindOnce(&CheckNautilusIsDefault),
  8.       base::BindOnce(&ShowItem, profile, full_path));
  9. }
Copy the Code

我们通过修改xdg-mime欺骗chrome,让它以为我们使用了Nautilus作为默认文件管理器。
不得不说Nautilus的面子还是大,在deepin上安装的Nautilus建立的desktop文件为org.gnome.nautilus.desktop,不是chrome代码中检查的“nautilus.desktop”,所以即使我们在deepin上安装了Nautilus,show in folder也不能选中相应的文件。

另外,deepin的dde-file-manager选中文件使用的是--show-item参数,而dolphin和nautilus都是用的--select,我不懂dde-file-manager为何要特立独行?

在修改chrome的desktop文件后,launcher里面的chrome就消失了,我没找到原因。另外双击修改后的/usr/share/applications/google-chrome.desktop文件可以启动chrome,但是将其固定到任务栏上之后,任务栏上的chrome图标点击是没用的,不知道是不是对于Exec的处理在任务栏上和之间双击的处理方法不同。我现在只能复制一份google-chrome.desktop在桌面上双击使用,右击也没有新建隐身窗口选项,难受。
Reply Favorite View the author
All Replies

No replies yet

New Thread

Popular Events

More
国际排名
WHLUG