Brightness Controller

Topics: Word / Pages: 2 (470 words) / Published: Aug 24th, 2013
#!/usr/bin/env python
# -*- coding:utf-8 -*-

import wx import subprocess from os import system

class BrightnessController(wx.Frame):

def debug_true(self): return False

def detect_display_devices(self): """Detects available displays""" connected_devs = []

xrandr_output = subprocess.check_output('xrandr -q', shell=True)

lines = xrandr_output.split('\n') for line in lines: words = line.split(' ') for word in words: if word == 'connected': connected_devs.append(words[0]) return connected_devs

def __init__(self, parent, title): super(BrightnessController, self).__init__(parent, title=title, size=(325, 100)) self.detected_devices = self.detect_display_devices() self.no_of_detected_device = len(self.detected_devices)

if self.no_of_detected_device == 1 or self.no_of_detected_device == 2: if self.debug_true(): print 'Found one' self.primary_name = self.detected_devices[0] else: self.primary_name = 'Not Found!' if self.no_of_detected_device == 2: if self.debug_true(): print 'Found two' self.secondary_name = self.detected_devices[1] else: self.secondary_name = 'Not Found'

self.array_value = 0.00 self.cmds_primary_display = [] self.cmds_secondary_display = []

for i in xrange(0, 101): cmd_primary_display = "xrandr --output \ %s --brightness %s" % (self.primary_name, self.array_value) cmd_secondary_display="xrandr --output \ %s --brightness %s" % (self.secondary_name, self.array_value) self.cmds_primary_display.append(cmd_primary_display)

You May Also Find These Documents Helpful

  • Automatic Headlight Brightness
  • Domain Controllers
  • financial controller
  • Brightness Constancy Definition
  • Financial Controller
  • PID controller
  • Pid Controller
  • The role of the controller
  • Game Controllers
  • Temperature Controller