Isoraqathedh

runprog-help.sh

Feb 26th, 2017
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.11 KB | None | 0 0
  1. #!/bin/zsh
  2. # Rough parsing script to display help for runprog-mode.
  3.  
  4. {
  5.     echo "Keybindings for runprog-mode:"
  6.     sed -n '/mode \$runprog {/,/}/p' ~/.config/i3/config | # Extract
  7.         perl -pe 's/\\\n//;s/ +//' | # Parse line continuations; \
  8.             # normalise whitespace
  9.         grep "bindsym" | # Remove anything that isn't a keybinding
  10.         while read bindsym keybind mode_or_exec executable; do
  11.             # Parse loop
  12.             case $mode_or_exec in
  13.                 "mode") # Assume no exec block means exit
  14.                     echo "$keybind: exit"
  15.                     ;;
  16.                 "exec") # Delete implicit exit block and print
  17.                     echo "$keybind: ${executable/; mode default}"
  18.                     ;;
  19.                 *) # Unreachable
  20.                     echo "Parse error: $mode_or_exec is neither mode or exec" >&2
  21.                     exit 1
  22.             esac
  23.         done
  24. } | # Dump everything into a text box and display.
  25.     zenity --title="runprog-mode Help" --width=750 --height 400 \
  26.            --text-info --font="Inziu Iosevka TC" ||
  27.     i3-msg "mode default"
Advertisement
Add Comment
Please, Sign In to add comment