diff --git a/Readme.md b/Readme.md index bf5a022..ba65e1d 100644 --- a/Readme.md +++ b/Readme.md @@ -21,10 +21,13 @@ Also, two way **Clipboard** sync for text! All selected files, photos and videos will be transfered to PC. Or you can use it from the share sheet. + ## Notes - Note: Transfer stops as soon as iPhone screen goes off. You need to keep the screen on while you are transfering too many photos or huge videos. - Note: To make large amount of photo/video transfer 'Allow Sharing Large Amounts of Data' needs to be turned on from 'Settings -> Shortcuts -> Advanced' screen. +- Note: Files are sent to ~\Downloads by default. Specify `--download-dir ` when running the host to set a new one. +- Note: To run as a Windows service, configure with the tool [NSSM - the Non-Sucking Service Manager](http://nssm.cc/) ## Run / Compile & Run hints diff --git a/ShortcutsListener.py b/ShortcutsListener.py index 0d28928..196dc98 100644 --- a/ShortcutsListener.py +++ b/ShortcutsListener.py @@ -1,10 +1,23 @@ from flask import Flask, request -import os, pyperclip +import os, pyperclip, argparse app = Flask(__name__) debug = False # set to True to print debug messages -UPLOAD_FOLDER = os.path.join(os.path.expanduser('~'), 'Downloads') +# Setup command line argument parsing +parser = argparse.ArgumentParser(description='Flask app to upload files and manage clipboard.') +# The default value is set to None initially to check if a directory was explicitly provided +parser.add_argument('--download-dir', type=str, help='Directory to save downloaded files.', default=None) +args = parser.parse_args() + +# Determine UPLOAD_FOLDER based on whether a command line argument was provided +if args.download_dir is None: + # Fallback to the Downloads folder if no directory is specified + UPLOAD_FOLDER = os.path.join(os.path.expanduser('~'), 'Downloads') +else: + UPLOAD_FOLDER = args.download_dir + +# Ensure the UPLOAD_FOLDER exists if not os.path.exists(UPLOAD_FOLDER): os.makedirs(UPLOAD_FOLDER)