示例#1
0
文件: main.c 项目: hellotanm/eyerest
int main(int argc, char* argv[]) 
{
    setlocale (LC_ALL, "");
    g_type_init();
    g_set_application_name ("eyerest-daemon");

    if (!config_init(argc, argv))
    {
        g_critical("config_init failed!\n");
        return -1;
    }

    if(!g_config.foreground)
    {
        daemon(0, 0);
    }

    if(!dbus_init())
    {
        g_critical("dbus_init failed!\n");
    }

    if (!notify_init())
    {
        g_critical("notify_init failed!\n");
    }

    if (!xfullscreen_init())
    {
        g_critical("xfullscreen_init failed!\n");
        return -1;
    }

    if (!xevent_init())
    {
        g_critical("xevent_init failed!\n");
        return -1;
    }
    xevent_run();

    if(!state_init())
    {
        g_critical("state_init failed\n");
        return -1;
    }

    if (!timer_init())
    {
        g_critical("timer_init failed!\n");
        return -1;
    }
    timer_loop();
    return 0;
}
示例#2
0
int main(int argc, char** argv)
{
    const char *pid_str;
    char str[ 16 ];
	GKeyFile* kf;

    pid_str = g_getenv(pid_env);

    display_name = g_getenv( display_env );
    if( ! display_name )
    {
        display_name = ":0.0";
        g_setenv( display_env, display_name, TRUE );
    }

    parse_options(argc, argv);

    /* initialize X-related stuff and connect to X Display */
    if( G_UNLIKELY(! xevent_init() ) )
        return 1;

    /* send command to existing daemon to reload settings */
    if( G_UNLIKELY( reload_settings ) )
    {
        send_internal_command( LXS_RELOAD );
        return 0;
    }
	else if( G_UNLIKELY( !single_instance_check()) )
	{
		/* only one instance is allowed for each X. */
		fprintf(stderr, "Only one lxsession can be executed at a time");
		return 1;
	}

    /* set pid */
    g_snprintf( str, 16, "%d", getpid() );
    g_setenv(pid_env, str, TRUE );

    main_loop = g_main_loop_new( NULL, TRUE );

	/* setup signal handlers */
    register_signals();

    if ( G_UNLIKELY(!session_name) )
        session_name = "LXDE";
    g_setenv( "DESKTOP_SESSION", session_name, TRUE );

    if ( G_UNLIKELY(!de_name) )
        de_name = session_name;
    g_setenv( "XDG_CURRENT_DESKTOP", de_name, TRUE );

    /* FIXME: load environment variables? */

	/* Load desktop session config file */
	kf = load_session_config(CONFIG_FILE_NAME);
	if( !kf )
	{
		xevent_finalize();
		return 1;
	}

	window_manager = g_key_file_get_string( kf, "Session", "window_manager", NULL );

    if( G_LIKELY(!no_settings) )
        start_settings_daemon(kf);

	g_key_file_free(kf);

    /* start desktop session and load autostart applications */
    start_session();

    g_main_loop_run( main_loop );
    g_main_loop_unref( main_loop );

	xevent_finalize();

    return 0;
}