23 lines
680 B
Nix
23 lines
680 B
Nix
{pkgs, ...}: let
|
|
mpd-server = "hetzner-vm.tailscale-internal.genderfucked.monster";
|
|
sync-with-mpd-server = pkgs.writeShellScriptBin "sync-with-mpd-server" ''
|
|
#!/usr/bin/env bash
|
|
set -x
|
|
|
|
vmMpc() {
|
|
mpc -h "$(cat /secrets/mpd-password)@${mpd-server}" "$@"
|
|
}
|
|
|
|
#mpc clear
|
|
POSITION=$(vmMpc status -f "%position%" | head -n 1)
|
|
CURRENT_TIMESTAMP=$(vmMpc status | awk '/^\[playing\]/ { sub(/\/.+/,"",$3); split($3,a,/:/); print a[1]*60+a[2] }')
|
|
|
|
mpc clear
|
|
mpc rescan
|
|
vmMpc -f "%file%" playlist | mpc add
|
|
mpc play "$POSITION"
|
|
mpc seek "$CURRENT_TIMESTAMP"
|
|
mpc play
|
|
'';
|
|
in {environment.systemPackages = [sync-with-mpd-server];}
|