forked from saltstack/salt
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an "osxdesktop" module that implements functions in a new virtual
"desktop" virtual module, such as lock, screensaver, get_output_volume, and set_output_volume
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
''' | ||
Mac OS X implementations of various commands in the "desktop" interface | ||
''' | ||
|
||
|
||
def __virtual__(): | ||
if __grains__['os'] == 'MacOS': | ||
return 'desktop' | ||
|
||
|
||
def get_output_volume(): | ||
''' | ||
Get the output volume (range 0 to 100) | ||
''' | ||
|
||
cmd = 'osascript -e "get output volume of (get volume settings)"' | ||
|
||
return __salt__['cmd.run'](cmd) | ||
|
||
|
||
def set_output_volume(volume): | ||
''' | ||
Set the volume of sound (range 0 to 100) | ||
''' | ||
|
||
cmd = 'osascript -e "set volume output volume {0}"'.format(volume) | ||
|
||
__salt__['cmd.run'](cmd) | ||
|
||
return get_output_volume() | ||
|
||
|
||
def screensaver(): | ||
''' | ||
Launch the screensaver | ||
''' | ||
|
||
cmd = 'open /System/Library/Frameworks/ScreenSaver.framework/Versions/A/Resources/ScreenSaverEngine.app' | ||
|
||
return __salt__['cmd.run'](cmd) | ||
|
||
|
||
def lock(): | ||
''' | ||
Lock the screen | ||
''' | ||
|
||
cmd = '/System/Library/CoreServices/Menu\ Extras/User.menu/Contents/Resources/CGSession -suspend' | ||
|
||
return __salt__['cmd.run'](cmd) |