From 06f2fc5c0c1db61c56f4bbe65a21d8be912bb860 Mon Sep 17 00:00:00 2001 From: Thanos Apollo Date: Fri, 18 Aug 2023 10:25:50 +0300 Subject: redo yeetube-send-command-to-socket Simplify network-process --- yeetube.el | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) (limited to 'yeetube.el') diff --git a/yeetube.el b/yeetube.el index 8d3101e..854a990 100644 --- a/yeetube.el +++ b/yeetube.el @@ -214,8 +214,6 @@ It's recommended you keep it as the default value." (when clear-saved (setq yeetube-saved-videos nil)))) -;; MPV STUFF - (defun yeetube-disable-video-mpv () "Toggle video on/off for mpv player." (interactive) @@ -228,20 +226,13 @@ 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 +(defun yeetube-send-command-to-socket (socket json-data) + "Send command with JSON-DATA to SOCKET." + (let* ((proc (make-network-process :name "yeet-socket" :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)))) + :service socket))) + (process-send-string proc (concat json-data "\n")) + (accept-process-output proc))) (defun yeetube--send-command (property value) "Send command with PROPERTY and VALUE as json-data to mpv socket." -- cgit v1.2.3