#!/usr/bin/env python
# -*- coding:utf-8 -*-

import subprocess
from os import system


class BrightnessRestore():

    def detect_display_devices(self):

        """
        Detects available displays
        """
        connected_devices = []
        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_devices.append(words[0])
        return connected_devices

    def __init__(self):
        self.detected_devices = self.detect_display_devices()
        self.primary_name = self.detected_devices[0]
        command = "xrandr --output \
                %s --brightness %s" % (self.primary_name, 1)
        system(command)


if __name__ == '__main__':
    BrightnessRestore()
