Skip to content

Instantly share code, notes, and snippets.

@janxkoci
Forked from cvoltz/dropbox.patch
Created April 26, 2024 09:23
Show Gist options
  • Save janxkoci/b0816c3a94748d313b72a898b245f3b3 to your computer and use it in GitHub Desktop.
Save janxkoci/b0816c3a94748d313b72a898b245f3b3 to your computer and use it in GitHub Desktop.
Patch to dropbox.py to get the correct PID when running Dropbox via flatpak
--- dropbox.py
+++ dropbox.py
@@ -134,11 +134,12 @@
FatalVisibleError("Platform not supported")
def is_dropbox_running():
- pidfile = os.path.expanduser("~/.dropbox/dropbox.pid")
-
try:
- with open(pidfile, "r") as f:
- pid = int(f.read())
+ pid = subprocess.run("flatpak ps | awk '/dropbox/ { print $2 }'",
+ shell=True, encoding="UTF-8",
+ stdout=subprocess.PIPE)
+ pid = int(pid.stdout.strip())
+
with open("/proc/%d/cmdline" % pid, "r") as f:
cmdline = f.read().lower()
except:
EOF
@janxkoci
Copy link
Author

patch for dropbox flatpak

The original post is here: flathub/com.dropbox.Client#43 (comment)

And the code to apply the patch:

wget \
  --output-document dropbox.py \
  --quiet \
  'https://www.dropbox.com/download?dl=packages/dropbox.py'

wget --quiet https://gist.githubusercontent.com/cvoltz/7198bddcf3d1f994cbd1bbec5d3db14a/raw/7e065eb5eb506a6f416e7e50fd938d3c69cd4e46/dropbox.patch

patch < dropbox.patch
chmod +x dropbox.py
mv dropbox.py ~/.local/bin/dropbox # cp is okay too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment