add dropbox protocel handler
This commit is contained in:
parent
45f2492857
commit
9a2776b53e
1 changed files with 32 additions and 0 deletions
32
dropbox.py
Executable file
32
dropbox.py
Executable file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#!/bin/env python3
|
||||||
|
|
||||||
|
|
||||||
|
import json
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
from subprocess import call
|
||||||
|
|
||||||
|
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
path = sys.argv[1]
|
||||||
|
if len(path) > 10:
|
||||||
|
path = path[10:]
|
||||||
|
config_file = os.path.expanduser('~/.dropbox/info.json')
|
||||||
|
if os.path.isfile(config_file):
|
||||||
|
with open(config_file) as file:
|
||||||
|
config = json.load(file)
|
||||||
|
if config and 'personal' in config and 'path' in config['personal']:
|
||||||
|
base_path = config['personal']['path']
|
||||||
|
path = os.path.join(base_path, path)
|
||||||
|
if os.path.exists(path):
|
||||||
|
call(['xdg-open', path])
|
||||||
|
else:
|
||||||
|
print("path {} does not exist".format(path))
|
||||||
|
else:
|
||||||
|
print("config format not recognized")
|
||||||
|
else:
|
||||||
|
print("config not found")
|
||||||
|
else:
|
||||||
|
print("url invalid")
|
||||||
|
else:
|
||||||
|
print("no url given")
|
||||||
Loading…
Add table
Add a link
Reference in a new issue