|
|
|
@ -2,37 +2,20 @@ |
|
|
|
|
WIN=$(xdotool getwindowfocus) |
|
|
|
|
|
|
|
|
|
programchoicesinit() { |
|
|
|
|
XPROPOUT="$(xprop -id $(xdotool getactivewindow))" |
|
|
|
|
XPROPOUT="$(xprop -id "$(xdotool getactivewindow)")" |
|
|
|
|
WMCLASS="${1:-$(echo "$XPROPOUT" | grep WM_CLASS | cut -d ' ' -f3-)}" |
|
|
|
|
|
|
|
|
|
# Default system menu (no matches) |
|
|
|
|
CHOICES="$(echo " |
|
|
|
|
$( |
|
|
|
|
[ -n "$(ls -A $XDG_CONFIG_HOME/sxmo/userscripts)" ] && |
|
|
|
|
echo 'Userscripts ^ 0 ^ sxmo_appmenu.sh userscripts' |
|
|
|
|
) |
|
|
|
|
Scripts ^ 0 ^ sxmo_appmenu.sh scripts |
|
|
|
|
Apps ^ 0 ^ sxmo_appmenu.sh applications |
|
|
|
|
Volume ↑ ^ 1 ^ sxmo_vol.sh up |
|
|
|
|
Volume ↓ ^ 1 ^ sxmo_vol.sh down |
|
|
|
|
Dialer ^ 0 ^ sxmo_modemcall.sh dial |
|
|
|
|
Texts ^ 0 ^ sxmo_modemtext.sh |
|
|
|
|
Camera ^ 0 ^ sxmo_camera.sh |
|
|
|
|
Wifi ^ 0 ^ st -e "nmtui" |
|
|
|
|
Audio ^ 0 ^ sxmo_appmenu.sh audioout |
|
|
|
|
Config ^ 0 ^ sxmo_appmenu.sh config |
|
|
|
|
Logout ^ 0 ^ pkill -9 dwm |
|
|
|
|
")" && WINNAME=Sys |
|
|
|
|
|
|
|
|
|
if echo "$WMCLASS" | grep -i "userscripts"; then |
|
|
|
|
# Userscripts menu |
|
|
|
|
echo $WMCLASS | grep -i "userscripts" && CHOICES="$( |
|
|
|
|
ls -1 $XDG_CONFIG_HOME/sxmo/userscripts | |
|
|
|
|
sed 's/ /\\ /' | |
|
|
|
|
CHOICES="$( |
|
|
|
|
find "$XDG_CONFIG_HOME/sxmo/userscripts" -type f -print0 | |
|
|
|
|
xargs -IF basename F | |
|
|
|
|
awk '{printf "%s\t^ 0 ^ $XDG_CONFIG_HOME/sxmo/userscripts/%s \n", $0, $0}' |
|
|
|
|
)" && WINNAME=Userscripts && return |
|
|
|
|
|
|
|
|
|
)" |
|
|
|
|
WINNAME=Userscripts |
|
|
|
|
elif echo "$WMCLASS" | grep -i "scripts"; then |
|
|
|
|
# Scripts menu |
|
|
|
|
echo $WMCLASS | grep -i "scripts" && CHOICES="$(echo " |
|
|
|
|
CHOICES=" |
|
|
|
|
Web Search ^ 0 ^ sxmo_websearch.sh |
|
|
|
|
Files ^ 0 ^ sxmo_files.sh |
|
|
|
|
Record ^ 0 ^ sxmo_record.sh |
|
|
|
@ -41,10 +24,11 @@ programchoicesinit() { |
|
|
|
|
Youtube (Audio) ^ 0 ^ sxmo_youtube.sh audio |
|
|
|
|
Weather ^ 0 ^ sxmo_weather.sh |
|
|
|
|
RSS ^ 0 ^ sxmo_rss.sh |
|
|
|
|
")" && WINNAME=Scripts && return |
|
|
|
|
|
|
|
|
|
" |
|
|
|
|
WINNAME=Scripts |
|
|
|
|
elif echo "$WMCLASS" | grep -i "applications"; then |
|
|
|
|
# Apps menu |
|
|
|
|
echo $WMCLASS | grep -i "applications" && CHOICES="$(echo " |
|
|
|
|
CHOICES=" |
|
|
|
|
Surf ^ 0 ^ surf |
|
|
|
|
Netsurf ^ 0 ^ netsurf |
|
|
|
|
Firefox ^ 0 ^ firefox |
|
|
|
@ -53,37 +37,40 @@ programchoicesinit() { |
|
|
|
|
Xcalc ^ 0 ^ xcalc |
|
|
|
|
St ^ 0 ^ st |
|
|
|
|
Foxtrotgps ^ 0 ^ foxtrotgps |
|
|
|
|
")" && WINNAME=Apps && return |
|
|
|
|
|
|
|
|
|
" |
|
|
|
|
WINNAME=Apps |
|
|
|
|
elif echo "$WMCLASS" | grep -i "config"; then |
|
|
|
|
# System Control menu |
|
|
|
|
echo $WMCLASS | grep -i "config" && CHOICES="$(echo " |
|
|
|
|
CHOICES=" |
|
|
|
|
Brightesss ↑ ^ 1 ^ sxmo_brightness.sh up |
|
|
|
|
Brightness ↓ ^ 1 ^ sxmo_brightness.sh down |
|
|
|
|
Modem Toggle ^ 1 ^ sxmo_modemmonitortoggle.sh |
|
|
|
|
Modem Info ^ 0 ^ sxmo_modeminfo.sh |
|
|
|
|
Modem Log ^ 0 ^ sxmo_modemlog.sh |
|
|
|
|
Flash $( |
|
|
|
|
cat /sys/class/leds/white:flash/brightness | |
|
|
|
|
grep -E '^0$' > /dev/null && |
|
|
|
|
echo -n "Off → On" || echo -n "On → Off"; |
|
|
|
|
echo -n "^ 1 ^ sxmo_flashtoggle.sh" |
|
|
|
|
grep -qE '^0$' /sys/class/leds/white:flash/brightness && |
|
|
|
|
printf %b "Off → On" || printf %b "On → Off"; |
|
|
|
|
printf %b "^ 1 ^ sxmo_flashtoggle.sh" |
|
|
|
|
) |
|
|
|
|
Bar Toggle ^ 1 ^ key Alt+b |
|
|
|
|
Change Timezone ^ 1 ^ sxmo_timezonechange.sh |
|
|
|
|
Rotate ^ 1 ^ sxmo_rotate.sh |
|
|
|
|
Upgrade Pkgs ^ 0 ^ st -e sxmo_upgrade.sh |
|
|
|
|
")" && WINNAME=Config && return |
|
|
|
|
|
|
|
|
|
" |
|
|
|
|
WINNAME=Config |
|
|
|
|
elif echo "$WMCLASS" | grep -i "audioout"; then |
|
|
|
|
# Audio Out menu |
|
|
|
|
echo $WMCLASS | grep -i "audioout" && CURRENTDEV="$(sxmo_audiocurrentdevice.sh)" && CHOICES="$(echo " |
|
|
|
|
Headphones $([[ "$CURRENTDEV" == "Headphone" ]] && echo "✓") ^ 1 ^ sxmo_audioout.sh Headphones |
|
|
|
|
Speaker $([[ "$CURRENTDEV" == "Line Out" ]] && echo "✓") ^ 1 ^ sxmo_audioout.sh Speaker |
|
|
|
|
Earpiece $([[ "$CURRENTDEV" == "Earpiece" ]] && echo "✓") ^ 1 ^ sxmo_audioout.sh Earpiece |
|
|
|
|
None $([[ "$CURRENTDEV" == "None" ]] && echo "✓") ^ 1 ^ sxmo_audioout.sh None |
|
|
|
|
")" && WINNAME="Audio" && return |
|
|
|
|
|
|
|
|
|
CURRENTDEV="$(sxmo_audiocurrentdevice.sh)" |
|
|
|
|
CHOICES=" |
|
|
|
|
Headphones $([ "$CURRENTDEV" = "Headphone" ] && echo "✓") ^ 1 ^ sxmo_audioout.sh Headphones |
|
|
|
|
Speaker $([ "$CURRENTDEV" = "Line Out" ] && echo "✓") ^ 1 ^ sxmo_audioout.sh Speaker |
|
|
|
|
Earpiece $([ "$CURRENTDEV" = "Earpiece" ] && echo "✓") ^ 1 ^ sxmo_audioout.sh Earpiece |
|
|
|
|
None $([ "$CURRENTDEV" = "None" ] && echo "✓") ^ 1 ^ sxmo_audioout.sh None |
|
|
|
|
" |
|
|
|
|
WINNAME="Audio" |
|
|
|
|
elif echo "$WMCLASS" | grep -i "mpv"; then |
|
|
|
|
# MPV |
|
|
|
|
echo $WMCLASS | grep -i "mpv" && CHOICES="$(echo " |
|
|
|
|
CHOICES=" |
|
|
|
|
Pause ^ 0 ^ key space |
|
|
|
|
Seek ← ^ 1 ^ key Left |
|
|
|
|
Seek → ^ 1 ^ key Right |
|
|
|
@ -95,17 +82,23 @@ programchoicesinit() { |
|
|
|
|
Loopmark ^ 1 ^ key l |
|
|
|
|
Info ^ 1 ^ key i |
|
|
|
|
Seek Info ^ 1 ^ key o |
|
|
|
|
")" && WINNAME=Mpv && return |
|
|
|
|
|
|
|
|
|
" |
|
|
|
|
WINNAME=Mpv && return |
|
|
|
|
elif echo "$WMCLASS" | grep -i "st-256color"; then |
|
|
|
|
# St |
|
|
|
|
echo $WMCLASS | grep -i "st-256color" && STSELMODEON="$(echo "$XPROPOUT" | grep -E '^_ST_SELMODE.+=' | cut -d= -f2 | tr -d ' ')" && CHOICES="$(echo " |
|
|
|
|
STSELMODEON="$( |
|
|
|
|
echo "$XPROPOUT" | grep -E '^_ST_SELMODE.+=' | cut -d= -f2 | tr -d ' ' |
|
|
|
|
)" |
|
|
|
|
CHOICES=" |
|
|
|
|
Type complete ^ 0 ^ key Ctrl+Shift+u |
|
|
|
|
Copy complete ^ 0 ^ key Ctrl+Shift+i |
|
|
|
|
Selmode $( |
|
|
|
|
[ $STSELMODEON == 1 ] && printf %b 'On → Off' || printf %b 'Off → On'; |
|
|
|
|
[ "$STSELMODEON" = 1 ] && |
|
|
|
|
printf %b 'On → Off' || |
|
|
|
|
printf %b 'Off → On' |
|
|
|
|
printf %b '^ 0 ^ key Ctrl+Shift+s' |
|
|
|
|
) |
|
|
|
|
$([ $STSELMODEON == 1 ] && echo 'Copy selection ^ 0 ^ key Ctrl+Shift+c') |
|
|
|
|
$([ "$STSELMODEON" = 1 ] && echo 'Copy selection ^ 0 ^ key Ctrl+Shift+c') |
|
|
|
|
Paste ^ 0 ^ key Ctrl+Shift+v |
|
|
|
|
Zoom + ^ 1 ^ key Ctrl+Shift+Prior |
|
|
|
|
Zoom - ^ 1 ^ key Ctrl+Shift+Next |
|
|
|
@ -113,26 +106,29 @@ programchoicesinit() { |
|
|
|
|
Scroll ↓ ^ 1 ^ key Ctrl+Shift+f |
|
|
|
|
Invert ^ 1 ^ key Ctrl+Shift+x |
|
|
|
|
Hotkeys ^ 0 ^ sxmo_appmenu.sh sthotkeys |
|
|
|
|
")" && WINNAME=St && return |
|
|
|
|
|
|
|
|
|
" |
|
|
|
|
WINNAME=St |
|
|
|
|
elif echo "$WMCLASS" | grep -i "sthotkeys"; then |
|
|
|
|
# St hotkeys |
|
|
|
|
echo $WMCLASS | grep -i "sthotkeys" && CHOICES="$(echo " |
|
|
|
|
CHOICES=" |
|
|
|
|
Send Ctrl-C ^ 0 ^ key Ctrl+c |
|
|
|
|
Send Ctrl-L ^ 0 ^ key Ctrl+l |
|
|
|
|
Send Ctrl-D ^ 0 ^ key Ctrl+d |
|
|
|
|
")" && WINNAME=St && return |
|
|
|
|
|
|
|
|
|
" |
|
|
|
|
WINNAME=St |
|
|
|
|
elif echo "$WMCLASS" | grep -i netsurf; then |
|
|
|
|
# Netsurf |
|
|
|
|
echo $WMCLASS | grep -i netsurf && CHOICES="$(echo " |
|
|
|
|
CHOICES=" |
|
|
|
|
Pipe URL ^ 0 ^ sxmo_urlhandler.sh |
|
|
|
|
Zoom + ^ 1 ^ key Ctrl+plus |
|
|
|
|
Zoom - ^ 1 ^ key Ctrl+minus |
|
|
|
|
History ← ^ 1 ^ key Alt+Left |
|
|
|
|
History → ^ 1 ^ key Alt+Right |
|
|
|
|
")" && WINNAME=Netsurf && return |
|
|
|
|
|
|
|
|
|
" |
|
|
|
|
WINNAME=Netsurf |
|
|
|
|
elif echo "$WMCLASS" | grep surf; then |
|
|
|
|
# Surf |
|
|
|
|
echo $WMCLASS | grep surf && CHOICES="$(echo " |
|
|
|
|
CHOICES=" |
|
|
|
|
Navigate ^ 0 ^ key Ctrl+g |
|
|
|
|
Link Menu ^ 0 ^ key Ctrl+d |
|
|
|
|
Pipe URL ^ 0 ^ sxmo_urlhandler.sh |
|
|
|
@ -143,37 +139,61 @@ programchoicesinit() { |
|
|
|
|
JS Toggle ^ 1 ^ key Ctrl+Shift+s |
|
|
|
|
History ← ^ 1 ^ key Ctrl+h |
|
|
|
|
History → ^ 1 ^ key Ctrl+l |
|
|
|
|
")" && WINNAME=Surf && return |
|
|
|
|
|
|
|
|
|
" |
|
|
|
|
WINNAME=Surf |
|
|
|
|
elif echo "$WMCLASS" | grep -i firefox; then |
|
|
|
|
# Firefox |
|
|
|
|
echo $WMCLASS | grep -i firefox && CHOICES="$(echo " |
|
|
|
|
CHOICES=" |
|
|
|
|
Pipe URL ^ 0 ^ sxmo_urlhandler.sh |
|
|
|
|
Zoom + ^ 1 ^ key Ctrl+plus |
|
|
|
|
Zoom - ^ 1 ^ key Ctrl+minus |
|
|
|
|
History ← ^ 1 ^ key Alt+Left |
|
|
|
|
History → ^ 1 ^ key Alt+Right |
|
|
|
|
")" && WINNAME=Firefox && return |
|
|
|
|
|
|
|
|
|
" |
|
|
|
|
WINNAME=Firefox |
|
|
|
|
elif echo "$WMCLASS" | grep -i foxtrot; then |
|
|
|
|
# Foxtrot GPS |
|
|
|
|
echo $WMCLASS | grep -i foxtrot && CHOICES="$(echo " |
|
|
|
|
CHOICES=" |
|
|
|
|
Zoom + ^ 1 ^ key i |
|
|
|
|
Zoom - ^ 1 ^ key o |
|
|
|
|
Panel toggle ^ 1 ^ key m |
|
|
|
|
Autocenter toggle ^ 0 ^ key a |
|
|
|
|
Route ^ 0 ^ key r |
|
|
|
|
")" && WINNAME=Gps && return |
|
|
|
|
" |
|
|
|
|
WINNAME=Gps |
|
|
|
|
else |
|
|
|
|
# Default system menu (no matches) |
|
|
|
|
CHOICES=" |
|
|
|
|
$( |
|
|
|
|
[ -n "$(ls -A "$XDG_CONFIG_HOME"/sxmo/userscripts)" ] && |
|
|
|
|
echo 'Userscripts ^ 0 ^ sxmo_appmenu.sh userscripts' |
|
|
|
|
) |
|
|
|
|
Scripts ^ 0 ^ sxmo_appmenu.sh scripts |
|
|
|
|
Apps ^ 0 ^ sxmo_appmenu.sh applications |
|
|
|
|
Volume ↑ ^ 1 ^ sxmo_vol.sh up |
|
|
|
|
Volume ↓ ^ 1 ^ sxmo_vol.sh down |
|
|
|
|
Dialer ^ 0 ^ sxmo_modemcall.sh dial |
|
|
|
|
Texts ^ 0 ^ sxmo_modemtext.sh |
|
|
|
|
Camera ^ 0 ^ sxmo_camera.sh |
|
|
|
|
Wifi ^ 0 ^ st -e nmtui |
|
|
|
|
Audio ^ 0 ^ sxmo_appmenu.sh audioout |
|
|
|
|
Config ^ 0 ^ sxmo_appmenu.sh config |
|
|
|
|
Logout ^ 0 ^ pkill -9 dwm |
|
|
|
|
" |
|
|
|
|
WINNAME=Sys |
|
|
|
|
fi |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getprogchoices() { |
|
|
|
|
# E.g. sets CHOICES var |
|
|
|
|
programchoicesinit $@ |
|
|
|
|
programchoicesinit "$@" |
|
|
|
|
|
|
|
|
|
# Decorate menu at top w/ incoming call entry if present |
|
|
|
|
INCOMINGCALL=$(cat /tmp/sxmo_incomingcall || echo NOCALL) |
|
|
|
|
echo "$INCOMINGCALL" | grep -v NOCALL && CHOICES="$(echo " |
|
|
|
|
Pickup $(echo $INCOMINGCALL | cut -d: -f2) ^ 0 ^ sxmo_modemcall.sh pickup $(echo $INCOMINGCALL | cut -d: -f1) |
|
|
|
|
INCOMINGCALL="$(cat /tmp/sxmo_incomingcall || echo NOCALL)" |
|
|
|
|
echo "$INCOMINGCALL" | grep -v NOCALL && CHOICES=" |
|
|
|
|
Pickup $(echo "$INCOMINGCALL" | cut -d: -f2) ^ 0 ^ sxmo_modemcall.sh pickup $(echo "$INCOMINGCALL" | cut -d: -f1) |
|
|
|
|
$CHOICES |
|
|
|
|
")" |
|
|
|
|
" |
|
|
|
|
|
|
|
|
|
# Decorate menu at bottom w/ system menu entry if not system menu |
|
|
|
|
echo $WINNAME | grep -v Sys && CHOICES=" |
|
|
|
@ -203,12 +223,12 @@ quit() { |
|
|
|
|
mainloop() { |
|
|
|
|
DMENUIDX=0 |
|
|
|
|
PICKED="" |
|
|
|
|
ARGS="$@" |
|
|
|
|
ARGS="$*" |
|
|
|
|
|
|
|
|
|
while : |
|
|
|
|
do |
|
|
|
|
# E.g. sets PROGCHOICES |
|
|
|
|
getprogchoices $ARGS |
|
|
|
|
getprogchoices "$ARGS" |
|
|
|
|
|
|
|
|
|
PICKED="$( |
|
|
|
|
echo "$PROGCHOICES" | |
|
|
|
@ -219,11 +239,11 @@ mainloop() { |
|
|
|
|
CMD="$(echo "$PROGCHOICES" | grep -F "$PICKED" | cut -d '^' -f3)" |
|
|
|
|
DMENUIDX="$(echo "$PROGCHOICES" | grep -F -n "$PICKED" | cut -d ':' -f1)" |
|
|
|
|
echo "Eval: <$CMD> from picked <$PICKED> with loop <$LOOP>" |
|
|
|
|
eval $CMD |
|
|
|
|
echo $LOOP | grep 1 || quit |
|
|
|
|
eval "$CMD" |
|
|
|
|
echo "$LOOP" | grep 1 || quit |
|
|
|
|
done |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pgrep -f sxmo_appmenu.sh | grep -Ev "^${$}$" | xargs kill -9 |
|
|
|
|
pkill -9 dmenu |
|
|
|
|
mainloop $@ |
|
|
|
|
mainloop "$@" |