Automatically sync images uploaded from ShareX (to Google Drive) into your Google Photos library using a lightweight Python script and systemd.
- Watch a Google Drive folder for new screenshots (uploaded via ShareX)
- Download new files to a temporary folder
- Upload them to Google Photos
- Automatically delete them from Drive and the local temp folder
- Run in the background using a persistent systemd timer
- Python 3.8+
- A Google Cloud project with Drive & Photos API enabled
- OAuth 2.0 "Desktop App" credentials (
credentials.jsonfile) - ShareX configured to upload to a specific Google Drive folder
- Visit: Google Cloud Console
- Create a project (if you don’t have one)
- Enable:
- Google Drive API
- Google Photos Library API
- Go to Credentials → Create Credentials → OAuth Client ID
- Application type: Desktop App
- Download the resulting
credentials.json
git clone https://github.com/vcandelario/sharex_sync.git
cd sharex_syncPlace your credentials.json file inside the project folder.
Run the installer:
python3 install.pyThis will:
- Create and install a systemd
.serviceand.timerunder your user - Start the timer (runs every 15 seconds)
- Launch
main.pyinteractively for first-time Google auth & folder ID input
Now every time you upload an image to your chosen Google Drive folder via ShareX, it will:
- Be automatically uploaded to Google Photos
- Deleted from Drive
- Deleted from your server’s temp folder (
/tmp/sharex_photos)
Just run main.py manually once:
python3 main.pyThis will trigger the Google OAuth flow and folder ID prompt.
systemctl --user stop sharex_sync.timer
systemctl --user stop sharex_sync.serviceTo prevent it from running again:
systemctl --user disable sharex_sync.timerGoogle restricted direct Google Photos API access. ShareX would need to verify their app and undergo a security audit which was not feasible for a volunteer project. This script sidesteps the restriction by using your own credentials and Google Drive.
If you ever want to reset:
rm token.json folderID.txtThen rerun main.py.
MIT License.