Jump to content

Denis The Menace

Member
  • Posts

    4
  • Joined

  • Last visited

Posts posted by Denis The Menace

  1. 32 minutes ago, deanishe said:

    mdfind might be a better choice than locate (if it finds the files). The locate database isn’t on by default on macOS, and it only updates once a day, so it won’t find recently-created entries.


    The optimal way is to run ls or find in a background process and cache the results, then use the cache in your workflow.

     

    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.

  2. 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:

    520907670_ScreenShot2020-08-19at21_24_11.thumb.png.0577533de1ded5543050a743456a7e3c.png

    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
  3. 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 :)

  4. 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!

×
×
  • Create New...