Files
sxbm/sxbm_dmenu
2021-09-09 14:40:36 +06:00

37 lines
705 B
Bash
Executable File

#!/bin/sh
# Description: dmenu/rofi wrapper around sxbm
# Dependency: sxbm, dmenu/rofi, xclip (optional)
#
# Author: NRK
## Copyright 2021 NRK
## Licensed under GPL v3. See LICENSE for more details.
sxbm="sbm"
prompt="dmenu -i -l 24"
bm_open() {
link_num="$($sxbm ls -c "$@" | $prompt | cut -d ")" -f 1)"
[ -n "$link_num" ] && $sxbm open "$link_num"
}
bm_yank() {
link="$($sxbm ls -c "$@" | $prompt | cut -d " " -f 2)"
[ -n "$link" ] && echo "$link" | xclip -in -selection clipboard
}
bm_add() {
$sxbm add "$@" 2>&1 | xargs -I{} $prompt -p {}
}
case "$1" in
"-a"|"--add")
shift && bm_add "$@"
;;
"-y"|"--yank")
shift && bm_yank "$@"
;;
*)
bm_open "$@"
;;
esac