Guest User

Key_Bindings

a guest
Jul 8th, 2022
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. set -eou pipefail
  4.  
  5. # The following describes the function of each line, that makes up the 'key' variable
  6. # - Delete all lines upto the keys definition, and then remove comments
  7. # - Delete all empty lines obtained from above operation, and then remove the tabs at the beginning of lines
  8. # - Look for Keybindings which start with `Key(`, and remove that part then, remove `[` and `]` brackets. After that delete the `lazy` functions.
  9. # - Remove tabs and empty lines, and also closing brackets.
  10. # - Finally remove `"`, and add `+` to the Keybindings.
  11. key=$(sed '1,105d' ./Dotfiles/qtile/Keybindings.py | sed 's|\#.*||' |
  12. sed '/^[[:space:]]*$/d' | sed 's|^ ||' |
  13. sed -e 's|Key(||g' -e 's|\[||g' -e 's|\]||g' | sed 's|^, ||' | sed 's|, laz.*||' |
  14. sed 's|^ .*||' | sed '/^[[:space:]]*$/d' | sed 's|^),||' | sed '/^[[:space:]]*$/d' |
  15. sed 's|"||g' | sed 's|, |+|g')
  16.  
  17. # The following describes the function of each line, that makes up the 'descs' variable
  18. # - Delete all lines upto the keys definition, and then remove comments
  19. # - 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.
  20. # - Delete everyting upto 'desc', and remove brackets, and commas.
  21. descs=$(sed '1,105d' ./Dotfiles/qtile/Keybindings.py | sed 's|\#.*||' |
  22. sed '/^[[:space:]]*$/d' | sed 's|^ ||' | grep "desc" |
  23. sed 's|^.*desc=||' | sed -e 's|),||' -e 's|)\]||' -e 's|"||g' -e 's|,||' |
  24. sed 's|$|,|')
  25.  
  26.  
  27. key=$(echo "${key}" | xargs)
  28. # echo "${descs}"
  29. esc_arr=$(echo "${descs}" | sed 's|,|+|')
  30.  
  31. # The lines below define IFS (Internal Field Separater) to be a '\n' character => new line.
  32. # Based on that, the list of keybindings and their descriptions are converted into arrays,
  33. # where each element in the array is keybinding and the description respectively.
  34.  
  35. # declare -a key_arr=()
  36. # declare -a desc_arr=()
  37.  
  38. IFS=$'+' read -ar desc_arr <<< $descs
  39.  
  40. key_arr=($key)
  41. # desc_arr=($descs)
  42. # echo "${descs}"
  43. # declare -a final_test=()
  44. # echo "${#key_arr[@]}"
  45. echo "${desc_arr[@]}"
  46. # for i in "${!key_arr[@]}" ; do
  47. # final_test[$i]="${key_arr[$i]}: ${desc_arr[$i]}"
  48. # echo "${final_test[$i]}"
  49. # done
  50.  
Advertisement
Add Comment
Please, Sign In to add comment