Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
How to Control Laptop Screen Brightness using Python?
Next article icon

How to Control Laptop Screen Brightness using Python?

Last Updated : 17 Aug, 2021
Comments
Improve
Suggest changes
Like Article
Like
Report

To control the brightness of the screen we are using the screen-brightness-control library. The screen-brightness-control library has only one class and few functions. The most useful functions are mentioned below:

  1. get_brightness()
  2. set_brightness()
  3. fade_brightness()
  4. list_monitors()

Installation: We can install the package by running the following pip command:

pip install screen-brightness-control

Example 1: How to Get Screen Brightness

The get_brightness() method returns the current brightness level.

Syntax: get_brightness(display=None, method=None, verbose_error=False)

Parameters:

  • display -: the specific display you wish to adjust. This can be the name, model, serial or index of the display
  • method -: the OS specific method to use. On Windows this can be "wmi" (for laptop displays) or "vcp" (for desktop monitors). On Linux this can be "light", "xrandr", "ddcutil" or "xbacklight".
  • verbose_error -: a boolean value to control how much detail any error messages should contain

Returns: Current brightness level

Python3
# importing the module import screen_brightness_control as sbc  # get current brightness  value current_brightness = sbc.get_brightness() print(current_brightness)  # get the brightness of the primary display primary_brightness = sbc.get_brightness(display=0) print(primary_brightness) 

 
 

Output: Suppose the brightness was this:

Then the output will be: 

50 50

The output can be a list or an integer depending on the number of detected monitors.
 

Example 2: How to Set Screen Brightness

The set_brightness() method changes the brightness of the screen.

Syntax: set_brightness(value, display=None, method=None, force=False, verbose_error=False, no_return=False)

Parameters:

  • value: the level to set the brightness to. Can either be an integer or a string.
  • display:  the specific display you wish to adjust. This can be the name, model, serial or index of the display
  • method:  the OS specific method to use. On Windows this can be "wmi" (for laptop displays) or "vcp" (for desktop monitors). On Linux this can be "light", "xrandr", "ddcutil" or "xbacklight".
  • force (Linux only): If set to False then the brightness is never set to less than 1 because on Linux this often turns the screen off. If set to True then it will bypass this check
  • verbose_error: A boolean value to control how much detail any error messages should contain
  • no_return: if False, this function will return what the brightness was set to. If True, this function returns nothing, which is slightly quicker
Python3
# importing the module import screen_brightness_control as sbc  # get current brightness value print(sbc.get_brightness())  #set brightness to 50% sbc.set_brightness(50)  print(sbc.get_brightness())  #set the brightness of the primary display to 75% sbc.set_brightness(75, display=0)  print(sbc.get_brightness()) 

 
   Output:

100 50 75

The output can be a list or an integer depending on the number of detected monitors.
 

  Example 3: How to Fade the Brightness

The fade_brightness() method gently fades the brightness to a value.

Syntax: fade_brightness(finish, start=None, interval=0.01, increment=1, blocking=True)

Parameters:

  • finish: The brightness value to fade to
  • start: The value to start from. If not specified it defaults to the current brightness
  • interval: The time interval between each step in brightness
  • increment: The amount to change the brightness by each step
  • blocking: If set to False it fades the brightness in a new thread
Python3
# importing the module import screen_brightness_control as sbc  # get current brightness value print(sbc.get_brightness())  # fade brightness from the current brightness to 50% sbc.fade_brightness(50) print(sbc.get_brightness())  # fade the brightness from 25% to 75% sbc.fade_brightness(75, start = 25) print(sbc.get_brightness())  # fade the brightness from the current # value to 100% in steps of 10% sbc.fade_brightness(100, increment = 10) print(sbc.get_brightness()) 

 
Output:

75 50 75 100

 Example 4: How to list available monitors

The list_monitors() method returns a list the names of all detected monitors

Syntax: list_monitors(method=None)

Parameters:

  • method: the OS specific method to use. On Windows this can be "wmi" (for laptop displays) or "vcp" (for desktop monitors). On Linux this can be "light", "xrandr", "ddcutil" or "xbacklight".
Python3
# import the library import screen_brightness_control as sbc  # get the monitor names monitors = sbc.list_monitors() print(monitors)  # now use this to adjust specific screens by name sbc.set_brightness(25, display=monitors[0]) 

Output:

["BenQ GL2450H", "Dell U2211H"]

The names and quantity of monitors will vary depending on what is plugged into your computer.


Next Article
How to Control Laptop Screen Brightness using Python?

M

mohammadtahzeebkhan
Improve
Article Tags :
  • Python
  • python-utility
Practice Tags :
  • python

Similar Reads

    Brightness Control With Hand Detection using OpenCV in Python
    In this article, we are going to make a Python project that uses OpenCV and Mediapipe to see hand gesture and accordingly set the brightness of the system from a range of 0-100.  We have used a HandTracking module that tracks all points on the hand and detects hand landmarks, calculate the distance
    6 min read
    Take and convert Screenshot to PDF using Python
    In order to take and convert a screenshot to PDF, firstly the PyAutoGUI can be used which is an automation library in python which can control mouse, keyboard and can handle many GUI control tasks. Secondly, for the conversion PIL(Python Imaging Library) of python can be used which provides image pr
    3 min read
    Wand brightness_contrast() function - Python
    The brightness_contrast() function is an inbuilt function in the Python Wand ImageMagick library which is used to change the brightness and contrast of the image. Syntax: brightness_contrast(brightness, contrast, channel) Parameters: This function accepts three parameters as mentioned above and defi
    2 min read
    Changing the contrast and brightness of an image using Python - OpenCV
    Changing the Brightness and Contrast level of any image is the most basic thing everyone does with an image. It is meant to change the value of each and every pixel of an image it can be done by either multiplying or dividing the pixels value of an image. In this article, we will see how we can impl
    6 min read
    Create Multiple jobs using python-crontab
    Cron is a Unix-like operating system software utility that allows us to schedule tasks. Cron's tasks are specified in a Crontab, which is a text file that contains the instructions to run. The Crontab module in Python allows us to handle scheduled operations using Cron. It has functionalities that a
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences