if not monitor.fade_thread.is_alive():
                     name = monitor.name
                     if args.verbose:
                         name += f' ({monitor.serial}) [{monitor.method.__name__}]'
                     print(
                         f'{name}: {monitor.initial_brightness}% -> {monitor.get_brightness()}%'
                     )
                     done.append(monitor)
             monitors = [i for i in monitors if i not in done]
             if monitors == []:
                 break
             time.sleep(0.1)
     except Exception:
         print(
             SBC.fade_brightness(args.fade,
                                 display=args.display,
                                 method=args.method,
                                 verbose_error=args.verbose))
 elif args.version:
     print(SBC.__version__)
 elif args.list:
     if args.verbose:
         monitors = SBC.list_monitors_info(method=args.method)
     else:
         monitors = SBC.list_monitors(method=args.method)
     if len(monitors) == 0:
         print('No monitors detected')
     else:
         for i in range(len(monitors)):
             if type(monitors[i]) is str:
                 print(f'Display {i}: {monitors[i]}')
             else:
Esempio n. 2
0
                monitors = None
            if monitors == None:
                print(values)
            else:
                values = [values] if type(values) is int else values
                if args.display == None or type(values) == list:
                    for i in range(len(monitors)):
                        try:
                            print(
                                f'{monitors[i]}: {values[i]}{"%" if values[i]!=None else ""}'
                            )
                        except IndexError:
                            break
                else:
                    print(f'Display {args.display}: {values}')
        elif args.set != None:
            SBC.set_brightness(args.set, **kw)
        elif args.fade != None:
            SBC.fade_brightness(args.fade, **kw)
        elif args.version:
            print(SBC.__version__)
        elif args.list:
            monitors = SBC.list_monitors(**kw)
            if len(monitors) == 0:
                print('No monitors detected')
            else:
                for i in range(len(monitors)):
                    print(f'Display {i}: {monitors[i]}')
        else:
            print("No valid arguments")
import serial
import screen_brightness_control as sbc
import time

port = 'COM7'

with serial.Serial(port, baudrate=9600, timeout=1) as ser:

    while 1:
        time.sleep(7)
        brightnessPercentage = ser.readline()
        if len(brightnessPercentage) > 0:
            print(int(brightnessPercentage))
            sbc.fade_brightness(int(brightnessPercentage))
Esempio n. 4
0
import screen_brightness_control as sbc
import keyboard, time

change = 70

while True:
    if keyboard.is_pressed('b'):
        change = 100
        sbc.fade_brightness(change)
    if keyboard.is_pressed('d'):
        change = 30
        sbc.fade_brightness(change)
    time.sleep(0.05)
Esempio n. 5
0
def ScreenChange(percent):
    print(percent)
    screen_brightness_control.fade_brightness(percent, interval=0.01)  # 设置亮度
Esempio n. 6
0
import argparse
import screen_brightness_control as SBC

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('-s',
                        '--set',
                        type=int,
                        help='set the brightness to this value')
    parser.add_argument('-g',
                        '--get',
                        action='store_true',
                        help='get the current screen brightness')
    parser.add_argument('-f',
                        '--fade',
                        type=int,
                        help='fade the brightness to this value')

    args = parser.parse_args()

    if args.get:
        print(SBC.get_brightness())
    elif args.set != None:
        SBC.set_brightness(args.set)
    elif args.fade != None:
        SBC.fade_brightness(args.fade)
    else:
        print("No valid arguments")
Esempio n. 7
0
def changeBrightness(value):
    try:
        bc.fade_brightness(value, bc.get_brightness())
    except bc.ScreenBrightnessError as error:
        print(error)