如何在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