func (p *Power) initPlan() { p.screensaver.ConnectIdleOn(p.handleIdleOn) p.screensaver.ConnectIdleOff(p.handleIdleOff) p.updateIdletimer() con, _ := xgb.NewConn() dpms.Init(con) dpmsOn = func() { dpms.ForceLevel(con, dpms.DPMSModeOn) } dpmsOff = func() { dpms.ForceLevel(con, dpms.DPMSModeOff) } }
func NewScreenSaver() *ScreenSaver { s := &ScreenSaver{inhibitors: make(map[uint32]inhibitor)} s.xu, _ = xgbutil.NewConn() screensaver.Init(s.xu.Conn()) screensaver.QueryVersion(s.xu.Conn(), 1, 0) screensaver.SelectInput(s.xu.Conn(), xproto.Drawable(s.xu.RootWin()), screensaver.EventNotifyMask|screensaver.EventCycleMask) dpms.Init(s.xu.Conn()) go s.loop() return s }