Ubuntu 20.04桌面复制粘贴路径
Ubuntu上拷贝文件路径比较常见:上传文件,粘到终端中cd进去比较方便。终归效率比较高。但是在20.04
上遇到问题了,桌面拷贝粘贴路径的结果是:
x-special/nautilus-clipboard
copy
file:///home/tony/Desktop/123
这下效率就降低不少。下面是解决方案。以下方案其实没有什么用,我快对20.04失去耐心了,最常用的桌面功能要改革,没有了右击新建文件,不支持放文件,图标还必须一个格子格子的摆放。系统本来都是用来作为生产工具的,搞这么多变数。老牌操作系统Win/Mac对这一点都没有改变,一个不知流的Linux桌面系统在这改来改去的。还好没有在去年底换20.04,发布1年半了也没有解决。继续保持使用着16.04和18.04,到时候看看22.04
会怎么样吧。
LTS |
根据上图,18.04还能再战两年。
再次重审不用最新系统,比如Mac升级了Monterey 12.0.1,结果蓝牙不正常了,无法和iPhone连接。这是链接。我是一个搞开发的,会用到这些边边角角的功能,如果一个系统经过一两年后才会稳定。 https://bynss.com/apple/504327.html
解决方案
方案1: 使用最新版本Ubuntu
直接使用21.10
(基于GNOME40,已解决此问题)即可,如果不想用非lts
版本或者最新版,那么向下看。
方案2: 使用nautilus-copypath插件实现(推荐)
nautilus-copypath安装后的效果如下:
nautilus-copypath |
方案3: 重新编译nautilus
gsettings中使用use-legacy-clipboard
I have prepared a patch which simply uses a gsettings key “use-legacy-clipboard” (which is false by default). This is simple enough and doesn’t modify default behavior any way. Thus anyone who doesn’t use can use it can just set that key to true, copy/paste between nemo/nautilus is now also possible again.
0001-Add-legacy-clipboard.patch
Note it’s based on 3.31.9 and not git master. I can update or make a pull if this approach seems feasible.
方案4: 使用nautilus插件2实现
Place a file in ~/.local/share/nautilus/scripts/ and add those lines:
wl-copy "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"
$HOME/.config/nautilus/scripts-accels
add <Control><Shift>c copypath
方案5: 修改粘贴板内容
I was really fond of this feature, using it hundreds of times a day to copy file paths from Nautilus to GUAKE terminal, so I’m trying to find a workaround for myself that does not includes further key presses or changing my workflow too much.
Following the direction of this stackoverflow answer
I set up a daemon intercepting clipboard events and when appropriate extracting file path from the annoying mime string.
from gi.repository import Gtk, Gdk
import re
def callBack(*args):
text = clip.wait_for_text()
if re.findall('nautilus-clipboard', text):
text = text.split('\n')[2].replace('file://','')
clip.set_text(text, -1)
clip = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
clip.connect('owner-change', callBack)
Gtk.main()
参考:https://gitlab.gnome.org/GNOME/nautilus/-/issues/634