Add scroll_step to worker_meta, swap title and artist.
This commit is contained in:
parent
9ddd3df773
commit
f7a240aaaf
@ -13,6 +13,7 @@ struct worker_meta {
|
|||||||
long long update_interval;
|
long long update_interval;
|
||||||
bool stop;
|
bool stop;
|
||||||
int scroll_length;
|
int scroll_length;
|
||||||
|
int scroll_step;
|
||||||
int scroll_index;
|
int scroll_index;
|
||||||
char* label;
|
char* label;
|
||||||
};
|
};
|
||||||
@ -134,7 +135,7 @@ print_status(struct mpd_connection *conn, struct worker_meta *meta)
|
|||||||
|
|
||||||
// the full song label. would be cool if this was customizable at runtime
|
// the full song label. would be cool if this was customizable at runtime
|
||||||
char full_label[strlen(artist) + strlen(title) + 4];
|
char full_label[strlen(artist) + strlen(title) + 4];
|
||||||
sprintf(full_label, "%s - %s", artist, title);
|
sprintf(full_label, "%s - %s", title, artist);
|
||||||
|
|
||||||
// compare current label against previous update's label
|
// compare current label against previous update's label
|
||||||
if (strcmp(meta->label, full_label) != 0) {
|
if (strcmp(meta->label, full_label) != 0) {
|
||||||
@ -161,8 +162,8 @@ print_status(struct mpd_connection *conn, struct worker_meta *meta)
|
|||||||
scroll_text(padded_text, g_utf8_strlen(padded_text, -1), label,
|
scroll_text(padded_text, g_utf8_strlen(padded_text, -1), label,
|
||||||
&meta->scroll_index, meta->scroll_length);
|
&meta->scroll_index, meta->scroll_length);
|
||||||
} else {
|
} else {
|
||||||
// Else we'll just print it out normally and reset the scroll index
|
// Else we'll just use the full label
|
||||||
sprintf(label, "%s - %s", artist, title);
|
strcpy(label, full_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%s%s %s (-%u:%02u) [%u/%u]\n",
|
printf("%s%s %s (-%u:%02u) [%u/%u]\n",
|
||||||
@ -185,7 +186,7 @@ status_loop(void* worker_meta)
|
|||||||
long long start = current_timestamp();
|
long long start = current_timestamp();
|
||||||
|
|
||||||
if (handle_error(conn, true) == 0 && print_status(conn, meta) == 0) {
|
if (handle_error(conn, true) == 0 && print_status(conn, meta) == 0) {
|
||||||
meta->scroll_index++;
|
meta->scroll_index += meta->scroll_step;
|
||||||
}
|
}
|
||||||
|
|
||||||
long long elapsed = current_timestamp() - start;
|
long long elapsed = current_timestamp() - start;
|
||||||
@ -229,7 +230,7 @@ mpd_run_command(struct worker_meta *meta, enum click_command command) {
|
|||||||
|
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
struct worker_meta meta = {950, false, 30, 0, malloc(1024)};
|
struct worker_meta meta = {950, false, 30, 3, 0, malloc(1024)};
|
||||||
|
|
||||||
struct sigaction new_actn, old_actn;
|
struct sigaction new_actn, old_actn;
|
||||||
new_actn.sa_handler = SIG_IGN;
|
new_actn.sa_handler = SIG_IGN;
|
||||||
|
Loading…
Reference in New Issue
Block a user