Last active
December 2, 2021 17:28
-
-
Save funasoul/43ccfbf588868486f7d2d130765bc60c to your computer and use it in GitHub Desktop.
Return 0 if dropbox is running.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
is_dropbox_running() { | |
# Return 0 if dropbox is running. | |
# Thanks to Official Dropbox Command Line Interface. | |
# https://www.dropboxwiki.com/tips-and-tricks/using-the-official-dropbox-command-line-interface-cli | |
if [[ -r ~/.dropbox/dropbox.pid ]]; then | |
pid=$(cat ~/.dropbox/dropbox.pid) | |
else | |
return 1 | |
fi | |
if [[ "$OSTYPE" == "linux-gnu" ]]; then | |
# Linux | |
if [[ -f /proc/${pid}/cmdline ]]; then | |
grep -qi dropbox /proc/${pid}/cmdline | |
return $? | |
else | |
return 1 | |
fi | |
elif [[ "$OSTYPE" == "darwin"* ]]; then | |
# macOS | |
ps -p $pid -o command | grep -qi dropbox.app | |
return $? | |
else | |
# Unknown. | |
return 1 | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment