Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IPC Updates, Detect Spotify on Service Launch, Minor Bugfixes #40

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
.vgcore.*
bin/
obj/

# added for clang diagnostics
compile_commands.json
.cache
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ Next, add the following spotify modules:
```
[module/previous]
type = custom/ipc
format = <output>
format-font = 2
; Default
hook-0 = echo ""
Expand All @@ -98,6 +99,7 @@ click-left = "spotifyctl -q previous"

[module/next]
type = custom/ipc
format = <output>
format-font = 2
; Default
hook-0 = echo ""
Expand All @@ -108,6 +110,7 @@ click-left = "spotifyctl -q next"

[module/playpause]
type = custom/ipc
format = <output>
format-font = 2
; Default
hook-0 = echo ""
Expand All @@ -120,6 +123,7 @@ click-left = "spotifyctl -q playpause"

[module/spotify]
type = custom/ipc
format = <output>
; Default
hook-0 = echo ""
; Playing/paused show song name and artist
Expand Down
22 changes: 21 additions & 1 deletion include/spotify-listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#define _SPOTIFY_LISTENER_H_

#include <dbus-1.0/dbus/dbus.h>
#include <glib-2.0/glib.h>
#include <glib-2.0/gio/gio.h>
#include <glib-2.0/glib-object.h>
#include <stdarg.h>

/**
Expand All @@ -12,7 +15,7 @@
*
* @returns dbus_bool_t TRUE if messages successfully sent, FALSE otherwise.
*/
dbus_bool_t send_ipc_polybar(int numOfMsgs, ...);
dbus_bool_t send_polybar_msg(int numOfMsgs, ...);

/**
* DBus handler function for PropertiesChanged signals. This is automatically
Expand Down Expand Up @@ -106,4 +109,21 @@ dbus_bool_t update_last_trackid(const char *trackid);
*/
dbus_bool_t spotify_update_track(const char *current_trackid);

/**
* Connect to dbus using a gio proxy and check the Identity property of the bus
* interface org.mpris.MediaPlayer2 for 'Spotify'
* @returns dbus_bool_t TRUE if Spotify is current player, FALSE otherwise
*/
dbus_bool_t get_spotify_status();

/**
* Connect to dbus, and use a gio proxy to query the Metadata prop. of the bus
* interface org.mpris.MediaPlayer2.Player.
* Calls spotify_playing() or spotify_paused() as appropriate to set hooks
* in the module.
* @returns char* <trackid> of from Metadata for use in updates or a null*
* if unable to get <trackid>
*/
const char* get_now_playing();

#endif
9 changes: 4 additions & 5 deletions src/Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
CC = gcc
LIBS := dbus-1
CFLAGS = $(shell pkg-config --cflags dbus-1)
LIBS := dbus-1 gio-2.0 glib-2.0
CFLAGS = $(shell pkg-config --cflags --libs dbus-1 gio-2.0 glib-2.0)

LIBS_INC := $(foreach lib,$(LIBS),-l$(lib))

PKG_NAME = polybar-spotify-module
BASE_INSTALL_PREFIX =
BASE_INSTALL_PREFIX =

IDIR = ../include
ODIR = ../obj
Expand Down Expand Up @@ -43,7 +43,7 @@ all: spotifyctl spotify-listener
debug: spotifyctl spotify-listener

install: spotifyctl spotify-listener
install -Dm755 -t $(BASE_INSTALL_PREFIX)$(BIN_INSTALL_DIR) $(EXES)
install -Dm755 -t $(BASE_INSTALL_PREFIX)$(BIN_INSTALL_DIR) $(EXES)
install -Dm644 $(LICENSE_FILE) $(BASE_INSTALL_PREFIX)$(LICENSE_INSTALL_PATH)
install -Dm644 $(README_FILE) $(BASE_INSTALL_PREFIX)$(README_INSTALL_PATH)
install -Dm644 $(SERVICE_FILE_NAME) $(BASE_INSTALL_PREFIX)$(SERVICE_INSTALL_PATH)
Expand Down Expand Up @@ -76,4 +76,3 @@ $(ODIR)/%.o: %.c $(DEPS) $(EXE_DEPS)

clean:
rm -f $(ODIR)/*.o *~ core vgcore.* $(IDIR)/*~ $(BIN_DIR)/*

Loading