diff --git a/macos/Alfred.alfredpreferences/workflows/user.workflow.2DA2DBB5-8E61-456C-800C-F90E52E7FBB6 b/macos/Alfred.alfredpreferences/workflows/user.workflow.2DA2DBB5-8E61-456C-800C-F90E52E7FBB6 new file mode 120000 index 0000000..8efb639 --- /dev/null +++ b/macos/Alfred.alfredpreferences/workflows/user.workflow.2DA2DBB5-8E61-456C-800C-F90E52E7FBB6 @@ -0,0 +1 @@ +/Users/alpha/.dotfiles/src/alphred-tools/workflow \ No newline at end of file diff --git a/src/alphred-tools/.gitignore b/src/alphred-tools/.gitignore new file mode 100644 index 0000000..eb5a316 --- /dev/null +++ b/src/alphred-tools/.gitignore @@ -0,0 +1 @@ +target diff --git a/src/alphred-tools/Cargo.lock b/src/alphred-tools/Cargo.lock new file mode 100644 index 0000000..15431b9 --- /dev/null +++ b/src/alphred-tools/Cargo.lock @@ -0,0 +1,327 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "addr2line" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a30b2e23b9e17a9f90641c7ab1549cd9b44f296d3ccbf309d2863cfe398a0cb" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + +[[package]] +name = "alphred" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "183163a75cc7bff7166b9a74f5b79f653370b2474d05bd35c61f368f3a515046" +dependencies = [ + "anyhow", + "serde", + "serde_json", +] + +[[package]] +name = "alphred-tools" +version = "0.1.0" +dependencies = [ + "alphred", + "color-eyre", + "serde_json", +] + +[[package]] +name = "anyhow" +version = "1.0.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" + +[[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]] +name = "cc" +version = "1.0.83" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" +dependencies = [ + "libc", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "color-eyre" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204" +dependencies = [ + "backtrace", + "color-spantrace", + "eyre", + "indenter", + "once_cell", + "owo-colors", + "tracing-error", +] + +[[package]] +name = "color-spantrace" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2" +dependencies = [ + "once_cell", + "owo-colors", + "tracing-core", + "tracing-error", +] + +[[package]] +name = "eyre" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bbb8258be8305fb0237d7b295f47bb24ff1b136a535f473baf40e70468515aa" +dependencies = [ + "indenter", + "once_cell", +] + +[[package]] +name = "gimli" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253" + +[[package]] +name = "indenter" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ce23b50ad8242c51a442f3ff322d56b02f08852c77e4c0b4d3fd684abc89c683" + +[[package]] +name = "itoa" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af150ab688ff2122fcef229be89cb50dd66af9e01a4ff320cc137eecc9bacc38" + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.150" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" + +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +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 = "object" +version = "0.32.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "owo-colors" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" + +[[package]] +name = "pin-project-lite" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58" + +[[package]] +name = "proc-macro2" +version = "1.0.70" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.33" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" + +[[package]] +name = "ryu" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad4cc8da4ef723ed60bced201181d83791ad433213d8c24efffda1eec85d741" + +[[package]] +name = "serde" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.193" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.108" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "sharded-slab" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "syn" +version = "2.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "thread_local" +version = "1.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" +dependencies = [ + "cfg-if", + "once_cell", +] + +[[package]] +name = "tracing" +version = "0.1.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" +dependencies = [ + "once_cell", + "valuable", +] + +[[package]] +name = "tracing-error" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" +dependencies = [ + "tracing", + "tracing-subscriber", +] + +[[package]] +name = "tracing-subscriber" +version = "0.3.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" +dependencies = [ + "sharded-slab", + "thread_local", + "tracing-core", +] + +[[package]] +name = "unicode-ident" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" + +[[package]] +name = "valuable" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" diff --git a/src/alphred-tools/Cargo.toml b/src/alphred-tools/Cargo.toml new file mode 100644 index 0000000..f6005c1 --- /dev/null +++ b/src/alphred-tools/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "alphred-tools" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +alphred = "*" +color-eyre = "*" +serde_json = "1.0.108" diff --git a/src/alphred-tools/src/bin/rot13.rs b/src/alphred-tools/src/bin/rot13.rs new file mode 100644 index 0000000..95bf848 --- /dev/null +++ b/src/alphred-tools/src/bin/rot13.rs @@ -0,0 +1,45 @@ +use alphred::{Item, Workflow}; +use std::{env, process::Command}; + +use color_eyre::eyre::Result; + +fn main() -> Result<()> { + color_eyre::install()?; + + let workflow = Workflow::new(|| { + let input = match env::args().nth(1) { + Some(arg) => arg, + None => String::from_utf8( + Command::new("sh") + .arg("-c") + .arg("echo hello") + .output()? + .stdout, + )?, + }; + let input = input.trim(); + let output: String = input + .chars() + .map(|c| { + if c.is_ascii_alphabetic() { + let origin = if c.is_lowercase() { + b'a' + } else if c.is_uppercase() { + b'A' + } else { + unimplemented!() + }; + ((((c as u8) - origin) + 13) % 26 + origin) as char + } else { + c + } + }) + .collect(); + let item = Item::new(&output).arg(&output).subtitle(input); + Ok(vec![item]) + }); + + println!("{}", workflow); + + Ok(()) +} diff --git a/src/alphred-tools/src/lib.rs b/src/alphred-tools/src/lib.rs new file mode 100644 index 0000000..7d12d9a --- /dev/null +++ b/src/alphred-tools/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: usize, right: usize) -> usize { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +} diff --git a/src/alphred-tools/workflow/BF6DAC15-EB38-45F3-86A6-6BA4767A8D34.png b/src/alphred-tools/workflow/BF6DAC15-EB38-45F3-86A6-6BA4767A8D34.png new file mode 100644 index 0000000..f8689b8 Binary files /dev/null and b/src/alphred-tools/workflow/BF6DAC15-EB38-45F3-86A6-6BA4767A8D34.png differ diff --git a/src/alphred-tools/workflow/icon.png b/src/alphred-tools/workflow/icon.png new file mode 100644 index 0000000..3269d4d Binary files /dev/null and b/src/alphred-tools/workflow/icon.png differ diff --git a/src/alphred-tools/workflow/info.plist b/src/alphred-tools/workflow/info.plist new file mode 100644 index 0000000..7bfc95d --- /dev/null +++ b/src/alphred-tools/workflow/info.plist @@ -0,0 +1,138 @@ + + + + + bundleid + dev.kejadlen.alphred-tools + category + Tools + connections + + BF6DAC15-EB38-45F3-86A6-6BA4767A8D34 + + + destinationuid + ADF20C3D-ABB1-4713-AEE3-88087C0E4930 + modifiers + 0 + modifiersubtext + + vitoclose + + + + + createdby + Alpha Chen + description + + disabled + + name + Alphred Tools + objects + + + config + + alignment + 0 + backgroundcolor + + fadespeed + 0 + fillmode + 0 + font + + ignoredynamicplaceholders + + largetypetext + {query} + textcolor + + wrapat + 50 + + type + alfred.workflow.output.largetype + uid + ADF20C3D-ABB1-4713-AEE3-88087C0E4930 + version + 3 + + + config + + alfredfiltersresults + + alfredfiltersresultsmatchmode + 0 + argumenttreatemptyqueryasnil + + argumenttrimmode + 0 + argumenttype + 1 + escaping + 0 + keyword + rot13 + queuedelaycustom + 3 + queuedelayimmediatelyinitially + + queuedelaymode + 0 + queuemode + 1 + runningsubtext + + script + + scriptargtype + 1 + scriptfile + rot13 + subtext + + title + rot13 + type + 8 + withspace + + + type + alfred.workflow.input.scriptfilter + uid + BF6DAC15-EB38-45F3-86A6-6BA4767A8D34 + version + 3 + + + readme + + uidata + + ADF20C3D-ABB1-4713-AEE3-88087C0E4930 + + xpos + 235 + ypos + 50 + + BF6DAC15-EB38-45F3-86A6-6BA4767A8D34 + + xpos + 45 + ypos + 50 + + + userconfigurationconfig + + webaddress + https://git.kejadlen.dev/alpha/alphred-tools + + diff --git a/src/alphred-tools/workflow/rot13 b/src/alphred-tools/workflow/rot13 new file mode 120000 index 0000000..7204689 --- /dev/null +++ b/src/alphred-tools/workflow/rot13 @@ -0,0 +1 @@ +/Users/alpha/.dotfiles/src/alphred-tools/target/release/rot13 \ No newline at end of file