Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,16 @@ tests/regression/*.log
# other
deploymentScpTarget
.hg*

# BEGIN CREDENTIAL HARDENING (managed)
.env
.env.*
!.env.example
.credentials/
credentials.json
client_secret*.json
token*.json
*.pem
*.p12
*.key
# END CREDENTIAL HARDENING (managed)
5 changes: 5 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.24.2
hooks:
- id: gitleaks
371 changes: 371 additions & 0 deletions ARCHITECTURE.md

Large diffs are not rendered by default.

154 changes: 154 additions & 0 deletions EVENTKIT_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
# icalBuddy64 - EventKit Migration

A modernized fork of icalBuddy that uses Apple's EventKit framework instead of the deprecated CalendarStore framework.

## Why This Fork?

The original icalBuddy uses CalendarStore, which was deprecated in macOS 10.8 (2012). On modern macOS (10.14+), CalendarStore doesn't integrate with the privacy system (TCC), causing icalBuddy to report "No calendars" even when calendars exist and permissions are granted.

This fork migrates to EventKit, which:
- Works with modern macOS privacy controls
- Triggers proper permission prompts
- Supports both Calendar and Reminders access
- Is actively maintained by Apple

## Repository

- **Fork:** https://github.com/mgunville/icalBuddy64
- **Upstream:** https://github.com/dkaluta/icalBuddy64
- **Branch:** `eventkit-migration`

## Quick Start

```bash
# Clone the fork
git clone https://github.com/mgunville/icalBuddy64.git
cd icalBuddy64
git checkout eventkit-migration

# Build
make clean && make

# Test (will prompt for calendar access on first run)
./icalBuddy calendars
./icalBuddy eventsToday

# Install
sudo cp icalBuddy /usr/local/bin/
# OR
cp icalBuddy ~/bin/
```

## Migration Status

| Component | Status |
|-----------|--------|
| Core framework switch | Done |
| Calendar queries | Done |
| Event queries | Done |
| Task/Reminder queries | Done |
| Permission handling | Done |
| Pretty print output | In Progress |
| Calendar colors | In Progress |
| Testing | Pending |
| Documentation | Pending |

## Documentation

- [MIGRATION_PLAN.md](./MIGRATION_PLAN.md) - Detailed migration plan and timeline
- [ARCHITECTURE.md](./ARCHITECTURE.md) - System architecture and module descriptions

## Key Changes from Upstream

### 1. Framework Change
```diff
- #import <CalendarStore/CalendarStore.h>
+ #import <EventKit/EventKit.h>
```

### 2. Permission Handling
New `EventKitStore.m` handles permission requests synchronously:
```objc
BOOL initEventStore(void); // Request calendar access
BOOL initReminderAccess(void); // Request reminders access
```

### 3. API Updates
| Old (CalendarStore) | New (EventKit) |
|---------------------|----------------|
| `[CalCalendarStore defaultCalendarStore]` | `eventStore` (global) |
| `[cal uid]` | `[cal calendarIdentifier]` |
| `[task dueDate]` | `[reminder dueDateComponents]` |
| Sync task queries | Async with semaphore |

## Usage Examples

```bash
# List all calendars
icalBuddy calendars

# Today's events
icalBuddy eventsToday

# Events for next 7 days
icalBuddy eventsToday+7

# Events from specific calendar
icalBuddy -ic "Work" eventsToday

# Formatted output (for Obsidian Templater)
icalBuddy -npn -nc -ps "/ - /" -iep "datetime,title" \
-po "datetime,title" -b "###### " -tf "%H%M" \
-ic "Work" eventsToday

# Uncompleted tasks
icalBuddy uncompletedTasks

# Tasks due before a date
icalBuddy tasksDueBefore:today+7
```

## Troubleshooting

### "No calendars" Error

1. **Check System Settings:**
- System Settings → Privacy & Security → Calendars
- Ensure Terminal (or your app) has access

2. **Reset permissions and retry:**
```bash
tccutil reset Calendar
./icalBuddy calendars # Will prompt again
```

3. **Check calendar exists:**
```bash
# Via AppleScript (bypasses TCC issues)
osascript -e 'tell application "Calendar" to get name of calendars'
```

### Permission Not Prompting

The permission prompt only appears once. If denied:
1. Open System Settings → Privacy & Security → Calendars
2. Manually add Terminal/iTerm/your app
3. Toggle access on

## Contributing

1. Fork the repository
2. Create a feature branch from `eventkit-migration`
3. Make changes with appropriate `#ifdef USE_MOCKED_CALENDARSTORE` guards
4. Test with `make && ./icalBuddy eventsToday`
5. Submit a pull request

## License

MIT License - see original icalBuddy license.

## Credits

- **Original Author:** Ali Rantakari (http://hasseg.org/icalBuddy)
- **64-bit Fork:** dkaluta
- **EventKit Migration:** mgunville
104 changes: 104 additions & 0 deletions EVENTKIT_TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# icalBuddy EventKit Migration - TODO

## Remaining Work

### High Priority (Required for MVP)

- [x] **icalBuddyPrettyPrint.m** - Update for EventKit types
- [x] `printCalEvent()` - EKEvent property access
- [x] `printCalTask()` - EKReminder property access (dueDateComponents → NSDate)
- [x] Calendar color access via CGColor instead of NSColor

- [x] **icalBuddyFormatting.m** - Update color handling
- [x] Convert CGColorRef to NSColor for ANSI color mapping
- [x] Update `closestSGRCodeForColor:` calls

- [x] **Build & Test**
- [x] Successful compilation with no errors
- [x] Test `calendars` command
- [x] Test `eventsToday` command
- [ ] Test `uncompletedTasks` command (requires Reminders permission)
- [x] Test with calendar filters (-ic, -ec)

### Medium Priority (Full Compatibility)

- [x] **icalBuddyPrettyPrint.h** - No changes needed (uses typedefs)

- [ ] **Testing**
- [x] Test `eventsToday+N` (multi-day) - works
- [ ] Test `eventsFrom:X to:Y` (date range)
- [ ] Test `eventsNow` (current events)
- [ ] Test `tasksDueBefore:DATE`
- [ ] Test `undatedUncompletedTasks`
- [x] Test `-sc` (separate by calendar) - works
- [ ] Test `-sd` (separate by date)
- [ ] Test `-sp` (separate by priority)
- [x] Test formatting options (-tf, -df, -b, -ps, etc.) - works

- [ ] **Edge Cases**
- [x] All-day events
- [ ] Multi-day events
- [ ] Recurring events
- [ ] Events with no end time
- [ ] Tasks with no due date
- [ ] Tasks with priority

### Low Priority (Polish)

- [ ] **Documentation**
- [ ] Update man page (icalBuddy.pod)
- [ ] Update FAQ
- [ ] Add EventKit-specific notes

- [ ] **Code Quality**
- [ ] Remove debug logging
- [ ] Clean up #ifdef blocks where possible
- [ ] Add comments for EventKit-specific code

- [ ] **Release**
- [ ] Bump version number
- [ ] Create GitHub release
- [ ] Update upstream README with fork info

## Files Changed Summary

```
Modified:
calendarStoreImport.h - EventKit imports and typedefs
Makefile - EventKit framework, compiler flags
icalBuddyFunctions.m - Core calendar/event/task queries
icalBuddy.m - Type casts in print loop
icalBuddyPrettyPrint.m - Output formatting (EventKit types)
icalBuddyFormatting.m - ANSI colors (CGColor handling)
icalBuddyFormatting.h - Import header update

New:
EventKitStore.m - EKEventStore singleton, permissions
```

## Current Status

**BUILD: PASSING** ✓
**CALENDARS: WORKING** ✓
**EVENTS: WORKING** ✓
**REMINDERS: Requires permission grant**

## Notes

- Keep `#ifdef USE_MOCKED_CALENDARSTORE` guards for test compatibility
- EventKit reminders API is async - using semaphores for sync behavior
- Permission requests happen on first access, not app launch
- CGColor API requires macOS 10.15+ (fallback to nil for older versions)
- EventKit uses `URL` property (capitalized), not `url`
- EventKit uses `calendarItemIdentifier` instead of `uid`

## Installation

Binary installed to: `~/bin/icalBuddy`
Symlink at: `/usr/local/bin/icalBuddy` → `~/bin/icalBuddy`

## Repository

- Fork: https://github.com/mgunville/icalBuddy64
- Branch: `eventkit-migration`
- Commit: 7d44235
Loading