Browse Source

worked on config

master
wes 12 years ago
parent
commit
0d4c9b8cd4
  1. 9
      config_parser.rkt
  2. 16
      helpers.rkt
  3. 19
      lazyplay.rkt
  4. 6
      lazyplay.sexp

9
config_parser.rkt

@ -1,6 +1,11 @@
#! /usr/bin/env racket #! /usr/bin/env racket
#lang racket #lang racket
(require "helpers.rkt")
(define ip (open-input-file "lazyplay.sexp")) (define ip (open-input-file "lazyplay.sexp"))
(read-syntax "~/lisp/lazyplay/lazyplay.sexp" ip) (define parsed
(close-input-port ip) (read ip))
(close-input-port ip)
(define settings (make-hash))
(update settings parsed)

16
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))

19
lazyplay.rkt

@ -1,7 +1,8 @@
#! /usr/bin/env racket #! /usr/bin/env racket
#lang racket #lang racket
(require racket/system) (require racket/system)
(require "helpers.rkt")
(define args (vector->list (current-command-line-arguments))) (define args (vector->list (current-command-line-arguments)))
; args: filename, mplayer-args ; args: filename, mplayer-args
@ -10,12 +11,6 @@
(define mplcmd (string->path "/usr/bin/mplayer")) ; command used to play files (define mplcmd (string->path "/usr/bin/mplayer")) ; command used to play files
; output file to /dev/null/ ; 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 (define (file-list) ; list of files in the current working directory
(map path->string ; get the strings from the list of paths (map path->string ; get the strings from the list of paths
(directory-list (current-directory)))) (directory-list (current-directory))))
@ -53,14 +48,6 @@
(hash-set! table fname #t)) (play-list)) (hash-set! table fname #t)) (play-list))
table)) 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 ; list of new files that have been seen
(define (new-files sett files) (define (new-files sett files)
(filter (filter
@ -88,7 +75,7 @@
(let* ((newfs (new-files played (play-list)))) (let* ((newfs (new-files played (play-list))))
(play (append (cdr fnames) newfs) (update played newfs)))))) (play (append (cdr fnames) newfs) (update played newfs))))))
; (play (play-list) played) (play (play-list) played)
(define (controller) (define (controller)
(let* ((input (read (current-input-port)))) (let* ((input (read (current-input-port))))
(cond ((eof-object? input)) (cond ((eof-object? input))

6
lazyplay.sexp

@ -1,4 +1,2 @@
( (("player" "mplayer")
("player" "mplayer") ("filetypes" ("avi" "mp4")))
("filetype" "avi")
)