Initial version

This commit is contained in:
davidon-top 2023-12-09 13:51:18 +00:00
parent 8afbd6324d
commit cea9ee6e51
Signed by: DavidOnTop
GPG key ID: FAB914DDC2F180EB
9 changed files with 683 additions and 375 deletions

View file

@ -14,18 +14,6 @@ env:
CARGO_TERM_COLOR: always CARGO_TERM_COLOR: always
jobs: jobs:
test:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install toolchain
uses: dtolnay/rust-toolchain@nightly
- name: Run cargo test
run: cargo test
clippy_check: clippy_check:
name: Clippy name: Clippy
runs-on: ubuntu-latest runs-on: ubuntu-latest

View file

@ -6,7 +6,7 @@ on:
- '*' - '*'
env: env:
binary: rust-template binary: rofi-edit
jobs: jobs:
@ -26,14 +26,14 @@ jobs:
- name: Upload binaries to artifacts - name: Upload binaries to artifacts
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
path: target/x86_64-unknown-linux-gnu/release/${{ env.binary }} path: target/x86_64-unknown-linux-gnu/release/${{ env.binary }}.so
name: ${{ env.binary }} name: ${{ env.binary }}.so
retention-days: 1 retention-days: 1
- name: Upload binaries to release - name: Upload binaries to release
uses: svenstaro/upload-release-action@v2 uses: svenstaro/upload-release-action@v2
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.binary }} file: ${{ env.binary }}.so
asset_name: ${{ env.binary }}-linux-${{ steps.get_version.outputs.tag }} asset_name: ${{ env.binary }}-linux-${{ steps.get_version.outputs.tag }}.so
tag: ${{ github.ref }} tag: ${{ github.ref }}
overwrite: true overwrite: true

663
Cargo.lock generated
View file

@ -3,19 +3,10 @@
version = 3 version = 3
[[package]] [[package]]
name = "addr2line" name = "anyhow"
version = "0.21.0" version = "1.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
dependencies = [
"gimli",
]
[[package]]
name = "adler"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe"
[[package]] [[package]]
name = "autocfg" name = "autocfg"
@ -23,21 +14,6 @@ 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 = "backtrace"
version = "0.3.69"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2089b7e3f35b9dd2d0ed921ead4f6d318c27680d4a5bd167b3ee120edb105837"
dependencies = [
"addr2line",
"cc",
"cfg-if",
"libc",
"miniz_oxide",
"object",
"rustc-demangle",
]
[[package]] [[package]]
name = "bitflags" name = "bitflags"
version = "1.3.2" version = "1.3.2"
@ -45,49 +21,234 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]] [[package]]
name = "bytes" name = "bitflags"
version = "1.5.0" version = "2.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07"
[[package]] [[package]]
name = "cc" name = "cairo-rs"
version = "1.0.83" version = "0.17.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" checksum = "ab3603c4028a5e368d09b51c8b624b9a46edcd7c3778284077a6125af73c9f0a"
dependencies = [ dependencies = [
"bitflags 1.3.2",
"cairo-sys-rs",
"glib",
"libc", "libc",
"once_cell",
"thiserror",
] ]
[[package]] [[package]]
name = "cfg-if" name = "cairo-sys-rs"
version = "1.0.0" version = "0.17.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "691d0c66b1fb4881be80a760cb8fe76ea97218312f9dfe2c9cc0f496ca279cb1"
dependencies = [
"glib-sys",
"libc",
"system-deps",
]
[[package]] [[package]]
name = "gimli" name = "cfg-expr"
version = "0.28.1" version = "0.15.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" checksum = "03915af431787e6ffdcc74c645077518c6b6e01f80b761e0fbbfa288536311b3"
dependencies = [
"smallvec",
"target-lexicon",
]
[[package]] [[package]]
name = "hermit-abi" name = "equivalent"
version = "0.3.3" version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7" checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5"
[[package]]
name = "futures-channel"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff4dd66668b557604244583e3e1e1eada8c5c2e96a6d0d6653ede395b78bbacb"
dependencies = [
"futures-core",
]
[[package]]
name = "futures-core"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb1d22c66e66d9d72e1758f0bd7d4fd0bee04cad842ee34587d68c07e45d088c"
[[package]]
name = "futures-executor"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f4fb8693db0cf099eadcca0efe2a5a22e4550f98ed16aba6c48700da29597bc"
dependencies = [
"futures-core",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-io"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bf34a163b5c4c52d0478a4d757da8fb65cabef42ba90515efee0f6f9fa45aaa"
[[package]]
name = "futures-macro"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53b153fd91e4b0147f4aced87be237c98248656bb01050b96bf3ee89220a8ddb"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
]
[[package]]
name = "futures-task"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efd193069b0ddadc69c46389b740bbccdd97203899b48d09c5f7969591d6bae2"
[[package]]
name = "futures-util"
version = "0.3.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a19526d624e703a3179b3d322efec918b6246ea0fa51d41124525f00f1cc8104"
dependencies = [
"futures-core",
"futures-macro",
"futures-task",
"pin-project-lite",
"pin-utils",
"slab",
]
[[package]]
name = "gio"
version = "0.17.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6973e92937cf98689b6a054a9e56c657ed4ff76de925e36fc331a15f0c5d30a"
dependencies = [
"bitflags 1.3.2",
"futures-channel",
"futures-core",
"futures-io",
"futures-util",
"gio-sys",
"glib",
"libc",
"once_cell",
"pin-project-lite",
"smallvec",
"thiserror",
]
[[package]]
name = "gio-sys"
version = "0.17.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ccf87c30a12c469b6d958950f6a9c09f2be20b7773f7e70d20b867fdf2628c3"
dependencies = [
"glib-sys",
"gobject-sys",
"libc",
"system-deps",
"winapi",
]
[[package]]
name = "glib"
version = "0.17.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3fad45ba8d4d2cea612b432717e834f48031cd8853c8aaf43b2c79fec8d144b"
dependencies = [
"bitflags 1.3.2",
"futures-channel",
"futures-core",
"futures-executor",
"futures-task",
"futures-util",
"gio-sys",
"glib-macros",
"glib-sys",
"gobject-sys",
"libc",
"memchr",
"once_cell",
"smallvec",
"thiserror",
]
[[package]]
name = "glib-macros"
version = "0.17.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eca5c79337338391f1ab8058d6698125034ce8ef31b72a442437fa6c8580de26"
dependencies = [
"anyhow",
"heck",
"proc-macro-crate",
"proc-macro-error",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]]
name = "glib-sys"
version = "0.17.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d80aa6ea7bba0baac79222204aa786a6293078c210abe69ef1336911d4bdc4f0"
dependencies = [
"libc",
"system-deps",
]
[[package]]
name = "gobject-sys"
version = "0.17.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd34c3317740a6358ec04572c1bcfd3ac0b5b6529275fae255b237b314bb8062"
dependencies = [
"glib-sys",
"libc",
"system-deps",
]
[[package]]
name = "hashbrown"
version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
[[package]]
name = "heck"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
[[package]]
name = "indexmap"
version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d530e1a18b1cb4c484e6e34556a0d948706958449fca0cab753d649f2bce3d1f"
dependencies = [
"equivalent",
"hashbrown",
]
[[package]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.9" version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c"
[[package]]
name = "lazy_static"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
[[package]] [[package]]
name = "libc" name = "libc"
@ -95,77 +256,12 @@ version = "0.2.150"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
[[package]]
name = "lock_api"
version = "0.4.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f"
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.6.4" version = "2.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
[[package]]
name = "miniz_oxide"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7"
dependencies = [
"adler",
]
[[package]]
name = "mio"
version = "0.8.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f3d0b296e374a4e6f3c7b0a1f5a51d748a0d34c85e7dc48fc3fa9a87657fe09"
dependencies = [
"libc",
"wasi",
"windows-sys",
]
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
dependencies = [
"overload",
"winapi",
]
[[package]]
name = "num_cpus"
version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
dependencies = [
"hermit-abi",
"libc",
]
[[package]]
name = "object"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0"
dependencies = [
"memchr",
]
[[package]] [[package]]
name = "once_cell" name = "once_cell"
version = "1.19.0" version = "1.19.0"
@ -173,32 +269,29 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
[[package]] [[package]]
name = "overload" name = "pango"
version = "0.1.1" version = "0.17.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39" checksum = "35be456fc620e61f62dff7ff70fbd54dcbaf0a4b920c0f16de1107c47d921d48"
[[package]]
name = "parking_lot"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
dependencies = [ dependencies = [
"lock_api", "bitflags 1.3.2",
"parking_lot_core", "gio",
"glib",
"libc",
"once_cell",
"pango-sys",
] ]
[[package]] [[package]]
name = "parking_lot_core" name = "pango-sys"
version = "0.9.9" version = "0.17.10"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e" checksum = "3da69f9f3850b0d8990d462f8c709561975e95f689c1cdf0fecdebde78b35195"
dependencies = [ dependencies = [
"cfg-if", "glib-sys",
"gobject-sys",
"libc", "libc",
"redox_syscall", "system-deps",
"smallvec",
"windows-targets",
] ]
[[package]] [[package]]
@ -207,6 +300,52 @@ version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
[[package]]
name = "pin-utils"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pkg-config"
version = "0.3.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964"
[[package]]
name = "proc-macro-crate"
version = "1.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919"
dependencies = [
"once_cell",
"toml_edit 0.19.15",
]
[[package]]
name = "proc-macro-error"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c"
dependencies = [
"proc-macro-error-attr",
"proc-macro2",
"quote",
"syn 1.0.109",
"version_check",
]
[[package]]
name = "proc-macro-error-attr"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869"
dependencies = [
"proc-macro2",
"quote",
"version_check",
]
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.70" version = "1.0.70"
@ -226,30 +365,37 @@ dependencies = [
] ]
[[package]] [[package]]
name = "redox_syscall" name = "rofi-edit"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
dependencies = [
"bitflags",
]
[[package]]
name = "rust-template"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"rofi-mode",
"serde", "serde",
"serde_json", "serde_json",
"tokio",
"tracing",
"tracing-subscriber",
] ]
[[package]] [[package]]
name = "rustc-demangle" name = "rofi-mode"
version = "0.1.23" version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" checksum = "1b8965aa7c7313bececbd2d43f7ced6060a8b146ad807f3371c8eeb0518b06ba"
dependencies = [
"bitflags 2.4.1",
"cairo-rs",
"libc",
"pango",
"rofi-plugin-sys",
]
[[package]]
name = "rofi-plugin-sys"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bf28cd51980f7033bd1c1607f98ae914184c21516f4e5583030e161efe81b01"
dependencies = [
"bitflags 2.4.1",
"cairo-sys-rs",
"glib-sys",
]
[[package]] [[package]]
name = "ryu" name = "ryu"
@ -257,12 +403,6 @@ version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741"
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]] [[package]]
name = "serde" name = "serde"
version = "1.0.193" version = "1.0.193"
@ -280,7 +420,7 @@ checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn 2.0.39",
] ]
[[package]] [[package]]
@ -295,21 +435,21 @@ dependencies = [
] ]
[[package]] [[package]]
name = "sharded-slab" name = "serde_spanned"
version = "0.1.7" version = "0.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80"
dependencies = [ dependencies = [
"lazy_static", "serde",
] ]
[[package]] [[package]]
name = "signal-hook-registry" name = "slab"
version = "1.4.1" version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8229b473baa5980ac72ef434c4415e70c4b5e71b423043adb4ba059f89c99a1" checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
dependencies = [ dependencies = [
"libc", "autocfg",
] ]
[[package]] [[package]]
@ -319,13 +459,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970" checksum = "4dccd0940a2dcdf68d092b8cbab7dc0ad8fa938bf95787e1b916b0e3d0e8e970"
[[package]] [[package]]
name = "socket2" name = "syn"
version = "0.5.5" version = "1.0.109"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b5fac59a5cb5dd637972e5fca70daf0523c9067fcdc4842f053dae04a18f8e9" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
dependencies = [ dependencies = [
"libc", "proc-macro2",
"windows-sys", "quote",
"unicode-ident",
] ]
[[package]] [[package]]
@ -340,100 +481,87 @@ dependencies = [
] ]
[[package]] [[package]]
name = "thread_local" name = "system-deps"
version = "1.1.7" version = "6.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" checksum = "2a2d580ff6a20c55dfb86be5f9c238f67835d0e81cbdea8bf5680e0897320331"
dependencies = [ dependencies = [
"cfg-if", "cfg-expr",
"once_cell", "heck",
"pkg-config",
"toml",
"version-compare",
] ]
[[package]] [[package]]
name = "tokio" name = "target-lexicon"
version = "1.34.0" version = "0.12.12"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0c014766411e834f7af5b8f4cf46257aab4036ca95e9d2c144a10f59ad6f5b9" checksum = "14c39fd04924ca3a864207c66fc2cd7d22d7c016007f9ce846cbb9326331930a"
[[package]]
name = "thiserror"
version = "1.0.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2"
dependencies = [ dependencies = [
"backtrace", "thiserror-impl",
"bytes",
"libc",
"mio",
"num_cpus",
"parking_lot",
"pin-project-lite",
"signal-hook-registry",
"socket2",
"tokio-macros",
"windows-sys",
] ]
[[package]] [[package]]
name = "tokio-macros" name = "thiserror-impl"
version = "2.2.0" version = "1.0.50"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn", "syn 2.0.39",
] ]
[[package]] [[package]]
name = "tracing" name = "toml"
version = "0.1.40" version = "0.8.8"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35"
dependencies = [ dependencies = [
"pin-project-lite", "serde",
"tracing-attributes", "serde_spanned",
"tracing-core", "toml_datetime",
"toml_edit 0.21.0",
] ]
[[package]] [[package]]
name = "tracing-attributes" name = "toml_datetime"
version = "0.1.27" version = "0.6.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1"
dependencies = [ dependencies = [
"proc-macro2", "serde",
"quote",
"syn",
] ]
[[package]] [[package]]
name = "tracing-core" name = "toml_edit"
version = "0.1.32" version = "0.19.15"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
dependencies = [ dependencies = [
"once_cell", "indexmap",
"valuable", "toml_datetime",
"winnow",
] ]
[[package]] [[package]]
name = "tracing-log" name = "toml_edit"
version = "0.2.0" version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3" checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03"
dependencies = [ dependencies = [
"log", "indexmap",
"once_cell", "serde",
"tracing-core", "serde_spanned",
] "toml_datetime",
"winnow",
[[package]]
name = "tracing-subscriber"
version = "0.3.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b"
dependencies = [
"nu-ansi-term",
"sharded-slab",
"smallvec",
"thread_local",
"tracing-core",
"tracing-log",
] ]
[[package]] [[package]]
@ -443,16 +571,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]] [[package]]
name = "valuable" name = "version-compare"
version = "0.1.0" version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" checksum = "579a42fc0b8e0c63b76519a339be31bed574929511fa53c1a3acae26eb258f29"
[[package]] [[package]]
name = "wasi" name = "version_check"
version = "0.11.0+wasi-snapshot-preview1" version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]] [[package]]
name = "winapi" name = "winapi"
@ -477,67 +605,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]] [[package]]
name = "windows-sys" name = "winnow"
version = "0.48.0" version = "0.5.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" checksum = "b67b5f0a4e7a27a64c651977932b9dc5667ca7fc31ac44b03ed37a0cf42fdfff"
dependencies = [ dependencies = [
"windows-targets", "memchr",
] ]
[[package]]
name = "windows-targets"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_i686_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_x86_64_gnu"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_msvc"
version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"

View file

@ -1,17 +1,17 @@
[package] [package]
name = "rust-template" name = "rofi-edit"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
description = "A template for rust projects" description = "A plugin for rofi that allows list editing"
authors = ["DavidOnTop <me@davidon.top>"] authors = ["DavidOnTop <me@davidon.top>"]
readme = "README.md" readme = "README.md"
documentation = "https://docs.rs/rust-template" license = "GPL-3.0"
license = "MIT" repository = "git@github.com:davidon-top/rofi-edit.git"
repository = "git@github.com:davidon-top/rust-template.git"
[lib]
crate-type = ["cdylib"]
[dependencies] [dependencies]
serde = { version = "1.0", features = ["derive"] } rofi-mode = "0.3.1"
serde_json = "1.0" serde = { version = "1.0.193", features = ["derive"] }
tracing = "0.1" serde_json = "1.0.108"
tracing-subscriber = "0.3"
tokio = { version = "1.0", features = ["full"] }

View file

@ -1,26 +0,0 @@
GLWTS(Good Luck With That Shit) Public License
Copyright (c) Every-fucking-one
Everyone is permitted to copy, distribute, modify, merge, sell, publish,
sublicense or whatever the fuck they want with this software but at their
OWN RISK.
Preamble
The author has absolutely no fucking clue what the code in this project
does. It might just fucking work or not, there is no third option.
GOOD LUCK WITH THAT SHIT PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION, AND MODIFICATION
0. You just DO WHATEVER THE FUCK YOU WANT TO as long as you NEVER LEAVE
A FUCKING TRACE TO TRACK THE AUTHOR of the original product to blame for
or held responsible.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
Good luck and Godspeed.

View file

@ -1,22 +0,0 @@
MIT License
Copyright (c) 2023 DavidOnTop
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -1 +1 @@
# Template repo # Rofi edit plugin

View file

@ -1 +1,301 @@
use std::io::Read;
#[derive(serde::Deserialize, serde::Serialize)]
struct ItemContainer {
name: String,
item: Item,
}
#[derive(serde::Deserialize, serde::Serialize)]
enum Item {
Bool {
#[serde(default)]
value: bool,
},
Int {
#[serde(default)]
value: i64,
min: Option<i64>,
max: Option<i64>,
},
Float {
#[serde(default)]
value: f64,
min: Option<f64>,
max: Option<f64>,
},
String {
#[serde(default)]
value: String,
},
Enum {
#[serde(default)]
value: usize,
options: Vec<String>,
}
}
impl Item {
fn get_value(&self) -> String {
match self {
Item::Bool { value } => value.to_string(),
Item::Int { value, .. } => value.to_string(),
Item::Float { value, .. } => value.to_string(),
Item::String { value } => value.clone(),
Item::Enum { value, options } => options[*value].clone(),
}
}
}
enum State {
Main,
Editing(usize),
}
struct Mode<'rofi> {
api: rofi_mode::Api<'rofi>,
entries: Vec<String>,
items: Vec<ItemContainer>,
state: State,
message: String,
}
impl<'rofi> Mode<'rofi> {
fn entries_from_items(&mut self) {
self.state = State::Main;
self.api.set_display_name("edit");
self.entries.clear();
self.items.iter().for_each(|item| {
self.entries.push(format!("{}: {}", item.name, item.item.get_value()));
});
self.entries.push("Apply".to_string());
}
fn enter_edit(&mut self, item: usize) -> String {
self.state = State::Editing(item);
let item = &self.items[item];
self.api.set_display_name(format!("editing {}", item.name));
self.message = format!("Old value: {}", item.item.get_value());
self.entries.clear();
match &item.item {
Item::Bool { .. } => {
self.entries.push("true".to_string());
self.entries.push("false".to_string());
},
Item::Int { value, min, max } => {
let min = min.map(|min| format!("Min: {};", min)).unwrap_or("".to_string());
let max = max.map(|max| format!("Max: {};", max)).unwrap_or("".to_string());
self.message = format!("Old value: {};\r{} {}", value, min, max);
},
Item::Float { value, min, max } => {
let min = min.map(|min| format!("Min: {};", min)).unwrap_or("".to_string());
let max = max.map(|max| format!("Max: {};", max)).unwrap_or("".to_string());
self.message = format!("Old value: {};\r{} {}", value, min, max);
},
Item::String { .. } => {},
Item::Enum { options, .. } => {
options.iter().for_each(|option| self.entries.push(option.clone()));
},
}
self.entries.push("Cancel".to_string());
return item.item.get_value();
}
fn finish_edit(&mut self, selected: Option<usize>, custom_input: Option<&mut rofi_mode::String>) {
match self.state {
State::Main => {panic!("finish_edit called in main state")},
State::Editing(item) => {
let item = &mut self.items[item];
match item.item {
Item::Bool { .. } => {
match selected {
Some(0) => item.item = Item::Bool { value: true },
Some(1) => item.item = Item::Bool { value: false },
_ => {},
}
},
Item::Int { value, min, max } => {
let mut new_value = value.clone();
if let Some(input) = custom_input {
new_value = input.replace("\\-", "-").parse().unwrap();
}
if let Some(min) = min {
if new_value < min {
new_value = min;
}
}
if let Some(max) = max {
if new_value > max {
new_value = max;
}
}
item.item = Item::Int { value: new_value, min, max };
},
Item::Float { value, min, max } => {
let mut new_value = value.clone();
if let Some(input) = custom_input {
new_value = input.replace("\\-", "-").parse().unwrap();
}
if let Some(min) = min {
if new_value < min {
new_value = min;
}
}
if let Some(max) = max {
if new_value > max {
new_value = max;
}
}
item.item = Item::Float { value: new_value, min, max };
},
Item::String { .. } => {
if let Some(input) = custom_input {
item.item = Item::String { value: input.into() };
}
},
Item::Enum { ref mut value, .. } => {
if let Some(selected) = selected {
*value = selected;
}
},
};
self.entries_from_items();
},
}
}
fn print_items(&self) {
println!("{}", serde_json::to_string(&self.items).unwrap());
}
}
// reads until 2 subsequent newlines
fn read_stdin() -> String {
let mut inp = Vec::new();
let mut buf = [0u8; 1];
let mut handle = std::io::stdin().lock();
loop {
handle.read_exact(&mut buf).unwrap();
inp.push(buf[0]);
if inp.ends_with(b"\n\n") {
break;
}
}
String::from_utf8(inp).unwrap()
}
impl<'rofi> rofi_mode::Mode<'rofi> for Mode<'rofi> {
const NAME: &'static str = "edit\0";
fn init(mut api: rofi_mode::Api<'rofi>) -> Result<Self, ()> {
api.set_display_name("edit");
let args = std::env::args().into_iter().collect::<Vec<_>>();
if args.contains(&"--edit-help".to_string()) {
eprintln!(r#"
--edit-stdin Read input from stdin, reads json until 2 newlines
--edit-file <file> Read input from file, json file
--edit-input <input> Read input, should be a string containing json
--edit-example Prints examples
"#);
return Err(());
}
if args.contains(&"--edit-example".to_string()) {
let mut its: Vec<ItemContainer> = Vec::new();
its.push(ItemContainer { name: "bool item".to_string(), item: Item::Bool { value: false } });
its.push(ItemContainer { name: "int item".to_string(), item: Item::Int { value: 0, min: Some(0), max: None } });
its.push(ItemContainer { name: "float item".to_string(), item: Item::Float { value: 0.0, min: None, max: Some(69.0) } });
its.push(ItemContainer { name: "string item".to_string(), item: Item::String { value: "hello".to_string() } });
its.push(ItemContainer { name: "enum items".to_string(), item: Item::Enum { value: 0, options: vec!["opt1".into(), "opt2".into(), "other_opt".into()] } });
eprintln!("Example input:\n{}\n\nOutput is the same with changed value keys\nKeys with value of null can be omited", serde_json::to_string_pretty(&its).unwrap());
return Err(());
}
let items: Vec<ItemContainer> = if args.contains(&"--edit-stdin".to_string()) {
let res = read_stdin();
serde_json::from_str(&res).unwrap()
} else if let Some(file_pos) = args.iter().position(|arg| *arg == "--edit-file".to_string()) {
let fp = args[file_pos + 1].clone();
let res = std::fs::read_to_string(fp).unwrap();
serde_json::from_str(&res).unwrap()
} else if let Some(input_pos) = args.iter().position(|arg| *arg == "--edit-input".to_string()) {
let res = args[input_pos + 1].clone();
serde_json::from_str(&res).unwrap()
} else {
eprintln!("No input specified, use --edit-help for help");
return Err(());
};
let mut s = Self {
api,
entries: Vec::with_capacity(items.len() + 1),
items,
state: State::Main,
message: String::new(),
};
s.entries_from_items();
Ok(s)
}
fn entries(&mut self) -> usize {
self.entries.len()
}
fn entry_content(&self, line: usize) -> rofi_mode::String {
self.entries[line].clone().into()
}
fn react(&mut self, event: rofi_mode::Event, input: &mut rofi_mode::String) -> rofi_mode::Action {
match event {
rofi_mode::Event::Cancel { .. } => {
if let State::Editing(item) = self.state {
*input = "".into();
self.entries_from_items();
} else {
self.print_items();
return rofi_mode::Action::Exit;
}
},
rofi_mode::Event::Ok { selected, .. } => {
if let State::Editing(item) = self.state {
self.finish_edit(Some(selected), None);
} else {
if selected == self.entries() - 1 {
self.print_items();
return rofi_mode::Action::Exit;
} else {
self.enter_edit(selected);
}
}
},
rofi_mode::Event::CustomInput { selected, .. } => {
if let State::Editing(item) = self.state {
self.finish_edit(None, Some(input));
*input = "".into();
} else {
*input = rofi_mode::format!("");
}
},
rofi_mode::Event::Complete { selected } => {
match selected {
None => {},
Some(item) => {
*input = rofi_mode::format!("{}", self.entries[item]);
}
}
},
rofi_mode::Event::DeleteEntry { selected } => {},
rofi_mode::Event::CustomCommand { number, selected } => {},
}
rofi_mode::Action::Reload
}
fn matches(&self, line: usize, matcher: rofi_mode::Matcher<'_>) -> bool {
matcher.matches(&self.entries[line])
}
fn message(&mut self) -> rofi_mode::String {
self.message.clone().into()
}
}
rofi_mode::export_mode!(Mode<'_>);

View file

@ -1,3 +0,0 @@
fn main() {
println!("Hello, world!");
}