aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bash/symlinks.sh3
-rwxr-xr-xscripts/buku-add.sh2
-rwxr-xr-xscripts/buku-archive.sh26
-rwxr-xr-xscripts/buku-delete.sh26
-rw-r--r--xmonad/xmonad.hs6
5 files changed, 49 insertions, 14 deletions
diff --git a/bash/symlinks.sh b/bash/symlinks.sh
index 573c817..f6adb0c 100644
--- a/bash/symlinks.sh
+++ b/bash/symlinks.sh
@@ -79,3 +79,6 @@ ln -fs /tmp/notmuch."$(date +%Y-%m-%d)".log /tmp/notmuch.log
## GNUS
ln -fs "$DOTFILES/encrypted/IMAP/authinfo.gpg" ~/.authinfo.gpg
+
+## Buku
+ln -fs /tmp/buku-xmonad."$(date +%Y-%m-%d)".log /tmp/buku-xmonad.log
diff --git a/scripts/buku-add.sh b/scripts/buku-add.sh
index beccd0a..005adbd 100755
--- a/scripts/buku-add.sh
+++ b/scripts/buku-add.sh
@@ -1,3 +1,3 @@
#!/usr/bin/env bash
-xsel | xargs -I{} buku -a "{}" ril
+xclip -o | xargs -I{} buku -a "{}" ril
diff --git a/scripts/buku-archive.sh b/scripts/buku-archive.sh
index 5af56a0..6ce1e80 100755
--- a/scripts/buku-archive.sh
+++ b/scripts/buku-archive.sh
@@ -1,12 +1,28 @@
#!/usr/bin/env bash
-set -x
-SEL="$(xsel)"
-BOOKMARK_ID="$(buku "$SEL" -f 1 --tacit | tail -n +2 | awk '{print $1}')"
-# tail to trim unwanted "waiting for input" output from buku https://github.com/jarun/Buku/blob/d60d56bc9f7f5e1410e99dc8bb4e35abf5068a14/buku#L4619
+SEL="$(xclip -o | tr -d '\n')"
+if [[ -z "${SEL// }" ]]; then
+ echo "Empty selection."
+ exit 1
+fi
+BOOKMARK_ID=
+IFS="
+"
+BOOKMARKS="$(buku "$SEL" -f 1 --tacit)"
+
+for bookmark in $BOOKMARKS; do
+ echo "$bookmark"
+ ID="$(echo "$bookmark" | cut -d$'\t' -f 1)"
+ URL="$(echo "$bookmark" | cut -d$'\t' -f 2)"
+ if [[ "$URL" = "$SEL" ]]; then
+ BOOKMARK_ID="$ID"
+ break
+ fi
+done
+
if [[ ! -z "$BOOKMARK_ID" ]]; then
- echo "Archiving $BOOKMARK_ID."
+ echo "Archiving $BOOKMARK_ID (URL: $SEL)."
buku -u "$BOOKMARK_ID" --tag - ril
buku -u "$BOOKMARK_ID" --tag + simple-archive
else
diff --git a/scripts/buku-delete.sh b/scripts/buku-delete.sh
index 3e2f3dd..552d6b0 100755
--- a/scripts/buku-delete.sh
+++ b/scripts/buku-delete.sh
@@ -1,12 +1,28 @@
#!/usr/bin/env bash
-set -x
-SEL="$(xsel)"
-BOOKMARK_ID="$(buku "$SEL" -f 1 --tacit | tail -n +2 | awk '{print $1}')"
-# tail to trim unwanted "waiting for input" output from buku https://github.com/jarun/Buku/blob/d60d56bc9f7f5e1410e99dc8bb4e35abf5068a14/buku#L4619
+SEL="$(xclip -o | tr -d '\n')"
+if [[ -z "${SEL// }" ]]; then
+ echo "Empty selection."
+ exit 1
+fi
+BOOKMARK_ID=
+IFS="
+"
+BOOKMARKS="$(buku "$SEL" -f 1 --tacit)"
+
+for bookmark in $BOOKMARKS; do
+ echo "$bookmark"
+ ID="$(echo "$bookmark" | cut -d$'\t' -f 1)"
+ URL="$(echo "$bookmark" | cut -d$'\t' -f 2)"
+ if [[ "$URL" = "$SEL" ]]; then
+ BOOKMARK_ID="$ID"
+ break
+ fi
+done
+
if [[ ! -z "$BOOKMARK_ID" ]]; then
- echo "Deleting $BOOKMARK_ID."
+ echo "Deleting $BOOKMARK_ID (URL: $SEL)."
buku -d "$BOOKMARK_ID" --tacit
else
echo "Bookmark for '$SEL' not found."
diff --git a/xmonad/xmonad.hs b/xmonad/xmonad.hs
index ff14005..8c12ae5 100644
--- a/xmonad/xmonad.hs
+++ b/xmonad/xmonad.hs
@@ -98,15 +98,15 @@ myKeyBindings =
-- save selection (link) in buku
, ((mod4Mask, xK_c),
- spawn "$HOME/dev/libre/dotfiles/scripts/buku-add.sh")
+ spawn "$HOME/dev/libre/dotfiles/scripts/buku-add.sh >> /tmp/buku-xmonad.log")
-- delete selection (link) from buku
, ((mod4Mask, xK_d),
- spawn "$HOME/dev/libre/dotfiles/scripts/buku-delete.sh > ~/tmp/dbg-delete")
+ spawn "$HOME/dev/libre/dotfiles/scripts/buku-delete.sh >> /tmp/buku-xmonad.log")
-- archive selection (link) in buku
, ((mod4Mask, xK_a),
- spawn "$HOME/dev/libre/dotfiles/scripts/buku-archive.sh > ~/tmp/dbg-archive")
+ spawn "$HOME/dev/libre/dotfiles/scripts/buku-archive.sh >> /tmp/buku-xmonad.log")
]
startup :: X()