added deeper context menus for vim/vis, nano, tuir, ncmpcpp, w3m

This patch looks at whatever application is running inside the st terminal.
and presents a more fine-tuned context menu based on it. It does so by
parsing WM_NAME.

Supported for the moment: vim/vis, nano, tuir, ncmpcpp, w3m

This probably won't work if you're in a terminal multiplexer like
screen/tmux, unless it's configured to propagate the name of running
application.

This patch is to be applied **after** my patch for feh/sxiv from earlier today (not included in this patch)

Signed-off-by: Miles Alan <m@milesalan.com>
master
Maarten van Gompel 4 years ago committed by Miles Alan
parent 03025fae5d
commit bfdbe29c0b
  1. 90
      scripts/core/sxmo_appmenu.sh

@ -123,6 +123,90 @@ programchoicesinit() {
WINNAME=Sxiv && return
elif echo "$WMCLASS" | grep -i "st-256color"; then
# St
# First we try to handle the app running inside st:
WMNAME="${1:-$(echo "$XPROPOUT" | grep -E "^WM_NAME" | cut -d ' ' -f3-)}"
if echo "$WMNAME" | grep -i -E "\"(vi|vim|vis|nvim|neovim)\""; then
#Vim in st
CHOICES="
Scroll ↑ ^ 1 ^ key Ctrl+Shift+u
Scroll ↓ ^ 1 ^ key Ctrl+Shift+d
Command prompt ^ 0 ^ key Escape Shift+semicolon
Save ^ 0 ^ key Escape Shift+semicolon w Return
Quit ^ 0 ^ key Escape Shift+semicolon q Return
Paste Selection ^ 0 ^ key Escape quotedbl asterisk p
Paste Clipboard ^ 0 ^ key Escape quotedbl plus p
Search ^ 0 ^ key Escape /
Zoom + ^ 1 ^ key Ctrl+Shift+Prior
Zoom - ^ 1 ^ key Ctrl+Shift+Next
St menu ^ 0 ^ sxmo_appmenu.sh st-256color
"
WINNAME=Vim
elif echo "$WMNAME" | grep -i -w "nano"; then
#Nano in st
CHOICES="
Scroll ↑ ^ 1 ^ key Prior
Scroll ↓ ^ 1 ^ key Next
Save ^ 0 ^ key Ctrl+O
Quit ^ 0 ^ key Ctrl+X
Paste ^ 0 ^ key Ctrl+U
Type complete ^ 0 ^ key Ctrl+Shift+u
Copy complete ^ 0 ^ key Ctrl+Shift+i
Zoom + ^ 1 ^ key Ctrl+Shift+Prior
Zoom - ^ 1 ^ key Ctrl+Shift+Next
St menu ^ 0 ^ sxmo_appmenu.sh st-256color
"
WINNAME=Nano
elif echo "$WMNAME" | grep -i -w "tuir"; then
#tuir (reddit client) in st
CHOICES="
Previous ↑ ^ 1 ^ key k
Next ↓ ^ 1 ^ key j
Scroll ↑ ^ 1 ^ key Prior
Scroll ↓ ^ 1 ^ key Next
Open ^ 0 ^ key o
Back ← ^ 0 ^ key h
Comments → ^ 0 ^ key l
Post ^ 0 ^ key c
Refresh ^ 0 ^ key r
Quit ^ 0 ^ key q
Zoom + ^ 1 ^ key Ctrl+Shift+Prior
Zoom - ^ 1 ^ key Ctrl+Shift+Next
St menu ^ 0 ^ sxmo_appmenu.sh st-256color
"
WINNAME=tuir
elif echo "$WMNAME" | grep -i -w "w3m"; then
#w3m
CHOICES="
Back ← ^ 1 ^ key B
Goto URL ^ 1 ^ key U
Next Link ^ 1 ^ key Tab
Previous Link ^ 1 ^ key Shift+Tab
Open tab ^ 0 ^ key T
Close tab ^ 0 ^ Ctrl+q
Next tab ^ 1 ^ key braceright
Previous tab ^ 1 ^ key braceleft
Zoom + ^ 1 ^ key Ctrl+Shift+Prior
Zoom - ^ 1 ^ key Ctrl+Shift+Next
St menu ^ 0 ^ sxmo_appmenu.sh st-256color
"
WINNAME=w3m
elif echo "$WMNAME" | grep -i -w "ncmpcpp"; then
#ncmpcpp
CHOICES="
Playlist ^ 0 ^ key 1
Browser ^ 0 ^ key 2
Search ^ 0 ^ key 2
Next track ^ 0 ^ key greater
Previous track ^ 0 ^ key less
Pause ^ 0 ^ key p
Stop ^ 0 ^ key s
Toggle repeat ^ 0 ^ key r
Toggle random ^ 0 ^ key z
Toggle consume ^ 0 ^ key R
St menu ^ 0 ^ sxmo_appmenu.sh st-256color
"
WINNAME=ncmpcpp
else
STSELMODEON="$(
echo "$XPROPOUT" | grep -E '^_ST_SELMODE.+=' | cut -d= -f2 | tr -d ' '
)"
@ -145,12 +229,16 @@ programchoicesinit() {
Hotkeys ^ 0 ^ sxmo_appmenu.sh sthotkeys
"
WINNAME=St
fi
elif echo "$WMCLASS" | grep -i "sthotkeys"; then
# St hotkeys
CHOICES="
Send Ctrl-C ^ 0 ^ key Ctrl+c
Send Ctrl-Z ^ 0 ^ key Ctrl+z
Send Ctrl-L ^ 0 ^ key Ctrl+l
Send Ctrl-D ^ 0 ^ key Ctrl+d
Send Ctrl-A ^ 0 ^ key Ctrl+a
Send Ctrl-B ^ 0 ^ key Ctrl+b
"
WINNAME=St
elif echo "$WMCLASS" | grep -i netsurf; then
@ -269,7 +357,7 @@ getprogchoices() {
key() {
xdotool windowactivate "$WIN"
xdotool key --clearmodifiers "$1"
xdotool key --delay 50 --clearmodifiers $* # <-- unquoted, word splitting is deliberate!
#--window $WIN
}

Loading…
Cancel
Save