diff options
author | Bastien Nocera <hadess@hadess.net> | 2013-01-22 15:21:43 +0100 |
---|---|---|
committer | Bastien Nocera <hadess@hadess.net> | 2013-01-22 16:20:14 +0100 |
commit | 8519828df96618819dfa0d4b6af9bb94d6991ca6 (patch) | |
tree | 35477acab5d8dd4b7105abc6ac31189731d7daed /plugins/power/gpm-common.c | |
parent | 1e29249448f8461b7ab140135be28b2c7447d3dc (diff) | |
download | gnome-settings-daemon-8519828df96618819dfa0d4b6af9bb94d6991ca6.tar.gz |
power: Add ability to override XRandR detection
For our tests. The only thing we know how to do is check whether
there's an external screen or not, so that's what we allow to override
by creating a GSD_MOCK_EXTERNAL_MONITOR file in the current directory
with either '0' (no external screen) or '1' (with external screen) as
the content. Send the SIGUSR1 signal to gsd-test-power to generate
a fake XRandR change event, and get the file re-read.
echo 1 > GSD_MOCK_EXTERNAL_MONITOR
killall -USR2 gsd-test-power
Diffstat (limited to 'plugins/power/gpm-common.c')
-rw-r--r-- | plugins/power/gpm-common.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/plugins/power/gpm-common.c b/plugins/power/gpm-common.c index fc8c0c55..1b053a1a 100644 --- a/plugins/power/gpm-common.c +++ b/plugins/power/gpm-common.c @@ -1606,6 +1606,24 @@ external_monitor_is_connected (GnomeRRScreen *screen) GnomeRROutput **outputs; guint i; +#ifdef MOCK_EXTERNAL_MONITOR + char *mock_external_monitor_contents; + gboolean ret; + + if (g_file_get_contents ("GSD_MOCK_EXTERNAL_MONITOR", &mock_external_monitor_contents, NULL, NULL)) { + if (mock_external_monitor_contents[0] == '1') { + g_free (mock_external_monitor_contents); + return TRUE; + } else if (mock_external_monitor_contents[0] == '0') { + g_free (mock_external_monitor_contents); + return FALSE; + } + + g_warning ("Unhandled value for GSD_MOCK_EXTERNAL_MONITOR contents: %s", mock_external_monitor_contents); + g_free (mock_external_monitor_contents); + } +#endif /* MOCK_EXTERNAL_MONITOR */ + /* see if we have more than one screen plugged in */ outputs = gnome_rr_screen_list_outputs (screen); for (i = 0; outputs[i] != NULL; i++) { |