about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--bollux63
1 files changed, 44 insertions, 19 deletions
diff --git a/bollux b/bollux index c3be520..9e8d6ce 100644 --- a/bollux +++ b/bollux
@@ -137,6 +137,15 @@ bollux_config() {
137 : "${BOLLUX_PROTO:=gemini}" # default protocol 137 : "${BOLLUX_PROTO:=gemini}" # default protocol
138 : "${BOLLUX_URL:=}" # start url 138 : "${BOLLUX_URL:=}" # start url
139 : "${BOLLUX_BYEMSG:=See You Space Cowboy ...}" # bye message 139 : "${BOLLUX_BYEMSG:=See You Space Cowboy ...}" # bye message
140 ## lesskeys
141 : "${KEY_OPEN:=o}" # prompt for a link to open
142 : "${KEY_GOTO:=g}" # prompt for a page to 'goto'
143 : "${KEY_GOTO_FROM:=G}" # goto a page with current prefilled
144 : "${KEY_BACK:='['}" # go back in the history
145 : "${KEY_FORWARD:=']'}" # go forward in the history
146 : "${KEY_REFRESH:=r}" # refresh the page
147 : "${KEY_CYCLE_PRE:=p}" # cycle T_PRE_DISPLAY
148 : "${BOLLUX_CUSTOM_LESSKEY:=${XDG_CONFIG_HOME:-$HOME/.config}/bollux/bollux.lesskey}"
140 ## files 149 ## files
141 : "${BOLLUX_DATADIR:=${XDG_DATA_HOME:-$HOME/.local/share}/bollux}" 150 : "${BOLLUX_DATADIR:=${XDG_DATA_HOME:-$HOME/.local/share}/bollux}"
142 : "${BOLLUX_DOWNDIR:=.}" # where to save downloads 151 : "${BOLLUX_DOWNDIR:=.}" # where to save downloads
@@ -689,8 +698,13 @@ display() { # display METADATA [TITLE]
689 set_title "$title${title:+ - }bollux" 698 set_title "$title${title:+ - }bollux"
690 # render ANSI color escapes and don't wrap pre-formatted blocks 699 # render ANSI color escapes and don't wrap pre-formatted blocks
691 less_cmd=(less -RS) 700 less_cmd=(less -RS)
692 mklesskey "$BOLLUX_LESSKEY" && less_cmd+=(-k "$BOLLUX_LESSKEY") 701 mklesskey && less_cmd+=(-k "$BOLLUX_LESSKEY")
693 local helpline="o:open, g/G:goto, [:back, ]:forward, r:refresh" 702 local helpline="${KEY_OPEN}:open, "
703 helpline+="${KEY_GOTO}/"
704 helpline+="${KEY_GOTO_FROM}:goto, "
705 helpline+="${KEY_BACK}:back, "
706 helpline+="${KEY_FORWARD}:forward, "
707 helpline+="${KEY_REFRESH}:refresh"
694 less_cmd+=( 708 less_cmd+=(
695 # 'status'line 709 # 'status'line
696 -Pm"$(less_prompt_escape "$BOLLUX_URL") - bollux$" 710 -Pm"$(less_prompt_escape "$BOLLUX_URL") - bollux$"
@@ -735,23 +749,31 @@ less_prompt_escape() { # less_prompt_escape STRING
735} 749}
736 750
737# generate a lesskey(1) file for custom keybinds 751# generate a lesskey(1) file for custom keybinds
738mklesskey() { # mklesskey FILENAME 752mklesskey() { # mklesskey
739 lesskey -o "$1" - <<-\END 753 if [[ -f "$BOLLUX_CUSTOM_LESSKEY" ]]; then
740 #command 754 log d "Using custom lesskey: '$BOLLUX_CUSTOM_LESSKEY'"
741 o quit 0 # 48 open a link 755 BOLLUX_LESSKEY="${BOLLUX_CUSTOM_LESSKEY}"
742 g quit 1 # 49 goto a url 756 elif [[ ! -f "$BOLLUX_LESSKEY" ]]; then
743 [ quit 2 # 50 back 757 log d "Generating lesskey: '$BOLLUX_LESSKEY'"
744 ] quit 3 # 51 forward 758 lesskey -o "$BOLLUX_LESSKEY" - <<END
745 r quit 4 # 52 re-request / download 759#command
746 G quit 5 # 53 goto a url (pre-filled) 760${KEY_OPEN} quit 0 # 48 open a link
747 p quit 6 # 54 cycle T_PRE_DISPLAY and refresh 761${KEY_GOTO} quit 1 # 49 goto a url
748 # other keybinds 762${KEY_BACK} quit 2 # 50 back
749 \40 forw-screen-force 763${KEY_FORWARD} quit 3 # 51 forward
750 h left-scroll 764${KEY_REFRESH} quit 4 # 52 re-request / download
751 l right-scroll 765${KEY_GOTO_FROM} quit 5 # 53 goto a url (pre-filled)
752 ? status # 'status' will show a little help thing. 766${KEY_CYCLE_PRE} quit 6 # 54 cycle T_PRE_DISPLAY and refresh
753 = noaction 767# other keybinds
754 END 768\\40 forw-screen-force
769h left-scroll
770l right-scroll
771? status # 'status' will show a little help thing.
772= noaction
773END
774 else
775 log d "Found lesskey: '$BOLLUX_LESSKEY'"
776 fi
755} 777}
756 778
757# normalize files 779# normalize files
@@ -1081,6 +1103,9 @@ bollux_init() {
1081 declare -a HISTORY # history is kept in an array 1103 declare -a HISTORY # history is kept in an array
1082 HN=0 # position of history in the array 1104 HN=0 # position of history in the array
1083 run mkdir -p "${BOLLUX_HISTFILE%/*}" 1105 run mkdir -p "${BOLLUX_HISTFILE%/*}"
1106 # Remove $BOLLUX_LESSKEY and re-generate keybindings (to catch rebinds)
1107 run rm "$BOLLUX_LESSKEY"
1108 mklesskey
1084} 1109}
1085 1110
1086# clean up on exit 1111# clean up on exit