aboutsummaryrefslogtreecommitdiffstats
path: root/pkgs/by-name
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-02-19 22:34:52 +0100
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-02-19 22:34:52 +0100
commit39a32c23f630dffbe1e5ce20c23149a9a518132e (patch)
treebe031c2b1ea22501cea8a6da33245924ad2c8e00 /pkgs/by-name
parentpkgs/mpdpopmd: Remove last remnant of channel config from config file (diff)
downloadnixos-config-39a32c23f630dffbe1e5ce20c23149a9a518132e.zip
pkgs/mpdpopmd: Allow starting automatically in DJ mode
Diffstat (limited to '')
-rw-r--r--pkgs/by-name/mp/mpdpopm/config.lsp1
-rw-r--r--pkgs/by-name/mp/mpdpopm/src/config.rs15
-rw-r--r--pkgs/by-name/mp/mpdpopm/src/lib.rs2
-rw-r--r--pkgs/by-name/mp/mpdpopm/src/messanges/mod.rs14
4 files changed, 29 insertions, 3 deletions
diff --git a/pkgs/by-name/mp/mpdpopm/config.lsp b/pkgs/by-name/mp/mpdpopm/config.lsp
index 0e9b587d..d3471a05 100644
--- a/pkgs/by-name/mp/mpdpopm/config.lsp
+++ b/pkgs/by-name/mp/mpdpopm/config.lsp
@@ -4,6 +4,7 @@
"path": "/run/user/1000/mpd/socket"
}
},
+ "mode": "Dj",
"local_music_dir": "/home/soispha/media/music/beets",
"log": "/home/soispha/.local/share/mpdpopm/log",
"version": "1"
diff --git a/pkgs/by-name/mp/mpdpopm/src/config.rs b/pkgs/by-name/mp/mpdpopm/src/config.rs
index 13a1891b..8bb5abfb 100644
--- a/pkgs/by-name/mp/mpdpopm/src/config.rs
+++ b/pkgs/by-name/mp/mpdpopm/src/config.rs
@@ -116,6 +116,17 @@ mod test_connection {
}
}
+/// THe possible start-up mode.
+#[derive(Default, Deserialize, Debug, Serialize)]
+pub enum Mode {
+ #[default]
+ /// Don't do anything special
+ Normal,
+
+ /// Already start the DJ mode on start-up
+ Dj,
+}
+
/// This is the most recent `mppopmd` configuration struct.
#[derive(Deserialize, Debug, Serialize)]
#[serde(default)]
@@ -133,6 +144,9 @@ pub struct Config {
/// How to connect to mpd
pub conn: Connection,
+ /// The mode to start in
+ pub mode: Mode,
+
/// The `mpd' root music directory, relative to the host on which *this* daemon is running
pub local_music_dir: PathBuf,
@@ -159,6 +173,7 @@ impl Config {
local_music_dir: [PREFIX, "Music"].iter().collect(),
played_thresh: 0.6,
poll_interval_ms: 5000,
+ mode: Mode::default(),
})
}
}
diff --git a/pkgs/by-name/mp/mpdpopm/src/lib.rs b/pkgs/by-name/mp/mpdpopm/src/lib.rs
index 6cc47807..a69beeb2 100644
--- a/pkgs/by-name/mp/mpdpopm/src/lib.rs
+++ b/pkgs/by-name/mp/mpdpopm/src/lib.rs
@@ -93,7 +93,7 @@ pub async fn mpdpopm(cfg: Config) -> std::result::Result<(), Error> {
.context("Failed to connect to TCP idle client")?,
};
- let mut mqueue = MessageQueue::new();
+ let mut mqueue = MessageQueue::new(cfg.mode);
idle_client
.subscribe(COMMAND_CHANNEL)
diff --git a/pkgs/by-name/mp/mpdpopm/src/messanges/mod.rs b/pkgs/by-name/mp/mpdpopm/src/messanges/mod.rs
index c5320dd9..ac0b9cbe 100644
--- a/pkgs/by-name/mp/mpdpopm/src/messanges/mod.rs
+++ b/pkgs/by-name/mp/mpdpopm/src/messanges/mod.rs
@@ -5,6 +5,7 @@ use tracing::info;
use crate::{
clients::{Client, IdleClient},
+ config::Mode,
dj::{Dj, algorithms::Discovery},
};
@@ -35,8 +36,17 @@ pub(crate) struct MessageQueue {
}
impl MessageQueue {
- pub(crate) fn new() -> Self {
- Self { dj: None }
+ pub(crate) fn new(mode: Mode) -> Self {
+ match mode {
+ Mode::Normal => Self { dj: None },
+ Mode::Dj => {
+ info!("Dj mode started on launch, as specified in config file");
+
+ Self {
+ dj: Some(Dj::new(Discovery::new(0.65, 0.5, 0.2))),
+ }
+ }
+ }
}
pub(crate) async fn advance_dj(&mut self, client: &mut Client) -> Result<()> {