func doIdleAction() { dp, _ := display.NewDisplay("com.deepin.daemon.Display", "/com/deepin/daemon/Display") stoper := make(chan bool) stopAnimation = append(stopAnimation, stoper) for _, p := range dp.Monitors.Get() { m, err := display.NewMonitor("com.deepin.daemon.Display", p) if err != nil { logger.Warningf("create monitor %v failed:%v", p, err) continue } go func() { outputs := m.Outputs.Get() for v := 0.8; v > 0.1; v -= 0.05 { <-time.After(time.Millisecond * time.Duration(float64(400)*(v))) select { case <-stoper: for _, name := range outputs { dp.ResetBrightness(name) } dpmsOn() return default: for _, name := range outputs { dp.ChangeBrightness(name, v) } } } }() } dpmsOff() if suspendDelta != 0 { for { select { case <-time.After(time.Second * time.Duration(suspendDelta)): doSuspend() return case <-stoper: return } } } }
func (*Power) handleIdleOff() { for _, c := range stopAnimation { close(c) } stopAnimation = nil dpmsOn() dp, _ := display.NewDisplay("com.deepin.daemon.Display", "/com/deepin/daemon/Display") defer display.DestroyDisplay(dp) for _, p := range dp.Monitors.Get() { m, _ := display.NewMonitor("com.deepin.daemon.Display", p) defer display.DestroyMonitor(m) for _, name := range m.Outputs.Get() { dp.ResetBrightness(name) } } }
func isMultihead() bool { if dp, err := display.NewDisplay("com.deepin.daemon.Display", "/com/deepin/daemon/Display"); err != nil { logger.Error("Can't build com.deepin.daemon.Display Object:", err) return false } else { paths := dp.Monitors.Get() if len(paths) > 1 { return true } else if len(paths) == 1 { if m, err := display.NewMonitor("com.deepin.daemon.Display", paths[0]); err != nil { return false } else if m.IsComposited.Get() { return true } else { return false } } } return false }