diff --git a/.local/bin/bookmark b/.local/bin/bookmark new file mode 100755 index 00000000..f6cde9ff --- /dev/null +++ b/.local/bin/bookmark @@ -0,0 +1,25 @@ +#!/bin/sh + +getbookmark() { + bookmark="$(xclip -selection clipboard -o)" + tags=$(echo "" | dmenu -p "Enter bookmark tags (ENTER to save without tags)") +} + +write_to_file () { + if grep -q -E "^$bookmark( |$)" "$file"; then + notify-send "Already bookmarked $bookmark!" + else + notify-send "Bookmarked $bookmark" + echo "$bookmark" "$tags" >> "$file" + echo "$bookmark" | xclip -selection clipboard -i + fi +} + +case "$(printf "šŸ“œ rss\nšŸŒ url\nšŸŒšŸ“œ site (rss + url)\nšŸŽµ song" | dmenu -i -p 'Bookmark: ')" in + 'šŸŒšŸ“œ site (rss + url)') getbookmark && rssget "$bookmark" "$tags" && file="$HOME/.local/share/larbs/snippets" && write_to_file ;; + 'šŸ“œ rss') getbookmark && rssget "$bookmark" "$tags" ;; + 'šŸŒ url') getbookmark && file="$HOME/.local/share/larbs/snippets" && write_to_file ;; + 'šŸŽµ song') bookmark="$(mpc | sed "/^volume:/d;s/\\&/&/g;s/\\[paused\\].*/āø/g;/\\[playing\\].*/d;/^ERROR/Q")" + file="$HOME/.local/share/larbs/songlog" && write_to_file ;; + *) exit 1 ;; +esac