summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/fi/fish-mk-maps
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/fi/fish-mk-maps')
-rw-r--r--pkgs/by-name/fi/fish-mk-maps/.envrc21
-rw-r--r--pkgs/by-name/fi/fish-mk-maps/.gitignore16
-rw-r--r--pkgs/by-name/fi/fish-mk-maps/Cargo.lock294
-rw-r--r--pkgs/by-name/fi/fish-mk-maps/Cargo.toml32
-rw-r--r--pkgs/by-name/fi/fish-mk-maps/package.unstable.nix29
-rw-r--r--pkgs/by-name/fi/fish-mk-maps/src/main.rs362
-rwxr-xr-xpkgs/by-name/fi/fish-mk-maps/update.sh14
7 files changed, 768 insertions, 0 deletions
diff --git a/pkgs/by-name/fi/fish-mk-maps/.envrc b/pkgs/by-name/fi/fish-mk-maps/.envrc
new file mode 100644
index 00000000..0001f149
--- /dev/null
+++ b/pkgs/by-name/fi/fish-mk-maps/.envrc
@@ -0,0 +1,21 @@
+#!/usr/bin/env sh
+
+# Mpdpopm - A mpd rating tracker
+#
+# Copyright (C) 2026 Benedikt Peetz, Michael Herstine <sp1ff@pobox.com> <benedikt.peetz@b-peetz.de, sp1ff@pobox.com>
+# SPDX-License-Identifier: AGPL-3.0-or-later
+#
+# This file is part of Mpdpopm.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/agpl.txt>.
+
+source_env_if_exists ./.nenvrc
+
+PATH_add ./scripts
+PATH_add ./target/debug/
+PATH_add ./target/release/
+
+if on_git_branch; then
+ echo && git status --short --branch
+fi
diff --git a/pkgs/by-name/fi/fish-mk-maps/.gitignore b/pkgs/by-name/fi/fish-mk-maps/.gitignore
new file mode 100644
index 00000000..c80d7eef
--- /dev/null
+++ b/pkgs/by-name/fi/fish-mk-maps/.gitignore
@@ -0,0 +1,16 @@
+# Mpdpopm - A mpd rating tracker
+#
+# Copyright (C) 2026 Benedikt Peetz, Michael Herstine <sp1ff@pobox.com> <benedikt.peetz@b-peetz.de, sp1ff@pobox.com>
+# SPDX-License-Identifier: AGPL-3.0-or-later
+#
+# This file is part of Mpdpopm.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/agpl.txt>.
+
+# build
+/target
+/result
+
+# dev env
+.direnv
diff --git a/pkgs/by-name/fi/fish-mk-maps/Cargo.lock b/pkgs/by-name/fi/fish-mk-maps/Cargo.lock
new file mode 100644
index 00000000..9ae541e2
--- /dev/null
+++ b/pkgs/by-name/fi/fish-mk-maps/Cargo.lock
@@ -0,0 +1,294 @@
+# This file is automatically @generated by Cargo.
+# It is not intended for manual editing.
+version = 4
+
+[[package]]
+name = "anstream"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "824a212faf96e9acacdbd09febd34438f8f711fb84e09a8916013cd7815ca28d"
+dependencies = [
+ "anstyle",
+ "anstyle-parse",
+ "anstyle-query",
+ "anstyle-wincon",
+ "colorchoice",
+ "is_terminal_polyfill",
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle"
+version = "1.0.14"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "940b3a0ca603d1eade50a4846a2afffd5ef57a9feac2c0e2ec2e14f9ead76000"
+
+[[package]]
+name = "anstyle-parse"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "52ce7f38b242319f7cabaa6813055467063ecdc9d355bbb4ce0c68908cd8130e"
+dependencies = [
+ "utf8parse",
+]
+
+[[package]]
+name = "anstyle-query"
+version = "1.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "40c48f72fd53cd289104fc64099abca73db4166ad86ea0b4341abe65af83dadc"
+dependencies = [
+ "windows-sys",
+]
+
+[[package]]
+name = "anstyle-wincon"
+version = "3.0.11"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "291e6a250ff86cd4a820112fb8898808a366d8f9f58ce16d1f538353ad55747d"
+dependencies = [
+ "anstyle",
+ "once_cell_polyfill",
+ "windows-sys",
+]
+
+[[package]]
+name = "anyhow"
+version = "1.0.105"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2cb931c189b85683d69a5cfad41d4d418671e1ac413dd209f3f2fc31e3cfd902"
+
+[[package]]
+name = "bind"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "clap",
+ "keymaps",
+ "serde",
+ "serde_json",
+ "shlex",
+]
+
+[[package]]
+name = "clap"
+version = "4.6.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "50066ca966813ca8957ee15361752f19424a8ff620dbe9c8993d9f99d99b04b3"
+dependencies = [
+ "clap_builder",
+ "clap_derive",
+]
+
+[[package]]
+name = "clap_builder"
+version = "4.6.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a0ed97c96ef4efb3cc84e09fa388df4463e7cc3224ec38d7b1d9e45749333590"
+dependencies = [
+ "anstream",
+ "anstyle",
+ "clap_lex",
+ "strsim",
+]
+
+[[package]]
+name = "clap_derive"
+version = "4.6.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b4c174f11f949b9ca8c60580925e282b9cbd5454750e506f08648b2038080cd7"
+dependencies = [
+ "heck",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "clap_lex"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e0921b3876b3a1df8a1c9f912e7f94342458022c2e84288015893d83c4d62a79"
+
+[[package]]
+name = "colorchoice"
+version = "1.0.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1d07550c9036bf2ae0c684c4297d503f838287c83c53686d05370d0e139ae570"
+
+[[package]]
+name = "heck"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
+
+[[package]]
+name = "is_terminal_polyfill"
+version = "1.70.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a6cb138bb79a146c1bd460005623e142ef0181e3d0219cb493e02f7d08a35695"
+
+[[package]]
+name = "itoa"
+version = "1.0.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
+
+[[package]]
+name = "keymaps"
+version = "1.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ea59e8e461942cf1d6a7ad938848d6fd2e40eb43799c21192c09226ecc86710f"
+dependencies = [
+ "serde",
+ "thiserror",
+]
+
+[[package]]
+name = "memchr"
+version = "2.8.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
+
+[[package]]
+name = "once_cell_polyfill"
+version = "1.70.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
+
+[[package]]
+name = "proc-macro2"
+version = "1.0.107"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
+dependencies = [
+ "unicode-ident",
+]
+
+[[package]]
+name = "quote"
+version = "1.0.47"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
+dependencies = [
+ "proc-macro2",
+]
+
+[[package]]
+name = "serde"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"
+dependencies = [
+ "serde_core",
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_core"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
+dependencies = [
+ "serde_derive",
+]
+
+[[package]]
+name = "serde_derive"
+version = "1.0.229"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "serde_json"
+version = "1.0.154"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6"
+dependencies = [
+ "itoa",
+ "memchr",
+ "serde",
+ "serde_core",
+ "zmij",
+]
+
+[[package]]
+name = "shlex"
+version = "2.0.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
+
+[[package]]
+name = "strsim"
+version = "0.11.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
+
+[[package]]
+name = "syn"
+version = "3.0.10"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "unicode-ident",
+]
+
+[[package]]
+name = "thiserror"
+version = "2.0.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
+dependencies = [
+ "thiserror-impl",
+]
+
+[[package]]
+name = "thiserror-impl"
+version = "2.0.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "unicode-ident"
+version = "1.0.27"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
+
+[[package]]
+name = "utf8parse"
+version = "0.2.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
+
+[[package]]
+name = "windows-link"
+version = "0.2.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
+
+[[package]]
+name = "windows-sys"
+version = "0.61.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
+dependencies = [
+ "windows-link",
+]
+
+[[package]]
+name = "zmij"
+version = "1.0.23"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
diff --git a/pkgs/by-name/fi/fish-mk-maps/Cargo.toml b/pkgs/by-name/fi/fish-mk-maps/Cargo.toml
new file mode 100644
index 00000000..83e3673f
--- /dev/null
+++ b/pkgs/by-name/fi/fish-mk-maps/Cargo.toml
@@ -0,0 +1,32 @@
+# Mpdpopm - A mpd rating tracker
+#
+# Copyright (C) 2026 Benedikt Peetz, Michael Herstine <sp1ff@pobox.com> <benedikt.peetz@b-peetz.de, sp1ff@pobox.com>
+# SPDX-License-Identifier: AGPL-3.0-or-later
+#
+# This file is part of Mpdpopm.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/agpl.txt>.
+
+[package]
+name = "bind"
+version = "0.1.0"
+edition = "2024"
+license = "AGPL-3.0-or-later"
+homepage = ""
+repository = "https://git.vhack.eu/bpeetz/nixos-config"
+authors = ["Benedikt Peetz", "Mechael Herstine"]
+keywords = ["mpd", "music", "daemon"]
+categories = ["multimedia", "network-programming", "database"]
+
+[dependencies]
+clap = { version = "4.6", features = ["derive"] }
+anyhow = "1.0.105"
+shlex = "2.0.1"
+serde = { version = "1.0.229", features = ["derive"] }
+serde_json = "1.0.154"
+keymaps = { version = "1.2.0", features = [
+ "serde",
+ "mouse-keys",
+ "modifier-keys",
+] }
diff --git a/pkgs/by-name/fi/fish-mk-maps/package.unstable.nix b/pkgs/by-name/fi/fish-mk-maps/package.unstable.nix
new file mode 100644
index 00000000..7048f41e
--- /dev/null
+++ b/pkgs/by-name/fi/fish-mk-maps/package.unstable.nix
@@ -0,0 +1,29 @@
+# nixos-config - My current NixOS configuration
+#
+# Copyright (C) 2025 Benedikt Peetz <benedikt.peetz@b-peetz.de>
+# SPDX-License-Identifier: GPL-3.0-or-later
+#
+# This file is part of my nixos-config.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
+{
+ rustPlatform,
+ lib,
+}:
+rustPlatform.buildRustPackage (finalAttrs: {
+ pname = "mpdpopm";
+ version = "0.1.0";
+
+ buildInputs = [];
+ nativeBuildInputs = [];
+
+ src = ./.;
+ cargoLock = {
+ lockFile = ./Cargo.lock;
+ };
+
+ meta = {
+ mainProgram = "mpdpopm";
+ };
+})
diff --git a/pkgs/by-name/fi/fish-mk-maps/src/main.rs b/pkgs/by-name/fi/fish-mk-maps/src/main.rs
new file mode 100644
index 00000000..57d221db
--- /dev/null
+++ b/pkgs/by-name/fi/fish-mk-maps/src/main.rs
@@ -0,0 +1,362 @@
+use std::{
+ collections::HashMap,
+ env::args,
+ fs,
+ io::{Read, Write},
+ mem,
+ os::unix::net::{UnixListener, UnixStream},
+ path::PathBuf,
+ process,
+ str::FromStr,
+};
+
+use anyhow::{Context, bail};
+use clap::Parser;
+use keymaps::map_tree::Trie;
+use serde::{Deserialize, Serialize};
+
+macro_rules! is_open {
+ ($is_open:ident, @set_element $value:ident[$idx:expr]) => {{
+ if let Some(value) = $value.get($idx - 1) && $value.len() > $idx {
+ if let Some(io) = &mut $is_open {
+ io.truncate($idx);
+ io.push(value.clone());
+ println!("{}\"{}\" = {{", " ".repeat($idx + 1), value);
+
+ eprintln!("Setting io element {} to '{}' (io: '{}')", $idx, value, io.join(","));
+ } else if $idx == 1 {
+ $is_open = Some(vec![value.clone()]);
+ println!(" \"{}\" = {{", value);
+
+ eprintln!("Initializing io with element '{}'", value);
+ } else {
+ unreachable!()
+ }
+ }
+ }};
+ ($is_open:ident, @query $value:ident [..$till:expr]) => {{
+ if $value.len() <= $till {
+ false
+ } else {
+ if let Some(io) = &$is_open {
+ let mut output = true;
+ for (idx, val) in $value.iter().take($till).enumerate() {
+ output = output && io.get(idx).map(|got| got == val).unwrap_or(false);
+ }
+ if output {
+ eprintln!("Query for '{}' (io: '{}') matched at element {}", $value.join(","), io.join(","), $till);
+ }
+ output
+ } else {
+ false
+ }
+ }
+ }};
+ ($is_open:ident, @close $num:expr) => {{
+ if let Some(io) = &mut $is_open {
+ eprintln!("Performing close for {} elements (io: '{}') ..", $num, io.join(","));
+ for idx in (0..io.len()).rev().take($num) {
+ io.pop();
+ eprintln!(" Emitting close at element {} (io now: '{}')", idx + 1, io.join(","));
+ println!("{}}};", " ".repeat(idx + 2));
+ }
+ } else {
+ unreachable!()
+ }
+ }};
+ ($is_open:ident, @close_till $value:ident $num:expr) => {{
+ if let Some(io) = $is_open.clone() {
+ is_open!($is_open, @close io.len() - $num)
+ } else {
+ }
+ }};
+ ($is_open:ident, @close_all) => {{
+ if let Some(io) = $is_open.clone() {
+ is_open!($is_open, @close io.len());
+ } else {
+ }
+ }};
+}
+
+fn print_key(key: Vec<String>, node: Mapping) {
+ print!(
+ "{}\"{}\" = {{ cmd = \"{}\"; ",
+ " ".repeat(key.len() + 1),
+ key.last().expect("That's the len"),
+ node.command.join(" "),
+ );
+ if let Some(sets_mode_to) = node.sets_mode_to {
+ println!("sets_mode_to = \"{}\";}};", sets_mode_to);
+ } else {
+ println!("}};");
+ }
+}
+
+#[derive(clap::Parser, Debug)]
+#[clap(rename_all = "snake_case")]
+pub(crate) struct Cli {
+ #[arg(long)]
+ preset: bool,
+
+ #[arg(short = 'M', default_value = "default")]
+ mode: MapMode,
+
+ #[arg(short = 'm', default_value = "default")]
+ sets_mode_to: MapMode,
+
+ key: String,
+
+ command: Vec<String>,
+}
+
+#[derive(
+ Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord, Hash, Clone, Copy, Debug, Default,
+)]
+#[expect(non_camel_case_types)]
+enum MapMode {
+ #[default]
+ Default,
+ Insert,
+ Operator,
+ ReplaceOne,
+ Replace,
+ Visual,
+ f,
+ F,
+ t,
+ T,
+}
+
+impl std::fmt::Display for MapMode {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ match self {
+ MapMode::Default => f.write_str("default")?,
+ MapMode::Insert => f.write_str("insert")?,
+ MapMode::Operator => f.write_str("operator")?,
+ MapMode::ReplaceOne => f.write_str("replace_one")?,
+ MapMode::Replace => f.write_str("replace")?,
+ MapMode::Visual => f.write_str("visual")?,
+ MapMode::f => f.write_str("f")?,
+ MapMode::F => f.write_str("F")?,
+ MapMode::t => f.write_str("t")?,
+ MapMode::T => f.write_str("T")?,
+ }
+ Ok(())
+ }
+}
+
+impl FromStr for MapMode {
+ type Err = anyhow::Error;
+
+ fn from_str(s: &str) -> Result<Self, Self::Err> {
+ let me = match s {
+ "operator" => Self::Operator,
+ "insert" => Self::Insert,
+ "replace_one" => Self::ReplaceOne,
+ "replace" => Self::Replace,
+ "visual" => Self::Visual,
+ "default" => Self::Default,
+ "f" => Self::f,
+ "F" => Self::F,
+ "t" => Self::t,
+ "T" => Self::T,
+ other => bail!("Mapping mode '{other}' not yet supported"),
+ };
+ Ok(me)
+ }
+}
+
+enum Message {
+ NewBinding(usize),
+ End(usize),
+}
+type Key = String;
+#[derive(Debug, Deserialize, Serialize)]
+struct Binding {
+ key: Vec<Key>,
+ command: Vec<String>,
+ sets_mode_to: Option<MapMode>,
+ mode: MapMode,
+}
+
+struct MapStore {
+ map: HashMap<MapMode, Trie<Key, Mapping>>,
+}
+
+#[derive(Clone, PartialEq, PartialOrd, Debug)]
+struct Mapping {
+ command: Vec<String>,
+ sets_mode_to: Option<MapMode>,
+}
+
+fn main() -> anyhow::Result<()> {
+ let communication_socket: PathBuf = PathBuf::from("/tmp/fish_map_store.socket");
+
+ match PathBuf::from(args().next().unwrap())
+ .file_name()
+ .unwrap()
+ .to_str()
+ .unwrap()
+ {
+ "bind-end" => {
+ let mut stream = UnixStream::connect(communication_socket)?;
+ let message_raw: [u8; size_of::<Message>()] =
+ unsafe { mem::transmute(Message::End(0)) };
+
+ stream.write_all(&message_raw)?;
+ stream.flush()?;
+ }
+ "bind" => {
+ let args = Cli::parse();
+ assert!(args.preset);
+
+ let binding = Binding {
+ key: args.key.split(',').map(|s| s.to_string()).collect(),
+ command: args.command,
+ sets_mode_to: if args.mode != args.sets_mode_to {
+ Some(args.sets_mode_to)
+ } else {
+ None
+ },
+ mode: args.mode,
+ };
+ let binding_msg = serde_json::to_string(&binding)?;
+
+ let mut stream = UnixStream::connect(communication_socket)?;
+
+ let length = binding_msg.len();
+
+ let message_raw: [u8; size_of::<Message>()] =
+ unsafe { mem::transmute(Message::NewBinding(length)) };
+
+ stream.write_all(&message_raw)?;
+ stream.write_all(binding_msg.as_bytes())?;
+ stream.flush()?;
+ drop(stream);
+ }
+ "bind-server" => bind_server_main(communication_socket)?,
+ other => {
+ eprintln!("Personality '{other}' not supported.");
+ process::exit(2);
+ }
+ }
+
+ // let mappings = store.map.entry(args.mode).or_insert(Vec::default());
+ // mappings.push(mapping);
+ //
+ // {
+ // let mut file = fs::OpenOptions::new()
+ // .create(true)
+ // .truncate(true)
+ // .append(false)
+ // .write(true)
+ // .open(storage_file)?;
+ //
+ // file.write_all(serde_json::to_string(&store)?.as_bytes())?;
+ // }
+ //
+ // {
+ // eprintln!("Added {}", args.key);
+ // }
+
+ Ok(())
+}
+
+fn bind_server_main(communication_socket: PathBuf) -> anyhow::Result<()> {
+ if communication_socket.exists() {
+ fs::remove_file(&communication_socket)?;
+ }
+
+ let mut store = MapStore {
+ map: HashMap::new(),
+ };
+
+ let listener = UnixListener::bind(communication_socket)?;
+
+ for stream in listener.incoming() {
+ match stream {
+ Ok(mut stream) => {
+ let mut next_message_raw = [0; size_of::<Message>()];
+ stream.read_exact(&mut next_message_raw)?;
+ let next_message: Message = unsafe { mem::transmute(next_message_raw) };
+
+ match next_message {
+ Message::NewBinding(length) => {
+ let mut binding_str = String::new();
+ stream.read_to_string(&mut binding_str)?;
+
+ let binding: Binding = serde_json::from_str(&binding_str[..length])
+ .with_context(|| {
+ format!("Failed to parse '{binding_str:?}' as json")
+ })?;
+
+ let trie = store.map.entry(binding.mode).or_default();
+ trie.insert(
+ &binding.key,
+ Mapping {
+ command: binding.command,
+ sets_mode_to: binding.sets_mode_to,
+ },
+ )?;
+ }
+ Message::End(_pointless_value) => {
+ println!("{{");
+ for (mode, trie) in store.map {
+ println!(" \"{mode}\" = {{");
+ {
+ let mut io: Option<Vec<String>> = None;
+ for (key, node) in trie.iter() {
+ if is_open!(io, @query key[..4]) {
+ is_open!(io, @close_till key 4);
+ print_key(key, node);
+ } else if is_open!(io, @query key[..3]) {
+ is_open!(io, @close_till key 3);
+ is_open!(io, @set_element key[4]);
+ print_key(key, node);
+ } else if is_open!(io, @query key[..2]) {
+ is_open!(io, @close_till key 2);
+ is_open!(io, @set_element key[3]);
+ is_open!(io, @set_element key[4]);
+ print_key(key, node);
+ } else if is_open!(io, @query key[..1]) {
+ is_open!(io, @close_till key 1);
+ is_open!(io, @set_element key[2]);
+ is_open!(io, @set_element key[3]);
+ is_open!(io, @set_element key[4]);
+ print_key(key, node);
+ } else {
+ {
+ eprint!("No query matched: '{}'", key.join(","));
+ if let Some(io) = &io {
+ eprintln!(" (io: '{}')", io.join(","));
+ } else {
+ eprintln!(" (io empty)");
+ }
+ }
+
+ is_open!(io, @close_all);
+ is_open!(io, @set_element key[1]);
+ is_open!(io, @set_element key[2]);
+ is_open!(io, @set_element key[3]);
+ is_open!(io, @set_element key[4]);
+ print_key(key, node);
+ }
+ }
+ is_open!(io, @close_all);
+ }
+ println!(" }};");
+ }
+ println!("}}");
+
+ break;
+ }
+ }
+ }
+ Err(_) => {
+ /* connection failed */
+ break;
+ }
+ }
+ }
+ Ok(())
+}
diff --git a/pkgs/by-name/fi/fish-mk-maps/update.sh b/pkgs/by-name/fi/fish-mk-maps/update.sh
new file mode 100755
index 00000000..5aedf3b3
--- /dev/null
+++ b/pkgs/by-name/fi/fish-mk-maps/update.sh
@@ -0,0 +1,14 @@
+#!/usr/bin/env sh
+
+# Mpdpopm - A mpd rating tracker
+#
+# Copyright (C) 2026 Benedikt Peetz, Michael Herstine <sp1ff@pobox.com> <benedikt.peetz@b-peetz.de, sp1ff@pobox.com>
+# SPDX-License-Identifier: AGPL-3.0-or-later
+#
+# This file is part of Mpdpopm.
+#
+# You should have received a copy of the License along with this program.
+# If not, see <https://www.gnu.org/licenses/agpl.txt>.
+
+[ "$1" = "upgrade" ] && cargo upgrade --incompatible allow --pinned allow --recursive true
+cargo update --recursive