Sorry for the old-thread revival, but I wanted to share a few updates I
made to the sc-idle.py script to make it more useful - maybe other
sc-idle users will benefit too.

The changes are:

1) added a condition to keep the server awake if any SMB clients are
active.

2) fixed an apparent logic bug in recognizing multiple active players

Here are the changed areas of code:


Code:
--------------------
    
  # Change to original main() to add smb_shares_active condition:
  def main():
  # Determine whether system is considered "idle"
  # (i.e. eligible for suspend/hibernate)
  system_is_idle = lambda: not (keepawake_file(path=opt.nosleep_path) \
  or tty_active() \
  or smb_shares_active() \
  or player_active(opt.cli_host, opt.cli_port))
  
  # New function for detecting active SMB clients:
  def smb_shares_active():
        active_smbusers_list = os.popen('smbstatus -b | sed -e 
"1,4d"').readlines()
        if len(active_smbusers_list):
        log.debug("Detected active smb user sessions, preventing idle.")
        return True
  
  # Revised original player_active function to fix problem handling multiple 
players.
  def player_active(host, port):
  'Returns True when players are active in SqueezeCenter'
  sc = sc_cli(host, port)
  
  is_off_fn = lambda cli, id: cli.query("%s power ?" % (id,)) == '0' \
  or cli.query("%s mode ?" % (id,)) in ['stop', 'pause']
  if False in [is_off_fn(sc, id) for id in sc.player_id()]:
  log.debug("At least one SqueezeCenter player is active.")
  del sc
  return True
  else:
  log.debug("No SqueezeCenter player found to be active.")
  del sc
  return False
  
--------------------


Many thanks to syburgh for sharing the information about getting the
MSI Wind PC setup running - it's been working quite well for my
server.

Thanks,

MJP


-- 
MJP
------------------------------------------------------------------------
MJP's Profile: http://forums.slimdevices.com/member.php?userid=30501
View this thread: http://forums.slimdevices.com/showthread.php?t=49028

_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix

Reply via email to