From: Mark Wooding Date: Wed, 29 Nov 2017 20:21:58 +0000 (+0000) Subject: bin/play-rawk: Import Tk hack for listening to my DisOrder Rawk stream. X-Git-Url: https://git.distorted.org.uk/~mdw/profile/commitdiff_plain/5f9b345abf0526aedb88dc42f9f06fe3328c10ee bin/play-rawk: Import Tk hack for listening to my DisOrder Rawk stream. --- diff --git a/Makefile b/Makefile index e98e946..196a33f 100644 --- a/Makefile +++ b/Makefile @@ -270,6 +270,7 @@ DOTLINKS += .config/gtk-3.0/settings.ini 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) diff --git a/bin/play-rawk b/bin/play-rawk new file mode 100755 index 0000000..cb0d6f9 --- /dev/null +++ b/bin/play-rawk @@ -0,0 +1,67 @@ +#! /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 . { .play invoke } +##bind . { puts "key <%K>" } +wm protocol . "WM_DELETE_WINDOW" { byebye }