Skip to content

Commit

Permalink
Merge pull request #77 from smithbm2316/lock-screen
Browse files Browse the repository at this point in the history
Added lock screen command
  • Loading branch information
ziulev committed Sep 26, 2021
2 parents b9cbbe8 + 7420734 commit 4abe215
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/plugins/preferences/preferences.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ export class PreferencesPlugin extends SpotterPlugin implements SpotterPluginLif
icon: '/System/Applications/System\ Preferences.app',
action: () => this.sleep(),
},
{
title: 'Lock Screen Preferences',
icon: '/System/Applications/System\ Preferences.app',
action: () => this.lockScreen(),
},
];
}

Expand All @@ -242,4 +247,8 @@ export class PreferencesPlugin extends SpotterPlugin implements SpotterPluginLif
private async sleep() {
await this.api.shell.execute("osascript -e 'tell app \"System Events\" to sleep'")
}

private async lockScreen() {
await this.api.shell.execute("osascript -e 'tell app \"System Events\"' -e 'tell process \"SystemUIServer\" to keystroke \"q\" using {command down, control down}' -e 'tell end'")
}
}

0 comments on commit 4abe215

Please sign in to comment.