SCRIPTLINKS += xinitcmd lock-screen xshutdown
SCRIPTLINKS += un-backslashify-selection
SCRIPTLINKS += xpra-start-xdummy
+SCRIPTLINKS += play-rawk
DOTCPP += .Xdefaults
Xdefaults_DEFS = -DEMACSWD=$(call mdw-conf,emacs-width,77)
--- /dev/null
+#! /usr/bin/wish
+
+package require Tclx
+
+set STREAM "http://rawk.distorted.org.uk/rawk"
+catch { source $env(HOME)/.play-rawk }
+
+set CMD [list \
+ gst-launch-1.0 uridecodebin uri=$STREAM ! \
+ pulsesink client-name=play-rawk]
+
+set kidstat -
+set playing false
+set status "\[Not started]"
+
+proc update-status {} {
+ global kidstat playing status
+ set r [gets $kidstat line]
+ if {$r >= 0} {
+ set status $line
+ } elseif {[eof $kidstat]} {
+ close $kidstat
+ set playing false
+ .play configure -text "Play"
+ set status "\[Stopped]"
+ }
+}
+
+proc infanticide {} {
+ global playing kidstat
+
+ if {$playing} { catch { kill [pid $kidstat] } }
+}
+
+proc toggle-playing {} {
+ global CMD playing kidstat
+
+ if {$playing} {
+ infanticide
+ } else {
+ set kidstat [open "|$CMD 2>@1"]
+ fconfigure $kidstat -blocking false -buffering line
+ fileevent $kidstat readable update-status
+ .play configure -text "Stop"
+ set playing true
+ }
+}
+
+proc byebye {} {
+ infanticide
+ exit 0
+}
+
+button .play \
+ -text "Play" \
+ -command "toggle-playing"
+entry .status \
+ -state readonly \
+ -width 48 \
+ -textvariable status
+pack .play -side left -padx 2 -pady 2
+pack .status -side left -padx 2 -pady 2 -fill x -expand true
+bind . "q" { byebye }
+bind . "z" { wm iconify . }
+bind . <space> { .play invoke }
+##bind . <KeyPress> { puts "key <%K>" }
+wm protocol . "WM_DELETE_WINDOW" { byebye }