6 DB_functions_t
*deadbeef
;
8 char tunefilepath
[100];
11 void updatetune(const char *title
, const char *artist
, const char *album
, int length
)
14 tunefile
= fopen(tunefilepath
, "w");
16 fprintf(tunefile
, "%s%s%s\n%s\n%s\n%s\n%d\n", title
, deadbeef
->conf_get_int("psipublish.showplayer", 0) ? " [DeaDBeeF]" : "", isplayed
? "" : " [PAUSED]", artist
, album
, title
, length
);
21 static int psipublish_songstarted(ddb_event_track_t
*ev
) {
22 if (deadbeef
->conf_get_int("psipublish.enable", 0)) {
23 DB_playItem_t
*track
= ev
->track
;
26 updatetune(deadbeef
->pl_find_meta(track
, "title"), deadbeef
->pl_find_meta(track
, "artist"), deadbeef
->pl_find_meta(track
, "album"), deadbeef
->pl_get_item_duration(track
));
32 static int psipublish_songfinished(ddb_event_track_t
*ev
) {
38 static int psipublish_paused() {
39 if (deadbeef
->conf_get_int("psipublish.enable", 0)) {
40 DB_playItem_t
*track
= deadbeef
->streamer_get_playing_track();
42 isplayed
= deadbeef
->get_output()->state() == OUTPUT_STATE_PLAYING
;
43 updatetune(deadbeef
->pl_find_meta(track
, "title"), deadbeef
->pl_find_meta(track
, "artist"), deadbeef
->pl_find_meta(track
, "album"), deadbeef
->pl_get_item_duration(track
));
44 deadbeef
->pl_item_unref(track
);
50 static int psipublish_pluginmessage(uint32_t id
, uintptr_t ctx
, uint32_t p1
, uint32_t p2
) {
52 case DB_EV_SONGSTARTED
:
53 psipublish_songstarted((ddb_event_track_t
*)ctx
);
55 case DB_EV_SONGFINISHED
:
56 psipublish_songfinished((ddb_event_track_t
*)ctx
);
65 int psipublish_pluginstart(void) {
66 sprintf(tunefilepath
, "%s/.cache/Psi+/tune", getenv("HOME"));
70 int psipublish_pluginstop (void) {
75 static const char settings_dlg
[] =
76 "property \"Enable publishing\" checkbox psipublish.enable 0;\n"
77 "property \"Show player\" checkbox psipublish.showplayer 0;\n"
81 DB_PLUGIN_SET_API_VERSION
82 .plugin
.type
= DB_PLUGIN_MISC
,
83 .plugin
.version_major
= 1,
84 .plugin
.version_minor
= 2,
85 .plugin
.id
= "psipublish",
86 .plugin
.name
= "Psi IM Publish Tune",
87 .plugin
.descr
= "Now playing for Psi IM",
89 .plugin
.start
= psipublish_pluginstart
,
90 .plugin
.stop
= psipublish_pluginstop
,
91 .plugin
.message
= psipublish_pluginmessage
,
92 .plugin
.configdialog
= settings_dlg
96 psipublish_load(DB_functions_t
*ddb
) {
98 return &plugin
.plugin
;