Complete the events system

This commit is contained in:
Anas Elgarhy 2023-02-13 20:10:39 +02:00
parent 1ea44b528c
commit f476ca21f2
No known key found for this signature in database
GPG key ID: 0501802A1D496528
7 changed files with 583 additions and 31 deletions

515
Cargo.lock generated
View file

@ -17,6 +17,24 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "ansi_colours"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7db9d9767fde724f83933a716ee182539788f293828244e9d999695ce0f7ba1e"
dependencies = [
"rgb",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "async-broadcast" name = "async-broadcast"
version = "0.5.0" version = "0.5.0"
@ -100,12 +118,75 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi 0.1.19",
"libc",
"winapi",
]
[[package]] [[package]]
name = "autocfg" name = "autocfg"
version = "1.1.0" version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bat"
version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fbfdea7507f0848118a3be1a76643a92705a9ff675796f9cadb309b7e95ab65d"
dependencies = [
"ansi_colours",
"ansi_term",
"bincode",
"bytesize",
"clircle",
"console",
"content_inspector",
"encoding",
"flate2",
"globset",
"grep-cli",
"once_cell",
"path_abs",
"semver 1.0.16",
"serde",
"serde_yaml",
"shell-words",
"syntect",
"thiserror",
"unicode-width",
]
[[package]]
name = "bincode"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
dependencies = [
"serde",
]
[[package]]
name = "bit-set"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1"
dependencies = [
"bit-vec",
]
[[package]]
name = "bit-vec"
version = "0.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb"
[[package]] [[package]]
name = "bit_field" name = "bit_field"
version = "0.10.1" version = "0.10.1"
@ -133,6 +214,18 @@ dependencies = [
"generic-array", "generic-array",
] ]
[[package]]
name = "bstr"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7f0778972c64420fdedc63f09919c8a88bda7b25135357fd25a5d9f3257e832"
dependencies = [
"memchr",
"once_cell",
"regex-automata",
"serde",
]
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.12.0" version = "3.12.0"
@ -151,6 +244,40 @@ version = "1.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610"
[[package]]
name = "bytesize"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c58ec36aac5066d5ca17df51b3e70279f5670a72102f5752cb7e7c856adfc70"
[[package]]
name = "cargo-expand"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cafe8e8eaaa2526fba9ed255ac6407b2b023e3537048548af96be0f7556c3e01"
dependencies = [
"atty",
"bat",
"cargo-subcommand-metadata",
"clap",
"prettyplease",
"proc-macro2",
"quote",
"serde",
"syn",
"syn-select",
"tempfile",
"termcolor",
"toml",
"toolchain_find",
]
[[package]]
name = "cargo-subcommand-metadata"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a33d3b80a8db16c4ad7676653766a8e59b5f95443c8823cb7cff587b90cb91ba"
[[package]] [[package]]
name = "cc" name = "cc"
version = "1.0.79" version = "1.0.79"
@ -201,10 +328,23 @@ dependencies = [
"os_str_bytes", "os_str_bytes",
] ]
[[package]]
name = "clircle"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e68bbd985a63de680ab4d1ad77b6306611a8f961b282c8b5ab513e6de934e396"
dependencies = [
"cfg-if",
"libc",
"serde",
"winapi",
]
[[package]] [[package]]
name = "cmus-notify" name = "cmus-notify"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"cargo-expand",
"clap", "clap",
"confy", "confy",
"id3", "id3",
@ -244,6 +384,28 @@ dependencies = [
"thiserror", "thiserror",
] ]
[[package]]
name = "console"
version = "0.15.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3d79fbe8970a77e3e34151cc13d3b3e248aa0faaecb9f6091fa07ebefe5ad60"
dependencies = [
"encode_unicode",
"lazy_static",
"libc",
"unicode-width",
"windows-sys 0.42.0",
]
[[package]]
name = "content_inspector"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b7bda66e858c683005a53a9a60c69a4aca7eeaa45d124526e389f7aec8e62f38"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "cpufeatures" name = "cpufeatures"
version = "0.2.5" version = "0.2.5"
@ -410,6 +572,76 @@ version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91" checksum = "7fcaabb2fef8c910e7f4c7ce9f67a1283a1715879a7c230ca9d6d1ae31f16d91"
[[package]]
name = "encode_unicode"
version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f"
[[package]]
name = "encoding"
version = "0.2.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b0d943856b990d12d3b55b359144ff341533e516d94098b1d3fc1ac666d36ec"
dependencies = [
"encoding-index-japanese",
"encoding-index-korean",
"encoding-index-simpchinese",
"encoding-index-singlebyte",
"encoding-index-tradchinese",
]
[[package]]
name = "encoding-index-japanese"
version = "1.20141219.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04e8b2ff42e9a05335dbf8b5c6f7567e5591d0d916ccef4e0b1710d32a0d0c91"
dependencies = [
"encoding_index_tests",
]
[[package]]
name = "encoding-index-korean"
version = "1.20141219.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dc33fb8e6bcba213fe2f14275f0963fd16f0a02c878e3095ecfdf5bee529d81"
dependencies = [
"encoding_index_tests",
]
[[package]]
name = "encoding-index-simpchinese"
version = "1.20141219.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d87a7194909b9118fc707194baa434a4e3b0fb6a5a757c73c3adb07aa25031f7"
dependencies = [
"encoding_index_tests",
]
[[package]]
name = "encoding-index-singlebyte"
version = "1.20141219.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3351d5acffb224af9ca265f435b859c7c01537c0849754d3db3fdf2bfe2ae84a"
dependencies = [
"encoding_index_tests",
]
[[package]]
name = "encoding-index-tradchinese"
version = "1.20141219.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd0e20d5688ce3cab59eb3ef3a2083a5c77bf496cb798dc6fcdb75f323890c18"
dependencies = [
"encoding_index_tests",
]
[[package]]
name = "encoding_index_tests"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a246d82be1c9d791c5dfde9a2bd045fc3cbba3fa2b11ad558f27d01712f00569"
[[package]] [[package]]
name = "enum-ordinalize" name = "enum-ordinalize"
version = "3.1.12" version = "3.1.12"
@ -487,6 +719,16 @@ dependencies = [
"threadpool", "threadpool",
] ]
[[package]]
name = "fancy-regex"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d6b8560a05112eb52f04b00e5d3790c0dd75d9d980eb8a122fb23b92a623ccf"
dependencies = [
"bit-set",
"regex",
]
[[package]] [[package]]
name = "fastrand" name = "fastrand"
version = "1.8.0" version = "1.8.0"
@ -519,6 +761,12 @@ dependencies = [
"spin", "spin",
] ]
[[package]]
name = "fnv"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]] [[package]]
name = "futures" name = "futures"
version = "0.3.26" version = "0.3.26"
@ -656,6 +904,36 @@ dependencies = [
"weezl", "weezl",
] ]
[[package]]
name = "globset"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc"
dependencies = [
"aho-corasick",
"bstr",
"fnv",
"log",
"regex",
]
[[package]]
name = "grep-cli"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d19fc6687bc64b6719a839cd24f2c700bcb05ffeb684d19da6a637c2455a7ba1"
dependencies = [
"atty",
"bstr",
"globset",
"lazy_static",
"log",
"regex",
"same-file",
"termcolor",
"winapi-util",
]
[[package]] [[package]]
name = "half" name = "half"
version = "2.2.1" version = "2.2.1"
@ -686,6 +964,15 @@ version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.2.6" version = "0.2.6"
@ -701,6 +988,15 @@ version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
[[package]]
name = "home"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "747309b4b440c06d57b0b25f2aee03ee9b5e5397d288c60e21fc709bb98a7408"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "id3" name = "id3"
version = "1.6.0" version = "1.6.0"
@ -766,12 +1062,18 @@ version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189" checksum = "28dfb6c8100ccc63462345b67d1bbc3679177c75ee4bf59bf29c8b1d110b8189"
dependencies = [ dependencies = [
"hermit-abi", "hermit-abi 0.2.6",
"io-lifetimes", "io-lifetimes",
"rustix", "rustix",
"windows-sys 0.42.0", "windows-sys 0.42.0",
] ]
[[package]]
name = "itoa"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fad582f4b9e86b6caa621cabeb0963332d92eea04729ab12892c2533951e6440"
[[package]] [[package]]
name = "jpeg-decoder" name = "jpeg-decoder"
version = "0.3.0" version = "0.3.0"
@ -999,7 +1301,7 @@ version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b"
dependencies = [ dependencies = [
"hermit-abi", "hermit-abi 0.2.6",
"libc", "libc",
] ]
@ -1083,6 +1385,25 @@ dependencies = [
"windows-sys 0.45.0", "windows-sys 0.45.0",
] ]
[[package]]
name = "path_abs"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05ef02f6342ac01d8a93b65f96db53fe68a92a15f41144f97fb00a9e669633c3"
dependencies = [
"std_prelude",
]
[[package]]
name = "pest"
version = "2.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "028accff104c4e513bad663bbcd2ad7cfd5304144404c31ed0a77ac103d00660"
dependencies = [
"thiserror",
"ucd-trie",
]
[[package]] [[package]]
name = "pin-project" name = "pin-project"
version = "1.0.12" version = "1.0.12"
@ -1147,6 +1468,16 @@ version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de"
[[package]]
name = "prettyplease"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e97e3215779627f01ee256d2fad52f3d95e8e1c11e9fc6fd08f7cd455d5d5c78"
dependencies = [
"proc-macro2",
"syn",
]
[[package]] [[package]]
name = "proc-macro-crate" name = "proc-macro-crate"
version = "1.3.0" version = "1.3.0"
@ -1154,7 +1485,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34" checksum = "66618389e4ec1c7afe67d51a9bf34ff9236480f8d51e7489b7d5ab0303c13f34"
dependencies = [ dependencies = [
"once_cell", "once_cell",
"toml_edit", "toml_edit 0.18.1",
] ]
[[package]] [[package]]
@ -1291,6 +1622,12 @@ dependencies = [
"regex-syntax", "regex-syntax",
] ]
[[package]]
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
[[package]] [[package]]
name = "regex-syntax" name = "regex-syntax"
version = "0.6.28" version = "0.6.28"
@ -1306,13 +1643,22 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "rgb"
version = "0.8.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7495acf66551cdb696b7711408144bcd3194fc78e32f3a09e809bfe7dd4a7ce3"
dependencies = [
"bytemuck",
]
[[package]] [[package]]
name = "rustc_version" name = "rustc_version"
version = "0.4.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366"
dependencies = [ dependencies = [
"semver", "semver 1.0.16",
] ]
[[package]] [[package]]
@ -1335,6 +1681,15 @@ version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde" checksum = "7b4b9743ed687d4b4bcedf9ff5eaa7398495ae14e61cba0a295704edbc7decde"
[[package]]
name = "same-file"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502"
dependencies = [
"winapi-util",
]
[[package]] [[package]]
name = "scoped_threadpool" name = "scoped_threadpool"
version = "0.1.9" version = "0.1.9"
@ -1347,12 +1702,30 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
[[package]]
name = "semver"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f301af10236f6df4160f7c3f04eec6dbc70ace82d23326abad5edee88801c6b6"
dependencies = [
"semver-parser",
]
[[package]] [[package]]
name = "semver" name = "semver"
version = "1.0.16" version = "1.0.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a" checksum = "58bc9567378fc7690d6b2addae4e60ac2eeea07becb2c64b9f218b53865cba2a"
[[package]]
name = "semver-parser"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0bef5b7f9e0df16536d3961cfb6e84331c065b4066afb39768d0e319411f7"
dependencies = [
"pest",
]
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.152" version = "1.0.152"
@ -1373,6 +1746,17 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "serde_json"
version = "1.0.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cad406b69c91885b5107daf2c29572f6c8cdb3c66826821e286c533490c0bc76"
dependencies = [
"itoa",
"ryu",
"serde",
]
[[package]] [[package]]
name = "serde_repr" name = "serde_repr"
version = "0.1.10" version = "0.1.10"
@ -1384,6 +1768,15 @@ dependencies = [
"syn", "syn",
] ]
[[package]]
name = "serde_spanned"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0efd8caf556a6cebd3b285caf480045fcc1ac04f6bd786b09a6f11af30c4fcf4"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "serde_yaml" name = "serde_yaml"
version = "0.8.26" version = "0.8.26"
@ -1407,6 +1800,12 @@ dependencies = [
"digest", "digest",
] ]
[[package]]
name = "shell-words"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde"
[[package]] [[package]]
name = "slab" name = "slab"
version = "0.4.7" version = "0.4.7"
@ -1447,6 +1846,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]]
name = "std_prelude"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8207e78455ffdf55661170876f88daf85356e4edd54e0a3dbc79586ca1e50cbe"
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.10.0" version = "0.10.0"
@ -1485,6 +1890,36 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "syn-select"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5341d05f60821d430a8a7a452b9e267a8c675da4ad1801e7c0a01566c4a4ba48"
dependencies = [
"syn",
]
[[package]]
name = "syntect"
version = "5.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c6c454c27d9d7d9a84c7803aaa3c50cd088d2906fe3c6e42da3209aa623576a8"
dependencies = [
"bincode",
"bitflags",
"fancy-regex",
"flate2",
"fnv",
"lazy_static",
"once_cell",
"regex-syntax",
"serde",
"serde_derive",
"serde_json",
"thiserror",
"walkdir",
]
[[package]] [[package]]
name = "tauri-winrt-notification" name = "tauri-winrt-notification"
version = "0.1.0" version = "0.1.0"
@ -1612,12 +2047,33 @@ version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd" checksum = "2e153e1f1acaef8acc537e68b44906d2db6436e2b35ac2c6b42640fff91f00fd"
[[package]]
name = "toml"
version = "0.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7afcae9e3f0fe2c370fd4657108972cbb2fa9db1b9f84849cefd80741b01cb6"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime 0.6.1",
"toml_edit 0.19.3",
]
[[package]] [[package]]
name = "toml_datetime" name = "toml_datetime"
version = "0.5.1" version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5" checksum = "4553f467ac8e3d374bc9a177a26801e5d0f9b211aa1673fb137a403afd1c9cf5"
[[package]]
name = "toml_datetime"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ab8ed2edee10b50132aed5f331333428b011c99402b5a534154ed15746f9622"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "toml_edit" name = "toml_edit"
version = "0.18.1" version = "0.18.1"
@ -1626,7 +2082,33 @@ checksum = "56c59d8dd7d0dcbc6428bf7aa2f0e823e26e43b3c9aca15bbc9475d23e5fa12b"
dependencies = [ dependencies = [
"indexmap", "indexmap",
"nom8", "nom8",
"toml_datetime", "toml_datetime 0.5.1",
]
[[package]]
name = "toml_edit"
version = "0.19.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e6a7712b49e1775fb9a7b998de6635b299237f48b404dde71704f2e0e7f37e5"
dependencies = [
"indexmap",
"nom8",
"serde",
"serde_spanned",
"toml_datetime 0.6.1",
]
[[package]]
name = "toolchain_find"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e85654a10e7a07a47c6f19d93818f3f343e22927f2fa280c84f7c8042743413"
dependencies = [
"home",
"lazy_static",
"regex",
"semver 0.11.0",
"walkdir",
] ]
[[package]] [[package]]
@ -1678,6 +2160,12 @@ version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba" checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
[[package]]
name = "ucd-trie"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e79c4d996edb816c91e4308506774452e55e95c3c9de07b6729e17e15a5ef81"
[[package]] [[package]]
name = "uds_windows" name = "uds_windows"
version = "1.0.2" version = "1.0.2"
@ -1709,6 +2197,12 @@ version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
[[package]]
name = "unicode-width"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.4" version = "0.9.4"
@ -1721,6 +2215,17 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca" checksum = "9d5b2c62b4012a3e1eca5a7e077d13b3bf498c4073e33ccd58626607748ceeca"
[[package]]
name = "walkdir"
version = "2.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
dependencies = [
"same-file",
"winapi",
"winapi-util",
]
[[package]] [[package]]
name = "wasi" name = "wasi"
version = "0.11.0+wasi-snapshot-preview1" version = "0.11.0+wasi-snapshot-preview1"

View file

@ -29,4 +29,5 @@ lyrics = ["lrc"]
default = ["lyrics"] default = ["lyrics"]
[dev-dependencies] [dev-dependencies]
cargo-expand = "1.0.40"
test-context = "0.1.4" test-context = "0.1.4"

View file

@ -1,9 +1,4 @@
use clap::Parser; use cmus_notify::{cmus::{self, query::CmusQueryResponse}, notification, settings::Settings, TrackCover};
use cmus_notify::{
settings::Settings,
cmus::{self, query::CmusQueryResponse, CmusError},
};
macro_rules! sleep { macro_rules! sleep {
($time: expr) => { ($time: expr) => {
@ -16,11 +11,11 @@ fn main() {
let settings = Settings::load_config_and_parse_args(); let settings = Settings::load_config_and_parse_args();
// Build the command, or use the default. (to speed up the main loop, because we don't need to build it every time) // Build the command, or use the default. (to speed up the main loop, because we don't need to build it every time)
let remote_bin_path = settings
.cmus_remote_bin_path.clone()
.unwrap_or("cmus-remote".to_string());
let mut query_command = cmus::build_query_command( let mut query_command = cmus::build_query_command(
&settings remote_bin_path.as_str(),
.cmus_remote_bin_path
.unwrap_or("cmus-remote".to_string())
.as_str(),
&settings.cmus_socket_address, &settings.cmus_socket_address,
&settings.cmus_socket_password, &settings.cmus_socket_password,
); );
@ -30,10 +25,10 @@ fn main() {
// Initialize the buffer to store the cover path, to compare it with the next one. // Initialize the buffer to store the cover path, to compare it with the next one.
// This is used to speed up the main loop, because we don't need to process the template and search for the cover every time. // This is used to speed up the main loop, because we don't need to process the template and search for the cover every time.
// We only need to do it when the track directory changes. // We only need to do it when the track directory changes.
let mut previous_cover_path: Option<String> = None; let mut previous_cover = TrackCover::None;
loop { loop {
// Get the track info, and compare it with the previous one. // Get the response from cmus.
let Ok(response) = cmus::ping_cmus(&mut query_command) else { let Ok(response) = cmus::ping_cmus(&mut query_command) else {
if settings.link { if settings.link {
std::process::exit(0) std::process::exit(0)
@ -44,16 +39,16 @@ fn main() {
} }
}; };
/* // Compare the track info with the previous one, and if they are the same, just sleep for a while and try again. // Compare the response with the previous one.
if track == previous_track { if response != previous_response {
sleep(); // Get the events (the changes) from the response.
continue; if let Ok(events) = previous_response.events(&response) {
// Update the previous response.
previous_response = response;
notification::show_notification(events, &settings, &mut previous_cover);
}
} }
// If the track info is different from the previous one, get the changes events.
let changes = track.get_changes(&previous_track);
*/
sleep!(settings.interval); sleep!(settings.interval);
} }
} }

View file

@ -1,12 +1,12 @@
use crate::cmus::player_settings::AAAMode; use crate::cmus::player_settings::{AAAMode, Shuffle};
use crate::cmus::TrackStatus; use crate::cmus::{Track, TrackStatus};
pub enum CmusEvent { pub enum CmusEvent {
StatusChanged(TrackStatus), StatusChanged(TrackStatus),
TrackChanged, TrackChanged(Track),
VolumeChanged { left: u8, right: u8 }, VolumeChanged { left: u8, right: u8 },
PositionChanged(u32), PositionChanged(u32),
ShuffleChanged(bool), ShuffleChanged(Shuffle),
RepeatChanged(bool), RepeatChanged(bool),
AAAMode(AAAMode), AAAMode(AAAMode),
} }

View file

@ -1,3 +1,4 @@
use crate::cmus::events::CmusEvent;
use crate::cmus::player_settings::PlayerSettings; use crate::cmus::player_settings::PlayerSettings;
use crate::cmus::{CmusError, Track}; use crate::cmus::{CmusError, Track};
use std::str::FromStr; use std::str::FromStr;
@ -37,6 +38,51 @@ impl CmusQueryResponse {
pub fn player_settings(&self) -> Result<PlayerSettings, CmusError> { pub fn player_settings(&self) -> Result<PlayerSettings, CmusError> {
PlayerSettings::from_str(&self.player_settings_row) PlayerSettings::from_str(&self.player_settings_row)
} }
pub fn events(&self, other: &Self) -> Result<Vec<CmusEvent>, CmusError> {
if self.track_row.is_empty() || self.player_settings_row.is_empty() {
return Ok(Vec::new());
}
let mut events = Vec::new();
let track = self.track()?;
let other_track = other.track()?;
if track != other_track {
if track.status != other_track.status {
events.push(CmusEvent::StatusChanged(other_track.status));
} else {
events.push(CmusEvent::TrackChanged(other_track));
}
}
let player_settings = self.player_settings()?;
let other_player_settings = other.player_settings()?;
if player_settings != other_player_settings {
if player_settings.shuffle != other_player_settings.shuffle {
events.push(CmusEvent::ShuffleChanged(player_settings.shuffle));
}
if player_settings.repeat != other_player_settings.repeat {
events.push(CmusEvent::RepeatChanged(player_settings.repeat));
}
if player_settings.aaa_mode != other_player_settings.aaa_mode {
events.push(CmusEvent::AAAMode(player_settings.aaa_mode));
}
if player_settings.volume != other_player_settings.volume {
events.push(CmusEvent::VolumeChanged {
left: player_settings.volume.left,
right: player_settings.volume.right,
});
}
}
Ok(events)
}
} }
#[cfg(test)] #[cfg(test)]

View file

@ -2,8 +2,9 @@
use std::path::Path; use std::path::Path;
pub mod settings;
pub mod cmus; pub mod cmus;
pub mod settings;
pub mod notification;
/// Extracts the first embedded picture from an ID3 tag of an Audio file. /// Extracts the first embedded picture from an ID3 tag of an Audio file.
/// ///

View file

@ -148,6 +148,9 @@ pub struct Settings {
/// No use the external lyrics file, even if it's available and the track's metadata doesn't have a lyrics. /// No use the external lyrics file, even if it's available and the track's metadata doesn't have a lyrics.
#[arg(short = 'o', long)] #[arg(short = 'o', long)]
pub no_use_external_lyrics: bool, pub no_use_external_lyrics: bool,
/// Show the player notifications, like if you change the shuffle mode, or the repeat mode, or the volume.
#[arg(short = 'g', long)]
pub show_player_notifications: bool,
} }
impl Default for Settings { impl Default for Settings {
@ -174,6 +177,7 @@ impl Default for Settings {
no_use_external_cover: false, no_use_external_cover: false,
#[cfg(feature = "lyrics")] #[cfg(feature = "lyrics")]
no_use_external_lyrics: false, no_use_external_lyrics: false,
show_player_notifications: false,
} }
} }
} }