chiark / gitweb /
el/dot-emacs.el (mdw-fontify-rust): Fix integer literal syntax.
[profile] / bin / play-rawk
1 #! /usr/bin/wish
2
3 package require Tclx
4
5 set STREAM "https://rawk.distorted.org.uk/rawk"
6 catch { source $env(HOME)/.play-rawk }
7
8 set CMD [list \
9              gst-launch-1.0 uridecodebin uri=$STREAM ! \
10              pulsesink client-name=play-rawk]
11
12 set kidstat -
13 set playing false
14 set status "\[Not started]"
15
16 proc update-status {} {
17   global kidstat playing status
18   set r [gets $kidstat line]
19   if {$r >= 0} {
20     set status $line
21   } elseif {[eof $kidstat]} {
22     close $kidstat
23     set playing false
24     .play configure -text "Play"
25     set status "\[Stopped]"
26   }
27 }
28
29 proc infanticide {} {
30   global playing kidstat
31
32   if {$playing} { catch { kill [pid $kidstat] } }
33 }
34
35 proc toggle-playing {} {
36   global CMD playing kidstat
37
38   if {$playing} {
39     infanticide
40   } else {
41     set kidstat [open "|$CMD 2>@1"]
42     fconfigure $kidstat -blocking false -buffering line
43     fileevent $kidstat readable update-status
44     .play configure -text "Stop"
45     set playing true
46   }
47 }
48
49 proc byebye {} {
50   infanticide
51   exit 0
52 }
53
54 button .play \
55     -text "Play" \
56     -command "toggle-playing"
57 entry .status \
58     -state readonly \
59     -width 48 \
60     -textvariable status
61 pack .play -side left -padx 2 -pady 2
62 pack .status -side left -padx 2 -pady 2 -fill x -expand true
63 bind . "q" { byebye }
64 bind . "z" { wm iconify . }
65 bind . <space> { .play invoke }
66 ##bind . <KeyPress> { puts "key <%K>" }
67 wm protocol . "WM_DELETE_WINDOW" { byebye }