多媒体键
现在很多键盘带有多媒体键,他们一般都有windows下的驱动,在Linux下是不是也可以一样使用这些多媒体键呢?幸运的是有些牛人写了个xbindkeys的程序,让用于可以随意定义键盘快捷键,包括多媒体键。xbindkey被包含在大多数GNU/Linux发行版中。如果没有,你可以从作者的主页上面下载并编译。
安装好了xbindkeys之后,你可以在命令行下输入
代码: 全选
xindkeys -k
代码: 全选
Press combination of keys or/and click under the window.
You can use one of the two lines after "NoCommand"
in $HOME/.xbindkeysrc to bind a key.
"NoCommand"
m:0x0 + c:160
NoSymbol
代码: 全选
mocp --play 运行MOC server并开始播放
mocp --stop 停止播放
mocp --toggle-pause 暂停/继续播放
mocp --next 播放下一首
mocp --previous 播放前一首
MOC & 系统监视器
理所当然,很多人想要知道是不是可以做点什么让正在播放的歌曲的歌曲名显示在桌面上,或者将MOC和监视器(比如conky)整合起来?这是当然可行的!:)怎么做?MOC有一个很有用的 --info 命令行参数用来显示当前的播放状态。Conky正好可以用来显示其他程序的输出,所以,只需要写一个小脚本可以了。以下是一个叫做 folken 的用户写的一个bash脚本。
代码: 全选
#!/bin/sh
TITLE="`mocp -i | grep 'Title:' | sed -e 's/^.*: //'`";
if [ "$TITLE" != "" ]; then
ARTIST="`mocp -i | grep 'Artist:' | sed -e 's/^.*: //'`";
SONGTITLE="`mocp -i | grep 'SongTitle:' | sed -e 's/^.*: //'`";
ALBUM="`mocp -i | grep 'Album:' | sed -e 's/^.*: //'`";
if [ "$ARTIST" != "" ]; then ARTIST="$ARTIST - "; fi
if [ "$ALBUM" != "" ]; then ALBUM="($ALBUM)"; fi
echo $ARTIST $SONGTITLE $ALBUM
else echo "MOC is idling"
fi
如果使用conky没有问题,你也应该可以把它应用到gkrellm插件或者gnome-panel applet。${exec 30 /.sh | fold -w55 -s}
MOC & OSD
MOC没有内置的功能显示OSD播放信息——毕竟这只是个基于命令行的程序。直到有个叫做 robo 的用户,写出了两个bash脚本用 osd_cat 命令实现了OSD功能。他的脚本可以OSD的方式显示歌曲名、歌手、专辑信息、进度条和音量条。
代码: 全选
#!/bin/bash
FONT=-adobe-helvetica-bold-*-*-*-24-*-*-*-*-*-*-*
COLOR=red
SHADOW=0
TOTALSEC=`mocp --info | egrep "TotalSec:" | sed 's/TotalSec: //'`
CURRENTSEC=`mocp --info | egrep "CurrentSec:" |
sed 's/CurrentSec: //'`
PERCENT=`echo $(($CURRENTSEC*100/$TOTALSEC))`
mocp --info | egrep "^Artist:|^SongTitle:|^Album:" |
osd_cat --offset=10 --indent=10 --color=$COLOR --font=$FONT --shadow=$SHADOW &
osd_cat --offset=120 --indent=10 --color=$COLOR --font=$FONT \
--shadow=$SHADOW --barmode=percentage --percentage=$PERCENT
代码: 全选
#!/bin/bash
COLOR=red
SHADOW=0
# pasek lub procenty
BARMODE=slider
VOLUME=`amixer get Master | grep Front.Left: |
sed -e s/" Front Left: Playback [0-9]* ["// | sed -e s/"%.*"//`
osd_cat --offset=10 --indent=10 --color=$COLOR --shadow=$SHADOW \
--barmode=$BARMODE --percentage=$VOLUME --delay=1
代码: 全选
amixer sset Master 1+ — 增加音量
amixer sset Master 1- — 减少音量
上面的两条可以让你用鼠标滚轮和alt键控制音量。当你按下alt键并滚动鼠标滚轮的时候,你不光可以调节音量,同时屏幕也会显示一个音量OSD进度条。"amixer sset Master 1+;~/.skrypty/volume.sh"
alt + b:4
"amixer sset Master 1-;~/.skrypty/volume.sh"
alt + b:5
自动运行MOC
MOC可以在不打开伪图形界面的状况下播放音乐。所以为什么不把MOC加入到启动脚本中呢?只需要用
代码: 全选
mocp -p
听电台
我一般playlist里面就一个电台……顺便提一下MOC里面按o可以输入电台url,不过不支持 AAC。电台可以用ctrl+u添加到playlist里面去,我听的电台都是在 http://shoutcast.com 找的。我用这个脚本来更新OSD电台播放状态
代码: 全选
#/bin/bash
FONT=-*-lucidabright-*-r-*-*-34-*-*-*-*-*-*-*
COLOR=green
SHADOW=2
OFFSET=100
if [ "`pgrep mocp`" == '' ]; then
exit
fi
if [ "$TITLEBK" == '' ]; then
TITLEBK=nil
export TITLEBK
fi
TITLE=`mocp --info | egrep "^SongTitle:"|sed 's/SongTitle: //' `
if [[ $TITLE != $TITLEBK ]]; then
export TITLEBK=$TITLE
echo $TITLE|
osd_cat --offset=$OFFSET -A center --color=$COLOR --font=$FONT \
--shadow=$SHADOWa --age=10
fi
sleep 2
exec $0 &
MOC快捷键列表
enter -- starts playing
s -- stops playing
n -- plays next item from the playlist
b -- plays previous item from the playlist
space -- pause
p -- pause
S -- plays at random
R -- repeats the same song in a loop,
Next (X button below) must be OFF
X -- switches to play sequentially
o -- plays a file from the Internet
u -- moves playlist item up
j -- moves playlist item down
Ctrl+u -- adds the URL to the playlist
g -- searches marked string in file names
/ -- searches marked string in file names
r -- rereads the directory
T -- switches to the theme selection menu
f -- toggles display mode of song titles
TAB -- switches marker bar between the playlist
and the file manager panels
l -- switches between displaying the playlist
or the file manager panel
P -- switches full path in the playlist
H -- toggles hidden files view
Ctrl-t -- toggles song duration time
Ctrl-f -- toggles format file view
m -- moves to directory entered in config file
G -- moves to directory with currently played file
i -- moves to marked directory
U -- moves to upper directory
a -- adds a file to the playlist
A -- adds a directory recursively to the playlist
C -- clears the playlist
V -- saves the playlist
d -- removes marked item from the playlist
Y -- removes all empty items from the playlist
< -- decreases volume by 1%
, -- decreases volume by 5%
> — increases volume by 1%
. — increases volume by 5%
x — toggles the mixer channel
? — shows help
! — goes to a fast dir 1 (set in config file)
@ — goes to a fast dir 2
# — goes to a fast dir 3
$ — goes to a fast dir 4
% — goes to a fast dir 5
^ — goes to a fast dir 6
& — goes to a fast dir 7
* — goes to a fast dir 8
( — goes to a fast dir 9
) — goes to a fast dir 10
F1 — executes ExecCommand1 (set in config file)
F2 — executes ExecCommand2
F3 — executes ExecCommand3
F4 — executes ExecCommand4
F5 — executes ExecCommand5
F6 — executes ExecCommand6
F7 — executes ExecCommand7
F8 — executes ExecCommand8
F9 — executes ExecCommand9
F10 — executes ExecCommand10