Debian Codegraph @

examples/cd-get-devices.py

raw
1 #!/usr/bin/python
2
3 # Copyright (C) 2013 Richard Hughes <[email protected]>
4 # Licensed under the GNU General Public License Version 2
5
6 from gi.repository import Colord
7 from gi.repository import Gio
8
9 # connect to colord
10 cancellable = Gio.Cancellable.new();
11 client = Colord.Client.new()
12 client.connect_sync(cancellable)
13
14 # find the device with the correct parameters
15 devices = client.get_devices_sync(cancellable)
16
17 for d in devices:
18
19 # get the default profile for the device
20 d.connect_sync(cancellable)
21 p = d.get_default_profile()
22 if not p:
23 continue
24 p.connect_sync(cancellable)
25 print d.get_id(), "has default profile filename", p.get_filename()
26 metadata = p.get_metadata()
27 if metadata.has_key('SCREEN_brightness'):
28 print "and device sets brightness", metadata['SCREEN_brightness']