Created
March 9, 2015 18:21
-
-
Save jacobsalmela/c045ddc4a79e5954adf2 to your computer and use it in GitHub Desktop.
pmset every computer with one script
This file contains hidden or 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
#!/usr/bin/python | |
#----------AUTHOR------------ | |
# Jacob Salmela | |
# 02 March 2015 | |
#-----------IMPORTS---------- | |
from os import system | |
from subprocess import call | |
from socket import gethostname | |
#----------VARIABLES--------- | |
computer_name = gethostname().split('-') | |
#----------FUNCTIONS--------- | |
########################################### | |
def run_pmset(startup_time, shutdown_time): | |
# Uncomment for debugging | |
#call(["/usr/bin/say", "-v", "Samantha", "Setting power events for " + str(computer_name[2])]) | |
call(["/usr/bin/pmset", "-a", "halfdim", "1", "disksleep", "0", "sleep", "0", "displaysleep", "240", "womp", "1", "repeat", "wakeorpoweron", "MTWRF", startup_time, "shutdown", "MTWRFSU", shutdown_time]) | |
################ | |
def set_sched(): | |
if (computer_name[2] == "Media") and (computer_name[3] == "A"): | |
run_pmset("06:00:00", "16:30:00") | |
elif (computer_name[2] == "Media") and (computer_name[3] == "B"): | |
run_pmset("06:05:00", "16:30:00") | |
elif (computer_name[2] == "S201"): | |
run_pmset("06:15:00", "16:30:00") | |
elif (computer_name[2] == "W105"): | |
pass | |
else: | |
print ("No special settings needed for " + gethostname()) | |
call(["/usr/bin/pmset", "-a", "halfdim", "1", "disksleep", "0", "sleep", "0", "displaysleep", "240", "womp", "1", "repeat", "shutdown", "MTWRFSU", "16:30:00"]) | |
#------------------------------ | |
#-------BEGIN SCRIPT----------- | |
#------------------------------ | |
set_sched() | |
call(["/usr/bin/pmset", "-g", "sched"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment