Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- set -eou pipefail
- # The following describes the function of each line, that makes up the 'key' variable
- # - Delete all lines upto the keys definition, and then remove comments
- # - Delete all empty lines obtained from above operation, and then remove the tabs at the beginning of lines
- # - Look for Keybindings which start with `Key(`, and remove that part then, remove `[` and `]` brackets. After that delete the `lazy` functions.
- # - Remove tabs and empty lines, and also closing brackets.
- # - Finally remove `"`, and add `+` to the Keybindings.
- key=$(sed '1,105d' ./Dotfiles/qtile/Keybindings.py | sed 's|\#.*||' |
- sed '/^[[:space:]]*$/d' | sed 's|^ ||' |
- sed -e 's|Key(||g' -e 's|\[||g' -e 's|\]||g' | sed 's|^, ||' | sed 's|, laz.*||' |
- sed 's|^ .*||' | sed '/^[[:space:]]*$/d' | sed 's|^),||' | sed '/^[[:space:]]*$/d' |
- sed 's|"||g' | sed 's|, |+|g')
- # The following describes the function of each line, that makes up the 'descs' variable
- # - Delete all lines upto the keys definition, and then remove comments
- # - Delete all empty lines obtained from above operation, and then remove the tabs at the beginning of lines, and grep the lines that contain grep.
- # - Delete everyting upto 'desc', and remove brackets, and commas.
- descs=$(sed '1,105d' ./Dotfiles/qtile/Keybindings.py | sed 's|\#.*||' |
- sed '/^[[:space:]]*$/d' | sed 's|^ ||' | grep "desc" |
- sed 's|^.*desc=||' | sed -e 's|),||' -e 's|)\]||' -e 's|"||g' -e 's|,||' |
- sed 's|$|,|')
- key=$(echo "${key}" | xargs)
- # echo "${descs}"
- esc_arr=$(echo "${descs}" | sed 's|,|+|')
- # The lines below define IFS (Internal Field Separater) to be a '\n' character => new line.
- # Based on that, the list of keybindings and their descriptions are converted into arrays,
- # where each element in the array is keybinding and the description respectively.
- # declare -a key_arr=()
- # declare -a desc_arr=()
- IFS=$'+' read -ar desc_arr <<< $descs
- key_arr=($key)
- # desc_arr=($descs)
- # echo "${descs}"
- # declare -a final_test=()
- # echo "${#key_arr[@]}"
- echo "${desc_arr[@]}"
- # for i in "${!key_arr[@]}" ; do
- # final_test[$i]="${key_arr[$i]}: ${desc_arr[$i]}"
- # echo "${final_test[$i]}"
- # done
Advertisement
Add Comment
Please, Sign In to add comment