def set_timeout(name, value, power='ac', scheme=None):
 ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
 comment = []
 if (name not in ['monitor', 'disk', 'standby', 'hibernate']):
  ret['result'] = False
  comment.append('{0} is not a valid setting'.format(name))
 elif (power not in ['ac', 'dc']):
  ret['result'] = False
  comment.append('{0} is not a power type'.format(power))
 else:
  check_func = __salt__['powercfg.get_{0}_timeout'.format(name)]
  set_func = __salt__['powercfg.set_{0}_timeout'.format(name)]
  values = check_func(scheme=scheme)
  if (values[power] == value):
   comment.append('{0} {1} is already set with the value {2}.'.format(name, power, value))
  else:
   ret['changes'] = {name: {power: value}}
   set_func(value, power, scheme=scheme)
 ret['comment'] = ' '.join(comment)
 return ret

def set_timeout ( name , value , power = 'ac' , scheme = None ) : ret = { 'name' : name , 'result' : True , 'comment' : '' , 'changes' : { } } comment = [ ] if ( name not in [ 'monitor' , 'disk' , 'standby' , 'hibernate' ] ) : ret [ 'result' ] = False comment . append ( '{0} is not a valid setting' . format ( name ) ) elif ( power not in [ 'ac' , 'dc' ] ) : ret [ 'result' ] = False comment . append ( '{0} is not a power type' . format ( power ) ) else : check_func = __salt__ [ 'powercfg.get_{0}_timeout' . format ( name ) ] set_func = __salt__ [ 'powercfg.set_{0}_timeout' . format ( name ) ] values = check_func ( scheme = scheme ) if ( values [ power ] == value ) : comment . append ( '{0} {1} is already set with the value {2}.' . format ( name , power , value ) ) else : ret [ 'changes' ] = { name : { power : value } } set_func ( value , power , scheme = scheme ) ret [ 'comment' ] = ' ' . join ( comment ) return ret
set the sleep timeouts of specific items such as disk .