Skip to content

Instantly share code, notes, and snippets.

@0xdevalias
Last active November 9, 2024 09:24
Show Gist options
  • Save 0xdevalias/38cfc92278f85ae89a46f0c156208fd5 to your computer and use it in GitHub Desktop.
Save 0xdevalias/38cfc92278f85ae89a46f0c156208fd5 to your computer and use it in GitHub Desktop.
Some notes on accessing / exporting Apple's Screen Time data

Accessing / Exporting Apple's Screen Time Data

Some notes on accessing / exporting Apple's Screen Time data

Table of Contents

knowledgeC.db SQLite CoreData Models / Tables

See also:

⇒ ./extract-coredata-model-hierarchy.py ~/Library/Application\ Support/Knowledge/knowledgeC.db
- 1: AdditionChangeSet (Table: ZADDITIONCHANGESET)
- 2: ContextualChangeRegistration (Table: ZCONTEXTUALCHANGEREGISTRATION)
- 3: ContextualKeyPath (Table: ZCONTEXTUALKEYPATH)
- 4: CustomMetadata (Table: ZCUSTOMMETADATA)
- 5: DeletionChangeSet (Table: ZDELETIONCHANGESET)
- 6: Histogram (Table: ZHISTOGRAM)
- 7: HistogramValue (Table: ZHISTOGRAMVALUE)
- 8: KeyValue (Table: ZKEYVALUE)
- 9: Object (Table: ZOBJECT)
  - 10: Category
  - 11: Event
  - 12: Identifier
  - 13: Quantity
- 14: Source (Table: ZSOURCE)
- 15: StructuredMetadata (Table: ZSTRUCTUREDMETADATA)
- 16: SyncPeer (Table: ZSYNCPEER)

Unsorted

⇒ ST_PID=$(pgrep ScreenTimeAgent); lsof -p $ST_PID
COMMAND   PID     USER   FD      TYPE DEVICE  SIZE/OFF                NODE NAME
ScreenTim 826 devalias  cwd       DIR    1,4       384               40725 /Users/devalias/Library/Containers/com.apple.ScreenTimeAgent/Data
ScreenTim 826 devalias  txt       REG    1,4   2858656 1152921500312301519 /System/Library/PrivateFrameworks/ScreenTimeCore.framework/Versions/A/ScreenTimeAgent
ScreenTim 826 devalias  txt       REG    1,4     52300           119749843 /Library/Preferences/Logging/.plist-cache.SaRrvI6F
ScreenTim 826 devalias  txt       REG    1,4    281152 1152921500312437674 /usr/lib/libobjc-trampolines.dylib
ScreenTim 826 devalias  txt       REG    1,4     32768               41700 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Local.sqlite-shm
ScreenTim 826 devalias  txt       REG    1,4       110 1152921500312100418 /System/Library/CoreServices/SystemVersion.bundle/English.lproj/SystemVersion.strings
ScreenTim 826 devalias  txt       REG    1,4    237664           107197209 /private/var/db/timezone/tz/2023c.1.0/icutz/icutz44l.dat
ScreenTim 826 devalias  txt       REG    1,4     32768               41754 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Cloud.sqlite-shm
ScreenTim 826 devalias  txt       REG    1,4  30447056 1152921500312449382 /usr/share/icu/icudt70l.dat
ScreenTim 826 devalias  txt       REG    1,4    134457 1152921500312134360 /System/Library/Frameworks/CoreData.framework/Versions/A/Resources/CoreDataErrors.loctable
ScreenTim 826 devalias  txt       REG    1,4     32768               82945 /Users/devalias/Library/Containers/com.apple.ScreenTimeAgent/Data/Library/Caches/com.apple.ScreenTimeAgent/Cache.db-shm
ScreenTim 826 devalias  txt       REG    1,4    626688           104208182 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/C/com.apple.iconservices/store.index
ScreenTim 826 devalias  txt       REG    1,4    825440 1152921500312138426 /System/Library/Frameworks/Foundation.framework/Versions/C/Resources/FoundationErrors.loctable
ScreenTim 826 devalias  txt       REG    1,4    132070           121959101 /private/var/db/analyticsd/events.allowlist
ScreenTim 826 devalias    0r      CHR    3,2       0t0                 314 /dev/null
ScreenTim 826 devalias    1u      CHR    3,2       0t0                 314 /dev/null
ScreenTim 826 devalias    2u      CHR    3,2 0t7142668                 314 /dev/null
ScreenTim 826 devalias    3u      REG    1,4  14741504               41682 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Local.sqlite
ScreenTim 826 devalias    4u      REG    1,4   2550312               41699 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Local.sqlite-wal
ScreenTim 826 devalias    5u      REG    1,4     32768               41700 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Local.sqlite-shm
ScreenTim 826 devalias    6u      REG    1,4  14741504               41682 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Local.sqlite
ScreenTim 826 devalias    7u      REG    1,4   2550312               41699 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Local.sqlite-wal
ScreenTim 826 devalias    8u      REG    1,4  13381632               41725 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Cloud.sqlite
ScreenTim 826 devalias    9u      REG    1,4    218392               41753 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Cloud.sqlite-wal
ScreenTim 826 devalias   10u      REG    1,4     32768               41754 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Cloud.sqlite-shm
ScreenTim 826 devalias   11u      REG    1,4  13381632               41725 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Cloud.sqlite
ScreenTim 826 devalias   12u      REG    1,4  13381632               41725 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Cloud.sqlite
ScreenTim 826 devalias   13u      REG    1,4    218392               41753 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Cloud.sqlite-wal
ScreenTim 826 devalias   14u      REG    1,4    218392               41753 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Cloud.sqlite-wal
ScreenTim 826 devalias   15u      REG    1,4  13381632               41725 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Cloud.sqlite
ScreenTim 826 devalias   16u      REG    1,4    218392               41753 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Cloud.sqlite-wal
ScreenTim 826 devalias   17u      REG    1,4  14741504               41682 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Local.sqlite
ScreenTim 826 devalias   18u      REG    1,4   2550312               41699 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Local.sqlite-wal
ScreenTim 826 devalias   19u      REG    1,4  14741504               41682 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Local.sqlite
ScreenTim 826 devalias   20u      REG    1,4   2550312               41699 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Local.sqlite-wal
ScreenTim 826 devalias   21   NPOLICY
ScreenTim 826 devalias   22u      REG    1,4  14741504               41682 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Local.sqlite
ScreenTim 826 devalias   23u      REG    1,4   2550312               41699 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Local.sqlite-wal
ScreenTim 826 devalias   24u      REG    1,4  14741504               41682 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Local.sqlite
ScreenTim 826 devalias   25u      REG    1,4     49152               82941 /Users/devalias/Library/Containers/com.apple.ScreenTimeAgent/Data/Library/Caches/com.apple.ScreenTimeAgent/Cache.db
ScreenTim 826 devalias   26u      REG    1,4  14741504               41682 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Local.sqlite
ScreenTim 826 devalias   27u      REG    1,4    778712               82944 /Users/devalias/Library/Containers/com.apple.ScreenTimeAgent/Data/Library/Caches/com.apple.ScreenTimeAgent/Cache.db-wal
ScreenTim 826 devalias   28u      REG    1,4     32768               82945 /Users/devalias/Library/Containers/com.apple.ScreenTimeAgent/Data/Library/Caches/com.apple.ScreenTimeAgent/Cache.db-shm
ScreenTim 826 devalias   29u      REG    1,4     49152               82941 /Users/devalias/Library/Containers/com.apple.ScreenTimeAgent/Data/Library/Caches/com.apple.ScreenTimeAgent/Cache.db
ScreenTim 826 devalias   30u      REG    1,4    778712               82944 /Users/devalias/Library/Containers/com.apple.ScreenTimeAgent/Data/Library/Caches/com.apple.ScreenTimeAgent/Cache.db-wal
ScreenTim 826 devalias   31u      REG    1,4   2550312               41699 /private/var/folders/j4/kxtq1cjs1l98xfqncjbsbx1c0000gn/0/com.apple.ScreenTimeAgent/Store/RMAdminStore-Local.sqlite-wal

See Also

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