ShareYourScreenTime is a project designed to track and visualize your daily screen time from your iPhone. It collects data on how much time you spend on different apps and presents this information in SVG format.
⚠️ Disclaimer: I highly recommend not attempting this at home. Currently, there is no official method to access iPhone's screen time data. This project operates by extracting data from Mac's system files following the synchronization of screen time between iPhone and Mac via iCloud.
This project was initiated following the inspiration from Felix Kohlhas's work, Exporting and Analyzing iOS Screen Time Data using Python and InfluxDB, with the objective of publicly disseminating my screen time data as a measure to combat phone addiction.
Data Collection: This process involves the use of a Python script coupled with a Shell script to extract data pertaining to screen time, which is subsequently transmitted to a Vercel server and stored within a Postgres database.
Visualization: Generates dynamic SVG with bar chart to visualize yesterday's screen time data.
To set up ShareYourScreenTime for personal use, follow these steps:
-
Enable Screen Time Sharing: On your iPhone, go to Screen Time settings and activate the
Share Across Devices
option. -
Clone the Repository: Clone this project to your local
-
Deploy on Vercel: Push the cloned repository to Vercel for hosting.
-
Database Connection: Link the Vercel server with a Postgres database hosted on Vercel.
-
Configure Database: Insert the app icon URLs into the database as specified in the
create-app-icons-table.ts
schema. -
Virtual Environment Setup: Run the following commands to set up the Python virtual environment:
python -m venv venv source venv/bin/activate pip install -r requirements.txt
-
Environment Variable Setup: Fill in the
VERCEL_DOMAIN
andDEVICE_MODEL
in the/script/crawler/.env
file. -
Script Permissions: Ensure
/script/cron/run.sh
is executable by modifying its permissions. -
Cron Job: Schedule a cron job to run
/script/cron/run.sh
at regular intervals to collect screen time data. (Note: This is essential as Apple does not facilitate real-time synchronization of screen time data).
A notable constraint, as previously highlighted, is Apple's lack of support for real-time synchronization of screen time data. Consequently, this can result in occasional omissions of screen time data.