Skip to content

Commit

Permalink
Added lock screen command
Browse files Browse the repository at this point in the history
  • Loading branch information
smithbm2316 committed Sep 24, 2021
1 parent b9cbbe8 commit 7420734
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 7420734

Please sign in to comment.