02-11-2020, 07:49 AM
Playing Music on your Fedora Terminal with MPD and ncmpcpp
<div><p>MPD, as the name implies, is a Music Playing Daemon. It can play music but, being a daemon, any piece of software can interface with it and play sounds, including some CLI clients.</p>
<p>One of them is called <em>ncmpcpp</em>, which is an improvement over the pre-existing <em>ncmpc</em> tool. The name change doesn’t have much to do with the language they’re written in: they’re both C++, but <em>ncmpcpp</em> is called that because it’s the <em>NCurses Music Playing Client</em> <em>Plus Plus</em>. </p>
<p> <span id="more-30252"></span> </p>
<h2>Installing MPD and ncmpcpp</h2>
<p>The <em>ncmpmpcc</em> client can be installed from the official Fedora repositories with DNF directly with</p>
<pre class="wp-block-preformatted">$ sudo dnf install ncmpcpp</pre>
<p>On the other hand, MPD has to be installed from the RPMFusion <em>free</em> repositories, which you can enable, <a href="https://rpmfusion.org/Configuration">as per the official installation instructions</a>, by running</p>
<pre class="wp-block-preformatted">$ sudo dnf install https://download1.rpmfusion.org/free/fed...ee-release-$(rpm -E %fedora).noarch.rpm</pre>
<p>and then you can install MPD by running</p>
<pre class="wp-block-preformatted">$ sudo dnf install mpd</pre>
<h2>Configuring and Starting MPD</h2>
<p>The most painless way to set up MPD is to run it as a regular user. The default is to run it as the dedicated <em>mpd</em> user, but that causes all sorts of issues with permissions.</p>
<p>Before we can run it, we need to create a local config file that will allow it to run as a regular user.</p>
<p>To do that, create a subdirectory called <em>mpd</em> in <em>~/.config</em>:</p>
<pre class="wp-block-preformatted">$ mkdir ~/.config/mpd</pre>
<p>copy the default config file into this directory:</p>
<pre class="wp-block-preformatted">$ cp /etc/mpd.conf ~/.config/mpd</pre>
<p>and then edit it with a text editor like <em>vim</em>, <em>nano</em> or <em>gedit</em>:</p>
<pre class="wp-block-preformatted">$ nano ~/.config/mpd/mpd.conf</pre>
<p>I recommend you read through all of it to check if there’s anything you need to do, but for most setups you can delete everything and just leave the following:</p>
<pre class="wp-block-preformatted">db_file "~/.config/mpd/mpd.db" log_file "syslog"</pre>
<p>At this point you should be able to just run</p>
<pre class="wp-block-preformatted">$ mpd</pre>
<p>with no errors, which will start the MPD daemon in the background.</p>
<h2>Using ncmpcpp</h2>
<p>Simply run</p>
<pre class="wp-block-preformatted">$ ncmpcpp</pre>
<p>and you’ll see a ncurses-powered graphical user interface in your terminal.</p>
<p>Press <em>4</em> and you should see your local music library, be able to change the selection using the arrow keys and press <em>Enter</em> to play a song.</p>
<p>Doing this multiple times will create a <em>playlist</em>, which allows you to move to the next track using the <em>></em> button (not the right arrow, the <em>></em> closing angle bracket character) and go back to the previous track with <em><</em>. The + and – buttons increase and decrease volume. The <em>Q</em> button quits ncmpcpp but it doesn’t stop the music. You can play and pause with <em>P</em>.</p>
<p>You can see the current playlist by pressing the <em>1</em> button (this is the default view). From this view you can press <em>i</em> to look at the information (tags) about the current song. You can change the tags of the currently playing (or paused) song by pressing <em>6</em>.</p>
<p>Pressing the \ button will add (or remove) an informative panel at the top of the view. In the top left, you should see something that looks like this:</p>
<pre class="wp-block-preformatted">[------]</pre>
<p>Pressing the <em>r</em>, <em>z</em>, <em>y</em>, <em>R</em>, <em>x</em> buttons will respectively toggle the <em>repeat</em>, <em>random</em>, <em>single</em>, <em>consume</em> and <em>crossfade</em> playback modes and will replace one of the <em>–</em> characters in that little indicator to the initial of the selected mode.</p>
<p>Pressing the <em>F1</em> button will display some help text, which contains a list of keybindings, so there’s no need to write a complete list here. So now go on, be geeky, and play all your music from your terminal!</p>
</div>
https://www.sickgaming.net/blog/2020/02/...d-ncmpcpp/
<div><p>MPD, as the name implies, is a Music Playing Daemon. It can play music but, being a daemon, any piece of software can interface with it and play sounds, including some CLI clients.</p>
<p>One of them is called <em>ncmpcpp</em>, which is an improvement over the pre-existing <em>ncmpc</em> tool. The name change doesn’t have much to do with the language they’re written in: they’re both C++, but <em>ncmpcpp</em> is called that because it’s the <em>NCurses Music Playing Client</em> <em>Plus Plus</em>. </p>
<p> <span id="more-30252"></span> </p>
<h2>Installing MPD and ncmpcpp</h2>
<p>The <em>ncmpmpcc</em> client can be installed from the official Fedora repositories with DNF directly with</p>
<pre class="wp-block-preformatted">$ sudo dnf install ncmpcpp</pre>
<p>On the other hand, MPD has to be installed from the RPMFusion <em>free</em> repositories, which you can enable, <a href="https://rpmfusion.org/Configuration">as per the official installation instructions</a>, by running</p>
<pre class="wp-block-preformatted">$ sudo dnf install https://download1.rpmfusion.org/free/fed...ee-release-$(rpm -E %fedora).noarch.rpm</pre>
<p>and then you can install MPD by running</p>
<pre class="wp-block-preformatted">$ sudo dnf install mpd</pre>
<h2>Configuring and Starting MPD</h2>
<p>The most painless way to set up MPD is to run it as a regular user. The default is to run it as the dedicated <em>mpd</em> user, but that causes all sorts of issues with permissions.</p>
<p>Before we can run it, we need to create a local config file that will allow it to run as a regular user.</p>
<p>To do that, create a subdirectory called <em>mpd</em> in <em>~/.config</em>:</p>
<pre class="wp-block-preformatted">$ mkdir ~/.config/mpd</pre>
<p>copy the default config file into this directory:</p>
<pre class="wp-block-preformatted">$ cp /etc/mpd.conf ~/.config/mpd</pre>
<p>and then edit it with a text editor like <em>vim</em>, <em>nano</em> or <em>gedit</em>:</p>
<pre class="wp-block-preformatted">$ nano ~/.config/mpd/mpd.conf</pre>
<p>I recommend you read through all of it to check if there’s anything you need to do, but for most setups you can delete everything and just leave the following:</p>
<pre class="wp-block-preformatted">db_file "~/.config/mpd/mpd.db" log_file "syslog"</pre>
<p>At this point you should be able to just run</p>
<pre class="wp-block-preformatted">$ mpd</pre>
<p>with no errors, which will start the MPD daemon in the background.</p>
<h2>Using ncmpcpp</h2>
<p>Simply run</p>
<pre class="wp-block-preformatted">$ ncmpcpp</pre>
<p>and you’ll see a ncurses-powered graphical user interface in your terminal.</p>
<p>Press <em>4</em> and you should see your local music library, be able to change the selection using the arrow keys and press <em>Enter</em> to play a song.</p>
<p>Doing this multiple times will create a <em>playlist</em>, which allows you to move to the next track using the <em>></em> button (not the right arrow, the <em>></em> closing angle bracket character) and go back to the previous track with <em><</em>. The + and – buttons increase and decrease volume. The <em>Q</em> button quits ncmpcpp but it doesn’t stop the music. You can play and pause with <em>P</em>.</p>
<p>You can see the current playlist by pressing the <em>1</em> button (this is the default view). From this view you can press <em>i</em> to look at the information (tags) about the current song. You can change the tags of the currently playing (or paused) song by pressing <em>6</em>.</p>
<p>Pressing the \ button will add (or remove) an informative panel at the top of the view. In the top left, you should see something that looks like this:</p>
<pre class="wp-block-preformatted">[------]</pre>
<p>Pressing the <em>r</em>, <em>z</em>, <em>y</em>, <em>R</em>, <em>x</em> buttons will respectively toggle the <em>repeat</em>, <em>random</em>, <em>single</em>, <em>consume</em> and <em>crossfade</em> playback modes and will replace one of the <em>–</em> characters in that little indicator to the initial of the selected mode.</p>
<p>Pressing the <em>F1</em> button will display some help text, which contains a list of keybindings, so there’s no need to write a complete list here. So now go on, be geeky, and play all your music from your terminal!</p>
</div>
https://www.sickgaming.net/blog/2020/02/...d-ncmpcpp/