コード例 #1
0
ファイル: mpd_watchupdates.c プロジェクト: dschoepe/configs
int main(int argc, char **argv) {
  int iport = 6600;
  char *hostname = getenv("MPD_HOST");
  char *port = getenv("MPD_PORT");
  char *password = getenv("MPD_PASSWORD");
  MpdObj *obj = NULL;
  if(!hostname) {
    hostname = "localhost";
  }
  if(port){
    iport = atoi(port);
  }
  /* Create mpd object */
  obj = mpd_new(hostname, iport,password); 
  /* Connect signals */
  mpd_signal_connect_error(obj,(ErrorCallback)error_callback, NULL);
  mpd_signal_connect_status_changed(obj,(StatusChangedCallback)status_changed, NULL);
  /* Set timeout */
  mpd_set_connection_timeout(obj, 10);

  if(!mpd_connect(obj))
    {
      mpd_send_password(obj);
      do{
        mpd_status_update(obj);
      } while(!usleep(300000));
    }
  mpd_free(obj);

  return 0;
}
コード例 #2
0
ファイル: mpdnp.c プロジェクト: Zariel/mpdnp
int main() {
    if(daemon(0, 0) < 0) {
        exit(1);
    }

    signal(SIGHUP, handler);
    signal(SIGTERM, handler);
    signal(SIGINT, handler);
    signal(SIGQUIT, handler);

    char *home = getenv("HOME");

    int size = snprintf(NULL, 0, "%s/.mpdnp.pipe", home) + 1;
    path = malloc(size);
    snprintf(path, size, "%s/.mpdnp.pipe", home);

    mkfifo(path, 0666);
    fd = open(path, O_WRONLY | O_NONBLOCK);

    if(path != NULL) {
        free(path);
    }

    write(fd, " ", 2);

    char *host = getenv("MPD_HOST");
    char *port = getenv("MPD_PORT");

    if(host == NULL) {
        host = "localhost";
    }

    if(port == NULL) {
        port = "6600";
    }

    // New object
    obj = mpd_new(host, atoi(port), NULL);

    // Connect the signal
    mpd_signal_connect_status_changed(obj, (StatusChangedCallback) status_changed, NULL);

    // Timeout
    mpd_set_connection_timeout(obj, 10);

    if(!mpd_connect(obj)) {
        while(!usleep(100000)) {
            if(obj == NULL) {
                break;
            } else {
                mpd_status_update(obj);
            }
        }
    }

    tidyUp();

    return 0;
}
コード例 #3
0
static void
gimmix_mpd_error (MpdObj *mo, int id, char *msg, void *userdata)
{
	if (id&MPD_STATUS_FAILED || id&MPD_STATS_FAILED || id&MPD_SERVER_ERROR || id&MPD_FATAL_ERROR)
	{
		mpd_free (gmo);
		gmo = gimmix_mpd_connect ();
		mpd_signal_connect_status_changed (gmo, (StatusChangedCallback)gimmix_status_changed, NULL);
		mpd_signal_connect_error (gmo, (ErrorCallback)gimmix_mpd_error, NULL);
	}
	
	return;
}
コード例 #4
0
ファイル: gimmix-core.c プロジェクト: BackupTheBerlios/gimmix
MpdObj *
gimmix_mpd_connect (void)
{
	MpdObj 	*mo;
	char 	*host;
	char	*pass;
	int		port;

	host = cfg_get_key_value (conf, "mpd_hostname");
	pass = cfg_get_key_value (conf, "mpd_password");
	port = atoi (cfg_get_key_value (conf, "mpd_port"));
	mo = mpd_new (host, port, pass);
	
	if (mpd_connect (mo) == MPD_OK)
	{
		mpd_signal_connect_status_changed (mo, (StatusChangedCallback)gimmix_status_changed, NULL);
		return mo;
	}
	
	return NULL;
}
コード例 #5
0
ファイル: gimmix-core.c プロジェクト: BackupTheBerlios/gimmix
MpdObj *
gimmix_mpd_connect (Conf *conf)
{
	MpdObj *mo;

	if (conf)
	{
		if ((conf->hostname!="") && (conf->port!=-1))
		{
			mo = mpd_new (conf->hostname, conf->port, conf->password);
			mpd_connect (mo);
			if (mpd_check_connected (mo))
			{
				mpd_signal_connect_status_changed (mo, (StatusChangedCallback)song_changed, NULL);
			return mo;
			}
		}
		else
		return NULL;
	}
	return NULL;
}
コード例 #6
0
ファイル: mpd.c プロジェクト: BackupTheBerlios/lcd-stuff
/* -------------------------------------------------------------------------- */
static bool mpd_start_connection(struct lcd_stuff_mpd *mpd)
{
    int     err;

    mpd->error = false;

    /* create the current song */
    mpd_song_delete(mpd->current_song);
    mpd->current_song = mpd_song_new("", "");

    /* create the object */
    if (mpd->mpd) {
        mpd_free(mpd->mpd);
        mpd->mpd = NULL;
    }
    mpd->mpd = mpd_new(mpd->connection->host, mpd->connection->port, mpd->connection->password);

    /* connect signal handlers */
    mpd_signal_connect_error(mpd->mpd, mpd_error_handler, mpd);
    mpd_signal_connect_status_changed(mpd->mpd, mpd_state_changed_handler, mpd);
    mpd_signal_connect_connection_changed(mpd->mpd, mpd_connection_changed_handler, mpd);

    /* set timeout */
    mpd_set_connection_timeout(mpd->mpd, mpd->timeout);
    if (mpd->error) {
        mpd_disconnect(mpd->mpd);
        return false;
    }

    /* connect */
    err = mpd_connect(mpd->mpd);
    if (err != MPD_OK || mpd->error) {
        report(RPT_ERR, "Failed to connect: %d", err);
        return false;
    }

    return true;
}
コード例 #7
0
ファイル: g15mpd.c プロジェクト: trainman419/g15mpd
int main(int argc, char **argv)
{
    int fdstdin = 0;
    pthread_t Lkeys;
    pthread_t g15display;
    pthread_t EKeys;
    int volume;
    int volume_new;
    char devname[256] = "Unknown";
    int iport = 6600;
    char *hostname = getenv("MPD_HOST");
    char *port = getenv("MPD_PORT");
    char *password = getenv("MPD_PASSWORD");
    int eventdev;
    char evdev_name[128];
    pthread_mutex_init(&lockit,NULL);
    pthread_mutex_init(&daemon_mutex,NULL);
    int i;
      
    for (i=0;i<argc;i++) {
    char argument[20];
    memset(argument,0,20);
    strncpy(argument,argv[i],19);
    if (!strncmp(argument, "-q",2) || !strncmp(argument, "--quickscroll",13)) {
        quickscroll=1;
    }
    if (!strncmp(argument, "-h",2) || !strncmp(argument, "--help",6)) {
        printf("  %s version %s\n  (c)2006-2007 Mike Lampard\n\n",argv[0],VERSION);
        printf("%s -q or --quickscroll	Use volume control to scroll through the playlist\n",argv[0]);
        printf("%s -v or --version	Show program version\n",argv[0]);
        printf("%s -h or --help		This help text\n\n",argv[0]);
        exit(0);
    }
    if (!strncmp(argument, "-v",2) || !strncmp(argument, "--version",9)) {
      printf("%s version %s\n",argv[0],VERSION);
      exit(0);     
    }    
  }

    
    for(eventdev=0;eventdev<127;eventdev++) {
        snprintf(evdev_name,127,"/dev/input/event%i",eventdev);
        if ((mmedia_fd = open(evdev_name, O_NONBLOCK|O_RDONLY)) < 0) {
            // ignore errors when opening devices
            //printf("error opening interface %i\n",eventdev);
        } else {
            ioctl(mmedia_fd, EVIOCGNAME(sizeof(devname)), devname);
            printf("Device Name %s on %s\n", devname, evdev_name);
            if(0==strncmp(devname,"Logitech Logitech Gaming Keyboard",256)){
                printf("Found device: \"%s\" on %s ", devname,evdev_name);
                break;
            } else if(0==strncmp(devname,"G15 Gaming Keyboard",256)){
                printf("Found device: \"%s\" on %s ", devname,evdev_name);
                break;
            }else
                close(mmedia_fd);
        }
    }
    if (mmedia_fd) { // we assume that the next event device is the multimedia keys
        close(mmedia_fd);
        snprintf(evdev_name,127,"/dev/input/event%i",++eventdev);
        printf("and %s\n",evdev_name);
        if ((mmedia_fd = open(evdev_name, O_NONBLOCK|O_RDONLY)) < 0) {
            printf("error opening interface %i",eventdev);
        }
    }else {
        printf("Unable to find Keyboard via EVENT interface... is /dev/input/event[0-9] readable??\n");
    }

    /* set correct hostname */	
    if(!hostname) {
        hostname = "localhost";
    }
    if(port){
        iport = atoi(port);
    }

    if((g15screen_fd = new_g15_screen(G15_G15RBUF))<0){
        printf("Sorry, cant connect to the G15daemon\n");
        return 1;
    }

    canvas = (g15canvas *) malloc (sizeof (g15canvas));
    if (canvas != NULL) {
        memset(canvas->buffer, 0, G15_BUFFER_LEN);
        canvas->mode_cache = 0;
        canvas->mode_reverse = 0;
        canvas->mode_xor = 0;
    }

    /* Create mpd object */
    obj = mpd_new(hostname, iport,password); 
    /* Connect signals */
    mpd_signal_connect_error(obj,(ErrorCallback)error_callback, NULL);
    mpd_signal_connect_status_changed(obj,(StatusChangedCallback)status_changed, NULL);
    /* Set timeout */
    mpd_set_connection_timeout(obj, 10);

    if(0==mpd_connect(obj))
    {
        char buffer[20];
        pthread_attr_t attr;

        mpd_send_password(obj);
        memset(buffer, '\0', 20);
        pthread_attr_init(&attr);
        pthread_attr_setstacksize(&attr,32*1024); /* set stack to 64k - dont need 8Mb !! */

        pthread_create(&Lkeys, &attr, Lkeys_thread, NULL);
        pthread_create(&EKeys, &attr,event_key_thread, NULL);
        pthread_create(&g15display, &attr, g15display_thread, NULL);

        do{
            pthread_mutex_lock(&daemon_mutex);
            if(voltimeout) 
               --voltimeout;
            if(mute){
                volume_adjust = 0;
                mute = 0;
                if (muted_volume == 0) {
                    //printf("mute\n");
                    muted_volume = mpd_status_get_volume(obj);
                    mpd_status_set_volume (obj,0);
                } else {
                    //printf("unmute\n");
                    if (mpd_status_get_volume(obj) == 0) { /* if no other client has set volume up */
                        mpd_status_set_volume (obj,muted_volume);
                    }
                    muted_volume = 0;
                }
            }
            if(volume_adjust != 0){
                if (muted_volume != 0) {
                    volume=muted_volume;
                } else {
                    volume=mpd_status_get_volume(obj);
                }
                volume_new = volume + volume_adjust;
                volume_adjust = 0;
                if(volume_new < 0)
                    volume_new = 0;
                if(volume_new > 100)
                    volume_new = 100;
                if(volume != volume_new || muted_volume){
                    //printf("volume %d -> %d\n", volume, volume_new);
                    mpd_status_set_volume (obj,volume_new);
                }
                voltimeout=100;
                muted_volume=0;
            }
            mpd_status_update(obj);
            pthread_mutex_unlock(&daemon_mutex);

        }while(!usleep(5000) &&  !leaving);
      leaving = 1;
      pthread_join(Lkeys,NULL);
      pthread_join(g15display,NULL);
    }else
      printf("Unable to connect to MPD server. Exiting\n");

    if(obj)
      mpd_free(obj);
    close(fdstdin);

    if(canvas!=NULL)
        free(canvas);

    close(g15screen_fd);
    close(mmedia_fd);

    pthread_mutex_destroy(&lockit);

    return 1;
}
コード例 #8
0
ファイル: mpd_cli.cpp プロジェクト: cyniu88/malina
void  *main_mpd_cli(void *data )
{
    blockQueue char_queue; // kolejka polecen
    thread_data  *my_data;
    my_data = (thread_data*)data;

    ////////////////////////////// LCD PART ///////////////////////
    my_data->mainLCD->set_print_song_state(0);
    ///////////////////////////////////////////////////////////////////
    int   iport = 6600, button_counter =0;
    char *hostname = getenv("MPD_HOST");
    char *port = getenv("MPD_PORT");
    char *password = getenv("MPD_PASSWORD");
    MpdObj *obj = NULL;


    std::cout << " adres hosta to " << hostname << std::endl;
    if(!hostname) {
        std::cout << " ip mpd to " <<  my_data->server_settings->MPD_IP << " ! \n";
        hostname = (char*)my_data->server_settings->MPD_IP.c_str();
    }
    if(port){
        iport = std::stoi(port);
    }
    /* Create mpd object */
    obj = mpd_new(hostname, iport,password);
    /* Connect signals */
    mpd_signal_connect_error(obj,(ErrorCallback)error_callback, NULL);
    mpd_signal_connect_status_changed(obj,(StatusChangedCallback)status_changed , my_data );
    /* Set timeout */
    mpd_set_connection_timeout(obj, 10);

    int work;
    work = mpd_connect(obj);

    while (work){
        log_file_mutex.mutex_lock();
        log_file_cout << ERROR << "nie udalo sie polaczyc z MPD "<<   std::endl;
        log_file_mutex.mutex_unlock();
        system("service mpd stop");
        sleep(1);
        system("service mpd start");
        log_file_mutex.mutex_lock();
        log_file_cout << INFO << "restart MPD "<<   std::endl;
        log_file_cout << INFO << "nawiazuje nowe polaczenie z MPD "<<   std::endl;
        log_file_mutex.mutex_unlock();
        my_data->myEventHandler.run("mpd")->addEvent("restart MPD");
        work = mpd_connect(obj);
    }

    std::cout << " stop "<<std::endl;

    if(!work)
    {
        char buffer;
        do{
            if(char_queue._size() > 0)
            {
                //digitalWrite(LED7,1);
                buffer = char_queue._get();
                switch(buffer)
                {
                case '\n':
                    break;
                case 'D':
                    mpd_player_next(obj);
                    break;
                case 'U':
                    mpd_player_prev(obj);
                    break;
                case 't':
                    mpd_player_play(obj);
                    break;
                case 'A':
                    mpd_player_pause(obj);
                    break;
                case 'P':
                    mpd_player_pause(obj);
                    mpd_player_stop(obj);
                    break;
                case 'q':
                    printf("Quitting....\n");
                    break;
                case 'R':
                    mpd_player_set_repeat(obj, !mpd_player_get_repeat(obj));
                    break;
                case 's':
                    mpd_player_set_random(obj, !mpd_player_get_random(obj));
                    break;

                case 'p':
                    /*if(char_queue._size() > 0)
{
buffer = char_queue._get();
int id = atoi(buffer);
printf(GREEN"Playing:"RESET" %i\n", id);
mpd_player_play_id(obj,id);
}
break;*/

                case '+':
                    mpd_status_set_volume(obj, mpd_status_get_volume(obj)+1);
                    break;
                case '-':
                    mpd_status_set_volume(obj, mpd_status_get_volume(obj)-1);
                    break;
                case '%':
                    mpd_status_set_volume(obj, my_data->ptr_MPD_info->volume);
                    break;
                case '2':
                    debug_level = (debug_level > 0)?0:3;
                    printf( "Debug:"" %s\n", (debug_level >0)? "Enabled":"Disabled");
                    break;
                case 'I':
                    mpd_player_play_id(obj,my_data->currentSongID);
                    break;
                case 'h':
                    printf("\th:\t\tHelp\n"\
                           "\td:\t\tToggle debug on/off\n"\
                           "\t+:\t\tIncrease volume\n"\
                           "\t-:\t\tDecrease volume\n"\
                           "\ta <pass>:\t Authentificate with pass\n"\
                           "\tp <id>:\t Play song with id\n"\
                           "\tl:\t\tList the playlist\n"\
                           "\ts:\t\tToggle shuffle mode\n"\
                           "\tr:\t\tToggle repeat\n"\
                           "\tq:\t\tQuit\n"\
                           "\tv:\t\tStop\n"\
                           "\tc:\t\tPause\n"\
                           "\tx:\t\tPlay\n"\
                           "\tz:\t\tPrevious\n"\
                           "\tb:\t\tNext\n");
                    break;
                default:
                    printf("buffer: %c\n", buffer);
                }
            }
            if (!mpd_check_connected(obj))
            {
                log_file_mutex.mutex_lock();
                log_file_cout << WARNING << "utracono polacznie z  MPD "<<   std::endl;
                log_file_cout << INFO << "restart MPD" << std::endl;
                log_file_mutex.mutex_unlock();
                system ("service mpd restart");
                mpd_connect(obj);
            }

            mpd_status_update(obj);
            my_data->mainLCD->checkState();

            if ( digitalRead(BUTTON_PIN) == HIGH )
            {
                std::cout << " wcisnieta pin !" << std::endl;
                if (check_title_song_to == true && button_counter ==4)
                {
                    char_queue._add('P');
                    std::cout << " \n\ngasze !" << std::endl;
                }
                else if (check_title_song_to == false && button_counter ==4)
                {
                    char_queue._add('t');
                    std::cout << " \n\n\n zapalam !" << std::endl;
                }
                else if (check_title_song_to == false && button_counter ==10)
                {
                    std::cout << " \n\n\n koniec programu z przyciska !" << std::endl;
                    go_while = false;
                }
                std::cout << " \n\n\n licznik guzika wskazuje "<< button_counter << std::endl;
                ++button_counter;
            }
            else
            {
                button_counter =0;
            }


        } while(!usleep(500000) &&  go_while);
        mpd_player_stop(obj);
        sleep (3);
    }
    else{
        std::cout << " NIE UDALO SIE POłączyć "<<std::endl;
    }
    mpd_free(obj);
    log_file_mutex.mutex_lock();
    log_file_cout << INFO << " koniec watku klient MPD  "<<   std::endl;
    log_file_mutex.mutex_unlock();
    return 0;
}
コード例 #9
0
void
gimmix_init (void)
{
	GtkWidget 		*widget;
	GtkWidget		*progressbox;
	GtkAdjustment		*vol_adj;
	GdkPixbuf		*app_icon;
	gchar			*path;
	
	/* Set the application icon */
	main_window = glade_xml_get_widget (xml, "main_window");
	g_signal_connect (G_OBJECT(main_window), "delete-event", G_CALLBACK(cb_gimmix_main_window_delete_event), NULL);
	gtk_window_set_default_size (GTK_WINDOW(main_window), -1, 80);
	gtk_window_resize (GTK_WINDOW(main_window), atoi(cfg_get_key_value(conf, "window_width")), atoi(cfg_get_key_value(conf, "window_height")));
	gtk_window_move (GTK_WINDOW(main_window), atoi(cfg_get_key_value(conf, "window_xpos")), atoi(cfg_get_key_value(conf, "window_ypos")));
	path = gimmix_get_full_image_path (GIMMIX_APP_ICON);
	app_icon = gdk_pixbuf_new_from_file_at_size (path, 48, 48, NULL);
	gtk_window_set_icon (GTK_WINDOW(main_window), app_icon);
	g_object_unref (app_icon);
	g_free (path);
	
	/* connect the key press signal */
	g_signal_connect (G_OBJECT(main_window), "key-press-event", G_CALLBACK(cb_gimmix_key_press), NULL);
	
	g_signal_connect (G_OBJECT(main_window), "configure-event", G_CALLBACK(cb_gimmix_main_window_configure_event), (gpointer)glade_xml_get_widget(xml, "volume_window"));
	
	/* connect the destroy signal */
	g_signal_connect(G_OBJECT(main_window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
	
	/* set icons for buttons */
	gtk_image_set_from_stock (GTK_IMAGE(glade_xml_get_widget(xml, "image_prev")), "gtk-media-previous", GTK_ICON_SIZE_BUTTON);
	gtk_image_set_from_stock (GTK_IMAGE(glade_xml_get_widget(xml, "image_play")), "gtk-media-play", GTK_ICON_SIZE_BUTTON);
	gtk_image_set_from_stock (GTK_IMAGE(glade_xml_get_widget(xml, "image_next")), "gtk-media-next", GTK_ICON_SIZE_BUTTON);
	gtk_image_set_from_stock (GTK_IMAGE(glade_xml_get_widget(xml, "image_stop")), "gtk-media-stop", GTK_ICON_SIZE_BUTTON);
	
	g_signal_connect (G_OBJECT(glade_xml_get_widget (xml, "prev_button")), "clicked", G_CALLBACK(cb_prev_button_clicked), NULL);

	g_signal_connect (G_OBJECT(glade_xml_get_widget (xml, "play_button")), "clicked", G_CALLBACK(cb_play_button_clicked), NULL);
	
	g_signal_connect (G_OBJECT(glade_xml_get_widget (xml, "next_button")), "clicked", G_CALLBACK(cb_next_button_clicked), NULL);
	
	g_signal_connect (G_OBJECT(glade_xml_get_widget (xml, "stop_button")), "clicked", G_CALLBACK(cb_stop_button_clicked), NULL);
	
	g_signal_connect (G_OBJECT(glade_xml_get_widget (xml, "pref_button")), "clicked", G_CALLBACK(cb_pref_button_clicked), NULL);
	
	shuffle_toggle_button = glade_xml_get_widget (xml, "shuffle_toggle");
	repeat_toggle_button = glade_xml_get_widget (xml, "repeat_toggle");
	volume_window = glade_xml_get_widget (xml, "volume_window");
	volume_scale = glade_xml_get_widget (xml, "volume_scale");
	volume_button = glade_xml_get_widget (xml, "volume_button");
	playlist_button = glade_xml_get_widget (xml, "playlist_button");
	playlist_box = glade_xml_get_widget (xml, "playlistbox");
	song_label = glade_xml_get_widget (xml, "song_label");
	artist_label = glade_xml_get_widget (xml, "artist_label");
	search_entry = glade_xml_get_widget (xml, "search_label");
	play_button = glade_xml_get_widget (xml, "play_button");
	image_play = glade_xml_get_widget (xml, "image_play");
	
	g_signal_connect (G_OBJECT(playlist_button), "button-press-event", G_CALLBACK(cb_playlist_button_press), NULL);

	if (is_gimmix_repeat (gmo))
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(repeat_toggle_button), TRUE);
	g_signal_connect (G_OBJECT(repeat_toggle_button), "toggled", G_CALLBACK(cb_repeat_button_toggled), NULL);
	
	if (is_gimmix_shuffle (gmo))
		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON(shuffle_toggle_button), TRUE);
	g_signal_connect (G_OBJECT(shuffle_toggle_button), "toggled", G_CALLBACK(cb_shuffle_button_toggled), NULL);

	widget = glade_xml_get_widget (xml, "info_button");
	g_signal_connect (G_OBJECT(widget), "button-release-event", G_CALLBACK(cb_info_button_press), NULL);

	g_signal_connect (G_OBJECT(volume_scale), "value_changed", G_CALLBACK(cb_volume_scale_changed), NULL);
	g_signal_connect (G_OBJECT(volume_scale), "scroll_event", G_CALLBACK(cb_volume_slider_scroll), NULL);
	vol_adj = gtk_range_get_adjustment (GTK_RANGE(volume_scale));
	gtk_adjustment_set_value (GTK_ADJUSTMENT(vol_adj), mpd_status_get_volume (gmo));
	g_signal_connect (G_OBJECT(volume_button), "clicked", G_CALLBACK(cb_volume_button_clicked), volume_window);
	g_signal_connect (G_OBJECT(volume_button), "scroll_event", G_CALLBACK(cb_volume_slider_scroll), NULL);

	progress = glade_xml_get_widget (xml,"progress");
	progressbox = glade_xml_get_widget (xml,"progress_event_box");
	g_signal_connect (G_OBJECT(progressbox), "button_press_event", G_CALLBACK(cb_gimmix_progress_seek), NULL);
	
	play_button_tooltip = gtk_tooltips_new ();
	
	if (strncasecmp(cfg_get_key_value(conf, "enable_systray"), "true", 4) == 0)
	{
		gimmix_create_systray_icon ();
	}
	if (strncasecmp(cfg_get_key_value(conf, "full_view_mode"), "true", 4) == 0)
	{	
		gtk_widget_show (playlist_box);
		gtk_window_set_resizable (GTK_WINDOW(main_window), TRUE);
	}
	else
	{	
		gtk_widget_hide (playlist_box);
		gtk_window_set_resizable (GTK_WINDOW(main_window), FALSE);
	}
	
	mpd_status_update (gmo);
	status = mpd_player_get_state (gmo);

	if (status == MPD_PLAYER_PLAY)
	{
		gimmix_set_song_info ();
		status = -1;
		gtk_image_set_from_stock (GTK_IMAGE(image_play), "gtk-media-pause", GTK_ICON_SIZE_BUTTON);
		gtk_tooltips_set_tip (play_button_tooltip, play_button, _("Pause <x or c>"), NULL);
	}
	else if (status == MPD_PLAYER_PAUSE)
	{
		gimmix_set_song_info ();
	}
	else if (status == MPD_PLAYER_STOP)
	{
		gtk_progress_bar_set_text (GTK_PROGRESS_BAR(progress), _("Stopped"));
		if (strncasecmp(cfg_get_key_value(conf, "enable_systray"), "true", 4) == 0)
		gtk_progress_bar_set_text (GTK_PROGRESS_BAR(tooltip->progressbar), _("Stopped"));
		gimmix_show_ver_info ();
	}

	g_timeout_add (300, (GSourceFunc)gimmix_timer, NULL);

	/* connect the main mpd callbacks */
	mpd_signal_connect_status_changed (gmo, (StatusChangedCallback)gimmix_status_changed, NULL);
	mpd_signal_connect_error (gmo, (ErrorCallback)gimmix_mpd_error, NULL);
	
	/* initialize playlist and tag editor */
	gimmix_playlist_init ();
	gimmix_tag_editor_init ();
	gimmix_update_current_playlist ();
	
	/* initialize preferences dialog */
	gimmix_prefs_init ();
	
	g_object_unref (xml);
	
	/* show the main window */
	gtk_widget_show (main_window);
	
	/* check if library needs to be updated on startup */
	if (strncasecmp(cfg_get_key_value(conf, "update_on_startup"), "true", 4) == 0)
	gimmix_library_update ();
	
	return;
}