Skip to content

Add Spotlight integration via App Intents #1

@GordonBeeming

Description

@GordonBeeming

Summary

Expose Insomnia's caffeination actions in macOS Spotlight search and the Shortcuts app using the App Intents framework (macOS 14+).

Context

Raycast shows "Caffeinate" and "Decaffeinate" commands in its search bar. We can achieve the same native Spotlight discoverability using AppIntent + AppShortcutsProvider.

Intents to Create

Intent Spotlight Phrase Parameters
CaffeinateIntent "Caffeinate Insomnia" --display (Bool)
DecaffeinateIntent "Decaffeinate Insomnia"
ToggleCaffeinateIntent "Toggle Insomnia"
CaffeinateForIntent "Caffeinate for 30 minutes" duration (Int, minutes)
CaffeinateUntilIntent "Caffeinate until 5pm" time (Date)
StatusIntent "Insomnia status"

Implementation Notes

  • Import AppIntents framework
  • Each intent conforms to AppIntent protocol with static let title: LocalizedStringResource
  • Use openAppWhenRun = false for background execution
  • Create InsomniaShortutsProvider: AppShortcutsProvider to register all intents
  • Intents communicate with the running app via DistributedNotificationCenter or direct InsomniaCore calls
  • Titles/descriptions must be constant values (extracted at compile time)
  • App must be installed in /Applications and signed for Spotlight indexing to work

Requirements

  • macOS 14+
  • App must be signed with Developer ID
  • New file: Sources/Insomnia/Intents/ directory with one file per intent + the shortcuts provider

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions