Browse files

data.lisp added. lbus-xset isn't talking with X yet.

  • Loading branch information...
1 parent 1940ef0 commit 53758b872ae67ef9c017e0733077a1d16c5a63d3 @otwieracz committed Jul 12, 2011
Showing with 54 additions and 0 deletions.
  1. +21 −0 date.lisp
  2. +33 −0 lbus-xset.lisp
View
21 date.lisp
@@ -0,0 +1,21 @@
+(require :cl-json)
+(require :cl-ppcre)
+(require :usocket)
+
+(defconstant +lbus-host+ #(127 0 0 1))
+(defconstant +lbus-port+ 9700)
+(defconstant +lbus-key+ "mpd-song")
+
+(loop
+ (let ((socket (usocket:socket-connect +lbus-host+ +lbus-port+)))
+ (format (usocket:socket-stream socket)
+ "~A~%"
+ (json:encode-json-to-string
+ (list (cons "act" "set")
+ (cons "key" "date")
+ (cons "value"
+ (multiple-value-bind (s m h d mt y) (get-decoded-time)
+ (format nil "~2,'0d:~2,'0d:~2,'0d [~d/~2,'0d/~d]"
+ h m s d mt y))))))
+ (usocket:socket-close socket))
+ (sleep 1))
View
33 lbus-xset.lisp
@@ -0,0 +1,33 @@
+(require :clx)
+(require :cl-json)
+(require :usocket)
+
+(defconstant +lbus-host+ #(127 0 0 1))
+(defconstant +lbus-port+ 9700)
+
+(defconstant +keys+ (list "date" "mpd-song"))
+
+(defun make-akv-list (act key value)
+ (list (cons :act act) (cons :key key) (cons :value value)))
+
+(defun get-values (keys)
+ (let ((values (list)))
+ (mapcan (lambda (key)
+ (let ((socket (usocket:socket-connect +lbus-host+ +lbus-port+)))
+ (format (usocket:socket-stream socket) "~A~%"
+ (json:encode-json-to-string (make-akv-list "get" key nil)))
+ (force-output (usocket:socket-stream socket))
+ (push (cdr (third (json:decode-json-from-string
+ (read-line (usocket:socket-stream socket)))))
+ values)
+ (usocket:socket-close socket)))
+ keys)
+ values))
+
+(print (get-values +keys+))
+
+(print (reduce #'(lambda (x y) (concatenate 'string x " · " y)) (get-values +keys+)))
+
+(mapcan (lambda (elem)
+ (format nil "~A · " elem))
+ (get-values +keys+))

0 comments on commit 53758b8

Please sign in to comment.