diff --git a/config_parser.rkt b/config_parser.rkt index 2c383a9..bf566cc 100755 --- a/config_parser.rkt +++ b/config_parser.rkt @@ -1,6 +1,11 @@ #! /usr/bin/env racket #lang racket +(require "helpers.rkt") (define ip (open-input-file "lazyplay.sexp")) -(read-syntax "~/lisp/lazyplay/lazyplay.sexp" ip) -(close-input-port ip) \ No newline at end of file +(define parsed + (read ip)) +(close-input-port ip) + +(define settings (make-hash)) +(update settings parsed) diff --git a/helpers.rkt b/helpers.rkt new file mode 100644 index 0000000..c8d0337 --- /dev/null +++ b/helpers.rkt @@ -0,0 +1,16 @@ +#! /usr/bin/env racket +#lang racket + +(define (update htable settings) + (cond ((null? settings) htable) + (else (map (lambda (setting) + (hash-set! htable (first setting) (second setting))) settings) + htable))) + +(define (partial f x) + (lambda (y) (f x y))) + +(define (flip f) + (lambda (y x) (f x y))) + +(provide (all-defined-out)) diff --git a/lazyplay.rkt b/lazyplay.rkt index 0f50357..7a87280 100644 --- a/lazyplay.rkt +++ b/lazyplay.rkt @@ -1,7 +1,8 @@ #! /usr/bin/env racket #lang racket - (require racket/system) +(require racket/system) +(require "helpers.rkt") (define args (vector->list (current-command-line-arguments))) ; args: filename, mplayer-args @@ -10,12 +11,6 @@ (define mplcmd (string->path "/usr/bin/mplayer")) ; command used to play files ; output file to /dev/null/ -(define (partial f x) - (lambda (y) (f x y))) - -(define (flip f) - (lambda (y x) (f x y))) - (define (file-list) ; list of files in the current working directory (map path->string ; get the strings from the list of paths (directory-list (current-directory)))) @@ -53,14 +48,6 @@ (hash-set! table fname #t)) (play-list)) table)) -; updates a hashtable with a bunch of filenames -; (update played (list "one" "two")) -(define (update htable fnames) - (cond ((null? fnames) htable) - (else (map (lambda (fname) - (hash-set! htable fname #f)) fnames) - htable))) - ; list of new files that have been seen (define (new-files sett files) (filter @@ -88,7 +75,7 @@ (let* ((newfs (new-files played (play-list)))) (play (append (cdr fnames) newfs) (update played newfs)))))) -; (play (play-list) played) +(play (play-list) played) (define (controller) (let* ((input (read (current-input-port)))) (cond ((eof-object? input)) diff --git a/lazyplay.sexp b/lazyplay.sexp index e1560cc..8cc294a 100644 --- a/lazyplay.sexp +++ b/lazyplay.sexp @@ -1,4 +1,2 @@ -( -("player" "mplayer") -("filetype" "avi") -) \ No newline at end of file +(("player" "mplayer") +("filetypes" ("avi" "mp4"))) \ No newline at end of file