Skip to content

Commit

Permalink
Bash script to lock computer in OSX.
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboy committed Apr 13, 2015
1 parent f2719c4 commit 28a3fd8
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions bin/osx_lock_computer
@@ -0,0 +1,11 @@
#!/bin/bash

sleep 0.5

if [[ "$(ioreg -c AppleSmartBattery | grep '"ExternalConnected" = Yes')" ]]; then
# Plugged in: start screensaver.
open /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app
else
# Battery power: go to lock menu.
/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend
fi

0 comments on commit 28a3fd8

Please sign in to comment.