Skip to content

Instantly share code, notes, and snippets.

@isoraqathedh
Created May 3, 2017 17:10
Show Gist options
  • Save isoraqathedh/ae541c4e419d8e64cfe6391073230a0b to your computer and use it in GitHub Desktop.
Save isoraqathedh/ae541c4e419d8e64cfe6391073230a0b to your computer and use it in GitHub Desktop.
#!/bin/zsh
# Rough parsing script to display help for runprog-mode.
{ echo "Keybindings for runprog-mode:"
sed -n '/mode \$runprog {/,/}/p' ~/.config/i3/config | # Extract
perl -pe 's/\\\n//;s/ +//;s/ --release//' | # Parse line continuations;\
# normalise whitespace; remove the --release modifier
grep "bindsym" | # Remove anything that isn't a keybinding
while read bindsym keybind mode_or_exec executable; do
# Parse loop
case $mode_or_exec in
"mode") # Assume no exec block means exit
echo "$keybind: exit"
;;
"exec") # Delete implicit exit block and print
echo "$keybind: ${executable/; mode default}"
;;
*) # Unreachable
echo "Parse error: $mode_or_exec is neither mode or exec" >&2
exit 1
esac
done
} | # Dump everything into a text box and display.
zenity --title="runprog-mode Help" --width=750 --height 400 \
--text-info --font="Inziu Iosevka TC" ||
i3-msg "mode default" # Cancel = exit runprog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment