Archive

Posts Tagged ‘Bash’

One Alternative Method to Surf

January 18th, 2010 Iron_Feet 8 comments
分享家:Addthis中国

不知是我心理敏感,还是事实如此。突然觉得最近我所处的网络世界老是出现道路故障,而且这一旦出了故障还没人来维修。这着实让我不能忍。

现实生活中,遇到交通故障,我们所做的要么就是不去目的地,或者就是绕道而行,费时费力费财。网络世界同样如此。而且从故障的缘由而言,也不指望有关部门会修复这个交通故障了。

我真是无奈和无语,为了能顺利到达我的目的地,我不能不考虑利用“Tunnel”绕道而行了。

通俗地说,网络隧道(Tunneling)就是:利用一种网络协议来传输另一种网络协议。
假设,我的PC因为一些原因无法通过http访问站点A;主机B可以无障碍的顺利通过http访问站点A;但是我拥有主机B的SSH权限。这样子SSH tunneling的使用就变得非常必要了。

Wiki提到:

An SSH tunnel consists of an encrypted tunnel created through an SSH protocol connection. Users may set up SSH tunnels to tunnel unencrypted traffic over a network through an encrypted channel.

SSH Tunneling就是将我的PC的http请求利用SSH借由主机B传输到站点A,然后站点A返回的信息在利用SSH借由主机B返回到我的PC。

我利用的是Hostmonster的SSH帐号来实现。有Hostmonster空间的朋友并不能马上使用其提供的SSH帐号,需要激活一下。
激活过程如下:

  1. 进入hostmonster的Cpanel后台,进入“SSH/Shell Access”,点击那个“Ticket”,内容写上“Please enable SSH for my account.”
  2. 你会在你填写的邮箱中收到一封邮件,大体内容就是希望你上传身份证的照片。你只要直接Reply这封邮件,附件中附上身份证照片就OK了。
    这里需要注意的是,很多朋友会因为hostmonster是英文网站而用自己的英文名填入注册信息,而这个名字和你的身份证名字是不匹配。因此您需要将您注册信息的姓名先修改为拼音的名字,再回复那个邮件并附上身份证照片。
    然后静待审核通过,会有个回复邮件,里面包含了域名、用户名和密码。这时,您可以再将您的注册信息改回您的英文名。
    此时,您再进入“SSH/Shell Access”,那个“Ticket”的按钮消失了,取而代之的是您的SSH帐号。

接下来就是如何使用SSH隧道了。其实很简单
假设Hostmonster给你的帐户如下:

Hostname: abc.com
Username: abcabcab
Password: Your Account Password

您可以通过该命令实现

ssh -N -v -D 8080 -l abcabcab abc.com

此时,您可以将您的浏览器Socket代理设置为 127.0.0.1:8080 。您就可以通过SSH隧道来浏览一下因为故障而不能访问的页面了。

经过我的实验,基本上很多站点都可以访问了,唯独Facebook非常诡异,依然不行。此站非常奇怪,好像对于一些IP段进行屏蔽或者是别的原因,我曾经尝试过用GAE也无法访问。但是现在大多数访问我也就满足了。

由于上面的命令是Shell命令,因此在Windows下的朋友需要借助于一些其他工具。我比较推荐Cygwin。虽然Cygwin经常不是很稳定,但是很幸运的Cygwin在SSH的表现上却极其的稳定!

如今网络因为一些原因频频故障了,不知道接下来是什么会故障呢?也许为了让我以后不会屡屡因为故障而受到打击,我应该天天在脑中想象一下以后所有电子产品都故障的场景。也许那个时候,我们可以回到小时候穿着开裆裤和一群孩子打打弹珠、玩玩洋画、拿瓦片打打水漂的日子了!但是同样是打打弹珠、玩玩洋画、拿拿瓦片打打水漂,真的是同样吗?我们还会像孩提时那么开心吗?或者说我们的孩子会像我们小时候玩这些东西时候那么快乐吗?

我突然发现我还是不去想象了,因为想象这些比我因为故障受到的打击要更大更大……

PS: 本文提到仅仅是另外一种访问网站的方法,并不是翻墙方法的介绍!
写该PS的原因有2:1、由于环境原因,周围的翻墙高手太多了,翻墙方法层出不穷,我不敢号称我这个是翻墙术。2、本站站长是合法公民,只介绍和交流技术,不介绍翻墙方法,嚯嚯~


以下更新于 2010年1月19日20点43分
受到Solrex启发,尝试了一下 Remote DNS Resolve。

很悲剧的是IE代理不支持Remote DNS Resolve,直接导致只要使用IE代理的浏览器都无法支持,我最爱用的Chrome也无法幸免。Opera没试过。Firefox倒是可以启动该功能,具体方法如下:

  1. 在地址栏输入“about:config”,回车
  2. 找到“network. proxy. socks_remote_dns”该项,将其修改为true即可。

以下更新于 2010年1月23日13点38分
前几天抱着试试看的心情,用了 Chrome 的 Proxy Switchy 插件。发现通过该插件,设置 Socket 5.0 的代理,可以支持 Remote DNS Resolve。太爽了!

Categories: IT Tags: , , , , , ,

Lyrics Show Based on Bash Script

December 4th, 2008 Iron_Feet No comments
分享家:Addthis中国

在Ubuntu听歌一直用的是Audacious听歌。
但是歌词问题总让我很不爽。
Lyriczilla还不错,但是效果一般。
昨天无意间在一个论坛看到一个叫mlrc的歌词显示脚本,非常之棒~
目前支持的播放器有audacious,amarok,exaile,mocp,mpd,rhythmbox,Quod Libet(只能由id3标签判断)
而且支持屏幕桌面的前端歌词显示

#!/bin/bash
 
#下载的歌词默认保存在~/.lyrics 
LRCDIR=~/.lyrics 
 
[ -d $LRCDIR ] || mkdir -p ~/.lyrics
 
USAGE(){
  cat <<EOF
 
  Usage: lrc [options] [arguments]
  Options
  -d, --download - download lyrics
  osd            - auto check player and show lyrics on OSD mod
  cli            - auto check player and show lyrics on CLI mod
  -h, --help     - display this
 
EOF
}
 
noid=0
nolrc=0
 
#获取歌曲名字
GETNAME(){
  case "$player" in
  'download')
    echo "$title-$artist";;
  'mpd')
    if [ "$readname" = "filename" ] ; then
      sn="`mpc playlist | grep ">" | sed -e 's/).*//' -e 's/>//'`"
      : $((fn=$sn-1))
      if [ -e ~/.mpdconf ] ; then
        state="`cat ~/.mpdconf | grep "^state_file" | awk -F'"' '{print $2}'`"
        cat "$state" | grep "^$fn" | sed -e 's/.*://' -e 's/.mp3//' -e 's/[0-9]\+[/./-]//g'
      else
        state="`cat /etc/mpd.conf | grep "^state_file" | awk -F'"' '{print $2}'`"
        cat "$state" | grep "^$fn" | sed -e 's/.*://' -e 's/.mp3//' -e 's/[0-9]\+[/./-]//g'
      fi
    else  
      if [ -n "`mpc playlist | grep ">" | sed -e "s/.*)\ //" | grep ".mp3"`" ] ; then
        echo "`mpc playlist | grep ">" | sed -e "s/.*)\ //" -e "s/.mp3//" -e "s/[0-9]\+[/./-]//g"`"
        noid=1
      else
        echo "`mpc playlist | grep ">" | sed -e "s/.*)\ //" -e "s/[0-9]\+[/./-]//g"`"
        noid=0
      fi
    fi;;
  'mocp')
    if [ "$readname" = "filename" ] ; then
      echo "`mocp -i | grep -i "^File" | sed -e "s/.*\///" -e "s/.mp3//" -e "s/[0-9]\+[/./-]//g"`"
    else
      if [ "`mocp -i | grep "^SongTitle:" | sed -e "s/.*:\ //"`" = "" ] ; then
        echo "`mocp -i | grep -i "^File" | sed -e "s/.*\///" -e "s/.mp3//" -e "s/[0-9]\+[/./-]//g"`"
        noid=1
      else
        echo "`mocp -i | grep "^Artist:" | sed -e "s/.*:\ //" -e "s/[0-9]\+[/./-]//g"` - `mocp -i | grep "^SongTitle:" | sed -e "s/.*:\ //" -e "s/[0-9]\+[/./-]//g"`"
        noid=0
      fi
    fi;;
  'aud')
    #p="`qdbus org.mpris.audacious /org/atheme/audacious org.atheme.audacious.Position`"
    #t="`qdbus org.mpris.audacious /org/atheme/audacious org.atheme.audacious.SongTitle $p | sed -e "s/[0-9]\+[/./-]//g"`"
    #n="`qdbus org.mpris.audacious /org/atheme/audacious org.atheme.audacious.SongFilename $p`"
    #if [ "$readname" = "filename" ] ; then
    #  echo "$n" | sed -e "s/.*\///" -e "s/.mp3//" -e "s/[0-9]\+[/./-]//g" | perl -p -e 's/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg'
    #else
    #  if [ -n "`echo "$t" | grep ".mp3"`" ] ; then
    #    echo "$t" | sed -e "s/.mp3//" -e "s/[0-9]\+[/./-]//g"
    #    noid=1
    #  else
    #    echo "$t" | awk -F'-' '{if (NF > 2) {printf $1"-"$3} else {print}}'
    #    noid=0
    #  fi
    #fi;;
    if [ "$readname" = "filename" ] ; then
      echo "`audtool current-song-filename`" | sed -e "s/.*\///" -e "s/.mp3//" -e "s/[0-9]\+[/./-]//g" | perl -p -e 's/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg'
    else
      if [ -n "`audtool current-song | grep ".mp3"`" ] ; then
        echo "`audtool current-song | grep ".mp3"`" | sed -e "s/.mp3//" -e "s/[0-9]\+[/./-]//g"
        noid=1
      else
        echo "`audtool current-song`" | awk -F'-' '{if (NF > 2) {printf $1"-"$3} else {print}}'
        noid=0
      fi
    fi;;
  'amok')
    if [ "$readname" = "filename" ] ; then
      echo "`dcop amarok player path | sed -e "s/.*\///" -e "s/.mp3//" -e "s/[0-9]\+[/./-]//g"`"
    else
      if [ -n "`dcop amarok player nowPlaying | grep ".mp3"`" ] ; then
        echo "`dcop amarok player nowPlaying | sed -e "s/.mp3//" -e "s/[0-9]\+[/./-]//g"`"
        noid=1
      else
        echo "`dcop amarok player nowPlaying | sed -e "s/[0-9]\+[/./-]//g"`"
        noid=0
      fi
    fi;;
  'exaile')
    t=`dbus-send --session --print-reply --dest=org.exaile.DBusInterface /DBusInterfaceObject org.exaile.DBusInterface.get_title | sed -n '$p' | awk -F[\"\"] '{print $2}' | sed -e 's/[0-9]\+[/./-]//g'`
    if [ -n "`echo "$t" | grep ".mp3"`" ] ; then
      echo "$t" | sed -e "s/.mp3//"
    else
      echo `dbus-send --session --print-reply --dest=org.exaile.DBusInterface /DBusInterfaceObject org.exaile.DBusInterface.get_artist | sed -n '$p' | awk -F[\"\"] '{print $2}' | sed -e 's/[0-9]\+[/./-]//g'` - "$t"
    fi;;
  'quodli')
    t=`dbus-send --session --print-reply --dest=net.sacredchao.QuodLibet /net/sacredchao/QuodLibet net.sacredchao.QuodLibet.CurrentSong | sed -n '/title/{n;p}' | sed q | awk -F[\"\"] '{print $2}' | sed -e 's/[0-9]\+[/./-]//g'`
    a=`dbus-send --session --print-reply --dest=net.sacredchao.QuodLibet /net/sacredchao/QuodLibet net.sacredchao.QuodLibet.CurrentSong | sed -n '/artist/{n;p}' | sed '1p' | awk -F[\"\"] '{print $2}' | sed -e 's/[0-9]\+[/./-]//g'`
    echo "$a" - "$t";;
  'rhythmbox')
    url=`dbus-send --session --print-reply --dest=org.gnome.Rhythmbox /org/gnome/Rhythmbox/Player org.gnome.Rhythmbox.Player.getPlayingUri | sed -n '$p' | awk -F[\"\"] '{print $2}'`
    if [ "$readname" = "filename" ] ; then
      echo "$url" | sed -e "s/.*\///" -e "s/.mp3//" -e "s/[0-9]\+[/./-]//g" | perl -p -e 's/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg'
    else
      t=`dbus-send --session --print-reply --dest=org.gnome.Rhythmbox /org/gnome/Rhythmbox/Shell org.gnome.Rhythmbox.Shell.getSongProperties string:"$url" | sed -n '/title/{n;p}' | sed -n '2p' | awk -F[\"\"] '{print $2}' | sed -e 's/[0-9]\+[/./-]//g'`
      a=`dbus-send --session --print-reply --dest=org.gnome.Rhythmbox /org/gnome/Rhythmbox/Shell org.gnome.Rhythmbox.Shell.getSongProperties string:"$url" | sed -n '/artist/{n;p}' | sed -n '$p' | awk -F[\"\"] '{print $2}' | sed -e 's/[0-9]\+[/./-]//g'`
      [ -z "$t" ] && break
      if [ -n "`echo "$t" | grep ".mp3"`" ] ; then
        echo $t | sed -e "s/.mp3//"
      else
        echo "$a" - "$t"
      fi
    fi;;
  esac
}
 
#下载歌词
DOWNLRC(){
  NM="$(GETNAME)"
  nolrc=0
  [ -e /tmp/lrc_file ] && rm /tmp/lrc_file
  [ -e /tmp/lrctmp ] && rm /tmp/lrctmp
  [ `locale |grep "LANG=.*UTF-8"` ] && lang=1
  if [ "$blurred" = "1" ] ; then
    if [ $lang ];then
      gb="`echo "$NM" | iconv -c -f utf-8 -t gb2312 | od -t x1 -A n |tr "\n" " " |tr " " % | sed 's/%*$//g'`"
    else 
      gb="`echo "$NM" | od -t x1 -A n | tr " " %`"
    fi
    wget "http://mp3.sogou.com/gecisearch.so?query="$gb"" -O /tmp/lrc_file -q
    links="`cat /tmp/lrc_file | grep -i "downlrc" | sed -e '2,$d' | awk -F'"' '{print $2}'`"
    [ "$links" != "" ] && wget http://mp3.sogou.com/"$links" -O /tmp/lrctmp -q
    [ "$links" = "" ] && nolrc=1 && DISPLAY
  else
    if [ $lang ] ; then
      gb="`echo "$NM" | iconv -c -f utf-8 -t gb2312`"
    else 
      gb="$NM"
    fi
    if [ "$readname" = "filename" ] || [ $noid ] ; then
      if [ "$namemode1" = "artist" ] ; then
        ar=`echo "$gb" | awk -F'-' '{printf $1}'`
      else
        ti=`echo "$gb" | awk -F'-' '{printf $1}'`
      fi
      if [ "$namemode2" = "title" ] ; then
        ti=`echo "$gb" | awk -F'-' '{printf $2}'`
      else
        ar=`echo "$gb" | awk -F'-' '{printf $2}'`
      fi
    else
      ar=`echo "$gb" | awk -F'-' '{printf $1}'`
      ti=`echo "$gb" | awk -F'-' '{printf $2}'`
    fi
    wget "http://lrc.aspxp.net/?ar=$ar&al=&ti=$ti" -O /tmp/lrc_file -q
    links="`cat /tmp/lrc_file | grep -i "&t=lrc&ac=dl" | sed -n 1p | awk -F'"' '{print $2}'`"
    [ "$links" != "" ] && wget http://lrc.aspxp.net/"$links" -O /tmp/lrctmp -q
    [ "$links" = "" ] && nolrc=1 && DISPLAY
  fi
  if [ $lang ];then
    [ -e /tmp/lrctmp ] && iconv -f gbk -t utf-8 -c /tmp/lrctmp -o $LRCDIR/"$NM.lrc"
  else
    cp /tmp/lrctmp $LRCDIR/"$NM.lrc"
  fi
  [ -e $LRCDIR/"$NM.lrc" ] && sed -i 's/\r//' $LRCDIR/"$NM.lrc"
}
 
#整理歌词
READLRC(){
  NM="$(GETNAME)"
  #[ -e $LRCDIR/"$NM.lrc" ] && awk '! /(\] *.?)$|^( *)$|^[^\[]/' $LRCDIR/"$NM.lrc" | awk -F"]" '{if (NF > 2) {for (i = 1; i < NF; i++) {print $i"]"$NF;}} else{print $0;}}' | sort -o $LRCDIR/"$NM.lrc"
}
 
#显示歌词
DISPLAY(){ 
  NM="$(GETNAME)"
  clear
  echo  -e "\033[;32m****** $NM ****** \033[0m "
  [ "$mode" = "osd" ] && gnome-osd-client "<span foreground='$foreground'>`echo -e "$NM"`</span>"
  if [ -e $LRCDIR/"$NM.lrc" ]; then
    echo ""
  else
    echo "lyrics not found..."
    [ "$mode" = "osd" ] && sleep 3 && gnome-osd-client "<span foreground='$foreground'>`echo -e "lyrics not found..."`</span>"
  fi
  if [ -e $LRCDIR/"$NM.lrc" ]; then
    LRC="$(< $LRCDIR/"$NM.lrc")"
  fi
  [ "$nolrc" = "1" ] && LRC=""
  while [ true ] ; do
    if [ "$NM" != "$(GETNAME)" ] ; then
      NM="$(GETNAME)"
      while [ ! -e $LRCDIR/"$NM.lrc" ] ; do
        DOWNLRC 
      done
      LRC="$(< $LRCDIR/"$NM.lrc")" 
      clear
      echo  -e "\033[;32m****** $NM ****** \033[0m " 
      echo ""
      [ "$mode" = "osd" ] && gnome-osd-client "<span foreground='$foreground'>`echo -e "$NM"`</span>"
      N=1
    fi
    if [ "$player" = "mocp" ] ; then
      TM="`mocp -i | grep "CurrentTime" | sed -e 's/CurrentTime:\ //'`"
    elif [ "$player" = "aud" ] ; then
      #t="`qdbus org.mpris.audacious /org/atheme/audacious org.atheme.audacious.Time`"
      #t="`dbus-send --session --print-reply --dest=org.atheme.audacious /org/atheme/audacious org.atheme.audacious.Time | grep "uint32" | awk -F' ' '{print $2}'`"
      t="`audtool current-song-output-length-frames`"
      #t="`python -c "import dbus;print dbus.SessionBus().get_object('org.atheme.audacious', '/Player').PositionGet()"`"
      : $((t=$t/1000))
      : $((m=$t/60))
      : $((s=$t%60))
      s=`printf '%.2d' $s`
      TM="$m:$s"
    elif [ "$player" = "amok" ] ; then
      t="`dcop amarok player trackCurrentTime`"
      : $((m=$t/60))
      : $((s=$t%60))
      s=`printf '%.2d' $s`
      TM="$m:$s"
    elif [ "$player" = "mpd" ] ; then
      TM="`mpc | grep "/" | awk -F' ' '{print $3}' | awk -F'/' '{print $1}'`"
    elif [ "$player" = "rhythmbox" ] ; then
      #t=`dbus-send --session --print-reply --dest=org.gnome.Rhythmbox /org/gnome/Rhythmbox/Player org.gnome.Rhythmbox.Player.getElapsed | sed -n '$p' | awk '{print $2}'`
      t=`qdbus org.gnome.Rhythmbox /org/gnome/Rhythmbox/Player org.gnome.Rhythmbox.Player.getElapsed`
      if [ "$t" != "" ] ; then
      [ -z "`echo $t | sed 's/[0-9]//g'`" ] && let m=$t/60
      [ -z "`echo $t | sed 's/[0-9]//g'`" ] && let s=$t%60
      fi
      s=`printf '%.2d' $s`
      TM="$m:$s"
    elif [ "$player" = "exaile" ] ; then
      TM="`dbus-send --session --print-reply --dest=org.exaile.DBusInterface /DBusInterfaceObject org.exaile.DBusInterface.query | sed -n '$p' | awk -F['\[\]'] '{print $2}'`"
    elif [ "$player" = "quodli" ] ; then
      t="`dbus-send --session --print-reply --dest=net.sacredchao.QuodLibet /net/sacredchao/QuodLibet net.sacredchao.QuodLibet.GetPosition | sed -n '$p' | awk '{print $2}'`"
      : $((t=$t/1000))
      : $((m=$t/60))
      : $((s=$t%60))
      s=`printf '%.2d' $s`
      TM="$m:$s"
    fi
    [ "$NM" = "No song playing."  ] && exit
    [ "$TM" = ""  ] && break
    NOW="`echo "$LRC" | sed -n "/$TM/p" | sed 's/\[.*\]//' | tr '<' '[' | tr '>' ']'`"
    if [ "$NOW" != ""  -a  "$NOW" != "$LAST" ] ; then 
      N=`expr $N + 1`
      if [ $N -ge "$row" ] ; then
        N=1
        clear
        echo  -e "\033[;32m****** $NM ****** \033[0m"
        echo "" 
        echo $LAST 
      fi
      LAST=$NOW 
      echo $NOW 
      [ "$mode" = "osd" ] && gnome-osd-client -f "<message id='mymusic' osd_fake_translucent_bg='off' osd_vposition='$vposition' osd_halignment='$halignment' animations='$animations' hide_timeout='$timeout'><span size='$size' foreground='$foreground'>`echo "$NOW"`</span></message>"
    fi 
    sleep 1
  done 
}
 
#默认流程
DEFAULT(){
  clear
  NM="$(GETNAME)"
  if [ ! -e $LRCDIR/"$NM"".lrc" ] ; then 
    DOWNLRC
    READLRC
    DISPLAY
  else
    READLRC
    DISPLAY
  fi
}
 
#main
case "$1" in
  '-d'|'--download')
    player='download'
    title=$2
    artist=$3
    blurred=1
    DOWNLRC;;
  ''|'osd'|'cli')
    [ -d ~/.config ] || mkdir -p ~/.config
    while [ ! -e ~/.config/mlrc.conf ] ; do
      echo -e "[config]\nmode=osd\nplayer=mpd\nblurred=0\nreadname=id3\nnamemode=artist-title\n[cli]\nrow=10\n[osd]\nvposition=bottom\nhalignment=left\ntimeout=10000\nsize=18000\nforeground=white\nanimations=on" > ~/.config/mlrc.conf
    done
    #判断模式
    if [ "$1" = "osd" ] ; then
      mode="osd"
      sed -i 's/^mode=.*/mode=osd/' ~/.config/mlrc.conf
    elif [ "$1" = "cli" ] ; then
      mode="cli"
      sed -i 's/^mode=.*/mode=cli/' ~/.config/mlrc.conf
    else
      mode="`cat ~/.config/mlrc.conf | sed -n /^mode/p | awk -F'=' '{print $2}'`"
    fi
    [ ! `which gnome-osd-client` ] && mode="cli"
    #判断播放器
    if [ -n "`ps -d | grep audacious`" ] ; then
      player="aud"
      sed -i 's/^player=.*/player=aud/' ~/.config/mlrc.conf
    elif [ -n "`ps -d | grep amarokapp`" ] ; then
      player="amok"
      sed -i 's/^player=.*/player=amok/' ~/.config/mlrc.conf
    elif [ -n "`ps -d | grep rhythmbox`" ] ; then
      player="rhythmbox"
      sed -i 's/^player=.*/player=rhythmbox/' ~/.config/mlrc.conf
    elif [ -n "`ps -d | grep exaile`" ] ;then
      player="exaile"
      sed -i 's/^player=.*/player=exaile/' ~/.config/mlrc.conf
    elif [ -n "`ps -d | grep quodli`" ] ;then
      player="quodli"
      sed -i 's/^player=.*/player=quodli/' ~/.config/mlrc.conf
    elif [ -n "`ps -A | grep mocp`" ] ; then
      player="mocp"
      sed -i 's/^player=.*/player=mocp/' ~/.config/mlrc.conf
    elif [ -n "`ps -d | grep mpd`" ] ;then
      player="mpd"
      sed -i 's/^player=.*/player=mpd/' ~/.config/mlrc.conf
    else
      player="`cat ~/.config/mlrc.conf | sed -n /^player/p | awk -F'=' '{print $2}'`"
    fi
    #读取配置文件数据
    blurred="`cat ~/.config/mlrc.conf | sed -n /^blurred/p | awk -F'=' '{print $2}'`"
    readname="`cat ~/.config/mlrc.conf | sed -n /^readname/p | awk -F'=' '{print $2}'`"
    namemode1="`cat ~/.config/mlrc.conf | sed -n /^namemode/p | awk -F'=' '{print $2}' | awk -F'-' '{print $1}'`"
    namemode2="`cat ~/.config/mlrc.conf | sed -n /^namemode/p | awk -F'=' '{print $2}' | awk -F'-' '{print $2}'`"
    row="`cat ~/.config/mlrc.conf | sed -n /^row/p | awk -F'=' '{print $2}'`"
    vposition="`cat ~/.config/mlrc.conf | sed -n /^vposition/p | awk -F'=' '{print $2}'`"
    halignment="`cat ~/.config/mlrc.conf | sed -n /^halignment/p | awk -F'=' '{print $2}'`"
    timeout="`cat ~/.config/mlrc.conf | sed -n /^timeout/p | awk -F'=' '{print $2}'`"
    size="`cat ~/.config/mlrc.conf | sed -n /^size/p | awk -F'=' '{print $2}'`"
    foreground="`cat ~/.config/mlrc.conf | sed -n /^foreground/p | awk -F'=' '{print $2}'`"
    animations="`cat ~/.config/mlrc.conf | sed -n /^animations/p | awk -F'=' '{print $2}'`"
    DEFAULT;;
  '-h'|'--help')
    USAGE;;
  *)
    echo "Option '$1' is not recognized, see $0 -h or --help.";;
esac

原帖
原帖的附近有点小问题,基本不影响使用,尽量使用上面的代码,可以直接用上面的代码覆盖到原帖的脚本代码

Categories: IT Tags: , , ,