Esempio n. 1
0
int
main(void) {
	Display *dpy;
	struct iwreq wreq;
	snd_mixer_t *handle;
	snd_mixer_elem_t *elem;
	snd_mixer_selem_id_t *vol_info;
	int sockfd, loops = 60;
	char *status, *mpd, *net, *vol, *bat, *clk;

	if(!(dpy = XOpenDisplay(NULL))) {
		fprintf(stderr, "dwmst: cannot open display.\n");
		exit(EXIT_FAILURE);
	}

	memset(&wreq, 0, sizeof(struct iwreq));
	snprintf(wreq.ifr_name, sizeof(WIRELESS_DEVICE), WIRELESS_DEVICE);
	sockfd = socket(AF_INET, SOCK_DGRAM, 0);

	snd_mixer_open(&handle, 0);
	snd_mixer_attach(handle, "default");
	snd_mixer_selem_register(handle, NULL, NULL);
	snd_mixer_load(handle);
	snd_mixer_selem_id_malloc(&vol_info);
	snd_mixer_selem_id_set_name(vol_info, VOL_CH);
	elem = snd_mixer_find_selem(handle, vol_info);
	if(elem == NULL) {
		fprintf(stderr, "dwmst: can not open device.\n");
		cleanup(dpy, sockfd, handle, vol_info);
		exit(EXIT_FAILURE);
	}

	for(;;sleep(INTERVAL)) {
		if(++loops > 60) {
			loops = 0;
			mpd = get_mpd();
			net = get_net(wreq, sockfd);
			bat = get_bat();
			clk = get_time();
		}
		vol = get_vol(handle, elem);
		status = smprintf("%s  %s  %s  %s  %s", mpd, net, vol, bat, clk);
		setstatus(dpy, status);
		free(vol);
		free(status);
	}

	free(mpd);
	free(net);
	free(bat);
	free(clk);
	cleanup(dpy, sockfd, handle, vol_info);
	exit(EXIT_SUCCESS);
}
Esempio n. 2
0
void bar_upd(int sig) {
    static char barstr[750];
    snprintf(barstr, 750, "%%{l}%s %s %s%%{c}%s%%{r}%s %s %s %s\n",
            get_win((sig == -2 ? false : true)),
            get_hname(),
            get_xtitle((sig == -1 ? false : true)),
            get_mpd(),
            get_vol(),
            get_load(),
            get_uname(),
            get_time());
    fputs(barstr, barfp);
    fflush(barfp);
}
Esempio n. 3
0
void *get_samples(void)
{
    while(1)
    {
#ifdef USE_ALSA
        get_alsa();
#endif
#ifdef USE_FIFO
        get_mpd();
#endif

        // find average of the input signal
        fft_input_avg = 0;
        for (int i = 0; i < SAMPLE_SIZE; i++)
            fft_input_avg += fft_input[i];
        fft_input_avg /= SAMPLE_SIZE;


    }
}