Skip to content

Instantly share code, notes, and snippets.

@liquidz
Created May 24, 2009 03:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save liquidz/116943 to your computer and use it in GitHub Desktop.
Save liquidz/116943 to your computer and use it in GitHub Desktop.
notify twitter updates with notify-send
#!/usr/bin/gosh
(use srfi-1)
(use srfi-13)
(use simply)
(use simply.sxml)
(use simply.notify)
;---------YOU CAN EDIT----------
(define *twitter-user* "hogehoge")
(define *twitter-password* "fugafuga")
(define *twitter-icon* "/hoge/fuga/twitter.png")
;-------------------------------
(define *text-limit* 40)
;(Sun May 24 02:12:43 +0000 2009)
#|
(define (change-date-format date)
(let1 tmp (cdr (string-split date #\space))
(string-join
(append (take tmp 3) (take-right tmp 1))
" ")
)
)
|#
; =shorted-text
; ------------------------------
(define (shorten-text text)
(if (> (string-length text) *text-limit*)
(string-append (string-take text *text-limit*) "...")
text
)
)
; =main
; -----------------------------
(define (main args)
(let1 sxml (string->sxml (http-get "http://twitter.com/statuses/friends_timeline.xml"
:user *twitter-user* :password *twitter-password*))
(notify-send
"twitter"
(string-join
(r fold (lambda (status res)
(let ((text (sxml:value (sxpath status '(text))))
(user (sxml:value (sxpath status '(user screen_name))))
;(date (change-date-format (sxml:value (sxpath status '(created_at)))))
)
(let1 tmp-text (if (> (string-length text) *text-limit*)
(string-append (string-take text *text-limit*) "...") text)
(cons (string-append user ": " (shorten-text text)) res)
)
)
)
'()
(take (sxpath sxml '(statuses status)) 5)
)
"\n")
:icon *twitter-icon*
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment