如何在Linux上配置mpd和ncmpcpp

在Linux上配置mpd和ncmpcpp:音乐播放器守护程序(MPD)是一种灵活而强大的服务器端应用程序,用于播放音乐。通过插件和库,您可以播放受网络协议控制的各种声音文件。要与mpd交互,您需要一个客户端程序。最常用的客户端应用程序:

  1. ncmpcpp :使用C ++编写的具有一些新功能(标签编辑器,搜索引擎)的ncmpc几乎准确的克隆
  2. 电脑:Ncurses mpd客户端
  3. 多媒体广告 — MPD服务器命令行用户界面

上面的应用程序是基于控制台的。

本指南提供了有关在Linux上安装和配置mpd和ncmpcpp的说明。该安装基于Ubuntu和Arch Linux。对于MacOS用户,请参阅如何在MacOS上安装和配置mpd和ncmpcpp。

在Linux上安装mpd

当开始如何在Linux上配置mpd和ncmpcpp时,请从安装过程开始。

在Arch Linux上安装mpd。

官方存储库和AUR中都提供Arch Linux MPD:

$ sudo pacman -S mpd --noconfirm

使用AUR获取最新的开发版本。查看AUR指南:

yay – Arch Linux / Manjaro的最佳AUR助手

$ yay -S --needed --noconfirm mpd-gitOR$ yaourt -S mpd-git

在Ubuntu上安装mpd。

对于Ubuntu,也可以从官方存储库中获得。

sudo apt-get install mpd

有关其他发行版,请参见官方安装指南。

MPD官方安装指南

配置mpd

接下来,创建mpd所需的目录。创建默认配置目录和播放列表目录。

$ mkdir -p ~/.mpd/playlists/

建立 mpd.conf 〜/ .mpd目录中的文件。您可以根据自己的喜好更改内容。

$ vim ~/.mpd/mpd.conf

添加以下内容:

 bind_to_address "127.0.0.1"
 #bind_to_address "~/.mpd/socket"
 music_directory "~/Music"
 playlist_directory "~/.mpd/playlists"   
 db_file      "~/.mpd/mpd.db"  
 log_file      "~/.mpd/mpd.log"  
 pid_file      "~/.mpd/mpd.pid"  
 state_file     "~/.mpd/mpdstate"  
 audio_output {  

     type  "pulse"  
     name  "pulse audio"
     device         "pulse" 
     mixer_type      "hardware" 
 }  

audio_output {
    type                    "fifo"
    name                    "my_fifo"
    path                    "/tmp/mpd.fifo"
    format                  "44100:16:2"
}

使用 阿尔萨 代替 脉冲音频第一个 audio_output 该块如下所示:

audio_output {
        type            "alsa"
        name            "Alsa for audio sound card"
        mixer_type      "software"      # optional
}

将mpd用户名添加到登录组和音频组

$ sudo gpasswd -a mpd 
$ chmod 710 ~/
$ sudo gpasswd -a mpd audio

启动mpd并测试配置文件是否有效。

$ mpd
$ ss -tunelp | grep 6600
tcp    LISTEN     0 5 127.0.0.1:6600  *:* users:(("mpd",pid=10906,fd=8)) uid:1000 ino:269403 sk:8 <->

mpd.service systemd单元可用于自动启动/usr/lib/systemd/system/mpd.service

ncmpcpp的安装和配置

在Arch Linux上安装ncmpcpp。

sudo pacman -S ncmpcpp --noconfirm

AUR的最新开发版本:

yay --needed --noconfirm -S ncmpcpp-git

在Ubuntu上安装和配置ncmpcpp

安装ncmpcpp apt-get

sudo apt-get install ncmpcpp
mkdir -p ~/.ncmcpp/lyrics

添加ncmpcpp配置文件。

$ vim ~/.ncmpcpp/config

添加内容:

##
# Files
 mpd_music_dir = "~/Music"  
 lyrics_directory  = ~/.ncmpcpp/lyrics
 ncmpcpp_directory  = ~/.ncmpcpp
 mpd_host = "localhost"
 mpd_port = "6600"  
 mpd_connection_timeout = "5"  
 mpd_crossfade_time = "5"  

 # Playlist
 playlist_disable_highlight_delay = "0"  
 playlist_display_mode = "columns"  
 playlist_show_remaining_time = "yes"

 browser_display_mode = "columns"  
 autocenter_mode = "yes"  
 fancy_scrolling = "yes"  
 follow_now_playing_lyrics = "yes"  
 display_screens_numbers_on_start = "yes"  
 ignore_leading_the = "yes"  
 lyrics_database = "1"  
 song_columns_list_format = "(10)[blue]{l} (30)[green]{a} (30)[magenta]{b} (50)[yellow]{t}"  
 colors_enabled = "yes"  
 main_window_color = "white"  
 main_window_highlight_color =  "blue"
 header_window_color = "cyan"  
 volume_color = "red"  
 progressbar_color = "cyan"  
 statusbar_color = "white"  
 active_column_color = "cyan"  
 active_window_border = "blue"

alternative_header_first_line_format = "$0$aqqu$/a {$7%a - $9}{$5%t$9}|{$8%f$9} $0$atqq$/a$9"
alternative_header_second_line_format = "{{$6%b$9}{ [$6%y$9]}}|{%D}"
song_list_format = "{$3%n │ $9}{$7%a - $9}{$5%t$9}|{$8%f$9}$R{$6 │ %b$9}{$3 │ %l$9}"
user_interface = "alternative"
#user_interface =                    "classic"
default_place_to_search_in = "database"


# visualizer
visualizer_fifo_path = "/tmp/mpd.fifo"
visualizer_output_name = "my_fifo"
visualizer_sync_interval = "12"
#visualizer_type = "wave" (spectrum/wave)
visualizer_type = "spectrum" (spectrum/wave)
visualizer_in_stereo = "yes"
visualizer_look = "+|"


## Navigation ##
cyclic_scrolling = "yes"
header_text_scrolling = "yes"
jump_to_now_playing_song_at_start = "yes"
lines_scrolled = "2"

## Other ##
system_encoding = "utf-8"
regular_expressions = "extended"



## Selected tracks ##
selected_item_prefix = "* "
discard_colors_if_item_is_selected = "no"

## Seeking ##
incremental_seeking = "yes"
seek_time = "1"

## Visivility ##
header_visibility = "yes"
statusbar_visibility = "yes"
titles_visibility = "yes"


progressbar_look =  "=>-"
progressbar_boldness = "yes"
progressbar_elapsed_color = "white"

now_playing_prefix = "> "
song_status_format = " $2%a $4⟫$3⟫ $8%t $4⟫$3⟫ $5%b "
autocenter_mode = "yes"
centered_cursor = "yes"

# Misc
display_bitrate = "yes"
# enable_window_title = "no"
follow_now_playing_lyrics = "yes"
ignore_leading_the = "yes"
empty_tag_marker = ""

启动ncmpcpp并更新mpd数据库

要启动ncmpcpp,只需在终端中输入命令:

$ ncmpcpp 

启动后,输入 u 自动检测歌曲以更新数据库 ~/Music/目录:

u

看起来像这样:

在ncmpcpp上找到的MPD播放列表

按下 8F8,出现Music Visualizer。

在Linux上配置mpd和ncmpcpp

下表是ncmpcpp操作的快速入门备忘单。

键盘按键功能
向下j:向下移动光标
向上翻页:向上翻页
向下翻页:向下翻页
首页:首页
完结:结束
标签页:在播放列表和浏览器之间切换
1 F1:帮助屏幕
2楼:播放列表屏幕
3 F3:浏览屏幕
4 F4:搜索引擎
5 F5:媒体库
6 F6:播放列表编辑器
7 F7:标签编辑器
0 F10:时钟画面

总结了如何在Linux上安装和配置mpd和ncmpcpp。请参阅此处未列出的Linux发行版的相关文档。

类似文章:

如何在CentOS 7 / Fedora 29 / Fedora 28上安装VLC

Sidebar