Skip to content

Instantly share code, notes, and snippets.

@dJani97
Last active February 16, 2018 16:17
Show Gist options
  • Save dJani97/e6723b8c818fa8c03dd427d54115c989 to your computer and use it in GitHub Desktop.
Save dJani97/e6723b8c818fa8c03dd427d54115c989 to your computer and use it in GitHub Desktop.
Dropbox Restarter
"""
Simple Python3 script that checks if your Dropbox Linux desktop client is running, and restarts it if it's stopped.
You may start the script from a systemd unit file, or execute it with another tool on system startup (eg. KDE autostart)
"""
import tkinter
from tkinter import messagebox
import subprocess
import time
sleep_seconds = 30
while True:
time.sleep(sleep_seconds)
output = subprocess.check_output(['ps', '-A'])
if "dropbox" not in str(output):
root = tkinter.Tk()
root.withdraw()
answer = messagebox.askyesno("Dropbox has stopped!", "Dropbox service has stopped!\nWould you like to restart it?")
root.destroy()
if answer:
subprocess.call(['dropbox', 'start'], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@dJani97
Copy link
Author

dJani97 commented Feb 16, 2018

Simple Python3 script that checks if your Dropbox Linux desktop client is running, and restarts it if it's stopped.
You may start the script from a systemd unit file, or execute it with another tool on system startup (eg. KDE autostart)

@dJani97
Copy link
Author

dJani97 commented Feb 16, 2018

I wrote this script because my Dropbox client often stopped on my KDE desktop, and I got tired of loosing parts of my work all the time.

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