当初の目的達成~ コンソールのステータス領域にに再生中の曲名を(ry
2014/6/20 ubuntu studio 14.04 + jack 環境向けに色々修正
元記事は2010年頃のfedora coreをベースに書かれています。画面とか撮り直すのめんどくさいのでそのまま使ってますが、ubuntuの画面とちょっと違うところがあるかもしれません。
- やりたいこと
- 作業手順の紹介
/etc/profile.d/juked.sh を新規作成し、以下のように書いてください。
#!/bin/bash /usr/bin/jackd -dalsa > /dev/null 2>&1
なお、jackd にはいろいろオプションが有るようです。音質に影響のあるオプションも色々あるみたいなので、ちょっとでもいい音で!って方は、色々調べてみてください。
- スクリプトとか設定とか
#!/bin/bash # ~/bin/mplay.sh find /var/music -name *.mp3 > playlist.txt find /var/music -name *.wma >> playlist.txt find /var/music -name *m4a >> playlist.txt nohup ruby ./exec_mplayer.rb &>/dev/null 2>&1 &
#!/usr/bin/env ruby # ~/bin/exec_mplayer.rb require 'nkf' f = /^Playing / t = /^ [Tt]itle\:/ ldir = "" fname = "" tname = "" at_exit{ c = open( "./current.txt", "w" ) c.close() } open( "| mplayer -ao jack -shuffle -playlist ./playlist.txt" ).each_line { |l| if f.match(l) l = NKF.nkf('-w8', l) fname = l.split( "/" ).last fname = fname.gsub( /^[ \t\r\n]+/, "" ) fname = fname.gsub( /[ \t\r\n]+$/, "" ) if fname != "" c = open( "./current.txt", "w" ) c.write( fname ) c.close end end if t.match(l) tname = l.gsub( t, "" ) tname = NKF.nkf( '-w8', tname ) tname = tname.gsub( /^[ \t\r\n]+/, "" ) tname = tname.gsub( /[ \t\r\n]+$/, "" ) if tname != "" c = open( "./current.txt", "w" ) c.write( tname ) c.close end end }
あんま綺麗なソースじゃないですが、やってることは、
mplayerの標準出力を解析し、再生中のTitleタグ、tagが定義されていなければファイル名を
./curret.txt に随時書き出しています。
最後に、tmuxのステータス領域を~/bin/current.txt の内容で随時更新してやれば完了です。
~/.tmux.conf に以下を追加
set-option -g status-right '#(cat ~/bin/current.txt) [%y/%m/%d %H:%M]' set-option -g status-interval 3
set-option -g status-right '....' が、ステータス領域の右端の表示内容を定義するためのオプションです。
その中の#(cat ~/bin/current.txt) が current.txt の内容をステータスバーに表示するための設定です。
#( command ) は、ステータス表示時に command を実行し、標準出力の先頭1行の内容に置き換えられるので、
tmux実行時再生中の曲名に置き換えられるはず。
また、
set-option -g status-interval 3
は、ステータスの更新間隔。
3秒おきに cat .... を動かして曲名を取得し、ステータス領域に反映させてる感じです。
更新間隔を短くすれば、表示されている曲名と、実際に流れている曲名がずれる時間を短くすることもできます。