diff options
| author | 0scar <qgt268@alumni.ku.dk> | 2023-03-22 11:09:00 +0000 |
|---|---|---|
| committer | 0scar <qgt268@alumni.ku.dk> | 2023-03-22 11:09:00 +0000 |
| commit | 0758a3f3ab9511455163237a8274c3f3769872ba (patch) | |
| tree | d74c1d66540873a11a38a2d32c4d3209640c6e45 /.local | |
| parent | e11c3e5c8404b92abcac2a64c8905d89c60616c0 (diff) | |
Add wayland support for open_man and open_book
Diffstat (limited to '.local')
| -rwxr-xr-x | .local/bin/open_book | 2 | ||||
| -rwxr-xr-x | .local/bin/open_man | 16 |
2 files changed, 13 insertions, 5 deletions
diff --git a/.local/bin/open_book b/.local/bin/open_book index e053e27..bd17202 100755 --- a/.local/bin/open_book +++ b/.local/bin/open_book @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh DOCUMENT=$(find -L ~/${1:-books} -name '*.pdf' \ | fzf --header 'Choose a pdf') 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 |
