Browse files

Added helper scripts from trunk.

git-svn-id: svn://nex.scrapping.cc/shell-fm/branches/clean@298 7df44517-d413-0410-91cf-82ca28b36b55
  • Loading branch information...
1 parent 07018a7 commit 4148d6550b086e287b17962bcf94edb9855779d1 jkr committed Feb 10, 2008
Showing with 100 additions and 0 deletions.
  1. +3 −0 CHANGES
  2. +18 −0 scripts/shell-colors.sh
  3. +50 −0 scripts/shell-fm-tune.sh
  4. +29 −0 scripts/zcontrol
View
3 CHANGES
@@ -1,4 +1,7 @@
* 2008-02-10, jkramer
+ - added helper scripts
+
+* 2008-02-10, jkramer
- added DESTDIR variable and "uninstall" target to Makefile.
* 2008-02-10, jkramer
View
18 scripts/shell-colors.sh
@@ -0,0 +1,18 @@
+#!/bin/bash
+# shell-colors.sh, prints possible fg/bg color combinations
+# using escape sequences.
+#
+# Copyright (C) 2007 by Jonas Kramer.
+# Published under the terms of the GNU General Public License (GPL).
+
+echo -ne "FG/BG\t"
+for bg in `seq 30 37`; do echo -ne " $bg "; done
+
+for fg in `seq 30 37`; do
+ echo -ne "\n$fg (N)\t"
+ for bg in `seq 40 47`; do echo -ne "\x1B[$bg;${fg}m Normal \x1B[0m"; done
+ echo -ne "\n$fg (B)\t"
+ for bg in `seq 40 47`; do echo -ne "\x1B[$bg;${fg};1m Bold \x1B[0m"; done
+done
+
+echo
View
50 scripts/shell-fm-tune.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+# Published under the terms of the GNU General Public License (GPL).
+
+extract ()
+{
+ KEY="$1"
+ VALUE="$(
+ sed -e "s/^$KEY\s*=\s*//" <<<"`
+ grep -oE "^$KEY[ ]*=[ ]*[^ ]+" $HOME/.shell-fm/shell-fm.rc \
+ | head -n 1
+ `"
+ )"
+ echo "$VALUE"
+}
+
+
+if [ $# -eq 0 ]; then
+ echo "Usage: shell-fm-tune lastfm://radio_url [HOST [PORT]]"
+ exit -1
+fi
+
+
+RADIO="$1"
+
+IP=
+PORT=
+CMD=
+
+if [ $# -gt 1 ]; then
+ IP="$2"
+ if [ $# -gt 2 ]; then PORT="$3"; fi
+elif [ -r "$HOME/.shell-fm/shell-fm.rc" ]; then
+ IP="`extract "bind"`"
+ PORT="`extract "port"`"
+fi
+
+
+if [ -n "`which nc 2>/dev/null`" ]; then
+ CMD="nc"
+elif [ -n "`which telnet`" ]; then
+ CMD="telnet"
+else
+ echo "Netcat or telnet must be installed!"
+ exit -1
+fi
+
+[ -z "$IP" ] && IP="127.0.0.1"
+[ -z "$PORT" ] && PORT="54311"
+
+echo "play $RADIO" | "$CMD" "$IP" "$PORT" >/dev/null 2>&1
View
29 scripts/zcontrol
@@ -0,0 +1,29 @@
+#!/usr/bin/zsh
+# zcontrol, shell-fm remote control script. Copyright (C) 2006 by Jonas Kramer.
+# Published under the terms of the GNU General Public License (GPL).
+
+setopt extendedglob
+export BIND="127.0.0.1" PORT="54311"
+
+if [[ $# -eq 0 || "$1" != (skip|love|ban|quit|play) ]]; then
+ print "Usage: $0 (skip|love|ban|quit|play) [argument]" >&2
+ exit -1
+fi
+
+if [[ -r "$HOME/.shell-fm/shell-fm.rc" ]]; then
+ for LINE in ${(f)"$(<$HOME/.shell-fm/shell-fm.rc)"}; do
+ LINE="${LINE%%\#*}"
+ if [[ "$LINE" == (#b)(bind|port)[\ ]#"="[\ ]#(#b)([^\ ]##)* ]]; then
+ export ${(U)match[1]}="$match[2]"
+ fi
+ done
+fi
+
+zmodload zsh/net/tcp
+if ! ztcp "$BIND" "$PORT"; then
+ print "Couldn't connect to [$BIND:$PORT]." >&2
+ exit -1
+fi
+
+print -u $REPLY "$1" $@[2,-1]
+ztcp -c $REPLY

0 comments on commit 4148d65

Please sign in to comment.