+ int good;
+ FILE *fp = popen(command, "r");
+ char buffer[64] = "";
+
+ if (fp == NULL) {
+ warn("Could not get command output for: %s", command);
+ return smprintf(UNKNOWN_STR);
+ }
+
+ fgets(buffer, sizeof(buffer)-1, fp);
+ pclose(fp);
+ for (int i = 0 ; i != sizeof(buffer); i++) {
+ if (buffer[i] == '\0') {
+ good = 1;
+ break;
+ }
+ }
+ if (good)
+ buffer[strlen(buffer)-1] = '\0';
+
+ return smprintf("%s", buffer);
+}
+
+static char *
+temp(const char *file)
+{
+ int temperature;
+ FILE *fp = fopen(file, "r");
+
+ if (fp == NULL) {
+ warn("Could not open temperature file");
+ return smprintf(UNKNOWN_STR);
+ }
+
+ fscanf(fp, "%d", &temperature);
+ fclose(fp);
+
+ return smprintf("%d°C", temperature / 1000);
+}
+
+static char *
+uptime(void)
+{
+ struct sysinfo info;
+ int hours = 0;
+ int minutes = 0;
+
+ sysinfo(&info);
+ hours = info.uptime / 3600;
+ minutes = (info.uptime - hours * 3600 ) / 60;
+
+ return smprintf("%dh %dm", hours, minutes);
+}
+
+static char *
+username(void)
+{
+ uid_t uid = geteuid();
+ struct passwd *pw = getpwuid(uid);
+
+ if (pw == NULL) {
+ warn("Could not get username");
+ return smprintf(UNKNOWN_STR);
+ }
+
+ return smprintf("%s", pw->pw_name);
+}
+
+static char *
+uid(void)
+{
+ return smprintf("%d", geteuid());
+}
+
+
+static char *
+vol_perc(const char *snd_card)
+{ /* FIX THIS SHIT! */
+ long int vol, max, min;
+ snd_mixer_t *handle;
+ snd_mixer_elem_t *elem;
+ snd_mixer_selem_id_t *s_elem;
+
+ snd_mixer_open(&handle, 0);
+ snd_mixer_attach(handle, snd_card);
+ snd_mixer_selem_register(handle, NULL, NULL);
+ snd_mixer_load(handle);
+ snd_mixer_selem_id_malloc(&s_elem);
+ snd_mixer_selem_id_set_name(s_elem, ALSA_CHANNEL);
+ elem = snd_mixer_find_selem(handle, s_elem);
+
+ if (elem == NULL) {
+ snd_mixer_selem_id_free(s_elem);
+ snd_mixer_close(handle);
+ warn("error: ALSA");
+ return smprintf(UNKNOWN_STR);
+ }
+
+ snd_mixer_handle_events(handle);
+ snd_mixer_selem_get_playback_volume_range(elem, &min, &max);
+ snd_mixer_selem_get_playback_volume(elem, 0, &vol);
+
+ snd_mixer_selem_id_free(s_elem);
+ snd_mixer_close(handle);
+
+ return smprintf("%d", ((uint_fast16_t)(vol * 100) / max));