Sunday, May 29, 2016

script to change screen brightness in ubuntu 16.04

1- save the script below as brightness.py

#!/usr/bin/python
import sys
import os
brifile = "/sys/class/backlight/intel_backlight/brightness"
if len(sys.argv) > 1:
  brlevel = sys.argv[1]
  if int(brlevel) >= 0 and int(brlevel) <= 5273:
   
    os.system("echo "+brlevel+" > " + brifile)
  else:
    print "range from 0 to 5273"
else:
  os.system("echo 1000 > " + brifile)



2- usages
- set brightness to 2000, possible input  from 0 to 5273"
$ sudo python brightness.py 2000

- if no input the default value is 1000
$ sudo python brightness.py

No comments:

Post a Comment