Skip to content

Instantly share code, notes, and snippets.

@Roy-Orbison
Last active October 10, 2023 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Roy-Orbison/ada4455eea3aef9b276f0b1ef448d212 to your computer and use it in GitHub Desktop.
Save Roy-Orbison/ada4455eea3aef9b276f0b1ef448d212 to your computer and use it in GitHub Desktop.
Simple link from Dolphin file manager to file/folder on Dropbox.com using Maestral GUI under KDE. The .desktop file goes under `~/.local/share/kio/servicemenus/` and the script should be anywhere in your PATH, I used `~/.local/bin/`. Script depends on realpath, xdg-open, notify-send, and of course maestral.
#!/bin/bash
if maestral status | grep -qFi 'not running'; then
err='Maestral not running'
elif ! droot="`maestral config get path`"; then
err='Maestral not found'
elif ! real="`realpath -eLPq "$1"`"; then
err='Path does not exist'
elif [[ ${#real} -le ${#droot} || "${real:0:${#droot}}" != "$droot" ]]; then
err="The path $real is not below the Dropbox root directory $droot"
else
if [[ -d "$real" ]]; then
pfx=home
else
pfx=preview
fi
xdg-open "https://www.dropbox.com/$pfx${real:${#droot}}"
exit
fi
notify-send Error "$err"
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
MimeType=inode/directory;application/octet-stream;
Actions=maestralOpenOnDropboxSite
[Desktop Action maestralOpenOnDropboxSite]
Name=Open on Dropbox website (via Maestral)
Icon=link
Exec=maestral-open-dropbox.sh %f;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment