Denis The Menace
-
Posts
4 -
Joined
-
Last visited
Content Type
Blogs
Gallery
Downloads
Events
Profiles
Forums
Articles
Media Demo
Posts posted by Denis The Menace
-
-
On 4/5/2020 at 12:52 AM, angoll said:
Hello,
I created a workflow that allows to list the entries of a KeePassXC database and retrieve the password for an entry.
...
Hey, @angoll!
Thanks for heavy lifting. I was looking for such integration for quite some time. There was no time to create it by myself from scratch.
However, I changed a few things and now it suits me better. I did not create pull request because I am not sure my functionality is in accordance of your workflow.
My KeePass database is big and contains hundreds of entries. Thus, I cannot afford list all entries. Instead, I change it to use "locate" command instead of "ls" for keepassxc-cli. Also, added some bells and whistles:
- fixed issue with spaces in entry names
- filtered out Recycle bin entries
- removed leading slash for display clarity
- replaced slashes with arrows to show folder names more clearly
Here's how it looks for me now:
Here's modified script:
query="{query}" IFS=$'\n' export PATH='/usr/local/bin/:/usr/bin' if [[ -z ${database} ]] || [[ -z ${keychain} ]]; then echo "{\"items\": [{\"title\":\"Not configured, please run: kpassinit\"}]}"; else keys=( $(security find-generic-password -a $(id -un) -c 'kpas' -C 'kpas' -s "AlfredWorkflow" -w "${keychain}" |\ keepassxc-cli locate -q "$database" "$query" | grep -Ev "\/Recycle Bin\/") ) if [ $? -eq 0 ]; then echo -n '{"items": [' first= for entry in ${keys[@]}; do if [ $first ] ; then echo -n ","; fi title=${entry/\//} title=${title//\// ➜ } echo -n "{\"uid\":\"${entry}\",\"title\":\"${title}\",\"arg\":\"${entry}\",\"autocomplete\":\"${entry}\",\"icon\":{\"type\":\"png\",\"path\":\"${PWD}/icon.png\"}}"; first=false done echo ']}' else echo -n "{\"items\": [{\"title\":\"Error listing database, please check config\"}]}" fi fi
And there are still two issues:
- keepassxc-cli was not on PATH and I created symlink to /usr/local/bin folder for it to be visible
- workflow fails if I enter nothing for time out period or search result is empty. Will try to deal with this later
-
7 hours ago, Acidham said:
BTW: Why are you not putting WF on Git? Would be easier to fork
Not a problem at all. I'm not very experienced with Workflows but as I see, exported workflow is actually a zip archive. To me, it wouldn't be very convenient to put binary zip into git.
I'll see if it is possible to put all files like icons, shells scripts, etc. separately and add simple script which bundles everything into .workflow file.
7 hours ago, Acidham said:I am getting lot of NULL devices. By adding after first grep this can be avoided:
Duly noted, thanks. As an excuse, I did not see any null devices at my side
-
Decided to share my workflow which allows to connect and disconnect with already paired bluetooth devices.
It relies on blueutil command line utility, which can be install via Homebrew:
brew install blueutil
I deliberately choose the fastest way to achieve the simple goal. Thus, workflow is fairly simple and works via shell scripts. Also, this approach allows anyone interested to modify and extend it like in no time.
Workflow features two shortcuts: btc and btd, they stand for BlueTooth Connect and BlueTooth Disconnect respectively. As you type, list of devices is populated on the fly.
https://drive.google.com/file/d/1AshZo4dYuQ5vEvCYJz8KTTh0xw71w4UD/view?usp=sharing
I don't think I will spare significant time improving this workflow since it already fulfills my needs. But I see it as a good starting point for further development for anyone curious.
Enjoy it!
KeePassXC Integration
in Share your Workflows
Posted
I'm using KeepassXC v.2.6.0 and there are neither mdfind nor find commands available. I did nothing to enable locate. It worked out of the box.