Alfred Workflow to search Good Links by tag #1

Open
opened 2023-07-05 01:35:13 +02:00 by snoblenet · 5 comments
snoblenet commented 2023-07-05 01:35:13 +02:00 (Migrated from github.com)

Thanks for the Add To Good Links workflow.

It made me wonder, have you by chance developed an Alfred Workflow to search Good Links by tag, and not yet posted it here?

Thanks for the Add To Good Links workflow. It made me wonder, have you by chance developed an Alfred Workflow to search Good Links by tag, and not yet posted it here?
gracjankn commented 2023-07-05 23:09:55 +02:00 (Migrated from github.com)

No, I haven't made a search workflow. You're welcome for the existing workflow though! Have a nice day!

No, I haven't made a search workflow. You're welcome for the existing workflow though! Have a nice day!
snoblenet commented 2023-07-07 23:59:33 +02:00 (Migrated from github.com)

So far, I've got as far as this working ZSH script...

listGoodLinksTags() {
  DB_PATH="$HOME/Library/Group Containers/group.com.ngocluu.goodlinks/Data/data.sqlite"
  sqlite3 "$DB_PATH" "SELECT DISTINCT tags FROM link" | tr ' ' '\n' | sort -u
}
So far, I've got as far as this working ZSH script... ``` listGoodLinksTags() { DB_PATH="$HOME/Library/Group Containers/group.com.ngocluu.goodlinks/Data/data.sqlite" sqlite3 "$DB_PATH" "SELECT DISTINCT tags FROM link" | tr ' ' '\n' | sort -u } ```
snoblenet commented 2023-07-08 00:19:32 +02:00 (Migrated from github.com)

Better, but not yet using Alfred...


openGoodLinksTag() {
  DB_PATH="$HOME/Library/Group Containers/group.com.ngocluu.goodlinks/Data/data.sqlite"
  TAGS=$(sqlite3 "$DB_PATH" "SELECT DISTINCT tags FROM link" | tr ' ' '\n' | sort -u)
  TAG="$(echo $TAGS | fzf)"
  URL="goodlinks://x-callback-url/tag?name=$TAG"
  open "$URL"
}
Better, but not yet using Alfred... ``` openGoodLinksTag() { DB_PATH="$HOME/Library/Group Containers/group.com.ngocluu.goodlinks/Data/data.sqlite" TAGS=$(sqlite3 "$DB_PATH" "SELECT DISTINCT tags FROM link" | tr ' ' '\n' | sort -u) TAG="$(echo $TAGS | fzf)" URL="goodlinks://x-callback-url/tag?name=$TAG" open "$URL" } ```
snoblenet commented 2023-07-08 00:48:30 +02:00 (Migrated from github.com)

Almost there.

Here's what I have:

image

image

image

image

But when I type "gl ag" in the Alfred launcher, it does not suggest "gl agile", and when I just plain type "gl agile" in the Alfred launcher and press return, it searches Google for the phrase "gl agile" instead of opening GoodLinks.

Almost there. Here's what I have: ![image](https://github.com/gracjankn/alfred-workflows/assets/62277/1d0a22a7-9b97-4661-abd2-00f43897e35d) ![image](https://github.com/gracjankn/alfred-workflows/assets/62277/713effa9-dfaa-4bce-8499-7ab0ee84165e) ![image](https://github.com/gracjankn/alfred-workflows/assets/62277/26dd97eb-8c3e-459b-9ba4-0f683b04c2a1) ![image](https://github.com/gracjankn/alfred-workflows/assets/62277/e17adbee-e4ad-4124-8337-e98a7e3e74c5) But when I type "gl ag" in the Alfred launcher, it does not suggest "gl agile", and when I just plain type "gl agile" in the Alfred launcher and press return, it searches Google for the phrase "gl agile" instead of opening GoodLinks.
snoblenet commented 2023-07-08 01:12:46 +02:00 (Migrated from github.com)

I revised the script filter to provide what looks like valid output:

DB_PATH="$HOME/Library/Group Containers/group.com.ngocluu.goodlinks/Data/data.sqlite"

TAGS=$(
  sqlite3 "$DB_PATH" "SELECT DISTINCT tags FROM link" \
    | sort -u \
    | xargs printf "{ \"title\": \"%s\", \"subtitle\": \"Open tag in GoodLinks\", \"arg\": \"%s\" },"
)

echo "{\"items\": [$TAGS]}" | sed 's/\(.*\),/\1 /'

(Or echo "{\"items\": [$TAGS]}" | sed 's/\(.*\),/\1 /' | jq for debugging)

I revised the script filter to provide what looks like valid output: ``` DB_PATH="$HOME/Library/Group Containers/group.com.ngocluu.goodlinks/Data/data.sqlite" TAGS=$( sqlite3 "$DB_PATH" "SELECT DISTINCT tags FROM link" \ | sort -u \ | xargs printf "{ \"title\": \"%s\", \"subtitle\": \"Open tag in GoodLinks\", \"arg\": \"%s\" }," ) echo "{\"items\": [$TAGS]}" | sed 's/\(.*\),/\1 /' ``` (Or `echo "{\"items\": [$TAGS]}" | sed 's/\(.*\),/\1 /' | jq` for debugging)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
gracjan/alfred-workflows#1
No description provided.