File: cd-get-devices.py

package info (click to toggle)
colord 1.4.8-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,336 kB
  • sloc: ansic: 48,896; xml: 24,173; python: 79; sh: 70; makefile: 48; cpp: 38
file content (28 lines) | stat: -rwxr-xr-x 828 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/python

# Copyright (C) 2013 Richard Hughes <richard@hughsie.com>
# Licensed under the GNU General Public License Version 2

from gi.repository import Colord
from gi.repository import Gio

# connect to colord
cancellable = Gio.Cancellable.new();
client = Colord.Client.new()
client.connect_sync(cancellable)

# find the device with the correct parameters
devices = client.get_devices_sync(cancellable)

for d in devices:

    # get the default profile for the device
    d.connect_sync(cancellable)
    p = d.get_default_profile()
    if not p:
        continue
    p.connect_sync(cancellable)
    print d.get_id(), "has default profile filename", p.get_filename()
    metadata = p.get_metadata()
    if metadata.has_key('SCREEN_brightness'):
        print "and device sets brightness", metadata['SCREEN_brightness']