00001 /***************************************************************************** 00002 * screensaver.c : disable screen savers when VLC is playing 00003 ***************************************************************************** 00004 * Copyright (C) 2003 the VideoLAN team 00005 * $Id: screensaver.c 12580 2005-09-17 12:12:54Z zorglub $ 00006 * 00007 * Authors: Sam Hocevar <[email protected]> 00008 * 00009 * This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 * GNU General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU General Public License 00020 * along with this program; if not, write to the Free Software 00021 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. 00022 *****************************************************************************/ 00023 00024 /***************************************************************************** 00025 * Preamble 00026 *****************************************************************************/ 00027 #include <stdlib.h> 00028 00029 #include <vlc/vlc.h> 00030 #include <vlc/intf.h> 00031 #include <vlc/aout.h> 00032 #include <vlc/vout.h> 00033 00034 /***************************************************************************** 00035 * Local prototypes 00036 *****************************************************************************/ 00037 static int Activate ( vlc_object_t * ); 00038 static void Run ( intf_thread_t *p_intf ); 00039 00040 /***************************************************************************** 00041 * Module descriptor 00042 *****************************************************************************/ 00043 vlc_module_begin(); 00044 set_description( _("X Screensaver disabler") ); 00045 set_capability( "interface", 0 ); 00046 set_callbacks( Activate, NULL ); 00047 vlc_module_end(); 00048 00049 /***************************************************************************** 00050 * Activate: initialize and create stuff 00051 *****************************************************************************/ 00052 static int Activate( vlc_object_t *p_this ) 00053 { 00054 intf_thread_t *p_intf = (intf_thread_t*)p_this; 00055 00056 p_intf->pf_run = Run; 00057 00058 return VLC_SUCCESS; 00059 } 00060 00061 /***************************************************************************** 00062 * Run: main thread 00063 ***************************************************************************** 00064 * This part of the module is in a separate thread so that we do not have 00065 * too much system() overhead. 00066 *****************************************************************************/ 00067 static void Run( intf_thread_t *p_intf ) 00068 { 00069 int i_lastcall = 0; 00070 00071 while( !p_intf->b_die ) 00072 { 00073 msleep( 100000 ); 00074 00075 /* Check screensaver every 30 seconds */ 00076 if( ++i_lastcall > 300 ) 00077 { 00078 vlc_object_t *p_vout; 00079 p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE ); 00080 /* If there is a video output, disable xscreensaver */ 00081 if( p_vout ) 00082 { 00083 vlc_object_release( p_vout ); 00084 00085 /* http://www.jwz.org/xscreensaver/faq.html#dvd */ 00086 system( "xscreensaver-command -deactivate >&- 2>&- &" ); 00087 00088 /* FIXME: add support for other screensavers */ 00089 } 00090 00091 i_lastcall = 0; 00092 } 00093 } 00094 } 00095