Skip to content

Commit

Permalink
trigger Squirrel syncUserData by $ Squirrel --sync
Browse files Browse the repository at this point in the history
close #65
  • Loading branch information
puttin authored and lotem committed Jan 27, 2023
1 parent 7e8eeb0 commit 65d21f5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions SquirrelApplicationDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,12 @@ -(void)rimeNeedsReload:(NSNotification *)aNotification
[self deploy:nil];
}

-(void)rimeNeedsSync:(NSNotification *)aNotification
{
NSLog(@"Sync rime on demand.");
[self syncUserData:nil];
}

-(NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
{
NSLog(@"Squirrel is quitting.");
Expand All @@ -228,6 +234,11 @@ -(void)awakeFromNib
name:@"SquirrelReloadNotification"
object:nil];

[notifCenter addObserver:self
selector:@selector(rimeNeedsSync:)
name:@"SquirrelSyncNotification"
object:nil];

}

-(void)dealloc
Expand Down
7 changes: 7 additions & 0 deletions main.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ int main(int argc, char *argv[]) {
return rime_get_api()->deploy() ? 0 : 1;
}

if (argc > 1 && !strcmp("--sync", argv[1])) {
[[NSDistributedNotificationCenter defaultCenter]
postNotificationName:@"SquirrelSyncNotification"
object:nil];
return 0;
}

@autoreleasepool {
// find the bundle identifier and then initialize the input method server
IMKServer *server __unused =
Expand Down

0 comments on commit 65d21f5

Please sign in to comment.