如何在 Thunar 中集成 Dropbox?

jbr*_*ock 4 xfce bash scripts dropbox thunar

如何将 Dropbox 集成到 Thunar?我正在使用通过 PPA 安装 Xfce 4.12 的 Xubuntu 14.04,thunar-dropbox-plugin但已损坏。我也听说它不适用于 Xubuntu 16.04。

jbr*_*ock 5

幸运的是,Dropbox 最近扩展了他们的 CLI 功能以包括共享链接等。要将 Dropbox 集成到 Thunar 中,请执行以下操作:

最初设定

~/bin如果尚未创建,请在您的主文件夹中创建一个目录。下载Dropbox python 脚本。将其重命名为dropbox. (不需要扩展。)使其可执行chmod +x ~/bin/dropbox

如果该~/bin目录尚未添加到您的$PATH(即选项卡完成不适用于脚本等),您可以将以下内容添加到~/.profile. 然后注销并重新登录。

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi
Run Code Online (Sandbox Code Playgroud)

xsel通过sudo apt-get install xsel在终端中粘贴来安装。该程序为以下脚本提供剪贴板功能。

将以下脚本保存到纯文本文件中,将其保存在 中~/bin,并使其可执行。我的名字是dropbox-online。更改icon_path="/full/path/to/dropbox-icon.png"Dropbox 图标的路径。

#!/bin/bash

# Name:     Dropbox Thunar Integration
# Author:   jbrock
# Dependencies: xsel (in Ubuntu repository), Dropbox python script https://linux.dropbox.com/packages/dropbox.py
# Installation: http://askubuntu.com/questions/777878/how-to-integrate-dropbox-in-thunar

notify_time=5000
icon_path="/full/path/to/dropbox-icon.png"
internet_status=$(ping -c 1 dropbox.com > /dev/null 2>&1; echo $?)
dropbox_status=$(dropbox status)

web_directory () {
    prepend_path="https://www.dropbox.com/home/"
    append_path=$(pwd | cut -d "/" -f5-)
    xdg-open "$prepend_path$append_path"
}

gui_notify () {
    notify-send -t "$notify_time" -i "$icon_path" "$1"
}

# Check: 1. internet connection; 2. if Dropbox is running; 3. if in Dropbox or Public folder.

if [ "$internet_status" != 0 ]; then
    gui_notify "There is an internet connectivity issue."
    exit 1
fi

if [ "$dropbox_status" = "Dropbox isn't running!" ]; then
    gui_notify "Dropbox isn't running."
    exit 1
fi

if [[ "$2" != *Dropbox* ]]; then
    gui_notify "You are not in Dropbox."
    exit 1
fi  

if [[ "$1" = -p && "$2" != *Dropbox\/Public* ]]; then
    gui_notify "You are not in the Dropbox/Public folder."
    exit 1
fi

case "$1" in
    -p )
        dropbox puburl "$2" | tr -d '\n' | xsel -ib && gui_notify "Public Link Copied" ;;
    -s )
        dropbox sharelink "$2" | tr -d '\n' | xsel -ib && gui_notify "Share Link Copied" ;;
    -d )
        web_directory ;;
esac
Run Code Online (Sandbox Code Playgroud)

图纳集成

融入图纳尔。转到编辑 > 配置自定义操作。单击加号以添加自定义操作。设置以下三个自定义操作:

添加分享链接

添加公共链接

在线添加目录

还要记住,您可以添加自己的图标以显示在 Thunar 上下文菜单项上。

考虑到您希望能够共享任何类型的文件或目录,对于其中的每一个,您都需要在第二个选项卡上执行以下操作。

外观条件

唯一的缺点是三个 Dropbox 菜单项在 Thunar 中全局显示,而不仅仅是在 Dropbox 中。但是,脚本会告诉您是否不小心离开了 Dropbox。

更新:该命令dropbox puburl不再有效。Dropbox 不再为免费帐户提供公共文件夹,并于 2017 年 9 月 1 日停止为付费帐户提供公共文件夹。