#!/bin/awk -f # # FVWM Bindings help form generator by # Dennis Katsonis, June 2021. # # v1.0.1 # # Don't add space in front of key if there are no modifiers. # # FVWM forms is quite useful, and one thing I like to have is # a help screen which will display my custom key bindings. # This awk script can create such a form configuration based # from a file which defines FVWM key bindings. # # HOW TO USE # Feed this awk script your fvwm bindings, and it will output # a form configuration which you can call up in FVWM # which will document those bindings. Redirect the output # to a file, then read that file in somewhere in your fvwm startup # config, or copy the output into some other file. # # The FVWM command "FvwmForm HelpForm" will bring it up. # Change the configuration in the "BEGIN" section to your liking. # # This script will ONLY document Keybindings, and ONLY # those which are defined with the word "KEY" in ALL CAPITALS. # Lines with "Key" at the start will be ignored. This way, you # can choose which keybindings to have documented in the help form # simply by capitalising the entire word of the "Key" command at the # start of the line. Following this binding definition line there # MUST be a comment line starting with a "#", # and this will contain the description of what the key does. # e.g # KEY H A MCS FvwmForm HelpForm # #Bring up Help Form BEGIN { printf("%s","DestroyModuleConfig HelpForm: *\n \ *HelpForm: Title \"Key Bindings\"\n\ *HelpForm: WarpPointer\n\ *HelpForm: Back LightGreen\n\ *HelpForm: Fore Black\n\ *HelpForm: Line center\n\ *HelpForm: Font -*-helvetica-bold-r-normal-*-18-*-*-*-*-*-*-*\n\ *HelpForm: Text \"Custom Key Bindings for FVWM\"\n\ *HelpForm: Line expand\n\ *HelpForm: Font -*-terminus-bold-r-normal-*-14-*-*-*-*-*-*-*\n") } $1 ~ /KEY/ { n = 0 key = $2 mod = $4 getline desc if(substr(desc,1,1) == "#") { printf("%s","*HelpForm: Line expand\n\ *HelpForm: Fore DarkBlue\n\ *HelpForm: Text \"") if(match(mod,"C")) { printf("Control") n++ } if(match(mod,"M")) { if(n) printf("+") printf("Alt") n++ } if(match(mod,"S")) { if(n) printf("+") printf("Shift") n++ } if(match(mod,"4")) { if(n) printf("+") printf("Super") n++ } if(n) printf(" "); printf("%s\"\n",key) printf("%s","*HelpForm: Fore DarkGreen\n\ *HelpForm: Text \"") printf("%s\"\n",substr(desc,2)) } else { print "No comment line after keybinding for line",$0 > "/dev/stderr" } } END { printf("%s","*HelpForm: Line expand\n\ *HelpForm: Button quit \"Close\" ^X\n") }