├── .gitignore
├── COPYING
├── ChangeLog
├── Makefile.am
├── README.md
├── configure.ac
├── doc
└── xiccd.8
├── etc
├── systemd
│ ├── functions.sh
│ └── xiccd.service
└── xdg
│ └── xiccd.desktop
└── src
├── icc.c
├── icc.h
├── randr-conn-private.c
├── randr-conn-private.h
├── randr-conn.c
├── randr-conn.h
└── xiccd.c
/.gitignore:
--------------------------------------------------------------------------------
1 | ### Autotools ###
2 | # http://www.gnu.org/software/automake
3 |
4 | Makefile.in
5 | /ar-lib
6 | /mdate-sh
7 | /py-compile
8 | /test-driver
9 | /ylwrap
10 | .deps/
11 | .dirstamp
12 |
13 | # http://www.gnu.org/software/autoconf
14 |
15 | autom4te.cache
16 | /autoscan.log
17 | /autoscan-*.log
18 | /aclocal.m4
19 | /compile
20 | /config.cache
21 | /config.guess
22 | /config.h.in
23 | /config.log
24 | /config.status
25 | /config.sub
26 | /configure
27 | /configure.scan
28 | /depcomp
29 | /install-sh
30 | /missing
31 | /stamp-h1
32 |
33 | # https://www.gnu.org/software/libtool
34 |
35 | /ltmain.sh
36 |
37 | # http://www.gnu.org/software/texinfo
38 |
39 | /texinfo.tex
40 |
41 | # http://www.gnu.org/software/m4
42 |
43 | m4/libtool.m4
44 | m4/ltoptions.m4
45 | m4/ltsugar.m4
46 | m4/ltversion.m4
47 | m4/lt~obsolete.m4
48 |
49 | # Generated Makefile
50 | Makefile
51 |
52 | ### Autotools Patch ###
53 |
54 | ### C ###
55 | # Prerequisites
56 | *.d
57 |
58 | # Object files
59 | *.o
60 | *.ko
61 | *.obj
62 | *.elf
63 |
64 | # Linker output
65 | *.ilk
66 | *.map
67 | *.exp
68 |
69 | # Precompiled Headers
70 | *.gch
71 | *.pch
72 |
73 | # Libraries
74 | *.lib
75 | *.a
76 | *.la
77 | *.lo
78 |
79 | # Shared objects (inc. Windows DLLs)
80 | *.dll
81 | *.so
82 | *.so.*
83 | *.dylib
84 |
85 | # Executables
86 | *.exe
87 | *.out
88 | *.app
89 | *.i*86
90 | *.x86_64
91 | *.hex
92 | /xiccd
93 |
94 | # Debug files
95 | *.dSYM/
96 | *.su
97 | *.idb
98 | *.pdb
99 |
--------------------------------------------------------------------------------
/COPYING:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/ChangeLog:
--------------------------------------------------------------------------------
1 | xiccd 0.4.0
2 | * Compatibility update
3 | * Use standard EDID parser instead of the own one
4 | * Various small cleanups
5 |
6 | xiccd 0.3.0
7 |
8 | * Correct X property setting for multiple screens
9 | * Race fixes
10 | * Memory leak fixes
11 | * Add desktop files
12 |
13 | xiccd 0.2.3
14 |
15 | * Removed obsolete DMI support
16 | * xiccd now registers OutputEdidMd5 property for devices
17 |
18 | xiccd 0.2.2
19 |
20 | * Coredump fix
21 | * XRandR hotplug fix
22 |
23 | xiccd 0.2.1
24 |
25 | * Bugfixes
26 |
27 | xiccd 0.2.0
28 |
29 | * Use new libcolord API (1.0.2 or higher)
30 |
31 | xiccd 0.1.1
32 |
33 | * Fix memory leak
34 | * Fix device naming
35 |
36 | xiccd 0.1.0
37 |
38 | * Initial release.
39 |
--------------------------------------------------------------------------------
/Makefile.am:
--------------------------------------------------------------------------------
1 | AUTOMAKE_OPTIONS = subdir-objects
2 |
3 | bin_PROGRAMS = xiccd
4 |
5 | xiccd_SOURCES = \
6 | src/xiccd.c \
7 | src/icc.h src/icc.c \
8 | src/randr-conn.h src/randr-conn.c \
9 | src/randr-conn-private.h src/randr-conn-private.c
10 |
11 | AM_CFLAGS = -Wall -Wextra -pedantic \
12 | $(GLIB_CFLAGS) $(X11_CFLAGS) $(XRANDR_CFLAGS) $(COLORD_CFLAGS)
13 | xiccd_LDADD = $(GLIB_LIBS) $(X11_LIBS) $(XRANDR_LIBS) $(COLORD_LIBS)
14 |
15 | dist_man_MANS = doc/xiccd.8
16 | dist_doc_DATA = README.md
17 |
18 | autostartdir = $(sysconfdir)/xdg/autostart
19 | autostart_DATA = etc/xdg/xiccd.desktop
20 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Xiccd
2 |
3 | A simple bridge between colord and X. It does the following tasks:
4 |
5 | - Enumerates displays and register them in colord.
6 | - Creates default ICC profiles based on EDID data.
7 | - Applies ICC profiles provided by colord.
8 | - Maintains user's private ICC storage directory.
9 |
10 | The primary goal of xiccd is providing color profile support for
11 | desktop environments other than Gnome and KDE (Xfce, LXDE, and probably
12 | others) that don't support native color management yet.
13 |
14 | It does basically the same as the `gnome-settings-daemon` color plugin
15 | or `colord-kde` but doesn't depend on any particular desktop.
16 | It doesn't even depend on GTK so it doesn't create a unnecessary GTK3
17 | dependency if the desktop environment is GTK2-based or vice versa.
18 |
19 | ## Dependencies
20 |
21 | Xiccd depends only on:
22 |
23 | - GLib
24 | - colord
25 | - libxrandr
26 |
27 | And to build, the following are required:
28 |
29 | - Autoconf
30 | - Automake
31 | - Make
32 | - Git
33 |
34 | You can install all of the above with the commands:
35 |
36 | ```sh
37 | # For Debian, Ubuntu, and derivatives:
38 | apt install build-essential libglib2.0-dev libcolord-dev libxrandr-dev git
39 |
40 | # For Arch, Manjaro, and derivatives:
41 | pacman -S base-devel glib2 colord libxrandr git
42 | ```
43 |
44 | ## Installation
45 |
46 | Xiccd uses Autotools to build, so if you've checked out the source code
47 | with `git`, you'll probably need to generate the build scripts with the
48 | following commands:
49 |
50 | ```sh
51 | aclocal
52 | autoconf
53 | automake --add-missing --foreign
54 | ```
55 |
56 | Once that's done, you'll be able to build and install the program with
57 | the traditional Make commands:
58 |
59 | ```sh
60 | ./configure
61 | make
62 | make install
63 | ```
64 |
65 | which will install Xiccd into `/usr/local` by default.
66 | The usual conventions (`PREFIX`, `DESTDIR`, etc.) are respected.
67 |
--------------------------------------------------------------------------------
/configure.ac:
--------------------------------------------------------------------------------
1 | AC_PREREQ([2.69])
2 | AC_INIT([xiccd], [m4_esyscmd_s([git describe --abbrev=7 --dirty --always --tags])])
3 |
4 | AC_CONFIG_SRCDIR([src/xiccd.c])
5 |
6 | AM_INIT_AUTOMAKE([1.9 no-dist-gzip dist-xz tar-ustar])
7 | AC_LANG([C])
8 | AC_PROG_CC
9 |
10 | PKG_CHECK_MODULES(X11, x11)
11 | PKG_CHECK_MODULES(XRANDR, xrandr >= 1.3)
12 | PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.36)
13 | PKG_CHECK_MODULES(COLORD, colord >= 1.0.2)
14 |
15 | AC_CONFIG_FILES([Makefile])
16 | AC_OUTPUT
17 |
--------------------------------------------------------------------------------
/doc/xiccd.8:
--------------------------------------------------------------------------------
1 | .TH XICCD "8" "March 2016" "xiccd" "System Administration Utilities"
2 | .SH NAME
3 | xiccd \- X color management daemon
4 | .SH SYNOPSIS
5 | .B xiccd [OPTION...]
6 | .SH DESCRIPTION
7 | xiccd is a simple bridge between colord and X. It performs the following
8 | tasks:
9 | .PP
10 | * Enumerating displays and registering them in colord;
11 | * Creating default ICC profiles based on EDID data;
12 | * Applying ICC profiles provided by colord;
13 | * Maintaining the user's private ICC storage directory.
14 | .PP
15 | It does not depend on any particular desktop environment nor toolkit and it
16 | should not be used in desktop environments that support color management
17 | natively, like GNOME and KDE do.
18 | .PP
19 | xiccd is usually automatically invoked by your desktop environment via
20 | .B /etc/xdg/autostart
21 | and there should not be any need to invoke this binary manually.
22 | .SS "Help Options:"
23 | .TP
24 | \fB\-h\fR, \fB\-\-help\fR
25 | Show help options
26 | .SS "Application Options:"
27 | .TP
28 | \fB\-V\fR, \fB\-\-version\fR
29 | Show version
30 | .TP
31 | \fB\-d\fR DISPLAY, \fB\-\-display\fR DISPLAY
32 | X server to contact
33 | .TP
34 | \fB\-e\fR, \fB\-\-edid\fR
35 | Generate profiles by monitor EDID
36 | .SH AUTHORS
37 | .B xiccd
38 | was primarily written by Alexey Galakhov . This manual page
39 | was written by Faidon Liambotis for the Debian project.
40 |
--------------------------------------------------------------------------------
/etc/systemd/functions.sh:
--------------------------------------------------------------------------------
1 | #! /bin/bash
2 |
3 | Service="xiccd.service"
4 |
5 |
6 | post_install () {
7 | if [[ "$(whoami)" == "root" ]]; then
8 | systemctl --user --global enable "${Service}"
9 | CommandForAllUsers systemctl --user start "${Service}"
10 | fi
11 | }
12 |
13 |
14 | pre_remove () {
15 | if [[ "$(whoami)" == "root" ]]; then
16 | CommandForAllUsers systemctl --user stop "${Service}"
17 | systemctl --user --global disable "${Service}"
18 | fi
19 | }
20 |
21 |
22 | post_remove () {
23 | if [[ "$(whoami)" == "root" ]]; then
24 | CommandForAllUsers systemctl --user daemon-reload
25 | fi
26 | }
27 |
28 |
29 | post_upgrade () {
30 | post_remove
31 | post_install
32 | }
33 |
34 |
35 | CommandAsUser () {
36 | local user="${1}"
37 | local command="${*:2}"
38 |
39 | local userId; userId="$(id --user "${user}")"
40 | local bus="unix:path=/run/user/${userId}/bus"
41 | local sudoAsUser="sudo -u ${user} DBUS_SESSION_BUS_ADDRESS=${bus}"
42 |
43 | #shellcheck disable=SC2086
44 | ${sudoAsUser} ${command}
45 | }
46 |
47 |
48 | CommandForAllUsers () {
49 | local command="${*}"
50 | local users; readarray -t users <<< "$(loginctl --no-legend list-users | awk '{print $2;}')"
51 |
52 | for user in "${users[@]}"; do
53 | CommandAsUser "${user}" "${command}"
54 | done
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/etc/systemd/xiccd.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=Xiccd Screen Color Profiler
3 | Documentation=man:xiccd(8)
4 | PartOf=dbus.service
5 | After=dbus.service
6 |
7 | [Service]
8 | ExecStart=/usr/bin/xiccd
9 | Restart=always
10 |
11 | [Install]
12 | WantedBy=dbus.service
13 |
--------------------------------------------------------------------------------
/etc/xdg/xiccd.desktop:
--------------------------------------------------------------------------------
1 | [Desktop Entry]
2 | Exec=xiccd
3 | Name=xiccd
4 | GenericName=X Color Management Daemon
5 | Comment=Applies color management profiles to your session
6 | Terminal=false
7 | Type=Application
8 | NotShowIn=GNOME;KDE;
9 |
--------------------------------------------------------------------------------
/src/icc.c:
--------------------------------------------------------------------------------
1 | #include "icc.h"
2 | #include
3 | #include
4 | #include
5 | #include
6 |
7 | static void
8 | reset_gamma (XRRCrtcGamma *gamma)
9 | {
10 | int i;
11 | for (i = 0; i < gamma->size; ++i) {
12 | guint value = i * 0xFFFF / (gamma->size - 1);
13 | gamma->red[i] = value;
14 | gamma->green[i] = value;
15 | gamma->blue[i] = value;
16 | }
17 | }
18 |
19 | void
20 | icc_to_gamma (XRRCrtcGamma *gamma, CdIcc *icc)
21 | {
22 | GPtrArray *vcgt = NULL;
23 | guint i;
24 |
25 | if (! icc) {
26 | reset_gamma (gamma);
27 | goto out;
28 | }
29 |
30 | vcgt = cd_icc_get_vcgt (icc, gamma->size, NULL);
31 | if (! vcgt) {
32 | g_debug ("ICC profile has no VCGT");
33 | reset_gamma (gamma);
34 | goto out;
35 | }
36 |
37 | g_assert (vcgt->len == (guint) gamma->size);
38 |
39 | for (i = 0; i < vcgt->len; ++i) {
40 | CdColorRGB *color = (CdColorRGB *) g_ptr_array_index (vcgt, i);
41 | gamma->red[i] = color->R * 0xFFFF;
42 | gamma->green[i] = color->G * 0xFFFF;
43 | gamma->blue[i] = color->B * 0xFFFF;
44 | }
45 |
46 | out:
47 | if (vcgt)
48 | g_ptr_array_unref (vcgt);
49 | }
50 |
51 |
52 | CdIcc *
53 | icc_from_edid (CdEdid *edid)
54 | {
55 | CdIcc *icc;
56 | GError *err = NULL;
57 | gboolean ret;
58 |
59 | if (! edid)
60 | return NULL;
61 |
62 | icc = cd_icc_new ();
63 | ret = cd_icc_create_from_edid_data (icc, edid, &err);
64 | if (! ret) {
65 | g_critical ("unable to create profile from EDID: %s", err->message);
66 | g_error_free (err);
67 | return NULL;
68 | }
69 |
70 | cd_icc_set_kind (icc, CD_PROFILE_KIND_DISPLAY_DEVICE);
71 |
72 | cd_icc_add_metadata (icc, CD_PROFILE_METADATA_CMF_PRODUCT, PACKAGE);
73 | cd_icc_add_metadata (icc, CD_PROFILE_METADATA_CMF_BINARY, g_get_prgname ());
74 | cd_icc_add_metadata (icc, CD_PROFILE_METADATA_CMF_VERSION, VERSION);
75 |
76 | return icc;
77 | }
78 |
79 | gchar *
80 | icc_identify (GFile *file)
81 | {
82 | gchar *retval = NULL;
83 | CdIcc *icc = cd_icc_new ();
84 | gboolean ret;
85 |
86 | ret = cd_icc_load_file (icc, file, CD_ICC_LOAD_FLAGS_FALLBACK_MD5, NULL, NULL);
87 | if (! ret)
88 | goto out;
89 |
90 | retval = g_strdup (cd_icc_get_checksum (icc));
91 |
92 | out:
93 | g_object_unref (icc);
94 | return retval;
95 | }
96 |
97 | /* vim: set ts=8 sw=8 tw=0 : */
98 |
--------------------------------------------------------------------------------
/src/icc.h:
--------------------------------------------------------------------------------
1 | #ifndef __ICC_H__
2 | #define __ICC_H__
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | void icc_to_gamma (XRRCrtcGamma *gamma, CdIcc *icc);
9 | CdIcc *icc_from_edid (CdEdid *edid);
10 | gchar *icc_identify (GFile *file);
11 |
12 | #endif /* __ICC_H__ */
13 |
14 | /* vim: set ts=8 sw=8 tw=0 : */
15 |
--------------------------------------------------------------------------------
/src/randr-conn-private.c:
--------------------------------------------------------------------------------
1 | #include "icc.h"
2 | #include "randr-conn.h"
3 | #include "randr-conn-private.h"
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | static void
13 | print_x_error (struct randr_conn *conn, int err, const gchar *msg)
14 | {
15 | char text[1024];
16 | XGetErrorText (conn->dpy, err, text, sizeof(text));
17 | g_critical ("X error: %s: %s", msg, text);
18 | }
19 |
20 | static void
21 | x_free_func (void *obj)
22 | {
23 | XFree (obj);
24 | }
25 |
26 | static GBytes *
27 | get_output_property (struct randr_conn *conn, RROutput out, Atom prop, Atom type, int fmt)
28 | {
29 | Atom act_type;
30 | int act_fmt;
31 | unsigned long size;
32 | unsigned long bytes_after;
33 | unsigned char *data;
34 |
35 | if (prop == None)
36 | return NULL;
37 |
38 | XRRGetOutputProperty (conn->dpy, out, prop, 0, 100, False, False,
39 | AnyPropertyType, &act_type, &act_fmt,
40 | &size, &bytes_after, &data);
41 |
42 | if (act_type != type || act_fmt != fmt || size == 0) {
43 | XFree (data);
44 | return NULL;
45 | }
46 |
47 | return g_bytes_new_with_free_func (data, size * (fmt / 8), x_free_func, data);
48 | }
49 |
50 | static gboolean
51 | get_output_property_atom (struct randr_conn *conn, RROutput out, Atom prop, const gchar *value_eq)
52 | {
53 | char *str;
54 | Atom atom;
55 | gboolean retval = FALSE;
56 | GBytes *raw = get_output_property (conn, out, prop, XA_ATOM, 32);
57 | if (! raw)
58 | return retval;
59 | if (g_bytes_get_size (raw) != 4)
60 | goto out;
61 | atom = *((Atom *) g_bytes_get_data (raw, NULL));
62 | str = XGetAtomName (conn->dpy, atom);
63 | if (str) {
64 | retval = (strcmp (value_eq, str) == 0);
65 | XFree (str);
66 | }
67 | out:
68 | g_bytes_unref (raw);
69 | return retval;
70 | }
71 |
72 | static void
73 | randr_display_free (struct randr_display_priv *disp)
74 | {
75 | if (disp->pub.name)
76 | g_free ((gpointer) disp->pub.name);
77 | if (disp->pub.xrandr_name)
78 | g_free ((gpointer) disp->pub.xrandr_name);
79 | g_object_unref(disp->pub.edid);
80 | g_free (disp);
81 | }
82 |
83 | static inline const gchar *
84 | make_name (struct randr_display_priv *disp, CdEdid *edid, gboolean use_edid)
85 | {
86 | int i = 0;
87 | const gchar *arr[16];
88 | const gchar *retval;
89 |
90 | memset (arr, 0, sizeof(arr));
91 | arr[i++] = "xrandr";
92 |
93 | if (use_edid) {
94 | const gchar *vendor = cd_edid_get_vendor_name (edid);
95 | const gchar *model = cd_edid_get_monitor_name (edid);
96 | const gchar *serial = cd_edid_get_serial_number (edid);
97 |
98 | if (vendor)
99 | arr[i++] = vendor;
100 | if (model)
101 | arr[i++] = model;
102 | if (serial)
103 | arr[i++] = serial;
104 | }
105 |
106 | /* last resort: use xrandr name */
107 | if (i <= 1)
108 | arr[i++] = disp->pub.xrandr_name;
109 |
110 | retval = g_strjoinv ("-", (gchar**)arr);
111 |
112 | return retval;
113 | }
114 |
115 | static inline gboolean
116 | is_laptop_conn (struct randr_conn *conn, RROutput out)
117 | {
118 | return get_output_property_atom (conn, out, conn->type_atom, "Panel");
119 | }
120 |
121 | static inline gboolean
122 | is_laptop_name (const gchar *name)
123 | {
124 | guint i;
125 | static const gchar *const laptop_names[] = {
126 | "LVDS", "Lvds", "lvds", "LCD", "eDP", "DFP"
127 | };
128 | for (i = 0; i < G_N_ELEMENTS (laptop_names); ++i) {
129 | if (strncmp (name, laptop_names[i], strlen (laptop_names [i])) == 0)
130 | return TRUE;
131 | }
132 | return FALSE;
133 | }
134 |
135 | static inline void
136 | populate_display (struct randr_display_priv *disp, GBytes *edid, RROutput out)
137 | {
138 | gsize edid_size = edid ? g_bytes_get_size (edid) : 0;
139 |
140 | disp->pub.is_laptop = is_laptop_conn (disp->conn, out)
141 | || is_laptop_name (disp->pub.xrandr_name);
142 |
143 | disp->pub.edid = cd_edid_new ();
144 | if (edid_size > 0) {
145 | GError *err = NULL;
146 | gboolean ok = cd_edid_parse (disp->pub.edid, edid, &err);
147 | if (! ok) {
148 | g_warning ("unable to parse ICC: %s", err->message);
149 | g_clear_error (&err);
150 | }
151 | }
152 |
153 | disp->pub.name = make_name (disp, disp->pub.edid, (edid_size != 0));
154 | }
155 |
156 | static inline struct randr_display_priv *
157 | process_output (struct randr_conn *conn, XRRScreenResources *rsrc,
158 | RROutput out, int *outn)
159 | {
160 | struct randr_display_priv *disp = NULL;
161 |
162 | XRROutputInfo *inf = XRRGetOutputInfo (conn->dpy, rsrc, out);
163 | if (! inf) {
164 | g_critical ("XRRGetOutputInfo() failed");
165 | return NULL;
166 | }
167 |
168 | if (inf->connection != RR_Disconnected) {
169 | GBytes *edid = get_output_property (conn, out, conn->edid_atom, XA_INTEGER, 8);
170 |
171 | disp = g_new0 (struct randr_display_priv, 1);
172 | disp->conn = conn;
173 | disp->pub.id = *outn;
174 | disp->pub.xrandr_name = g_strdup (inf->name);
175 | disp->crtc = inf->crtc;
176 |
177 | populate_display (disp, edid, out);
178 |
179 | if (edid)
180 | g_bytes_unref (edid);
181 |
182 | ++*outn;
183 | }
184 |
185 | XRRFreeOutputInfo (inf);
186 |
187 | return disp;
188 | }
189 |
190 | static inline void
191 | iterate_outputs (struct randr_conn *conn, int scr, GPtrArray *retval)
192 | {
193 | int io;
194 | int outn = 0;
195 | Window root = RootWindow (conn->dpy, scr);
196 | RROutput primary = XRRGetOutputPrimary (conn->dpy, root);
197 | XRRScreenResources *rsrc =
198 | XRRGetScreenResources (conn->dpy, root);
199 | if (! rsrc) {
200 | g_critical ("XRRGetScreenResources() failed"
201 | " at screen %i", scr);
202 | return;
203 | }
204 |
205 | for (io = 0; io < rsrc->noutput; ++io) {
206 | struct randr_display_priv *disp =
207 | process_output (conn, rsrc, rsrc->outputs[io], &outn);
208 | if (disp) {
209 | disp->root = root; /* more convenient to set it here */
210 | disp->pub.is_primary = (rsrc->outputs[io] == primary);
211 | g_ptr_array_add (retval, disp);
212 | }
213 | }
214 |
215 | XRRFreeScreenResources (rsrc);
216 | }
217 |
218 | static inline GPtrArray *
219 | enum_displays (struct randr_conn *conn)
220 | {
221 | int scr;
222 | GPtrArray *retval = g_ptr_array_new_full (4,
223 | (GDestroyNotify) randr_display_free);
224 | for (scr = 0; scr < ScreenCount (conn->dpy); ++scr) {
225 | iterate_outputs (conn, scr, retval);
226 | }
227 | return retval;
228 | }
229 |
230 | static inline gboolean
231 | same_display (const struct randr_display *a, const struct randr_display *b)
232 | {
233 | return ! strcmp (a->name, b->name);
234 | }
235 |
236 | void
237 | randr_conn_private_update (struct randr_conn *conn)
238 | {
239 | guint i, j;
240 | GPtrArray *disps;
241 | GPtrArray *added_disps = g_ptr_array_new_full (4, NULL);
242 | GPtrArray *updated_disps = g_ptr_array_new_full (4, NULL);
243 |
244 | if (! conn->dpy)
245 | return;
246 |
247 | disps = enum_displays (conn);
248 | for (i = 0; i < disps->len; ++i) {
249 | gboolean found = FALSE;
250 | struct randr_display *disp = (struct randr_display *)
251 | g_ptr_array_index (disps, i);
252 | for (j = 0; j < conn->displays->len; ++j) {
253 | struct randr_display *odisp = (struct randr_display *)
254 | g_ptr_array_index (conn->displays, j);
255 | if (same_display (odisp, disp)) {
256 | g_ptr_array_remove_index_fast (conn->displays, j);
257 | g_ptr_array_add (updated_disps, disp);
258 | found = TRUE;
259 | break;
260 | }
261 | }
262 | if (found)
263 | continue;
264 | g_ptr_array_add (added_disps, disp);
265 | }
266 |
267 | for (j = 0; j < conn->displays->len; ++j) {
268 | const struct randr_display *odisp = (const struct randr_display *)
269 | g_ptr_array_index (conn->displays, j);
270 | g_signal_emit (conn->object,
271 | randr_signals[SIG_DISPLAY_REMOVED], 0, odisp);
272 | }
273 |
274 | g_ptr_array_unref (conn->displays);
275 | conn->displays = disps;
276 |
277 | /* emitting added and changed signals after conn->displays is set */
278 | for (j = 0; j < added_disps->len; ++j) {
279 | const struct randr_display *disp = (const struct randr_display *)
280 | g_ptr_array_index (added_disps, j);
281 | g_signal_emit (conn->object,
282 | randr_signals[SIG_DISPLAY_ADDED], 0, disp);
283 | }
284 |
285 | for (j = 0; j < updated_disps->len; ++j) {
286 | const struct randr_display *disp = (const struct randr_display *)
287 | g_ptr_array_index (updated_disps, j);
288 | g_signal_emit (conn->object,
289 | randr_signals[SIG_DISPLAY_CHANGED], 0, disp);
290 | }
291 |
292 | g_ptr_array_unref (added_disps);
293 | g_ptr_array_unref (updated_disps);
294 | }
295 |
296 |
297 | static gboolean
298 | randr_source_prepare (GSource *source, gint *timeout)
299 | {
300 | (void) timeout;
301 | struct randr_source *src = (struct randr_source *) source;
302 | return (XPending (src->conn->dpy) > 0);
303 | }
304 |
305 | static gboolean
306 | randr_source_dispatch (GSource *source, GSourceFunc callback, gpointer user_data)
307 | {
308 | struct randr_conn *conn = ((struct randr_source *) source)->conn;
309 | gboolean happened = FALSE;
310 | (void) callback;
311 | (void) user_data;
312 |
313 | while (XPending (conn->dpy)) {
314 | XEvent ev;
315 | XNextEvent(conn->dpy, &ev);
316 | switch (ev.xany.type - conn->event_base) {
317 | case RRScreenChangeNotify:
318 | happened = TRUE;
319 | break;
320 | case RRNotify:
321 | switch (((const XRRNotifyEvent*)&ev)->subtype) {
322 | case RRNotify_CrtcChange:
323 | case RRNotify_OutputChange:
324 | happened = TRUE;
325 | break;
326 | default:
327 | break;
328 | }
329 | break;
330 | default:
331 | break;
332 | }
333 | }
334 |
335 | if (happened)
336 | randr_conn_private_update (conn);
337 |
338 | return TRUE;
339 | }
340 |
341 | static GSourceFuncs randr_source_funcs = {
342 | randr_source_prepare,
343 | NULL, /* check */
344 | randr_source_dispatch,
345 | NULL, /* finalize */
346 | NULL, /* closure_callback */
347 | NULL /* closure_marshal */
348 | };
349 |
350 | static GSource *
351 | randr_source_new (struct randr_conn *conn)
352 | {
353 | GSource *retval;
354 | struct randr_source *src;
355 |
356 | retval = g_source_new (&randr_source_funcs, sizeof (struct randr_source));
357 | g_source_set_name (retval, "RandrSource");
358 |
359 | src = (struct randr_source *) retval;
360 | src->conn = conn;
361 |
362 | src->poll_fd.fd = ConnectionNumber (conn->dpy);
363 | src->poll_fd.events = G_IO_IN;
364 | g_source_add_poll (retval, &src->poll_fd);
365 |
366 | return retval;
367 | }
368 |
369 | static inline void
370 | setup_events (struct randr_conn *conn)
371 | {
372 | int s;
373 | for (s = 0; s < ScreenCount (conn->dpy); ++s) {
374 | Window w = RootWindow (conn->dpy, s);
375 | XRRSelectInput (conn->dpy, w,
376 | RRScreenChangeNotifyMask |
377 | RRCrtcChangeNotifyMask |
378 | RROutputChangeNotifyMask);
379 | }
380 | GSource *src = randr_source_new (conn);
381 | g_source_attach (src, NULL);
382 | g_source_unref (src);
383 | }
384 |
385 | void
386 | randr_conn_private_start (struct randr_conn *conn)
387 | {
388 | randr_conn_private_update (conn);
389 | setup_events (conn);
390 | }
391 |
392 | void
393 | randr_conn_private_init (struct randr_conn *conn, const gchar *disp_name)
394 | {
395 | int major, minor;
396 |
397 | conn->displays = g_ptr_array_new ();
398 |
399 | g_debug ("opening display %s", disp_name);
400 | conn->dpy = XOpenDisplay (disp_name);
401 | if (conn->dpy == NULL) {
402 | g_critical ("Can't open display: %s", XDisplayName (disp_name));
403 | goto out;
404 | }
405 |
406 | if (! XRRQueryExtension (conn->dpy,&conn->event_base, &conn->error_base)
407 | || ! XRRQueryVersion (conn->dpy, &major, &minor)) {
408 | g_critical ("RandR extension is not working on display %s",
409 | DisplayString (conn->dpy));
410 | goto out;
411 | }
412 |
413 | /* We need RandR 1.3 to support multiple display color mgmt */
414 | if ((major < 1) || (major == 1 && minor < 3)) {
415 | g_critical ("RandR %i.%i found on display %s but 1.3 is needed",
416 | major, minor, DisplayString (conn->dpy));
417 | goto out;
418 | }
419 |
420 | /* RandR 1.2 calls it "EDID_DATA" but we don't support 1.2 */
421 | conn->edid_atom = XInternAtom (conn->dpy, "EDID", False);
422 | conn->type_atom = XInternAtom (conn->dpy, "ConnectorType", False);
423 |
424 | return;
425 |
426 | out:
427 | randr_conn_private_finalize (conn);
428 | }
429 |
430 |
431 |
432 | void
433 | randr_conn_private_finalize (struct randr_conn *conn)
434 | {
435 | if (conn->dpy)
436 | XCloseDisplay (conn->dpy);
437 | if (conn->displays)
438 | g_ptr_array_unref (conn->displays);
439 | conn->dpy = NULL;
440 | }
441 |
442 |
443 |
444 | static inline void
445 | apply_gamma (struct randr_display_priv *disp, CdIcc *icc)
446 | {
447 | Display *dpy = disp->conn->dpy;
448 | XRRCrtcGamma *gamma = NULL;
449 | XRRCrtcGamma *gamma2 = NULL;
450 |
451 | int gsize = XRRGetCrtcGammaSize (dpy, disp->crtc);
452 | if (gsize <= 0) {
453 | g_critical ("Gamma size is %i at output %s", gsize, disp->pub.name);
454 | return;
455 | }
456 |
457 | gamma = XRRAllocGamma (gsize);
458 | if (! gamma) {
459 | g_critical ("XRRAllocGamma() failed at output %s", disp->pub.name);
460 | return;
461 | }
462 |
463 | icc_to_gamma (gamma, icc);
464 |
465 | XRRSetCrtcGamma (dpy, disp->crtc, gamma);
466 |
467 | /* For some reason gamma may not apply without this */
468 | gamma2 = XRRGetCrtcGamma (dpy, disp->crtc);
469 | XRRFreeGamma (gamma2);
470 |
471 | XRRFreeGamma (gamma);
472 | }
473 |
474 | static gboolean
475 | is_main_icc_profile (struct randr_display_priv *disp)
476 | {
477 | int main_id = -1;
478 | int laptop_id = -1;
479 | int primary_id = -1;
480 | guint i;
481 |
482 | if (disp->pub.is_primary)
483 | return TRUE;
484 |
485 | for (i = 0; i < disp->conn->displays->len; ++i) {
486 | struct randr_display_priv *odisp = g_ptr_array_index (disp->conn->displays, i);
487 | if (! odisp->crtc)
488 | continue;
489 | if (main_id == -1)
490 | main_id = odisp->pub.id;
491 | if (odisp->pub.is_laptop)
492 | laptop_id = odisp->pub.id;
493 | if (odisp->pub.is_primary)
494 | primary_id = odisp->pub.id;
495 | }
496 |
497 | if (primary_id >= 0) {
498 | main_id = primary_id;
499 | } else if (laptop_id >= 0) {
500 | main_id = laptop_id;
501 | }
502 |
503 | return (disp->pub.id == main_id);
504 | }
505 |
506 | static inline void
507 | apply_icc (struct randr_display_priv *disp, GBytes *icc_bytes)
508 | {
509 | int res;
510 | Display *dpy = disp->conn->dpy;
511 | const gchar *oper = NULL;
512 | Atom at;
513 |
514 | if (! is_main_icc_profile (disp))
515 | return;
516 |
517 | at = XInternAtom (dpy, "_ICC_PROFILE", False);
518 |
519 | if (icc_bytes) {
520 | g_debug ("setting _ICC_PROFILE for display %s", disp->pub.name);
521 | res = XChangeProperty (dpy, disp->root, at, XA_CARDINAL, 8, PropModeReplace,
522 | (unsigned char *) g_bytes_get_data (icc_bytes, NULL),
523 | g_bytes_get_size (icc_bytes));
524 | oper = "XChangeProperty()";
525 | } else {
526 | res = XDeleteProperty (dpy, disp->root, at);
527 | oper = "XDeleteProperty()";
528 | }
529 | /* Due to a bug in X this may "fail" with BadRequest but still work */
530 | if (res != Success && res != BadRequest) {
531 | print_x_error (disp->conn, res, oper);
532 | }
533 |
534 | }
535 |
536 | void
537 | randr_display_private_apply_icc (struct randr_display *disp, CdIcc *icc)
538 | {
539 | GBytes *icc_bytes = NULL;
540 | GError *err = NULL;
541 | struct randr_display_priv *pdisp = (struct randr_display_priv *) disp;
542 | if (! pdisp->crtc) /* is display currently off? */
543 | return;
544 | if (icc) {
545 | icc_bytes = cd_icc_save_data (icc, CD_ICC_SAVE_FLAGS_NONE, &err);
546 | if (! icc_bytes) {
547 | g_warning ("unable to get ICC data: %s", err->message);
548 | g_clear_error (&err);
549 | }
550 | }
551 | apply_gamma (pdisp, icc);
552 | apply_icc (pdisp, icc_bytes);
553 | if (icc_bytes)
554 | g_bytes_unref (icc_bytes);
555 | }
556 |
557 | struct randr_display *
558 | randr_conn_private_find_display (struct randr_conn *conn,
559 | const gchar *key,
560 | get_find_key_fn get_find_key)
561 | {
562 | guint i;
563 |
564 | if (! conn->dpy)
565 | return NULL;
566 |
567 | for (i = 0; i < conn->displays->len; ++i) {
568 | struct randr_display *cand = (struct randr_display *)
569 | g_ptr_array_index (conn->displays, i);
570 | if (! strcmp (get_find_key(cand), key))
571 | return cand;
572 | }
573 | return NULL;
574 | }
575 |
576 | /* vim: set ts=8 sw=8 tw=0 : */
577 |
--------------------------------------------------------------------------------
/src/randr-conn-private.h:
--------------------------------------------------------------------------------
1 | #ifndef __RANDR_CONN_PRIVATE_H__
2 | #define __RANDR_CONN_PRIVATE_H__
3 |
4 | #include
5 | #include "randr-conn.h"
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | G_BEGIN_DECLS
12 |
13 | typedef struct randr_conn {
14 | GObject *object;
15 | Display *dpy;
16 | int event_base;
17 | int error_base;
18 | Atom edid_atom;
19 | Atom type_atom;
20 | GPtrArray *displays;
21 | } RandrConnPrivate;
22 |
23 | struct randr_display_priv {
24 | struct randr_display pub;
25 |
26 | struct randr_conn *conn;
27 | Window root;
28 | RRCrtc crtc;
29 | };
30 |
31 | struct randr_source {
32 | GSource parent;
33 | struct randr_conn *conn;
34 | GPollFD poll_fd;
35 | };
36 |
37 | enum {
38 | SIG_DISPLAY_ADDED,
39 | SIG_DISPLAY_REMOVED,
40 | SIG_DISPLAY_CHANGED,
41 | N_SIG
42 | };
43 |
44 | extern guint randr_signals[N_SIG];
45 |
46 | typedef const gchar *(*get_find_key_fn)(struct randr_display *);
47 |
48 | void randr_conn_private_init (struct randr_conn *conn, const gchar *disp_name);
49 | void randr_conn_private_finalize (struct randr_conn *conn);
50 | void randr_conn_private_start (struct randr_conn *conn);
51 | void randr_conn_private_update (struct randr_conn *conn);
52 | struct randr_display *randr_conn_private_find_display (struct randr_conn *conn,
53 | const gchar *key,
54 | get_find_key_fn get_find_key);
55 | void randr_display_private_apply_icc (struct randr_display *disp, CdIcc *icc);
56 |
57 | G_END_DECLS
58 |
59 | #endif /* __RANDR_CONN_PRIVATE_H__ */
60 |
61 | /* vim: set ts=8 sw=8 tw=0 : */
62 |
--------------------------------------------------------------------------------
/src/randr-conn.c:
--------------------------------------------------------------------------------
1 | #include "randr-conn.h"
2 | #include "randr-conn-private.h"
3 | #include
4 | #include
5 | #include
6 |
7 | struct _RandrConn {
8 | GObject parent;
9 | };
10 |
11 | G_DEFINE_TYPE_WITH_PRIVATE (RandrConn, randr_conn, G_TYPE_OBJECT)
12 |
13 | guint randr_signals[N_SIG];
14 |
15 | enum {
16 | PROP_0 = 0,
17 | PROP_DISPLAY,
18 | N_PROPERTIES
19 | };
20 |
21 | static void
22 | randr_conn_init (RandrConn *self)
23 | {
24 | struct randr_conn *priv = randr_conn_get_instance_private (self);
25 | memset (priv, 0, sizeof (*priv));
26 | }
27 |
28 | static GObject *
29 | randr_conn_constructor (GType type, guint n_params, GObjectConstructParam *params)
30 | {
31 | GObject *obj = G_OBJECT_CLASS (randr_conn_parent_class)
32 | ->constructor (type, n_params, params);
33 |
34 | guint i;
35 | const gchar *display_name = NULL;
36 | for (i = 0; i < n_params; ++i) {
37 | if (! strcmp(params[i].pspec->name, "display")) {
38 | display_name = g_value_get_string (params[i].value);
39 | break;
40 | }
41 | }
42 |
43 | struct randr_conn *priv = randr_conn_get_instance_private (RANDR_CONN (obj));
44 | priv->object = obj;
45 | randr_conn_private_init (priv, display_name);
46 |
47 | return obj;
48 | }
49 |
50 | static void
51 | randr_conn_finalize (GObject *self)
52 | {
53 | struct randr_conn *priv = randr_conn_get_instance_private (RANDR_CONN (self));
54 | randr_conn_private_finalize (priv);
55 | G_OBJECT_CLASS (randr_conn_parent_class)->finalize (self);
56 | }
57 |
58 | static void
59 | randr_conn_set_property (GObject *object, guint prop_id, const GValue *val, GParamSpec *pspec)
60 | {
61 | (void) object;
62 | (void) prop_id;
63 | (void) val;
64 | (void) pspec;
65 | }
66 |
67 | static void
68 | randr_conn_class_init (RandrConnClass *klass)
69 | {
70 | GObjectClass *obj_class = G_OBJECT_CLASS (klass);
71 |
72 | obj_class->constructor = randr_conn_constructor;
73 | obj_class->finalize = randr_conn_finalize;
74 | obj_class->set_property = randr_conn_set_property;
75 |
76 | randr_signals[SIG_DISPLAY_ADDED] = g_signal_new ("display_added",
77 | G_TYPE_FROM_CLASS (obj_class), G_SIGNAL_RUN_LAST,
78 | 0, NULL, NULL, NULL,
79 | G_TYPE_NONE, 1, G_TYPE_POINTER);
80 |
81 | randr_signals[SIG_DISPLAY_REMOVED] = g_signal_new ("display_removed",
82 | G_TYPE_FROM_CLASS (obj_class), G_SIGNAL_RUN_LAST,
83 | 0, NULL, NULL, NULL,
84 | G_TYPE_NONE, 1, G_TYPE_POINTER);
85 |
86 | randr_signals[SIG_DISPLAY_CHANGED] = g_signal_new ("display_changed",
87 | G_TYPE_FROM_CLASS (obj_class), G_SIGNAL_RUN_LAST,
88 | 0, NULL, NULL, NULL,
89 | G_TYPE_NONE, 1, G_TYPE_POINTER);
90 |
91 | g_object_class_install_property (obj_class, PROP_DISPLAY,
92 | g_param_spec_string ("display", NULL, "X Display", NULL,
93 | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)
94 | );
95 | }
96 |
97 |
98 | RandrConn *
99 | randr_conn_new (const gchar *display)
100 | {
101 | RandrConn *obj = RANDR_CONN (g_object_new (RANDR_TYPE_CONN, "display", display, NULL));
102 | return obj;
103 | }
104 |
105 | void
106 | randr_conn_start (RandrConn *conn)
107 | {
108 | struct randr_conn *priv = randr_conn_get_instance_private (conn);
109 | randr_conn_private_start (priv);
110 | }
111 |
112 | static const gchar *
113 | get_name_key (struct randr_display *dpy)
114 | {
115 | return dpy->name;
116 | }
117 |
118 | struct randr_display *
119 | randr_conn_find_display_by_name (RandrConn *conn, const gchar *name)
120 | {
121 | struct randr_conn *priv = randr_conn_get_instance_private (conn);
122 | return randr_conn_private_find_display (priv, name, get_name_key);
123 | }
124 |
125 | static const gchar *
126 | get_edid_key (struct randr_display *dpy)
127 | {
128 | return cd_edid_get_checksum (dpy->edid);
129 | }
130 |
131 | struct randr_display *randr_conn_find_display_by_edid (RandrConn *conn, const gchar *edid_cksum)
132 | {
133 | struct randr_conn *priv = randr_conn_get_instance_private (conn);
134 | return randr_conn_private_find_display (priv, edid_cksum, get_edid_key);
135 | }
136 |
137 | void
138 | randr_display_apply_icc (struct randr_display *disp, CdIcc *icc)
139 | {
140 | randr_display_private_apply_icc (disp, icc);
141 | }
142 |
143 | /* vim: set ts=8 sw=8 tw=0 : */
144 |
--------------------------------------------------------------------------------
/src/randr-conn.h:
--------------------------------------------------------------------------------
1 | #ifndef __RANDR_CONN_H__
2 | #define __RANDR_CONN_H__
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | G_BEGIN_DECLS
9 |
10 | #define RANDR_TYPE_CONN \
11 | (randr_conn_get_type ())
12 | G_DECLARE_FINAL_TYPE (RandrConn, randr_conn, RANDR, CONN, GObject)
13 |
14 | struct randr_display {
15 | int id;
16 | const gchar *name;
17 |
18 | const gchar *xrandr_name;
19 |
20 | gboolean is_laptop;
21 | gboolean is_primary;
22 | CdEdid *edid;
23 | };
24 |
25 | GType randr_conn_get_type (void);
26 | RandrConn *randr_conn_new (const gchar *display);
27 | void randr_conn_start (RandrConn *conn);
28 | struct randr_display *randr_conn_find_display_by_name (RandrConn *conn, const gchar *name);
29 | struct randr_display *randr_conn_find_display_by_edid (RandrConn *conn, const gchar *edid_cksum);
30 | void randr_display_apply_icc (struct randr_display *disp, CdIcc *icc);
31 |
32 | G_END_DECLS
33 |
34 | #endif /* __RANDR_CONN_H__ */
35 |
36 | /* vim: set ts=8 sw=8 tw=0 : */
37 |
--------------------------------------------------------------------------------
/src/xiccd.c:
--------------------------------------------------------------------------------
1 | #include "icc.h"
2 | #include "randr-conn.h"
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | typedef struct _Daemon {
9 | GMainLoop *loop;
10 | RandrConn *rcon;
11 | CdClient *cli;
12 | CdIccStore *stor;
13 | } Daemon;
14 |
15 | static struct {
16 | const gchar *display;
17 | gboolean edid;
18 | } config;
19 |
20 | static void
21 | show_version (void)
22 | {
23 | g_print ("%s - Version %s\n", g_get_application_name (), VERSION);
24 | exit (0);
25 | }
26 |
27 | static GOptionEntry config_entries[] = {
28 | { "version", 'V', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK,
29 | (void*)(intptr_t) show_version,
30 | "Show version", NULL },
31 | { "display", 'd', 0, G_OPTION_ARG_STRING, &config.display,
32 | "Uses a specific display", NULL },
33 | { "edid", 'e', 0, G_OPTION_ARG_NONE, &config.edid,
34 | "Generates a default color profile based on the display model", NULL },
35 | { NULL }
36 | };
37 |
38 | static void
39 | config_free (void)
40 | {
41 | if (config.display)
42 | g_free ((gpointer) config.display);
43 | }
44 |
45 |
46 | static inline gboolean
47 | signal_term (gpointer loop)
48 | {
49 | g_main_loop_quit ((GMainLoop *) loop);
50 | return FALSE;
51 | }
52 |
53 | static gchar *
54 | profile_id (CdIcc *icc)
55 | {
56 | return g_strdup_printf ("icc-%s", cd_icc_get_checksum (icc));
57 | }
58 |
59 | static gchar *
60 | profile_filename (CdEdid *edid)
61 | {
62 | const gchar *cksum = cd_edid_get_checksum (edid);
63 | return g_strdup_printf ("edid-%s.icc", cksum);
64 | }
65 |
66 | static void
67 | update_device_cb (GObject *src, GAsyncResult *res, gpointer user_data)
68 | {
69 | CdDevice *device = CD_DEVICE (src);
70 | Daemon *daemon = (Daemon *) user_data;
71 | GError *err = NULL;
72 | const gchar *xrandr_id;
73 | struct randr_display *disp;
74 | CdProfile *profile = NULL;
75 | gboolean ret;
76 |
77 | ret = cd_device_connect_finish (device, res, &err);
78 | if (! ret) {
79 | g_critical ("unable to connect to device: %s", err->message);
80 | g_error_free (err);
81 | goto out;
82 | }
83 |
84 | if (cd_device_get_kind (device) != CD_DEVICE_KIND_DISPLAY) {
85 | g_debug ("ignoring device %s: not a display\n", cd_device_get_id (device));
86 | goto out;
87 | }
88 |
89 | xrandr_id = cd_device_get_id (device);
90 | disp = randr_conn_find_display_by_name (daemon->rcon, xrandr_id);
91 | if (! disp) {
92 | g_critical ("device '%s' does not exist", xrandr_id);
93 | goto out;
94 | }
95 |
96 | profile = cd_device_get_default_profile (device);
97 |
98 | if (profile) {
99 | /* Use sync mode. We do not want race conditions here. */
100 | ret = cd_profile_connect_sync (profile, NULL, &err);
101 | if (! ret) {
102 | g_critical ("unable to connect to profile: %s", err->message);
103 | g_error_free (err);
104 | } else {
105 | CdIcc *icc = cd_profile_load_icc (profile, CD_ICC_LOAD_FLAGS_ALL,
106 | NULL, &err);
107 | if (! icc) {
108 | g_critical ("can't get profile for display %s: %s", disp->name,
109 | err->message);
110 | g_clear_error (&err);
111 | }
112 | g_debug ("loading profile '%s' for display %s",
113 | icc ? cd_icc_get_filename (icc) : "(none)", disp->name);
114 | randr_display_apply_icc (disp, icc);
115 | if (icc)
116 | g_object_unref (icc);
117 | }
118 | } else {
119 | g_debug ("unloading profile for display %s", disp->name);
120 | randr_display_apply_icc (disp, NULL);
121 | }
122 |
123 | out:
124 |
125 | if (profile)
126 | g_object_unref (profile);
127 | }
128 |
129 | static void
130 | cd_device_add_profile_cb (GObject *src, GAsyncResult *res, gpointer user_data)
131 | {
132 | CdDevice *device = CD_DEVICE (src);
133 | GError *err = NULL;
134 | gboolean ret;
135 | (void) user_data;
136 |
137 | ret = cd_device_add_profile_finish (device, res, &err);
138 | if (! ret) {
139 | if (! g_error_matches (err, CD_DEVICE_ERROR, CD_DEVICE_ERROR_PROFILE_ALREADY_ADDED))
140 | g_critical ("unable to add device profile: %s", err->message);
141 | g_error_free (err);
142 | return;
143 | }
144 |
145 | g_object_unref (device);
146 | }
147 |
148 | static void
149 | update_profile_cb (GObject *src, GAsyncResult *res, gpointer user_data)
150 | {
151 | CdProfile *profile = CD_PROFILE (src);
152 | Daemon *daemon = (Daemon *) user_data;
153 | GError *err = NULL;
154 | const gchar *edid_md5;
155 | struct randr_display *disp;
156 | CdDevice *device = NULL;
157 | gboolean ret;
158 |
159 | ret = cd_profile_connect_finish (profile, res, &err);
160 | if (! ret) {
161 | g_critical ("unable to connect to profile: %s", err->message);
162 | g_error_free (err);
163 | goto out;
164 | }
165 |
166 | edid_md5 = cd_profile_get_metadata_item (profile, CD_PROFILE_METADATA_EDID_MD5);
167 | if (! edid_md5)
168 | goto out;
169 |
170 | disp = randr_conn_find_display_by_edid (daemon->rcon, edid_md5);
171 | if (! disp)
172 | goto out;
173 |
174 | g_debug ("profile %s matches display %s", cd_profile_get_id (profile), disp->name);
175 |
176 | /* Use sync mode. We do not want race conditions here. */
177 | device = cd_client_find_device_sync (daemon->cli, disp->name, NULL, &err);
178 | if (! device) {
179 | g_critical ("unable to find device %s: %s", disp->name, err->message);
180 | g_error_free (err);
181 | goto out;
182 | }
183 |
184 | ret = cd_device_connect_sync (device, NULL, &err);
185 | if (! ret) {
186 | g_critical ("unable to connect to device: %s", err->message);
187 | g_error_free (err);
188 | goto out;
189 | }
190 |
191 | g_object_ref (device);
192 | cd_device_add_profile (device, CD_DEVICE_RELATION_SOFT, profile, NULL,
193 | cd_device_add_profile_cb, daemon);
194 |
195 | out:
196 |
197 | if (device)
198 | g_object_unref (device);
199 | }
200 |
201 | static void
202 | update_device (CdDevice *device, Daemon *daemon)
203 | {
204 | cd_device_connect (device, NULL, update_device_cb, daemon);
205 | }
206 |
207 | static void
208 | update_profile (CdProfile *profile, Daemon *daemon)
209 | {
210 | cd_profile_connect (profile, NULL, update_profile_cb, daemon);
211 | }
212 |
213 | static void
214 | cd_profile_added_sig (CdClient *client, CdProfile *profile, Daemon *daemon)
215 | {
216 | g_assert (client == daemon->cli);
217 | update_profile (profile, daemon);
218 | }
219 |
220 | static void
221 | cd_device_added_sig (CdClient *client, CdDevice *device, Daemon *daemon)
222 | {
223 | g_assert (client == daemon->cli);
224 | update_device (device, daemon);
225 | }
226 |
227 | static void
228 | cd_device_changed_sig (CdClient *client, CdDevice *device, Daemon *daemon)
229 | {
230 | g_assert (client == daemon->cli);
231 | update_device (device, daemon);
232 | }
233 |
234 | static void
235 | cd_create_device_cb (GObject *src, GAsyncResult *res, gpointer user_data)
236 | {
237 | Daemon *daemon = (Daemon *) user_data;
238 | GError *err = NULL;
239 | CdDevice *dev;
240 |
241 | g_assert (CD_CLIENT (src) == daemon->cli);
242 |
243 | dev = cd_client_create_device_finish (daemon->cli, res, &err);
244 | if (! dev) {
245 | if (err->domain != CD_CLIENT_ERROR || err->code != CD_CLIENT_ERROR_ALREADY_EXISTS)
246 | g_critical ("failed to create colord device: %s", err->message);
247 | g_error_free (err);
248 | return;
249 | }
250 |
251 | g_object_unref (dev);
252 | }
253 |
254 | static void
255 | create_profile_from_edid(CdIccStore *store, CdEdid *edid)
256 | {
257 | gchar *filename;
258 | gchar *filepath;
259 | GFile *file;
260 | CdIcc *icc = NULL;
261 | GError *err = NULL;
262 | gboolean ret;
263 | const gchar *cksum = cd_edid_get_checksum (edid);
264 |
265 | filename = profile_filename (edid);
266 | filepath = g_build_filename (g_get_user_data_dir (), "icc", filename, NULL);
267 | g_free (filename);
268 | file = g_file_new_for_path (filepath);
269 | g_free (filepath);
270 |
271 | icc = cd_icc_store_find_by_filename (store, g_file_get_path (file));
272 | if (icc) {
273 | g_debug ("profile for edid %s already exists", cksum);
274 | goto out;
275 | }
276 |
277 | icc = icc_from_edid (edid);
278 | if (! icc) {
279 | g_critical ("profile for EDID %s was not created", cksum);
280 | goto out;
281 | }
282 |
283 | g_debug ("WRITING profile for EDID %s", cksum);
284 |
285 | ret = cd_icc_save_file (icc, file, CD_ICC_SAVE_FLAGS_NONE, NULL, &err);
286 | if (! ret) {
287 | g_critical ("unable to write file %s: %s", g_file_get_path (file), err->message);
288 | g_error_free (err);
289 | goto out;
290 | }
291 |
292 | out:
293 | if (icc)
294 | g_object_unref (icc);
295 | g_object_unref (file);
296 | }
297 |
298 | static void
299 | randr_display_added_sig (RandrConn *conn, struct randr_display *disp, Daemon *daemon)
300 | {
301 | const gchar *cksum;
302 | GHashTable *props = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
303 |
304 | g_assert (conn == daemon->rcon);
305 |
306 | g_debug ("added display: '%s'", disp->name);
307 |
308 | if (config.edid) {
309 | create_profile_from_edid (daemon->stor, disp->edid);
310 | }
311 |
312 | g_hash_table_insert (props, CD_DEVICE_PROPERTY_KIND,
313 | (gchar *) cd_device_kind_to_string (CD_DEVICE_KIND_DISPLAY));
314 | g_hash_table_insert (props, CD_DEVICE_PROPERTY_MODE,
315 | (gchar *) cd_device_mode_to_string (CD_DEVICE_MODE_PHYSICAL));
316 | g_hash_table_insert (props, CD_DEVICE_PROPERTY_COLORSPACE,
317 | (gchar *) cd_colorspace_to_string (CD_COLORSPACE_RGB));
318 |
319 | g_hash_table_insert (props, CD_DEVICE_PROPERTY_VENDOR, (gchar *) cd_edid_get_vendor_name (disp->edid));
320 | g_hash_table_insert (props, CD_DEVICE_PROPERTY_MODEL, (gchar *) cd_edid_get_monitor_name (disp->edid));
321 | g_hash_table_insert (props, CD_DEVICE_PROPERTY_SERIAL, (gchar *) cd_edid_get_serial_number (disp->edid));
322 |
323 | g_hash_table_insert (props, CD_DEVICE_METADATA_XRANDR_NAME, (gchar *) disp->xrandr_name);
324 |
325 | g_hash_table_insert (props, CD_DEVICE_METADATA_OUTPUT_PRIORITY,
326 | disp->is_primary ? CD_DEVICE_METADATA_OUTPUT_PRIORITY_PRIMARY
327 | : CD_DEVICE_METADATA_OUTPUT_PRIORITY_SECONDARY);
328 |
329 | cksum = cd_edid_get_checksum (disp->edid);
330 | if (cksum)
331 | g_hash_table_insert (props, CD_DEVICE_METADATA_OUTPUT_EDID_MD5, (gchar *) cksum);
332 |
333 | if (disp->is_laptop)
334 | g_hash_table_insert (props, CD_DEVICE_PROPERTY_EMBEDDED, NULL);
335 |
336 | cd_client_create_device (daemon->cli, disp->name, CD_OBJECT_SCOPE_TEMP,
337 | props, NULL, cd_create_device_cb, daemon);
338 |
339 | g_hash_table_unref (props);
340 | }
341 |
342 | static void
343 | cd_device_remove_cb (GObject *src, GAsyncResult *res, gpointer user_data)
344 | {
345 | Daemon *daemon = (Daemon *) user_data;
346 | GError *err = NULL;
347 | gboolean ret;
348 |
349 | g_assert (CD_CLIENT (src) == daemon->cli);
350 |
351 | ret = cd_client_delete_device_finish (daemon->cli, res, &err);
352 | if (! ret) {
353 | g_critical ("device not removed: %s", err->message);
354 | g_error_free (err);
355 | return;
356 | }
357 | }
358 |
359 | static void
360 | randr_display_removed_sig (RandrConn *conn, struct randr_display *disp, Daemon *daemon)
361 | {
362 | CdDevice *device = NULL;
363 | GError *err = NULL;
364 |
365 | g_assert (conn == daemon->rcon);
366 |
367 | g_debug ("removed display: '%s'", disp->name);
368 |
369 | /* We do not want race conditions here */
370 | device = cd_client_find_device_sync (daemon->cli, disp->name,
371 | NULL, &err);
372 | if (! device) {
373 | g_debug ("device %s not found so not removed: %s", disp->name, err->message);
374 | g_error_free (err);
375 | return;
376 | }
377 |
378 | cd_client_delete_device (daemon->cli, device, NULL,
379 | cd_device_remove_cb, daemon);
380 |
381 | g_object_unref (device);
382 | }
383 |
384 | static void
385 | randr_display_changed_sig (RandrConn *conn, struct randr_display *disp, Daemon *daemon)
386 | {
387 | CdDevice *device = NULL;
388 | GError *err = NULL;
389 |
390 | g_assert (conn == daemon->rcon);
391 | g_assert (daemon->cli != NULL);
392 | g_debug ("changed display: '%s'", disp->name);
393 |
394 | /* We do not want race conditions here */
395 | device = cd_client_find_device_sync (daemon->cli, disp->name,
396 | NULL, &err);
397 | if (! device) {
398 | g_debug ("device %s not found so not changed: %s", disp->name, err->message);
399 | g_error_free (err);
400 | return;
401 | }
402 |
403 | update_device (device, daemon);
404 |
405 | g_object_unref (device);
406 | }
407 |
408 | static void
409 | cd_existing_devices_cb (GObject *src, GAsyncResult *res, gpointer user_data)
410 | {
411 | Daemon *daemon = (Daemon *) user_data;
412 | GError *err = NULL;
413 | GPtrArray *devs;
414 |
415 | g_assert (CD_CLIENT (src) == daemon->cli);
416 |
417 | devs = cd_client_get_devices_finish (daemon->cli, res, &err);
418 | if (! devs) {
419 | g_critical ("Failed to get device list: %s", err->message);
420 | g_error_free (err);
421 | return;
422 | }
423 |
424 | g_ptr_array_foreach (devs, (GFunc) update_device, daemon);
425 | g_ptr_array_unref (devs);
426 | }
427 |
428 | static void
429 | cd_existing_profiles_cb (GObject *src, GAsyncResult *res, gpointer user_data)
430 | {
431 | Daemon *daemon = (Daemon *) user_data;
432 | GError *err = NULL;
433 | GPtrArray *profs;
434 |
435 | g_assert (CD_CLIENT (src) == daemon->cli);
436 |
437 | profs = cd_client_get_profiles_finish (daemon->cli, res, &err);
438 | if (! profs) {
439 | g_critical ("Failed to get profile list: %s", err->message);
440 | g_error_free (err);
441 | return;
442 | }
443 |
444 | g_ptr_array_foreach (profs, (GFunc) update_profile, daemon);
445 | g_ptr_array_unref (profs);
446 | }
447 |
448 | static void
449 | cd_client_create_profile_cb (GObject *src, GAsyncResult *res, gpointer user_data)
450 | {
451 | Daemon *daemon = (Daemon *) user_data;
452 | GError *err = NULL;
453 | CdProfile *profile;
454 |
455 | g_assert (CD_CLIENT (src) == daemon->cli);
456 |
457 | profile = cd_client_create_profile_finish (daemon->cli, res, &err);
458 | if (! profile) {
459 | if (! g_error_matches (err, CD_CLIENT_ERROR, CD_CLIENT_ERROR_ALREADY_EXISTS))
460 | g_critical ("unable to create profile: %s", err->message);
461 | g_error_free (err);
462 | return;
463 | }
464 | g_object_unref (profile);
465 | }
466 |
467 | static void
468 | cd_client_delete_profile_cb (GObject *src, GAsyncResult *res, gpointer user_data)
469 | {
470 | Daemon *daemon = (Daemon *) user_data;
471 | GError *err = NULL;
472 | gboolean ret;
473 |
474 | g_assert (CD_CLIENT (src) == daemon->cli);
475 |
476 | ret = cd_client_delete_profile_finish (daemon->cli, res, &err);
477 | if (! ret) {
478 | g_critical ("unable to remove profile: %s", err->message);
479 | g_error_free (err);
480 | }
481 | }
482 |
483 | static void
484 | cd_icc_store_file_added_sig (CdIccStore *stor, CdIcc *icc, Daemon *daemon)
485 | {
486 | GHashTable *props;
487 | gchar *id;
488 |
489 | g_assert (stor == daemon->stor);
490 |
491 | props = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
492 | id = profile_id (icc);
493 |
494 | g_hash_table_insert (props, CD_PROFILE_PROPERTY_FILENAME,
495 | (gchar *) cd_icc_get_filename (icc));
496 | g_hash_table_insert (props, CD_PROFILE_METADATA_FILE_CHECKSUM,
497 | (gchar *) cd_icc_get_checksum (icc));
498 |
499 | cd_client_create_profile (daemon->cli, id, CD_OBJECT_SCOPE_TEMP, props,
500 | NULL, cd_client_create_profile_cb, daemon);
501 |
502 | g_free (id);
503 | g_hash_table_unref (props);
504 | }
505 |
506 | static void
507 | cd_icc_store_file_removed_sig (CdIccStore *stor, CdIcc *icc, Daemon *daemon)
508 | {
509 | CdProfile *prof = NULL;
510 | GError *err = NULL;
511 | gchar *id;
512 |
513 | g_assert (stor == daemon->stor);
514 |
515 | id = profile_id (icc);
516 |
517 | prof = cd_client_find_profile_sync (daemon->cli, id, NULL, &err);
518 | if (! prof) {
519 | g_debug ("profile not found so not removed: %s: %s", id, err->message);
520 | g_error_free (err);
521 | goto out;
522 | }
523 |
524 | cd_client_delete_profile (daemon->cli, prof, NULL, cd_client_delete_profile_cb, daemon);
525 | out:
526 | g_free (id);
527 | }
528 |
529 | static void
530 | cd_connect_cb (GObject *src, GAsyncResult *res, gpointer user_data)
531 | {
532 | Daemon *daemon = (Daemon *) user_data;
533 | GError *err = NULL;
534 | gboolean ret;
535 |
536 | g_assert (CD_CLIENT (src) == daemon->cli);
537 |
538 | ret = cd_client_connect_finish (daemon->cli, res, &err);
539 | if (! ret) {
540 | g_critical ("Failed to connect to colord: %s", err->message);
541 | g_error_free (err);
542 | return;
543 | }
544 |
545 | g_signal_connect (daemon->cli, "profile-added",
546 | G_CALLBACK (cd_profile_added_sig), daemon);
547 |
548 | g_signal_connect (daemon->cli, "device-added",
549 | G_CALLBACK (cd_device_added_sig), daemon);
550 |
551 | g_signal_connect (daemon->cli, "device-changed",
552 | G_CALLBACK (cd_device_changed_sig), daemon);
553 |
554 | g_signal_connect (daemon->rcon, "display-added",
555 | G_CALLBACK (randr_display_added_sig), daemon);
556 |
557 | g_signal_connect (daemon->rcon, "display-removed",
558 | G_CALLBACK (randr_display_removed_sig), daemon);
559 |
560 | g_signal_connect (daemon->rcon, "display-changed",
561 | G_CALLBACK (randr_display_changed_sig), daemon);
562 |
563 | g_signal_connect (daemon->stor, "added",
564 | G_CALLBACK (cd_icc_store_file_added_sig), daemon);
565 |
566 | g_signal_connect (daemon->stor, "removed",
567 | G_CALLBACK (cd_icc_store_file_removed_sig), daemon);
568 |
569 | cd_icc_store_set_load_flags (daemon->stor, CD_ICC_LOAD_FLAGS_FALLBACK_MD5);
570 |
571 | ret = cd_icc_store_search_kind (daemon->stor, CD_ICC_STORE_SEARCH_KIND_USER,
572 | CD_ICC_STORE_SEARCH_FLAGS_CREATE_LOCATION, NULL, &err);
573 | if (! ret) {
574 | g_critical ("unable to watch profile store: %s", err->message);
575 | g_clear_error (&err);
576 | }
577 |
578 | cd_client_get_devices_by_kind (daemon->cli,
579 | CD_DEVICE_KIND_DISPLAY,
580 | NULL,
581 | cd_existing_devices_cb,
582 | daemon);
583 |
584 | cd_client_get_profiles (daemon->cli,
585 | NULL,
586 | cd_existing_profiles_cb,
587 | daemon);
588 |
589 | randr_conn_start (daemon->rcon);
590 | }
591 |
592 | int
593 | main (int argc, char *argv[])
594 | {
595 | int retval = 1;
596 |
597 | Daemon daemon;
598 | GOptionContext *opt;
599 | GError *err = NULL;
600 | gboolean ret = 0;
601 |
602 | g_set_prgname (PACKAGE);
603 |
604 | memset (&config, 0, sizeof (config));
605 | opt = g_option_context_new (NULL);
606 | g_option_context_set_summary (opt, "X color management daemon");
607 | g_option_context_add_main_entries (opt, config_entries, 0);
608 | ret = g_option_context_parse (opt, &argc, &argv, &err);
609 | g_option_context_free (opt);
610 | if (! ret) {
611 | config_free ();
612 | g_print ("%s\n", err->message);
613 | g_error_free (err);
614 | return retval;
615 | }
616 |
617 | daemon.loop = g_main_loop_new (NULL, FALSE);
618 | daemon.rcon = randr_conn_new (config.display);
619 | daemon.cli = cd_client_new ();
620 | daemon.stor = cd_icc_store_new ();
621 |
622 | config_free ();
623 |
624 | g_unix_signal_add (SIGTERM, signal_term, daemon.loop);
625 | g_unix_signal_add (SIGINT, signal_term, daemon.loop);
626 |
627 | cd_client_connect (daemon.cli, NULL, cd_connect_cb, &daemon);
628 |
629 | g_main_loop_run (daemon.loop);
630 |
631 | g_warning ("Exiting");
632 |
633 | retval = 0;
634 |
635 | g_object_unref (daemon.stor);
636 | g_object_unref (daemon.cli);
637 | g_object_unref (daemon.rcon);
638 | g_main_loop_unref (daemon.loop);
639 |
640 | return retval;
641 | }
642 |
643 | /* vim: set ts=8 sw=8 tw=0 : */
644 |
--------------------------------------------------------------------------------