]>
code.delx.au - pulseaudio/blob - src/pulse/client-conf-x11.c
8d0c612b63e9b286b02435b2da00fac7d050ed66
2 This file is part of PulseAudio.
4 Copyright 2004-2006 Lennart Poettering
6 PulseAudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 2.1 of the License,
9 or (at your option) any later version.
11 PulseAudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with PulseAudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-13071
30 #include <pulse/xmalloc.h>
32 #include <pulsecore/i18n.h>
33 #include <pulsecore/x11prop.h>
34 #include <pulsecore/log.h>
35 #include <pulsecore/core-util.h>
36 #include <pulsecore/macro.h>
38 #include "client-conf-x11.h"
40 int pa_client_conf_from_x11(pa_client_conf
*c
, const char *dname
) {
41 xcb_connection_t
*xcb
= NULL
;
42 int ret
= -1, screen
= 0;
47 if (!dname
&& !(dname
= getenv("DISPLAY")))
53 if (!(xcb
= xcb_connect(dname
, NULL
))) {
54 pa_log(_("xcb_connect() failed"));
58 if (xcb_connection_has_error(xcb
)) {
59 pa_log(_("xcb_connection_has_error() returned true"));
63 if (pa_x11_get_prop(xcb
, screen
, "PULSE_SERVER", t
, sizeof(t
))) {
64 bool disable_autospawn
= true;
66 pa_xfree(c
->default_server
);
67 c
->default_server
= pa_xstrdup(t
);
69 if (pa_x11_get_prop(xcb
, screen
, "PULSE_SESSION_ID", t
, sizeof(t
))) {
72 if ((id
= pa_session_id())) {
74 disable_autospawn
= false;
79 if (disable_autospawn
)
83 if (pa_x11_get_prop(xcb
, screen
, "PULSE_SINK", t
, sizeof(t
))) {
84 pa_xfree(c
->default_sink
);
85 c
->default_sink
= pa_xstrdup(t
);
88 if (pa_x11_get_prop(xcb
, screen
, "PULSE_SOURCE", t
, sizeof(t
))) {
89 pa_xfree(c
->default_source
);
90 c
->default_source
= pa_xstrdup(t
);
93 if (pa_x11_get_prop(xcb
, screen
, "PULSE_COOKIE", t
, sizeof(t
))) {
94 if (pa_client_conf_load_cookie_from_hex(c
, t
) < 0) {
95 pa_log(_("Failed to parse cookie data"));