~mil/mepo

ref: 041d978478ae78e241802ca9d750677e101c3f5b mepo/scripts/mepo_ui_helper_menu.sh -rwxr-xr-x 1.5 KiB
041d9784Miles Alan Show progress in % complete for transfer datum on tiles while downloading 5 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env sh
N_LINES=15
FONT="Inconsolata"

main() {
  [ -z "$PROMPT" ] && PROMPT="Mepo menu"

  if [ -n "$MEPO_MENU" ]; then
    # Custom menu support
    "$MEPO_MENU" "$PROMPT"
  elif pidof squeekboard >/dev/null; then
    # Phosh support
    busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true
    bemenu --fn "$FONT" --scrollbar autohide -s -n -l $N_LINES -i -p "$PROMPT"
    busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b false
  elif command -v sxmo_dmenu_with_kb.sh > /dev/null; then
    # Sxmo support
    sxmo_dmenu_with_kb.sh -p "$PROMPT"
  elif [ -n "$WAYLAND_DISPLAY" ]; then
    # Generic Wayland enviroment support
    bemenu --fn "$FONT" --scrollbar autohide -s -n -c -l $N_LINES -i -p "$PROMPT"
  elif [ -n "$DISPLAY" ]; then
    # Generic X enviroment support
    dmenu -fn "$FONT" -i -l $N_LINES -w "$(xdotool getactivewindow)" -p "$PROMPT"
  else
    # Framebuffer enviroment support
    RESULTFILE="$(mktemp)"
    OPTSFILE="$(mktemp)"
    cat > "$OPTSFILE"
    OLDVT=1
    busybox openvt -c 11 -s -w sh -c "
      clear;
      echo Mepo terminal VT menu;
      [ -p /tmp/fbp.fifo ] && { sleep .2; printf %b \"\a\" > /tmp/fbp.fifo; }
      cat \"$OPTSFILE\" | vis-menu -p \"$PROMPT\" -l 50 > $RESULTFILE
    " > /dev/null
    cat "$RESULTFILE" | tr -d "\n"
    busybox chvt "$OLDVT" > /dev/null
    rm "$RESULTFILE" "$OPTSFILE"
    [ -p /tmp/fbp.fifo ] && { sleep .2; printf %b "\b" > /tmp/fbp.fifo; }
  fi
}

if [ -n "$1" ]; then "$@"; else main; fi