diff options
author | Thanos Apollo <[email protected]> | 2023-08-18 10:03:23 +0300 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2023-08-18 10:03:23 +0300 |
commit | bb8cd69540c81094061fe558061f08b6d9877a9d (patch) | |
tree | 8540a2de8b54d351822adfeef2316e2620b316c9 /yeetube.el | |
parent | aa8685ba161b0ec19970e8474e71272ffe794a6f (diff) |
Add yeetube-send-command-to-socket
No need for socat anymore
Diffstat (limited to 'yeetube.el')
-rw-r--r-- | yeetube.el | 14 |
1 files changed, 14 insertions, 0 deletions
@@ -226,6 +226,20 @@ It's recommended you keep it as the default value." (concat mpv no-video socket))) (message (format "Yeetube Player: %s" yeetube-player)))) +(defun yeetube-send-command-to-socket (socket-file json-data) + "Send command with JSON-DATA to SOCKET-FILE." + (let* ((proc-name "mpv-socket") + (proc-buffer (generate-new-buffer proc-name)) + (proc (make-network-process :name proc-name + :family 'local + :buffer proc-buffer + :service socket-file))) + (let ((json-string (concat json-data "\n"))) + (process-send-string proc json-string)) + (accept-process-output proc) + (sit-for 0.1) ; wait for the process to finish + (with-current-buffer proc-buffer + (buffer-string)))) (defun yeetube-toggle-pause-mpv () "Toggle play/pause mpv." (interactive) |