summaryrefslogtreecommitdiff
path: root/.local/bin/open_man
diff options
context:
space:
mode:
Diffstat (limited to '.local/bin/open_man')
-rwxr-xr-x.local/bin/open_man16
1 files changed, 12 insertions, 4 deletions
diff --git a/.local/bin/open_man b/.local/bin/open_man
index f86f1f9..b37d94b 100755
--- a/.local/bin/open_man
+++ b/.local/bin/open_man
@@ -1,5 +1,14 @@
#!/usr/bin/env bash
+MENU_CMD=dmenu "$@"
+
+if [ "$XDG_SESSION_TYPE" = "wayland" ]; then
+ MENU_CMD=bemenu "$@"
+ TERM=$TERM -d none
+else
+ MENU_CMD=dmenu "$@"
+fi
+
cachedir=${XDG_CACHE_HOME:-"$HOME/.cache"}
if [ -d "$cachedir" ]; then
cache=$cachedir/dmenu_run_man
@@ -9,8 +18,6 @@ else # if no xdg dir, fall back to dotfiles in ~
historyfile=$HOME/.dmenu_man_history
fi
-FONT="DejaVuSansMono Nerd Font Mono:pixelsize=16:antialias=true:autohint=true:style=book"
-
# Generate a new cache if necessary
if stest -dqr -n "$cache" /usr/share/man/**/*; then
ls /usr/share/man/**/* \
@@ -26,7 +33,7 @@ awk -v histfile=$historyfile '
x[$0]=1
}
} !x[$0]++ ' "$cache" \
- | dmenu "$@" \
+ | $MENU_CMD \
| awk -v histfile=$historyfile '
BEGIN {
FS=OFS="\t"
@@ -53,6 +60,7 @@ awk -v histfile=$historyfile '
| while read MAN; do
VERSION=$(echo $MAN | sed -Ee 's/.* \(([0-9].*)\)/\1/g')
PAGE=$(echo $MAN | sed -Ee 's/(.*) \([0-9].*\)/\1/g')
+ ## Uncomment for debugging
#echo "Man: $VERSION $PAGE"
- st -e man $VERSION $PAGE
+ $TERM man $VERSION $PAGE
done