Raspberry Pi MPD server

Notes about starting fresh on a Raspberry Pi and making a Music Player Daemon (MPD) server out of it.

New image preparation

I did use the Raspberry Pi Imager program and put the base Debian with no desktop environment on the SD card. I did use the customizer to put a user and password on it.

I also have put the MAC in my DHCP server so that the Pi gets a static IP address, and I put an entry in DNS so that IP address maps to the host name I want.

First, an update:

sudo apt-get update

Then I install vim. The default is to use nano, but I like vim.

sudo apt-get install vim -y

Followed by

sudo update-alternatives --config editor

Choice 3 picks vim as my editor.

Followed by turning off Wi-Fi. For music streaming, I only want the Raspberry Pi to be hard-wired into the network.

sudo vim /boot/firmware/config.txt

At the very bottom, I added this to the config.txt file:

dtoverlay=disable-wifi

It goes underneath the [all] section. Then I reboot and log in, and perform

sudo apt update
sudo apt upgrade -y

Now I get to install my favorite aliases and history search keystrokes. These are detailed here.

The next steps are so that I can do ssh from my main machine. I followed this, although I wanted to set a root user password first:

sudo passwd root

Then I mostly followed these steps: New Debian install; ssh and sudo changes

Then I did the ssh-copy-id thing and changed Password Authentication back to no in /etc/ssh/sshd_config

Start with the MPD install

The documentation says that the version of MPD that one can install from the Debian repositories is out of date. I can confirm that.

However, going through those motions sets things up well for later.

apt install mpd -y

Followed by

apt install snapserver -y

The Snapcast server needs to be configured to look to MPD for the sound source.

vim /etc/snapserver.conf

to say:

[stream]  
source = pipe:///tmp/snapfifo?name=MPD

That line was already there, except the name= was default instead of MPD

So later I get to download the latest .tar.xy file, and copy it to the Raspberry Pi. Then:

tar xf mpd-version.tar.xz
cd mpd-version

At this point, I should simply point you at https://mpd.readthedocs.io/en/stable/user.html

There’s a whole bit about apt install meson g++ pkgconf \ and some whole bunches of packages. Then there’s the compile after that. 696 things it compiles.

After all that is done, it is time to update the /etc/mpd.conf file.

This is what mine looks like with the comments stripped out:

music_directory       "/var/lib/mpd/music"
playlist_directory "/var/lib/mpd/playlists"
db_file "/var/lib/mpd/tag_cache"

state_file "/var/lib/mpd/state"
sticker_file "/var/lib/mpd/sticker.sql"

user "mpd"
bind_to_address "0.0.0.0"
port "6600"

auto_update "yes"
auto_update_depth "0"

zeroconf_enabled "yes"
zeroconf_name "Music Player @ %h"

input {
plugin "curl"
}

decoder {
plugin "hybrid_dsd"
enabled "no"
}

decoder {
plugin "wildmidi"
enabled "no"
#config_file "/etc/timidity/timidity.cfg"
}

audio_output {
type "fifo"
encoder "flac"
name "snapserver"
format "48000:16:2"
path "/tmp/snapfifo"
compression "8"
mixer_type "software"
}

filesystem_charset "UTF-8"

Eventually, we get it installed, which includes creating the /var/lib/mpd/music directory. We need that for the next step.

Access to the sound files

This took an edit of /etc/fstab although this is always more difficult than I think it should be.

I did it for Nextcloud, so it is the same thing, kind of. Nextcloud gets read/write access, where this MPD server doesn’t need to be able to write to the sound files or directory.

First, set up a credentials file, with the login name and password:

touch /root/credentials.smb
vim /root/credentials.smb
username=epstein_did_not_kill_himself
password=Apparently-Child-Rape-Is-Okay-If-0.1%-Richest-People-Opt-In-To-Doing-It,Obviously,Because-Otherwise-The-Rapists-Would-Have-Gone-To-Jail

Then we can edit /etc/fstab

//hostname/smbsharename/data /var/lib/mpd/music cifs vers=3.0,credentials=/root/credentials.smb,_netdev,iocharset=utf8 0 0

One thing that kicked my ass for a couple of hours:

vim /usr/local/lib/systemd/system/mpd.service

And on the ExecStart line, I had to explicitly add the configuration file path and file name.

So before, it looked like this:

ExecStart=/usr/local/bin/mpd --systemd

But that would err out with “could not find config file”. I changed it to this:

ExecStart=/usr/local/bin/mpd --systemd /etc/mpd.conf

And now it magically works. Of course, yesterday the first time I set it up, I had no such problems. Sigh.

I still have one more thing to add: Snapweb, where Snapcast server will show you what is currently running. I had that running yesterday, and liked it.

Home alarm clock update

I am delighted with my current home alarm clock setup.

I have the Morefine M8S N100 Alder Lake PC running Fedora Workstation KDE Spin. It is cabled into an OLED television set. I use the remote on the TV: settings > energy saving > panel > turn the panel completely off.

The Morefine M8S stands out in that crowd of machines for having active cooling, but running quiet. At the moment, they are on sale with 12 GB RAM and a 128 GB NVME drive for $170.

A full kit Raspberry Pi isn’t that much less, doesn’t have full size HDMI, isn’t running Intel hardware (super Linux compatible) and they do have that nasty problem of writing /var/log to the SD card, burning it out. The newer Pi can do an NVME drive, but that’s going to drive the cost up close to the M8S. But I digress.

The tuner part of the TV stays on all the time. The M8S is cabled to the TV via an HDMI cable. Although the OLED panel is off, the tuner keeps the HDMI port active, so the M8S doesn’t disconnect or try to rejigger the display when the panel is turned off for sleep mode.

Previously, to connect to the sound bar, I used Bluetooth, bypassing the TV. This was not great. Specifically, Bluetooth wants to disconnect if not streaming, and Linux doesn’t want to play with an audio source that isn’t there. Sure, there are kludgy ways to get it to light up for a sound, but this is clearly paddling upstream for drudgery and debt.

But I saw the Toslink optical S/PDIF connector on the sound bar, and the lightbulb went on. Feed everything in to the TV over HDMI, and feed the audio from the TV to the sound bar over Toslink. We’re back to fun and profit. Well, fun, at least.

This is working out great.

The M8S is a Nextcloud client, so it has access to my audio files directory, and via the web, the Music app player.

KAlarm on the M8S runs VideoLAN Client (VLC) headless, pointing at the audio file (or for waking up, a .pls playlist file). I have seven .pls files for seven days of the week.

I also happen to have my source files for iPhone ringtones in Nextcloud, so when I want a short alarm sound, I’ve got a passel of those available.

KAlarm lets me set schedules for every Sunday of the month. I happen to need a different schedule for the second Sunday, where the first, third, fourth, and fifth are a normal schedule.

What is super nice is that I can have Nextcloud playing music at a low volume, but when VLC kicks in, it plays at the normal volume. They don’t interrupt each other, they simply multiplex.

Lastly, I’ve been playing with Coqui TTS (text-to-speech), so sometimes the sound being played by KAlarm is a feminine Scottish voice saying “Do daily inventory”. 🙂

Next, I want to generate Westminster Chimes sound files, and have it play those on the hour. It would be fun to generate the sound file on-the-fly, starting with the announcement chime and then Coqui TTS saying “Seven” or “Noon” or “Thirteen hundred”.

A future project I have in mind is to write a Perl script to pull down my calendar out of Nextcloud, and then write entries into the KAlarm file for special events.

Also, I wouldn’t mind turning the M8S (and my other machines) into Snapcast clients.

Fun indeed.

The surveillance state makes things screwy

One of my volunteer service opportunities is to record speakers at meetings and then put the recordings on a website. I use the Sony ICD-UX570 Digital Voice Recorder, which I’ve talked about before. I take the MP3 file and edit it using Audacity, trimming off everything before and after the speaker. Then I export the audio with a smaller bitrate to make a smaller file. Lastly, I rename it and upload it.

Today, a friend called me, and asked if I could burn a recording to CD. His friend, the gentleman who spoke, is almost 80 years old, and he would be best served with a physical CD – none of this Podcast Feed nonsense or USB stick which his truck may or may not be able to use. Sure, I said. This should be easy.

Okay, first I tried Fedora Workstation KDE Spin and got errors. I tried Brasero first, but it was super grumpy. Then I tried K3B which is my old favorite, and it was grumpy too.

I gave up and went to a Windows laptop. Did I want to use Microsoft Windows Media Player or Apple iTunes?

I went with iTunes because I’m not a fan of anything Microsoft.

Freaking iTunes worked, but….

What the hell is the name on this CD?

audiocd:/Philip Kerr – 01 – Game Over – Track 01.wav?device=/dev/sr0

At 80 years old, I’d be acutely aware of my mortality.

Oh! That is certainly what I want this 80-year-old man to see when he pops this gift CD into his truck CD player display:

Philip Kerr - 01 - Game Over

If I’m him, there’s no way I don’t think to myself: What the hell? And then he’d have to say some Hail Mary’s to apologize to God for the cursing.

This gentleman’s name is not Philip Kerr. I did write his name in the various properties fields in iTunes. None of those appear to have come over.

I know that the music industry wants to keep tabs on every sound file ever, so they can in theory collect royalties. But this was my recording, done live and in-person.

This is just screwy.

And apparently, this isn’t a problem on the CD, it is a problem in Fedora. I didn’t know that yet. All I got was the Orwellian vibes.


Okay, back to Fedora KDE Spin.

Ooooooooffffffff.

Thank goodness for Perplexity.AI. It turns out to only be an 8 step problem.

One: Check group memberships – must be a member of cdrom – I’m good

Two: Adjust K3B settings

K3B > Settings > Configure K3B > Programs > Permissions > Change Permissions > Apply

Three: Add a system policy

sudo vim /etc/polkit-1/rules.d/85-cdrecord.rules
polkit.addRule(function(action, subject) {
if (action.id == "org.freedesktop.udisks2.filesystem-mount-system" &&
subject.isInGroup("cdrom")) {
return polkit.Result.YES;
}
});

Four: Restart services

sudo systemctl restart polkit

Five: Update udev rules

sudo vim /etc/udev/rules.d/99-cd-burner.rules
SUBSYSTEM=="block", KERNEL=="sr[0-9]*", MODE="0660", GROUP="cdrom"

Six: Reload udev rules

sudo udevadm control --reload-rules

Seven: reboot the computer.

Eight: try to burn the CD with K3B.

Thank goodness it worked.

I had forgotten that CDs are as small as they are. The older gentleman actually had two recordings on file, one for 45 minutes and another for 55 minutes. That’s too much for a single audio CD. Heh.

Text-to-speech notes

This is simply for my own notes, on how to do Coqui text-to-speech

Initial setup required this:

python -m venv tts_env
source tts_env/bin/activate
pip install --upgrade pip
pip install coqui-tts

Subsequent invocations needed only this:

python -m venv tts_env
source tts_env/bin/activate

tts --text "Insert text here" --model_name tts_models/en/jenny/jenny --pipe_out --out_path /home/path/to/tts_output/whatever.wav | aplay


How to make (whatever) Linux have a nice bash shell with my favorite aliases

This is a newer version of my post How to make Ubuntu have a nice bash shell like OpenSuSE which should supersede it. I keep coming back to this topic, and think that the right way to do this is:

touch ~/.bash_aliases
vim ~/.bash_aliases
alias ll='ls -la'
alias ..='cd ..'

And then alter .bashrc to include this aliases file:

vim ~/.bashrc

At the end of the file, insert this:

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

Finally, reload bash with this:

source ~/.bashrc

The other change I always make is to edit /etc/inputrc and make the history search keys the PgUp key.

sudo vim /etc/inputrc

Find # "\e[5~": history-search-backward and uncomment it

New Fedora KDE Spin: re-do power saving setting

There is a bug in my AMD Ryzen 1700 which manifests on Linux during power sleep states. Now that I’m on Fedora KDE Spin, I need to implement it again. Fedora KDE Spin does startup scripts a little differently than the previous systems I’ve used before.

Previously, I’d used /etc/init.d/

Well, Fedora KDE Spin doesn’t use that; it uses Systemd and systemctl

As root:

cd /etc/systemd/system

vim set_c6_acpi_state_disabled.service

Paste in the following:

[Unit]
Description=Set C6 ACPI State Disabled
After=network.target

[Service]
Type=simple
ExecStart=/usr/bin/python3 /home/bazoozle/zenstates.py --c6-disable

[Install]
WantedBy=multi-user.target

Technically, I don’t need to wait until after the network is started to run the zenstates.py python script. But it isn’t obvious what would be the equivalent to @reboot in a crontab.

Then we do this:

systemctl start set_c6_acpi_state_disabled.service

systemctl enable set_c6_acpi_state_disabled.service

Migrated from Manjaro to Fedora KDE Spin on my main machine

Around six months ago, I migrated my main machine to Manjaro, as mentioned here. I liked it, and I liked it enough that I also switched to using it as my home media PC / alarm clock.

It has been great, using it as my alarm clock. I don’t think I’ve been happier with my alarm clock setup, ever. The interface of using KAlarm is super easy, and as a proper calendar ought to, it can handle “second Sunday of the month” or “on the 15th of the month” events (for example). That Manjaro hooks into the high-quality audio on the soundbar I use on my television, makes the music it plays a joy to wake up to.

Alas, on my main machine, I drive Manjaro harder, and it crashes.

Of course, I have a lot more installed on my main machine. I do more with ImageMagick, Tesseract OCR, The GIMP, Kdenlive, and Mozilla Thunderbird. Although I have webmail, my primary interface to my mail server is Thunderbird. I like Thunderbird enough that I do a monthly donation to the project to help keep it going.

Both machines have the Nextcloud client on them; that’s how I get the MP3 files to the alarm clock PC. But I tend to do more file organizing on my main machine than on the alarm clock PC.

I don’t do Discord on the alarm clock PC, and I do on my main PC.

The problem I was experiencing with Manjaro was that I’d click on something, and then Manjaro would crash to reboot.

The crash to reboot would happen maybe twice or thrice a week. This last Sunday, it did again, and that was the straw that broke the camel’s back, so-to-speak.

What to move to? Although OpenSuSE has always been super stable, I still dislike how woke they’ve gone. Also, the last time I tried to install from an ISO of theirs, there was definitely something broken in the image.

I decided to try the Fedora KDE Spin. So far, I like it. It did present a couple of problems, however.

The first was that after I rebooted, I changed /home to mount to my second hard drive and I rebooted again. I could not log in as me. I could log in as root, but attempting to log in as me failed. In the journalctl the message was that an attempt to cd to my home drive failed, due to permissions.

I was fortunate that (logged in as root) the very first search I did found a Stack Overflow article which showed that the /home ownership had the wrong owner. I wish I could find that article now, so I could link to it. Anyway, the solution was:

restorecon -Rv /home

from the command line. I was already logged in as root, so I didn’t need sudo. If I could have gotten logged in as me, I wouldn’t have needed restorecon.

The second problem was that Firefox does not come with all the codecs for playing multimedia preinstalled. Manjaro did this beautifully. OpenSuSE is like Fedora this way, but it is easier to solve on OpenSuSE.

I ended up having to do a Firefox Refresh, which is less than fun. All my Multi-Account Containers now need to be redone, and I have a lot of them.

There are only two things that I don’t like about moving to this Fedora KDE spin.

One is that I have two monitors, and every time I move the mouse between them, something in KDE Plasma wants to “stick” the mouse cursor to the boundary between the two. I have to push the mouse an extra bit, to push past the current monitor and to the next one. I haven’t taken the time to find out if there is an easy fix for this, but I suspect that there is.

The other is that in Thunderbird, apparently Tools > Message Filters are stored in the Thunderbird directory and not in my user profile. This isn’t Fedora’s fault; it is something in Thunderbird.

I did choose to install the non-Flatpak version of Thunderbird, because I don’t like Flatpak. I have no idea if me keeping everything in my /home on a separate hard drive plays nice with Flatpak. Admittedly, I have not done the research. But it seems to me that when one changes distributions with significantly different packaging (rpm versus deb versus tar) that Flatpak would be a problem. I don’t know, but I doubted that Flatpak was the universal image for all Linux’s forever. Wasn’t Snap supposed to be that? (I don’t like Snap, either).

Anyway, I had more than 30 message filters, some with 20 email addresses in them, for filtering my mail into folders. Those message filters are gone. Rats!


I am thrilled to find the Thunderbird Add-On quickFilters which is delightful.


I do like how Fedora KDE Spin puts the OK and Open buttons in the upper-right corner of dialog boxes instead of the lower right.

I’m giving up on Apple HomeKit

My setup for Apple HomeKit was an iPad, a HomePod Mini, and my personal iPhone. The iPad was where I would configure Shortcuts > Automation > Personal Automation, which would light up Bluetooth and play playlists. My goal was to replace my Amazon gear as my home alarm clock. The Amazon Echo system started well, but enshitification happened, and I removed all that gear from my life.

The HomeKit solution mostly worked, except when it didn’t. The iPad would, once in a while, simply register an error instead of doing the automation task. It can be a real bummer when your alarm clock doesn’t go off. I lived with the poor behavior because it only happened every week or two or so. But I had a nagging feeling that long term, this is not going to be acceptable to me. Computers can be reliable, and I’m not willing to pay Apple’s price for an Apple TV. I think I confused the Mac Mini with the Apple TV; the Apple TV is about the same price as what I went with later.

Speaking of which, I’ve abandoned the low quality competitor, too: my Roku Ultra is powered off and headed for the scrap heap.

The thing that kicked my ass into gear on abandoning HomeKit was the most recent upgrade of iPadOS. I forget if it was 18.1 or 18.2, but after the upgrade, all my playlists were empty. The MP3 files are still on the iPad, but the playlists I’d programmed into Apple Music were empty. Would I like to add my music from the Apple iTunes store? Go kick rocks. I copied the MP3 files to the box for a reason.

So now I have a choice: recreate the playlists on a box I don’t think is going to work out in the long run, or, start over on something new.

I chose to start over on something new.

Nicely enough, my brother gave me a great Christmas gift last year: the Morefine M8S N100 Alder Lake PC. My brother specifically looked for one of these because a reviewer he listens to said this small form factor PC is one of the quietest boxes with active cooling, and specifically is Linux compatible. I wiped Windows off of it and installed Manjaro Linux, just like my main desktop. The HDMI on it drives my television (monitor) and I use Bluetooth to connect to the soundbar.

As mentioned in the Home alarm clock: no progress post, I’m not having success running it headless. So why not go whole hog in the other direction? I have a work-around: turn the display panel off. I have to use the TV remote to pull up the menu which lets me power down the display panel. If I want to see the screen again, I use the remote. Other than that, the Morefine M8S is a normal Linux desktop driving a television set, and the television set never turns off (well, the electronics driving the tuner / HDMI ports, at least). This also lets me use Rumble as a YouTube replacement, with a wireless mouse and keyboard from my bed. But I digress.

I’m using KAlarm to run commands on a schedule. The commands are:

vlc --intf dummy /path/to/music/playlist.file

And so far, it hasn’t failed to play an alarm yet.

A bonus feature I didn’t expect: the alarm music sounds better. Of course it does, an iPad playing an MP3 to a soundbar doesn’t do 5.1 stereo; but Manjaro on the Morefine M8S does know how to send that type of stream over Bluetooth. My guess is that Apple was nerfing the MP3s in favor of AAC from the Apple iTunes store; I don’t know. But I do know that the new setup simply sounds way better.

And a future bonus feature will be that I could write a Perl script to replace the contents of the .pls or .m3u files if a desire for variety should strike me.

The only downside has been that the HomePod Mini is now kind of useless. It was nice, having the automation on the iPad to be able to play something in either the soundbar in my bedroom (mornings and evenings) or the HomePod Mini in the living room near my main PC (lunch break times).

I am going to flash a Raspberry Pi with Homebridge, but I don’t know if that will let me send a VLC stream to the HomePod.

Still, I have a great setup for watching Rumble or such while I fold my laundry, listen to a podcast to fall asleep to, and I have faith that my alarms will no longer fail me.

Manjaro fresh install – oof, things changed

I’m playing the new Factorio Space Age game, and so far I like it. One thing that has bothered me though is that it is not as smooth on Manjaro as it was on OpenSuSE. So I went looking for tweaks to fix things, and even get to a point where gamemode doesn’t work (cannot adjust CPU speed), and that may be due to a missing BIOS upgrade. Wow, talk about going down the rabbit hole.

Previously, I would install an OS, then mount my second hard drive as /home, and reboot. With this process, all the software I install later is pre-configured: they already have their config files in place from the previous OS.

One of the changes I made was to switch from legacy BIOS mode to UEFI BIOS mode. So I thought that a complete fresh installation of Manjaro was the best chance for success.

I did install some software prior to mounting my second hard drive as /home.

Things went pretty well, except for one thing: Manjaro uses Z shell (Zsh) instead of bash. Man, Zsh broke a lot of the terminal I use (Konsole).

When I tried to uninstall Z shell in the package manager, it barked at me with “removing zsh breaks dependency 'zsh' required by manjaro-zsh-config

Okay, I uninstalled manjaro-zsh-config first.

Then trying to uninstall Z shell barks at me with “removing zsh breaks dependency 'zsh' required by manjaro-kde-settings“. Sigh. This will likely get rid of more than I’d like it to, but here I go….

Although I have successfully uninstalled Z shell, my terminal key bindings are still all fucked up. The <home> key doesn’t take me to the beginning of the line; the <end> key doesn’t take me to the end of the line. Sometimes the <end> key inserts a tilde (the ~ key).

Logged in as root, this sets me back to (a) default:

cat > /etc/inputrc << "EOF"
# Begin /etc/inputrc

# Make sure we don't output everything on the 1 line
set horizontal-scroll-mode Off

# Enable 8bit input
set meta-flag On
set input-meta On

# Turns off 8th bit stripping
set convert-meta Off

# Keep the 8th bit for display
set output-meta On

# none, visible or audible
set bell-style none

# All of the following map the escape sequence of the
# value contained inside the 1st argument to the
# readline specific functions

"\eOd": backward-word
"\eOc": forward-word

# for linux console
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert

# End /etc/inputrc
EOF

Bad news is, I’m still getting nothing for the <home> key, and a tilde for the <end> key.

And I cannot tell why. Clearly, something other than /etc/inputrc and ~./bashrc are at play here.

I did get switched to Wayland, instead of X11. Factorio does seem smoother now. That is what I really wanted.

A web page, scrolling quickly (Firefox on Amazon), did spontaneously crash to reboot. Oof, that’s bad. Thankfully, I didn’t have anything else running which suffers from catastrophic failure of a spontaneous reboot.

Proxmox copy of WordPress virtual machine – changing the siteurl

I’ve gone into Proxmox and cloned a WordPress machine to a new machine. I configured DNS and DHCP to assign a new host name for the machine; now I need to get WordPress to understand that too.

Because WordPress stores the site URL inside the database, this means running a MySQL query.

The problem is that the old WordPress site (because that is what is in the new machine’s database) keeps telling Apache to serve up the pages from the old machine. So everything on the new machine will need to resolve at https://tratest.example.com but because WordPress is going to its database to find out where everything is, as soon as the page loads, it tries to go to https://aawp.example.com

That machine is powered off in Proxmox, so obviously nothing works.

Can’t really use any tools inside WordPress to do the search-and-replace, so I need something outside of WordPress. I generally do not install phpMyAdmin, because 1) it is extra work to configure Apache to serve up a different website just for this one function, and 2) that becomes just one more place a bored 14 year old might try to break in. If I don’t need it, why put it out there?

So let’s try some MySQL queries from the command line.

UPDATE wp_options SET option_value = replace(option_value, 'https://aawp.example.com', 'https://tratest.example.com') WHERE option_name = 'home' OR option_name = 'siteurl';

Nice! I did a restart of Apache, and now the new machine at the new domain name serves up the content from the cloned machine. I know that this worked because the old machine in Proxmox is still powered off.

There are also several other changes I made:

  • hostnamectl set-hostname tratest.example.com
  • edited /etc/hosts and copied the 127.0.1.1 entry to 127.0.2.1 and added the new host name, per Change host name and domain
  • edited the Apache .conf file in /etc/apache2/sites-available/ and replaced the ServerName entry