(no commit message) master
authorChristian Weiske <cweiske@cweiske.de>
Tue, 5 Apr 2016 11:24:29 +0000 (13:24 +0200)
committerwww-cweiske <www-cweiske@localhost.localdomain>
Tue, 5 Apr 2016 11:24:29 +0000 (13:24 +0200)
cli.sh [new file with mode: 0644]
sendsongtoslack.php [new file with mode: 0644]
sendsongtoslack.sh [new file with mode: 0644]

diff --git a/cli.sh b/cli.sh
new file mode 100644 (file)
index 0000000..6c811b1
--- /dev/null
+++ b/cli.sh
@@ -0,0 +1,3 @@
+$ dbus-monitor --session "path=/org/mpris/MediaPlayer2,member=PropertiesChanged" --monitor\\r
+ | stdbuf -i0 -oL grep xesam:title\\r
+ | stdbuf -i0 -oL xargs -L 1 sendsongtoslack
\ No newline at end of file
diff --git a/sendsongtoslack.php b/sendsongtoslack.php
new file mode 100644 (file)
index 0000000..7db499a
--- /dev/null
@@ -0,0 +1,22 @@
+#!/usr/bin/env php\r
+<?php\r
+/**\r
+ * https://api.slack.com/incoming-webhooks\r
+ * https://my.slack.com/services/new/incoming-webhook/\r
+ */\r
+$url = 'https://hooks.slack.com/services/foo';\r
+$payload = array(\r
+    'text' => file_get_contents('php://stdin')\r
+);\r
+$context = stream_context_create(\r
+    array(\r
+        'http' => array(\r
+            'method'  => 'POST',\r
+            'header'  => 'Content-Type: application/json',\r
+            'content' => json_encode($payload)\r
+        )\r
+    )\r
+);\r
+$response = file_get_contents($url, false, $context);\r
+echo $response . "\n";\r
+?>\r
diff --git a/sendsongtoslack.sh b/sendsongtoslack.sh
new file mode 100644 (file)
index 0000000..b4211d8
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh\r
+rhythmbox-client --print-playing | sendtoslack.php\r