Make playerctl support optional with a compiler flag

As Ubuntu doesn't provide `playerctl` by default, it's better to make
this optional.

Furthermore another build with playerctl support has been added to the
CI matrix.
This commit is contained in:
Maximilian Bosch 2017-10-03 20:16:22 +02:00
parent 027fd7df3d
commit 9809dcd07d
No known key found for this signature in database
GPG key ID: 091DBF4D1FC46B8E
3 changed files with 36 additions and 1 deletions

View file

@ -2,6 +2,26 @@ sudo: false
dist: trusty
matrix:
include:
- script: make yabar
compiler: gcc
language: c
sudo: required
env: CPPFLAGS=-DOLD_LIBCONFIG PLAYERCTL=1
addons:
apt:
packages:
- libxcb-randr0-dev
- libconfig-dev
- libcairo2-dev
- libpango1.0-dev
- libxcb-ewmh-dev
- libxcb-icccm4-dev
- libasound2-dev
- libiw-dev
- wget
before_install:
- wget https://github.com/acrisci/playerctl/releases/download/v0.5.0/playerctl-0.5.0_amd64.deb -O playerctl.deb
- sudo dpkg -i playerctl.deb
- script: make yabar
compiler: gcc
language: c

View file

@ -3,8 +3,16 @@ CPPFLAGS += -DVERSION=\"$(VERSION)\" -D_POSIX_C_SOURCE=199309L -DYA_INTERNAL -DY
-DYA_ENV_VARS -DYA_INTERNAL_EWMH -DYA_ICON -DYA_NOWIN_COL -DYA_MUTEX -DYA_VAR_WIDTH \
-DYA_BSPWM
CFLAGS += -std=c99 -Iinclude -pedantic -Wall -flto -O2 `pkg-config --cflags pango pangocairo libconfig gdk-pixbuf-2.0 alsa`
DEPS += pango pangocairo libconfig gdk-pixbuf-2.0 alsa
ifdef PLAYERCTL
CFLAGS += -DPLAYERCTL
CPPFLAGS += -DPLAYERCTL
DEPS += playerctl-1.0
endif
LDFLAGS += -flto -O2
LDLIBS += -liw -lxcb -lpthread -lxcb-randr -lxcb-ewmh -lxcb-icccm -lm `pkg-config --libs pango pangocairo libconfig gdk-pixbuf-2.0 alsa playerctl-1.0`
LDLIBS += -liw -lxcb -lpthread -lxcb-randr -lxcb-ewmh -lxcb-icccm -lm `pkg-config --libs $(DEPS)`
PROGRAM := yabar
DOCS := $(PROGRAM).1
PREFIX ?= /usr

View file

@ -22,10 +22,15 @@ void ya_int_battery(ya_block_t *blk);
void ya_int_volume(ya_block_t *blk);
void ya_int_wifi(ya_block_t *blk);
void ya_int_diskspace(ya_block_t *blk);
#ifdef PLAYERCTL
void ya_int_song(ya_block_t *blk);
#endif
struct reserved_blk ya_reserved_blks[YA_INTERNAL_LEN] = {
#ifdef PLAYERCTL
{"YABAR_SONG", ya_int_song},
#endif
{"YABAR_DATE", ya_int_date},
{"YABAR_UPTIME", ya_int_uptime},
{"YABAR_THERMAL", ya_int_thermal},
@ -131,6 +136,7 @@ __attribute__ ((gnu_inline)) inline void ya_setup_prefix_suffix(ya_block_t *blk,
}
}
#ifdef PLAYERCTL
#include <playerctl/playerctl.h>
#define CHECK_PLAYER_ERROR(PREFIX) \
if (PREFIX) \
@ -190,6 +196,7 @@ void ya_int_song(ya_block_t *blk) {
sleep(blk->sleep);
}
}
#endif
#include <time.h>
void ya_int_date(ya_block_t * blk) {