0001-Detect-which-awk-to-use.patch 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  1. From 39b6eec51f0c2fa5f2b0e876b14dcfc9c1febf97 Mon Sep 17 00:00:00 2001
  2. From: Nicolas Boichat <drinkcat@google.com>
  3. Date: Fri, 4 Aug 2023 12:55:36 +0000
  4. Subject: [PATCH] Detect which awk to use
  5. Some embedded distributions (e.g. buildroot) may only provide mawk,
  6. without a symlink to awk.
  7. At first glance, awk scripts to appear to work fine with either
  8. gawk or mawk.
  9. Signed-off-by: Nicolas Boichat <drinkcat@google.com>
  10. Upstream: https://github.com/KittyKatt/screenFetch/commit/b49a2334b8ba806dbc532219e86363886a85d9c8
  11. [rebased on 3.9.1]
  12. ---
  13. screenfetch-dev | 245 +++++++++++++++++++++++++-----------------------
  14. 1 file changed, 130 insertions(+), 115 deletions(-)
  15. diff --git a/screenfetch-dev b/screenfetch-dev
  16. index 1e53b2c..765930f 100755
  17. --- a/screenfetch-dev
  18. +++ b/screenfetch-dev
  19. @@ -352,9 +352,9 @@ colorNumberToCode () {
  20. detectColors () {
  21. my_colors=$(sed 's/^,/na,/;s/,$/,na/;s/,/ /' <<< "${OPTARG}")
  22. - my_lcolor=$(awk -F' ' '{print $1}' <<< "${my_colors}")
  23. + my_lcolor=$("${AWK}" -F' ' '{print $1}' <<< "${my_colors}")
  24. my_lcolor=$(colorNumberToCode "${my_lcolor}")
  25. - my_hcolor=$(awk -F' ' '{print $2}' <<< "${my_colors}")
  26. + my_hcolor=$("${AWK}" -F' ' '{print $2}' <<< "${my_colors}")
  27. my_hcolor=$(colorNumberToCode "${my_hcolor}")
  28. }
  29. @@ -462,7 +462,22 @@ case $1 in
  30. --version) displayVersion; exit 0;;
  31. esac
  32. +# Detect which awk to use (unless already specified in environment)
  33. +if [[ -z "${AWK}" ]]; then
  34. + for awk in awk gawk mawk; do
  35. + if command -v "${awk}" > /dev/null; then
  36. + AWK="${awk}"
  37. + break
  38. + fi
  39. + done
  40. +fi
  41. +
  42. +if ! command -v "${AWK}" > /dev/null; then
  43. + errorOut "No awk interpreter available (AWK=\"${AWK}\")."
  44. + exit 1
  45. +fi
  46. +# Parse the rest of the flags (some of these functions require awk)
  47. while getopts ":hsu:evVEnLNtlS:A:D:o:c:d:pa:w" flags; do
  48. case $flags in
  49. h) displayHelp; exit 0 ;;
  50. @@ -608,8 +623,8 @@ detectdistro () {
  51. "Debian")
  52. if [[ -f /etc/crunchbang-lsb-release || -f /etc/lsb-release-crunchbang ]]; then
  53. distro="CrunchBang"
  54. - distro_release=$(awk -F'=' '/^DISTRIB_RELEASE=/ {print $2}' /etc/lsb-release-crunchbang)
  55. - distro_codename=$(awk -F'=' '/^DISTRIB_DESCRIPTION=/ {print $2}' /etc/lsb-release-crunchbang)
  56. + distro_release=$("${AWK}" -F'=' '/^DISTRIB_RELEASE=/ {print $2}' /etc/lsb-release-crunchbang)
  57. + distro_codename=$("${AWK}" -F'=' '/^DISTRIB_DESCRIPTION=/ {print $2}' /etc/lsb-release-crunchbang)
  58. elif [[ -f /etc/siduction-version ]]; then
  59. distro="Siduction"
  60. distro_release="(Debian Sid)"
  61. @@ -620,10 +635,10 @@ detectdistro () {
  62. elif [[ -f /etc/os-release ]]; then
  63. if grep -q -i 'Raspbian' /etc/os-release ; then
  64. distro="Raspbian"
  65. - distro_release=$(awk -F'=' '/^PRETTY_NAME=/ {print $2}' /etc/os-release)
  66. + distro_release=$("${AWK}" -F'=' '/^PRETTY_NAME=/ {print $2}' /etc/os-release)
  67. elif grep -q -i 'BlankOn' /etc/os-release ; then
  68. distro='BlankOn'
  69. - distro_release=$(awk -F'=' '/^PRETTY_NAME=/ {print $2}' /etc/os-release)
  70. + distro_release=$("${AWK}" -F'=' '/^PRETTY_NAME=/ {print $2}' /etc/os-release)
  71. else
  72. distro="Debian"
  73. fi
  74. @@ -639,7 +654,7 @@ detectdistro () {
  75. ;;
  76. "Sulin")
  77. distro="Sulin"
  78. - distro_release=$(awk -F'=' '/^ID_LIKE=/ {print $2}' /etc/os-release)
  79. + distro_release=$("${AWK}" -F'=' '/^ID_LIKE=/ {print $2}' /etc/os-release)
  80. distro_codename="Roolling donkey" # this is not wrong :D
  81. ;;
  82. "KaOS"|"kaos")
  83. @@ -718,7 +733,7 @@ detectdistro () {
  84. if grep -q 'SailfishOS' /etc/os-release; then
  85. distro="SailfishOS"
  86. distro_codename="$(grep 'VERSION=' /etc/os-release | cut -d '(' -f2 | cut -d ')' -f1)"
  87. - distro_release="$(awk -F'=' '/^VERSION=/ {print $2}' /etc/os-release)"
  88. + distro_release="$("${AWK}" -F'=' '/^VERSION=/ {print $2}' /etc/os-release)"
  89. fi
  90. fi
  91. ;;
  92. @@ -753,7 +768,7 @@ detectdistro () {
  93. if grep -q -i 'SUSE Linux Enterprise' /etc/os-release ; then
  94. distro="SUSE Linux Enterprise"
  95. distro_codename="n/a"
  96. - distro_release=$(awk -F'=' '/^VERSION_ID=/ {print $2}' /etc/os-release | tr -d '"')
  97. + distro_release=$("${AWK}" -F'=' '/^VERSION_ID=/ {print $2}' /etc/os-release | tr -d '"')
  98. fi
  99. fi
  100. if [[ "${distro_codename}" == "Tumbleweed" ]]; then
  101. @@ -789,7 +804,7 @@ detectdistro () {
  102. distro="SailfishOS"
  103. if [[ -f /etc/os-release ]]; then
  104. distro_codename="$(grep 'VERSION=' /etc/os-release | cut -d '(' -f2 | cut -d ')' -f1)"
  105. - distro_release="$(awk -F'=' '/^VERSION=/ {print $2}' /etc/os-release)"
  106. + distro_release="$("${AWK}" -F'=' '/^VERSION=/ {print $2}' /etc/os-release)"
  107. fi
  108. ;;
  109. "Sparky"|"SparkyLinux")
  110. @@ -863,12 +878,12 @@ detectdistro () {
  111. ;;
  112. "Haiku")
  113. distro="Haiku"
  114. - distro_more="$(uname -v | awk '/^hrev/ {print $1}')"
  115. + distro_more="$(uname -v | "${AWK}" '/^hrev/ {print $1}')"
  116. ;;
  117. "GNU/Linux")
  118. if type -p crux >/dev/null 2>&1; then
  119. distro="CRUX"
  120. - distro_more="$(crux | awk '{print $3}')"
  121. + distro_more="$(crux | "${AWK}" '{print $3}')"
  122. fi
  123. if type -p nixos-version >/dev/null 2>&1; then
  124. distro="NixOS"
  125. @@ -944,7 +959,7 @@ detectdistro () {
  126. [[ "${distro}" == "Neon" ]] && distro="KDE neon"
  127. [[ "${distro}" == "SLED" || "${distro}" == "sled" || "${distro}" == "SLES" || "${distro}" == "sles" ]] && distro="SUSE Linux Enterprise"
  128. if [[ "${distro}" == "SUSE Linux Enterprise" && -f /etc/os-release ]]; then
  129. - distro_more="$(awk -F'=' '/^VERSION_ID=/ {print $2}' /etc/os-release | tr -d '"')"
  130. + distro_more="$("${AWK}" -F'=' '/^VERSION_ID=/ {print $2}' /etc/os-release | tr -d '"')"
  131. fi
  132. if [[ "${distro}" == "Debian" && -f /usr/bin/pveversion ]]; then
  133. distro="Proxmox VE"
  134. @@ -955,7 +970,7 @@ detectdistro () {
  135. if [[ "${distro}" == "Unknown" && "${OSTYPE}" =~ "linux" && -f /etc/lsb-release ]]; then
  136. LSB_RELEASE=$(</etc/lsb-release)
  137. - distro=$(echo "${LSB_RELEASE}" | awk 'BEGIN {
  138. + distro=$(echo "${LSB_RELEASE}" | "${AWK}" 'BEGIN {
  139. distro = "Unknown"
  140. }
  141. {
  142. @@ -1001,7 +1016,7 @@ detectdistro () {
  143. if [ -f /etc/os-release ]; then
  144. if grep -q -i 'SUSE Linux Enterprise' /etc/os-release ; then
  145. distro="SUSE Linux Enterprise"
  146. - distro_more=$(awk -F'=' '/^VERSION_ID=/ {print $2}' /etc/os-release | tr -d '"')
  147. + distro_more=$("${AWK}" -F'=' '/^VERSION_ID=/ {print $2}' /etc/os-release | tr -d '"')
  148. fi
  149. fi
  150. if [[ "${distro_more}" =~ "Tumbleweed" ]]; then
  151. @@ -1051,7 +1066,7 @@ detectdistro () {
  152. if [[ -x /usr/bin/sw_vers ]] && /usr/bin/sw_vers | grep -i 'Mac OS X' >/dev/null; then
  153. distro="Mac OS X"
  154. elif [[ -f /var/run/dmesg.boot ]]; then
  155. - distro=$(awk 'BEGIN {
  156. + distro=$("${AWK}" 'BEGIN {
  157. distro = "Unknown"
  158. }
  159. {
  160. @@ -1080,7 +1095,7 @@ detectdistro () {
  161. if [[ "${distro}" == "Unknown" ]] && [[ "${OSTYPE}" =~ "linux" || "${OSTYPE}" == "gnu" ]]; then
  162. if [[ -f /etc/issue ]]; then
  163. - distro=$(awk 'BEGIN {
  164. + distro=$("${AWK}" 'BEGIN {
  165. distro = "Unknown"
  166. }
  167. {
  168. @@ -1123,8 +1138,8 @@ detectdistro () {
  169. fi
  170. elif [[ -f /etc/lsb-release ]]; then
  171. if grep -q -i 'CHROMEOS_RELEASE_NAME' /etc/lsb-release; then
  172. - distro="$(awk -F'=' '/^CHROMEOS_RELEASE_NAME=/ {print $2}' /etc/lsb-release)"
  173. - distro_more="$(awk -F'=' '/^CHROMEOS_RELEASE_VERSION=/ {print $2}' /etc/lsb-release)"
  174. + distro="$("${AWK}" -F'=' '/^CHROMEOS_RELEASE_NAME=/ {print $2}' /etc/lsb-release)"
  175. + distro_more="$("${AWK}" -F'=' '/^CHROMEOS_RELEASE_VERSION=/ {print $2}' /etc/lsb-release)"
  176. fi
  177. fi
  178. fi
  179. @@ -1301,7 +1316,7 @@ detectuptime () {
  180. now=$(date +%s)
  181. uptime=$((now - boot))
  182. elif [[ "${distro}" == "Haiku" ]]; then
  183. - uptime=$(uptime | awk -F', up ' '{gsub(/ *hours?,/, "h"); gsub(/ *minutes?/, "m"); print $2;}')
  184. + uptime=$(uptime | "${AWK}" -F', up ' '{gsub(/ *hours?,/, "h"); gsub(/ *minutes?/, "m"); print $2;}')
  185. else
  186. if [[ -f /proc/uptime ]]; then
  187. uptime=$(</proc/uptime)
  188. @@ -1322,9 +1337,9 @@ detectuptime () {
  189. fi
  190. else
  191. if [[ "$distro" =~ "NetBSD" ]]; then
  192. - uptime=$(awk -F. '{print $1}' /proc/uptime)
  193. + uptime=$("${AWK}" -F. '{print $1}' /proc/uptime)
  194. elif [[ "$distro" =~ "BSD" ]]; then
  195. - uptime=$(uptime | awk '{$1=$2=$(NF-6)=$(NF-5)=$(NF-4)=$(NF-3)=$(NF-2)=$(NF-1)=$NF=""; sub(" days","d");sub(",","");sub(":","h ");sub(",","m"); print}')
  196. + uptime=$(uptime | "${AWK}" '{$1=$2=$(NF-6)=$(NF-5)=$(NF-4)=$(NF-3)=$(NF-2)=$(NF-1)=$NF=""; sub(" days","d");sub(",","");sub(":","h ");sub(",","m"); print}')
  197. fi
  198. fi
  199. verboseOut "Finding current uptime...found as '${uptime}'"
  200. @@ -1483,21 +1498,21 @@ detectcpu () {
  201. cpu="Unknown"
  202. fi
  203. elif [ "$distro" == "FreeBSD" ]; then
  204. - cpu=$(dmesg | awk -F': ' '/^CPU/ {gsub(/ +/," "); gsub(/\([^\(\)]*\)|CPU /,"", $2); print $2; exit}')
  205. + cpu=$(dmesg | "${AWK}" -F': ' '/^CPU/ {gsub(/ +/," "); gsub(/\([^\(\)]*\)|CPU /,"", $2); print $2; exit}')
  206. elif [ "$distro" == "DragonFlyBSD" ]; then
  207. cpu=$(sysctl -n hw.model)
  208. elif [ "$distro" == "OpenBSD" ]; then
  209. cpu=$(sysctl -n hw.model | sed 's/@.*//')
  210. elif [ "$distro" == "Haiku" ]; then
  211. - cpu=$(sysinfo -cpu | awk -F': ' '/^CPU #0/ {gsub(/ +/," "); gsub(/\([^\(\)]*\)|CPU /,"", $2); print $2; exit}')
  212. + cpu=$(sysinfo -cpu | "${AWK}" -F': ' '/^CPU #0/ {gsub(/ +/," "); gsub(/\([^\(\)]*\)|CPU /,"", $2); print $2; exit}')
  213. else
  214. - cpu=$(awk -F':' '/^model name/ {split($2, A, " @"); print A[1]; exit}' /proc/cpuinfo)
  215. + cpu=$("${AWK}" -F':' '/^model name/ {split($2, A, " @"); print A[1]; exit}' /proc/cpuinfo)
  216. cpun=$(grep -c '^processor' /proc/cpuinfo)
  217. if [ -z "$cpu" ]; then
  218. - cpu=$(awk 'BEGIN{FS=":"} /Hardware/ { print $2; exit }' /proc/cpuinfo)
  219. + cpu=$("${AWK}" 'BEGIN{FS=":"} /Hardware/ { print $2; exit }' /proc/cpuinfo)
  220. fi
  221. if [ -z "$cpu" ]; then
  222. - cpu=$(awk 'BEGIN{FS=":"} /^cpu/ { gsub(/ +/," ",$2); print $2; exit}' /proc/cpuinfo | sed 's/, altivec supported//;s/^ //')
  223. + cpu=$("${AWK}" 'BEGIN{FS=":"} /^cpu/ { gsub(/ +/," ",$2); print $2; exit}' /proc/cpuinfo | sed 's/, altivec supported//;s/^ //')
  224. if [[ $cpu =~ ^(PPC)*9.+ ]]; then
  225. model="IBM PowerPC G5 "
  226. elif [[ $cpu =~ 740/750 ]]; then
  227. @@ -1541,15 +1556,15 @@ detectcpu () {
  228. bl="${loc}/bios_limit"
  229. smf="${loc}/scaling_max_freq"
  230. if [ -f "$bl" ] && [ -r "$bl" ]; then
  231. - cpu_mhz=$(awk '{print $1/1000}' "$bl")
  232. + cpu_mhz=$("${AWK}" '{print $1/1000}' "$bl")
  233. elif [ -f "$smf" ] && [ -r "$smf" ]; then
  234. - cpu_mhz=$(awk '{print $1/1000}' "$smf")
  235. + cpu_mhz=$("${AWK}" '{print $1/1000}' "$smf")
  236. else
  237. - cpu_mhz=$(awk -F':' '/cpu MHz/{ print int($2+.5) }' /proc/cpuinfo | head -n 1)
  238. + cpu_mhz=$("${AWK}" -F':' '/cpu MHz/{ print int($2+.5) }' /proc/cpuinfo | head -n 1)
  239. fi
  240. if [ -n "$cpu_mhz" ]; then
  241. if [ "${cpu_mhz%.*}" -ge 1000 ]; then
  242. - cpu_ghz=$(awk '{print $1/1000}' <<< "${cpu_mhz}")
  243. + cpu_ghz=$("${AWK}" '{print $1/1000}' <<< "${cpu_mhz}")
  244. cpufreq="${cpu_ghz}GHz"
  245. else
  246. cpufreq="${cpu_mhz}MHz"
  247. @@ -1603,16 +1618,16 @@ detectgpu () {
  248. # gpu=$(sed 's/.*device.*= //' <<< "${gpu_info}" | sed "s/'//g")
  249. fi
  250. elif [[ "${distro}" == "OpenBSD" ]]; then
  251. - gpu=$(glxinfo 2> /dev/null | awk '/OpenGL renderer string/ { sub(/OpenGL renderer string: /,""); print }')
  252. + gpu=$(glxinfo 2> /dev/null | "${AWK}" '/OpenGL renderer string/ { sub(/OpenGL renderer string: /,""); print }')
  253. elif [[ "${distro}" == "Mac OS X" ]]; then
  254. - gpu=$(system_profiler SPDisplaysDataType | awk -F': ' '/^ *Chipset Model:/ {print $2}' | awk '{ printf "%s / ", $0 }' | sed -e 's/\/ $//g')
  255. + gpu=$(system_profiler SPDisplaysDataType | "${AWK}" -F': ' '/^ *Chipset Model:/ {print $2}' | "${AWK}" '{ printf "%s / ", $0 }' | sed -e 's/\/ $//g')
  256. elif [[ "${distro}" == "Cygwin" || "${distro}" == "Msys" ]]; then
  257. gpu=$(wmic path Win32_VideoController get caption | sed -n '2p')
  258. elif [[ "${distro}" == "Haiku" ]]; then
  259. - gpu="$(listdev | grep -A2 -e 'device Display controller' | awk -F': ' '/^ +device/ {print $2}')"
  260. + gpu="$(listdev | grep -A2 -e 'device Display controller' | "${AWK}" -F': ' '/^ +device/ {print $2}')"
  261. else
  262. if [[ -n "$(PATH="/opt/bin:$PATH" type -p nvidia-smi)" ]]; then
  263. - gpu=$($(PATH="/opt/bin:$PATH" type -p nvidia-smi | cut -f1) -q | awk -F':' '/Product Name/ {gsub(/: /,":"); print $2}' | sed ':a;N;$!ba;s/\n/, /g')
  264. + gpu=$($(PATH="/opt/bin:$PATH" type -p nvidia-smi | cut -f1) -q | "${AWK}" -F':' '/Product Name/ {gsub(/: /,":"); print $2}' | sed ':a;N;$!ba;s/\n/, /g')
  265. elif [[ -n "$(PATH="/usr/sbin:$PATH" type -p glxinfo)" && -z "${gpu}" ]]; then
  266. gpu_info=$($(PATH="/usr/sbin:$PATH" type -p glxinfo | cut -f1) 2>/dev/null)
  267. gpu=$(grep "OpenGL renderer string" <<< "${gpu_info}" | cut -d ':' -f2 | sed -n -e '1h;2,$H;${g;s/\n/, /g' -e 'p' -e '}')
  268. @@ -1650,12 +1665,12 @@ detectgpu () {
  269. # Run it only on Intel Processors if GPU is unknown
  270. DetectIntelGPU() {
  271. if [ -r /proc/fb ]; then
  272. - gpu=$(awk 'BEGIN {ORS = " &"} {$1="";print}' /proc/fb | sed -r s/'^\s+|\s*&$'//g)
  273. + gpu=$("${AWK}" 'BEGIN {ORS = " &"} {$1="";print}' /proc/fb | sed -r s/'^\s+|\s*&$'//g)
  274. fi
  275. case $gpu in
  276. *mfb)
  277. - gpu=$(lspci | grep -i vga | awk -F ": " '{print $2}')
  278. + gpu=$(lspci | grep -i vga | "${AWK}" -F ": " '{print $2}')
  279. ;;
  280. *intel*)
  281. gpu="intel"
  282. @@ -1667,7 +1682,7 @@ DetectIntelGPU() {
  283. if [[ "$gpu" = "intel" ]]; then
  284. #Detect CPU
  285. - local CPU=$(uname -p | awk '{print $3}')
  286. + local CPU=$(uname -p | "${AWK}" '{print $3}')
  287. CPU=${CPU#*'-'}; #Detect CPU number
  288. #Detect Intel GPU
  289. @@ -1710,7 +1725,7 @@ detectdisk () {
  290. if [[ "${distro}" =~ (Free|Net|DragonFly)BSD ]]; then
  291. totaldisk=$(df -h -c 2>/dev/null | tail -1)
  292. elif [[ "${distro}" == "OpenBSD" ]]; then
  293. - totaldisk=$(df -Pk 2> /dev/null | awk '
  294. + totaldisk=$(df -Pk 2> /dev/null | "${AWK}" '
  295. /^\// {total+=$2; used+=$3; avail+=$4}
  296. END{printf("total %.1fG %.1fG %.1fG %d%%\n", total/1048576, used/1048576, avail/1048576, used*100/total)}')
  297. elif [[ "${distro}" == "Mac OS X" ]]; then
  298. @@ -1718,9 +1733,9 @@ detectdisk () {
  299. else
  300. totaldisk=$(df -h -x aufs -x tmpfs -x overlay --total 2>/dev/null | tail -1)
  301. fi
  302. - disktotal=$(awk '{print $2}' <<< "${totaldisk}")
  303. - diskused=$(awk '{print $3}' <<< "${totaldisk}")
  304. - diskusedper=$(awk '{print $5}' <<< "${totaldisk}")
  305. + disktotal=$("${AWK}" '{print $2}' <<< "${totaldisk}")
  306. + diskused=$("${AWK}" '{print $3}' <<< "${totaldisk}")
  307. + diskusedper=$("${AWK}" '{print $5}' <<< "${totaldisk}")
  308. diskusage="${diskused} / ${disktotal} (${diskusedper})"
  309. diskusage_verbose=$(sed 's/%/%%/' <<< "$diskusage")
  310. fi
  311. @@ -1733,17 +1748,17 @@ detectdisk () {
  312. detectmem () {
  313. if [ "$distro" == "Mac OS X" ]; then
  314. totalmem=$(echo "$(sysctl -n hw.memsize)" / 1024^2 | bc)
  315. - wiredmem=$(vm_stat | grep wired | awk '{ print $4 }' | sed 's/\.//')
  316. - activemem=$(vm_stat | grep ' active' | awk '{ print $3 }' | sed 's/\.//')
  317. - compressedmem=$(vm_stat | grep occupied | awk '{ print $5 }' | sed 's/\.//')
  318. + wiredmem=$(vm_stat | grep wired | "${AWK}" '{ print $4 }' | sed 's/\.//')
  319. + activemem=$(vm_stat | grep ' active' | "${AWK}" '{ print $3 }' | sed 's/\.//')
  320. + compressedmem=$(vm_stat | grep occupied | "${AWK}" '{ print $5 }' | sed 's/\.//')
  321. if [[ ! -z "$compressedmem | tr -d" ]]; then # FIXME: is this line correct?
  322. compressedmem=0
  323. fi
  324. usedmem=$(((wiredmem + activemem + compressedmem) * 4 / 1024))
  325. elif [[ "${distro}" == "Cygwin" || "${distro}" == "Msys" ]]; then
  326. - total_mem=$(awk '/MemTotal/ { print $2 }' /proc/meminfo)
  327. + total_mem=$("${AWK}" '/MemTotal/ { print $2 }' /proc/meminfo)
  328. totalmem=$((total_mem / 1024))
  329. - free_mem=$(awk '/MemFree/ { print $2 }' /proc/meminfo)
  330. + free_mem=$("${AWK}" '/MemFree/ { print $2 }' /proc/meminfo)
  331. used_mem=$((total_mem - free_mem))
  332. usedmem=$((used_mem / 1024))
  333. elif [[ "$distro" == "FreeBSD" || "$distro" == "DragonFlyBSD" ]]; then
  334. @@ -1769,21 +1784,21 @@ detectmem () {
  335. usedmem=$((used_mem / 1024 / 1024))
  336. elif [ "$distro" == "OpenBSD" ]; then
  337. totalmem=$(($(sysctl -n hw.physmem) / 1024 / 1024))
  338. - usedmem=$(vmstat | awk '!/[a-z]/{gsub("M",""); print $3}')
  339. + usedmem=$(vmstat | "${AWK}" '!/[a-z]/{gsub("M",""); print $3}')
  340. elif [ "$distro" == "NetBSD" ]; then
  341. - phys_mem=$(awk '/MemTotal/ { print $2 }' /proc/meminfo)
  342. + phys_mem=$("${AWK}" '/MemTotal/ { print $2 }' /proc/meminfo)
  343. totalmem=$((phys_mem / 1024))
  344. if grep -q 'Cached' /proc/meminfo; then
  345. - cache=$(awk '/Cached/ {print $2}' /proc/meminfo)
  346. + cache=$("${AWK}" '/Cached/ {print $2}' /proc/meminfo)
  347. usedmem=$((cache / 1024))
  348. else
  349. - free_mem=$(awk '/MemFree/ { print $2 }' /proc/meminfo)
  350. + free_mem=$("${AWK}" '/MemFree/ { print $2 }' /proc/meminfo)
  351. used_mem=$((phys_mem - free_mem))
  352. usedmem=$((used_mem / 1024))
  353. fi
  354. elif [ "$distro" == "Haiku" ]; then
  355. - totalmem=$(sysinfo -mem | awk 'NR == 1 {gsub(/[\(\)\/]/, ""); printf("%d", $6/1024**2)}')
  356. - usedmem=$(sysinfo -mem | awk 'NR == 1 {gsub(/[\(\)\/]/, ""); printf("%d", $5/1024**2)}')
  357. + totalmem=$(sysinfo -mem | "${AWK}" 'NR == 1 {gsub(/[\(\)\/]/, ""); printf("%d", $6/1024**2)}')
  358. + usedmem=$(sysinfo -mem | "${AWK}" 'NR == 1 {gsub(/[\(\)\/]/, ""); printf("%d", $5/1024**2)}')
  359. else
  360. # MemUsed = Memtotal + Shmem - MemFree - Buffers - Cached - SReclaimable
  361. # Source: https://github.com/dylanaraps/neofetch/pull/391/files#diff-e863270127ca6116fd30e708cdc582fc
  362. @@ -1798,7 +1813,7 @@ detectmem () {
  363. #done
  364. #usedmem=$((usedmem / 1024))
  365. #totalmem=$((totalmem / 1024))
  366. - mem=$(free -b | awk 'NR==2{print $2"-"$7}')
  367. + mem=$(free -b | "${AWK}" 'NR==2{print $2"-"$7}')
  368. usedmem=$((mem / 1024 / 1024))
  369. totalmem=$((${mem//-*} / 1024 / 1024))
  370. fi
  371. @@ -1823,7 +1838,7 @@ detectshell_ver () {
  372. esac
  373. if [[ -n $version_data ]];then
  374. - version=$(awk '
  375. + version=$("${AWK}" '
  376. BEGIN {
  377. IGNORECASE=1
  378. }
  379. @@ -1842,7 +1857,7 @@ detectshell () {
  380. if [[ ! "${shell_type}" ]]; then
  381. if [[ "${distro}" == "Cygwin" || "${distro}" == "Msys" || "${distro}" == "Haiku" || "${distro}" == "Alpine Linux" ||
  382. "${distro}" == "Mac OS X" || "${distro}" == "TinyCore" || "${distro}" == "Raspbian" || "${OSTYPE}" == "gnu" ]]; then
  383. - shell_type=$(echo "$SHELL" | awk -F'/' '{print $NF}')
  384. + shell_type=$(echo "$SHELL" | "${AWK}" -F'/' '{print $NF}')
  385. elif readlink -f "$SHELL" 2>&1 | grep -q -i 'busybox'; then
  386. shell_type="BusyBox"
  387. else
  388. @@ -1851,7 +1866,7 @@ detectshell () {
  389. elif [[ "${distro}" =~ "BSD" ]]; then
  390. shell_type=$(ps -p $PPID -o command | tail -1)
  391. else
  392. - shell_type=$(ps -p "$(ps -p $PPID | awk '$1 !~ /PID/ {print $1}')" | awk 'FNR>1 {print $1}')
  393. + shell_type=$(ps -p "$(ps -p $PPID | "${AWK}" '$1 !~ /PID/ {print $1}')" | "${AWK}" 'FNR>1 {print $1}')
  394. fi
  395. shell_type=${shell_type/-}
  396. shell_type=${shell_type//*\/}
  397. @@ -1881,7 +1896,7 @@ detectshell () {
  398. shell_version_data=$( detectshell_ver "$shell_type" "^zsh" "2" )
  399. ;;
  400. fish)
  401. - shell_version_data=$( fish --version | awk '{print $3}' )
  402. + shell_version_data=$( fish --version | "${AWK}" '{print $3}' )
  403. ;;
  404. esac
  405. @@ -1899,17 +1914,17 @@ detectshell () {
  406. detectres () {
  407. xResolution="No X Server"
  408. if [[ ${distro} == "Mac OS X" ]]; then
  409. - xResolution=$(system_profiler SPDisplaysDataType | awk '/Resolution:/ {print $2"x"$4" "}')
  410. + xResolution=$(system_profiler SPDisplaysDataType | "${AWK}" '/Resolution:/ {print $2"x"$4" "}')
  411. if [[ "$(echo "$xResolution" | wc -l)" -ge 1 ]]; then
  412. xResolution=$(echo "$xResolution" | tr "\\n" "," | sed 's/\(.*\),/\1/')
  413. fi
  414. elif [[ "${distro}" == "Cygwin" || "${distro}" == "Msys" ]]; then
  415. - xResolution=$(wmic path Win32_VideoController get CurrentHorizontalResolution,CurrentVerticalResolution | awk 'NR==2 {print $1"x"$2}')
  416. + xResolution=$(wmic path Win32_VideoController get CurrentHorizontalResolution,CurrentVerticalResolution | "${AWK}" 'NR==2 {print $1"x"$2}')
  417. elif [[ "${distro}" == "Haiku" ]]; then
  418. - xResolution="$(screenmode | grep Resolution | awk '{gsub(/,/,""); print $2"x"$3}')"
  419. + xResolution="$(screenmode | grep Resolution | "${AWK}" '{gsub(/,/,""); print $2"x"$3}')"
  420. elif [[ -n ${DISPLAY} ]]; then
  421. if type -p xdpyinfo >/dev/null 2>&1; then
  422. - xResolution=$(xdpyinfo | awk '/^ +dimensions/ {print $2}')
  423. + xResolution=$(xdpyinfo | "${AWK}" '/^ +dimensions/ {print $2}')
  424. fi
  425. fi
  426. verboseOut "Finding current resolution(s)...found as '$xResolution'"
  427. @@ -1937,7 +1952,7 @@ detectde () {
  428. if type -p xprop >/dev/null 2>&1;then
  429. xprop_root="$(xprop -root 2>/dev/null)"
  430. if [[ -n ${xprop_root} ]]; then
  431. - DE=$(echo "${xprop_root}" | awk 'BEGIN {
  432. + DE=$(echo "${xprop_root}" | "${AWK}" 'BEGIN {
  433. de = "Not Present"
  434. }
  435. {
  436. @@ -2099,7 +2114,7 @@ detectde () {
  437. elif [[ ${KDE_FULL_SESSION} == 'true' ]]; then
  438. DE="KDE"
  439. DEver_data=$(kded --version 2>/dev/null)
  440. - DEver=$(grep -si '^KDE:' <<< "$DEver_data" | awk '{print $2}')
  441. + DEver=$(grep -si '^KDE:' <<< "$DEver_data" | "${AWK}" '{print $2}')
  442. fi
  443. fi
  444. fi
  445. @@ -2154,7 +2169,7 @@ detectde () {
  446. fi
  447. elif [[ ${DE} == "LXQt" ]]; then
  448. if type -p lxqt-about >/dev/null 2>&1; then
  449. - DEver=$(lxqt-about --version | awk '/^liblxqt/ {print $2}')
  450. + DEver=$(lxqt-about --version | "${AWK}" '/^liblxqt/ {print $2}')
  451. DE="${DE} ${DEver}"
  452. fi
  453. elif [[ ${DE} == "MATE" ]]; then
  454. @@ -2169,12 +2184,12 @@ detectde () {
  455. fi
  456. elif [[ ${DE} == "Deepin" ]]; then
  457. if [[ -f /etc/deepin-version ]]; then
  458. - DEver="$(awk -F '=' '/Version/ {print $2}' /etc/deepin-version)"
  459. + DEver="$("${AWK}" -F '=' '/Version/ {print $2}' /etc/deepin-version)"
  460. DE="${DE} ${DEver//* }"
  461. fi
  462. elif [[ ${DE} == "Trinity" ]]; then
  463. if type -p tde-config >/dev/null 2>&1; then
  464. - DEver="$(tde-config --version | awk -F ' ' '/TDE:/ {print $2}')"
  465. + DEver="$(tde-config --version | "${AWK}" -F ' ' '/TDE:/ {print $2}')"
  466. DE="${DE} ${DEver//* }"
  467. fi
  468. fi
  469. @@ -2418,7 +2433,7 @@ detectwmtheme () {
  470. else
  471. themeFile="$(reg query 'HKCU\Software\Microsoft\Windows\CurrentVersion\Themes' /v 'CurrentTheme')"
  472. fi
  473. - Win_theme=$(echo "$themeFile" | awk -F"\\" '{print $NF}' | sed 's|\.theme$||')
  474. + Win_theme=$(echo "$themeFile" | "${AWK}" -F"\\" '{print $NF}' | sed 's|\.theme$||')
  475. fi
  476. else
  477. case $WM in
  478. @@ -2433,7 +2448,7 @@ detectwmtheme () {
  479. ;;
  480. 'BlackBox')
  481. if [ -f "$HOME/.blackboxrc" ]; then
  482. - Win_theme="$(awk -F"/" '/styleFile/ {print $NF}' "$HOME/.blackboxrc")"
  483. + Win_theme="$("${AWK}" -F"/" '/styleFile/ {print $NF}' "$HOME/.blackboxrc")"
  484. fi
  485. ;;
  486. 'BudgieWM')
  487. @@ -2465,11 +2480,11 @@ detectwmtheme () {
  488. fi
  489. ;;
  490. 'E16')
  491. - Win_theme="$(awk -F"= " '/theme.name/ {print $2}' "$HOME/.e16/e_config--0.0.cfg")"
  492. + Win_theme="$("${AWK}" -F"= " '/theme.name/ {print $2}' "$HOME/.e16/e_config--0.0.cfg")"
  493. ;;
  494. 'E17'|'Enlightenment')
  495. if [ "$(which eet 2>/dev/null)" ]; then
  496. - econfig="$(eet -d "$HOME/.e/e/config/standard/e.cfg" config | awk '/value \"file\" string.*.edj/{ print $4 }')"
  497. + econfig="$(eet -d "$HOME/.e/e/config/standard/e.cfg" config | "${AWK}" '/value \"file\" string.*.edj/{ print $4 }')"
  498. econfigend="${econfig##*/}"
  499. Win_theme=${econfigend%.*}
  500. elif [ -n "${E_CONF_PROFILE}" ]; then
  501. @@ -2485,12 +2500,12 @@ detectwmtheme () {
  502. ;;
  503. 'FluxBox'|'Fluxbox')
  504. if [ -f "$HOME/.fluxbox/init" ]; then
  505. - Win_theme="$(awk -F"/" '/styleFile/ {print $NF}' "$HOME/.fluxbox/init")"
  506. + Win_theme="$("${AWK}" -F"/" '/styleFile/ {print $NF}' "$HOME/.fluxbox/init")"
  507. fi
  508. ;;
  509. 'IceWM')
  510. if [ -f "$HOME/.icewm/theme" ]; then
  511. - Win_theme="$(awk -F"[\",/]" '!/#/ {print $2}' "$HOME/.icewm/theme")"
  512. + Win_theme="$("${AWK}" -F"[\",/]" '!/#/ {print $2}' "$HOME/.icewm/theme")"
  513. fi
  514. ;;
  515. 'KWin'*)
  516. @@ -2507,14 +2522,14 @@ detectwmtheme () {
  517. Win_theme="Not Applicable"
  518. KDE_CONFIG_DIR=${KDE_CONFIG_DIR%/}
  519. if [[ -f $KDE_CONFIG_DIR/share/config/kwinrc ]]; then
  520. - Win_theme="$(awk '/PluginLib=kwin3_/{gsub(/PluginLib=kwin3_/,"",$0); print $0; exit}' "$KDE_CONFIG_DIR/share/config/kwinrc")"
  521. + Win_theme="$("${AWK}" '/PluginLib=kwin3_/{gsub(/PluginLib=kwin3_/,"",$0); print $0; exit}' "$KDE_CONFIG_DIR/share/config/kwinrc")"
  522. if [[ -z "$Win_theme" ]]; then
  523. Win_theme="Not Applicable"
  524. fi
  525. fi
  526. if [[ "$Win_theme" == "Not Applicable" ]]; then
  527. if [[ -f $KDE_CONFIG_DIR/share/config/kdebugrc ]]; then
  528. - Win_theme="$(awk '/(decoration)/ {gsub(/\[/,"",$1); print $1; exit}' "$KDE_CONFIG_DIR/share/config/kdebugrc")"
  529. + Win_theme="$("${AWK}" '/(decoration)/ {gsub(/\[/,"",$1); print $1; exit}' "$KDE_CONFIG_DIR/share/config/kdebugrc")"
  530. if [[ -z "$Win_theme" ]]; then
  531. Win_theme="Not Applicable"
  532. fi
  533. @@ -2522,7 +2537,7 @@ detectwmtheme () {
  534. fi
  535. if [[ "$Win_theme" == "Not Applicable" ]]; then
  536. if [[ -f $KDE_CONFIG_DIR/share/config/kdeglobals ]]; then
  537. - Win_theme="$(awk '/\[General\]/ {flag=1;next} /^$/{flag=0} flag {print}' "$KDE_CONFIG_DIR/share/config/kdeglobals" | grep -oP 'Name=\K.*')"
  538. + Win_theme="$("${AWK}" '/\[General\]/ {flag=1;next} /^$/{flag=0} flag {print}' "$KDE_CONFIG_DIR/share/config/kdeglobals" | grep -oP 'Name=\K.*')"
  539. if [[ -z "$Win_theme" ]]; then
  540. Win_theme="Not Applicable"
  541. fi
  542. @@ -2552,20 +2567,20 @@ detectwmtheme () {
  543. ;;
  544. 'OpenBox'|'Openbox')
  545. if [ -f "${XDG_CONFIG_HOME:-${HOME}/.config}/openbox/rc.xml" ]; then
  546. - Win_theme="$(awk -F"[<,>]" '/<theme/ { getline; print $3 }' "${XDG_CONFIG_HOME:-${HOME}/.config}/openbox/rc.xml")";
  547. + Win_theme="$("${AWK}" -F"[<,>]" '/<theme/ { getline; print $3 }' "${XDG_CONFIG_HOME:-${HOME}/.config}/openbox/rc.xml")";
  548. elif [[ -f ${XDG_CONFIG_HOME:-${HOME}/.config}/openbox/lxde-rc.xml && "${DE}" == "LXDE" ]]; then
  549. - Win_theme="$(awk -F"[<,>]" '/<theme/ { getline; print $3 }' "${XDG_CONFIG_HOME:-${HOME}/.config}/openbox/lxde-rc.xml")";
  550. + Win_theme="$("${AWK}" -F"[<,>]" '/<theme/ { getline; print $3 }' "${XDG_CONFIG_HOME:-${HOME}/.config}/openbox/lxde-rc.xml")";
  551. elif [[ -f ${XDG_CONFIG_HOME:-${HOME}/.config}/openbox/lxqt-rc.xml && "${DE}" =~ "LXQt" ]]; then
  552. - Win_theme="$(awk -F'=' '/^theme/ {print $2}' ${HOME}/.config/lxqt/lxqt.conf)"
  553. + Win_theme="$("${AWK}" -F'=' '/^theme/ {print $2}' ${HOME}/.config/lxqt/lxqt.conf)"
  554. fi
  555. ;;
  556. 'PekWM')
  557. if [ -f "$HOME/.pekwm/config" ]; then
  558. - Win_theme="$(awk -F"/" '/Theme/ {gsub(/\"/,""); print $NF}' "$HOME/.pekwm/config")"
  559. + Win_theme="$("${AWK}" -F"/" '/Theme/ {gsub(/\"/,""); print $NF}' "$HOME/.pekwm/config")"
  560. fi
  561. ;;
  562. 'Sawfish')
  563. - Win_theme="$(awk -F")" '/\(quote default-frame-style/{print $2}' "$HOME/.sawfish/custom" | sed 's/ (quote //')"
  564. + Win_theme="$("${AWK}" -F")" '/\(quote default-frame-style/{print $2}' "$HOME/.sawfish/custom" | sed 's/ (quote //')"
  565. ;;
  566. 'TWin')
  567. if [[ -z $TDE_CONFIG_DIR ]]; then
  568. @@ -2576,7 +2591,7 @@ detectwmtheme () {
  569. if [[ -n $TDE_CONFIG_DIR ]]; then
  570. TDE_CONFIG_DIR=${TDE_CONFIG_DIR%/}
  571. if [[ -f $TDE_CONFIG_DIR/share/config/kcmthememanagerrc ]]; then
  572. - Win_theme=$(awk '/CurrentTheme=/ {gsub(/CurrentTheme=/,"",$0); print $0; exit}' "$TDE_CONFIG_DIR/share/config/kcmthememanagerrc")
  573. + Win_theme=$("${AWK}" '/CurrentTheme=/ {gsub(/CurrentTheme=/,"",$0); print $0; exit}' "$TDE_CONFIG_DIR/share/config/kcmthememanagerrc")
  574. fi
  575. if [[ -z $Win_theme ]]; then
  576. Win_theme="Not Applicable"
  577. @@ -2672,31 +2687,31 @@ detectgtk () {
  578. if [[ -n ${KDE_CONFIG_FILE} ]]; then
  579. if grep -q 'widgetStyle=' "${KDE_CONFIG_FILE}"; then
  580. - gtk2Theme=$(awk -F"=" '/widgetStyle=/ {print $2}' "${KDE_CONFIG_FILE}")
  581. + gtk2Theme=$("${AWK}" -F"=" '/widgetStyle=/ {print $2}' "${KDE_CONFIG_FILE}")
  582. elif grep -q 'colorScheme=' "${KDE_CONFIG_FILE}"; then
  583. - gtk2Theme=$(awk -F"=" '/colorScheme=/ {print $2}' "${KDE_CONFIG_FILE}")
  584. + gtk2Theme=$("${AWK}" -F"=" '/colorScheme=/ {print $2}' "${KDE_CONFIG_FILE}")
  585. fi
  586. if grep -q 'Theme=' "${KDE_CONFIG_FILE}"; then
  587. - gtkIcons=$(awk -F"=" '/Theme=/ {print $2}' "${KDE_CONFIG_FILE}")
  588. + gtkIcons=$("${AWK}" -F"=" '/Theme=/ {print $2}' "${KDE_CONFIG_FILE}")
  589. fi
  590. if grep -q 'Font=' "${KDE_CONFIG_FILE}"; then
  591. - gtkFont=$(awk -F"=" '/font=/ {print $2}' "${KDE_CONFIG_FILE}")
  592. + gtkFont=$("${AWK}" -F"=" '/font=/ {print $2}' "${KDE_CONFIG_FILE}")
  593. fi
  594. fi
  595. if [[ -f $HOME/.gtkrc-2.0 ]]; then
  596. - gtk2Theme=$(grep '^gtk-theme-name' "$HOME"/.gtkrc-2.0 | awk -F'=' '{print $2}')
  597. + gtk2Theme=$(grep '^gtk-theme-name' "$HOME"/.gtkrc-2.0 | "${AWK}" -F'=' '{print $2}')
  598. gtk2Theme=${gtk2Theme//\"/}
  599. - gtkIcons=$(grep '^gtk-icon-theme-name' "$HOME"/.gtkrc-2.0 | awk -F'=' '{print $2}')
  600. + gtkIcons=$(grep '^gtk-icon-theme-name' "$HOME"/.gtkrc-2.0 | "${AWK}" -F'=' '{print $2}')
  601. gtkIcons=${gtkIcons//\"/}
  602. - gtkFont=$(grep 'font_name' "$HOME"/.gtkrc-2.0 | awk -F'=' '{print $2}')
  603. + gtkFont=$(grep 'font_name' "$HOME"/.gtkrc-2.0 | "${AWK}" -F'=' '{print $2}')
  604. gtkFont=${gtkFont//\"/}
  605. fi
  606. if [[ -f $HOME/.config/gtk-3.0/settings.ini ]]; then
  607. - gtk3Theme=$(grep '^gtk-theme-name=' "$HOME"/.config/gtk-3.0/settings.ini | awk -F'=' '{print $2}')
  608. + gtk3Theme=$(grep '^gtk-theme-name=' "$HOME"/.config/gtk-3.0/settings.ini | "${AWK}" -F'=' '{print $2}')
  609. fi
  610. ;;
  611. 'Cinnamon'*) # Desktop Environment found as "Cinnamon"
  612. @@ -2728,7 +2743,7 @@ detectgtk () {
  613. gtkFont=$(gconftool-2 -g /desktop/gnome/interface/font_name)
  614. if [ "$background_detect" == "1" ]; then
  615. gtkBackgroundFull=$(gconftool-2 -g /desktop/gnome/background/picture_filename)
  616. - gtkBackground=$(echo "$gtkBackgroundFull" | awk -F"/" '{print $NF}')
  617. + gtkBackground=$(echo "$gtkBackgroundFull" | "${AWK}" -F"/" '{print $NF}')
  618. fi
  619. fi
  620. ;;
  621. @@ -2745,10 +2760,10 @@ detectgtk () {
  622. ;;
  623. 'Xfce'*) # Desktop Environment found as "Xfce"
  624. if [ "$distro" == "BunsenLabs" ] ; then
  625. - gtk2Theme=$(awk -F'"' '/^gtk-theme/ {print $2}' "$HOME"/.gtkrc-2.0)
  626. - gtk3Theme=$(awk -F'=' '/^gtk-theme-name/ {print $2}' "$HOME"/.config/gtk-3.0/settings.ini)
  627. - gtkIcons=$(awk -F'"' '/^gtk-icon-theme/ {print $2}' "$HOME"/.gtkrc-2.0)
  628. - gtkFont=$(awk -F'"' '/^gtk-font-name/ {print $2}' "$HOME"/.gtkrc-2.0)
  629. + gtk2Theme=$("${AWK}" -F'"' '/^gtk-theme/ {print $2}' "$HOME"/.gtkrc-2.0)
  630. + gtk3Theme=$("${AWK}" -F'=' '/^gtk-theme-name/ {print $2}' "$HOME"/.config/gtk-3.0/settings.ini)
  631. + gtkIcons=$("${AWK}" -F'"' '/^gtk-icon-theme/ {print $2}' "$HOME"/.gtkrc-2.0)
  632. + gtkFont=$("${AWK}" -F'"' '/^gtk-font-name/ {print $2}' "$HOME"/.gtkrc-2.0)
  633. else
  634. if type -p xfconf-query >/dev/null 2>&1; then
  635. gtk2Theme=$(xfconf-query -c xsettings -p /Net/ThemeName 2>/dev/null)
  636. @@ -2779,15 +2794,15 @@ detectgtk () {
  637. fi
  638. if grep -q 'sNet\/ThemeName' "${config_home}${lxdeconf}" 2>/dev/null; then
  639. - gtk2Theme=$(awk -F'=' '/sNet\/ThemeName/ {print $2}' "${config_home}${lxdeconf}")
  640. + gtk2Theme=$("${AWK}" -F'=' '/sNet\/ThemeName/ {print $2}' "${config_home}${lxdeconf}")
  641. fi
  642. if grep -q 'IconThemeName' "${config_home}${lxdeconf}" 2>/dev/null; then
  643. - gtkIcons=$(awk -F'=' '/sNet\/IconThemeName/ {print $2}' "${config_home}${lxdeconf}")
  644. + gtkIcons=$("${AWK}" -F'=' '/sNet\/IconThemeName/ {print $2}' "${config_home}${lxdeconf}")
  645. fi
  646. if grep -q 'FontName' "${config_home}${lxdeconf}" 2>/dev/null; then
  647. - gtkFont=$(awk -F'=' '/sGtk\/FontName/ {print $2}' "${config_home}${lxdeconf}")
  648. + gtkFont=$("${AWK}" -F'=' '/sGtk\/FontName/ {print $2}' "${config_home}${lxdeconf}")
  649. fi
  650. ;;
  651. @@ -2796,15 +2811,15 @@ detectgtk () {
  652. *) # Lightweight or No DE Found
  653. if [ -f "$HOME/.gtkrc-2.0" ]; then
  654. if grep -q 'gtk-theme' "$HOME/.gtkrc-2.0"; then
  655. - gtk2Theme=$(awk -F'"' '/^gtk-theme/ {print $2}' "$HOME/.gtkrc-2.0")
  656. + gtk2Theme=$("${AWK}" -F'"' '/^gtk-theme/ {print $2}' "$HOME/.gtkrc-2.0")
  657. fi
  658. if grep -q 'icon-theme' "$HOME/.gtkrc-2.0"; then
  659. - gtkIcons=$(awk -F'"' '/^gtk-icon-theme/ {print $2}' "$HOME/.gtkrc-2.0")
  660. + gtkIcons=$("${AWK}" -F'"' '/^gtk-icon-theme/ {print $2}' "$HOME/.gtkrc-2.0")
  661. fi
  662. if grep -q 'font' "$HOME/.gtkrc-2.0"; then
  663. - gtkFont=$(awk -F'"' '/^gtk-font-name/ {print $2}' "$HOME/.gtkrc-2.0")
  664. + gtkFont=$("${AWK}" -F'"' '/^gtk-font-name/ {print $2}' "$HOME/.gtkrc-2.0")
  665. fi
  666. fi
  667. # $HOME/.gtkrc.mine theme detect only
  668. @@ -2815,37 +2830,37 @@ detectgtk () {
  669. fi
  670. if [ -f "$minegtkrc" ]; then
  671. if grep -q '^include' "$minegtkrc"; then
  672. - gtk2Theme=$(grep '^include.*gtkrc' "$minegtkrc" | awk -F "/" '{ print $5 }')
  673. + gtk2Theme=$(grep '^include.*gtkrc' "$minegtkrc" | "${AWK}" -F "/" '{ print $5 }')
  674. fi
  675. if grep -q '^gtk-icon-theme-name' "$minegtkrc"; then
  676. - gtkIcons=$(grep '^gtk-icon-theme-name' "$minegtkrc" | awk -F '"' '{print $2}')
  677. + gtkIcons=$(grep '^gtk-icon-theme-name' "$minegtkrc" | "${AWK}" -F '"' '{print $2}')
  678. fi
  679. fi
  680. # /etc/gtk-2.0/gtkrc compatibility
  681. if [[ -f /etc/gtk-2.0/gtkrc && ! -f "$HOME/.gtkrc-2.0" && ! -f "$HOME/.gtkrc.mine" && ! -f "$HOME/.gtkrc-2.0.mine" ]]; then
  682. if grep -q 'gtk-theme-name' /etc/gtk-2.0/gtkrc; then
  683. - gtk2Theme=$(awk -F'"' '/^gtk-theme-name/ {print $2}' /etc/gtk-2.0/gtkrc)
  684. + gtk2Theme=$("${AWK}" -F'"' '/^gtk-theme-name/ {print $2}' /etc/gtk-2.0/gtkrc)
  685. fi
  686. if grep -q 'gtk-fallback-theme-name' /etc/gtk-2.0/gtkrc && ! [ "x$gtk2Theme" = "x" ]; then
  687. - gtk2Theme=$(awk -F'"' '/^gtk-fallback-theme-name/ {print $2}' /etc/gtk-2.0/gtkrc)
  688. + gtk2Theme=$("${AWK}" -F'"' '/^gtk-fallback-theme-name/ {print $2}' /etc/gtk-2.0/gtkrc)
  689. fi
  690. if grep -q 'icon-theme' /etc/gtk-2.0/gtkrc; then
  691. - gtkIcons=$(awk -F'"' '/^icon-theme/ {print $2}' /etc/gtk-2.0/gtkrc)
  692. + gtkIcons=$("${AWK}" -F'"' '/^icon-theme/ {print $2}' /etc/gtk-2.0/gtkrc)
  693. fi
  694. if grep -q 'gtk-fallback-icon-theme' /etc/gtk-2.0/gtkrc && ! [ "x$gtkIcons" = "x" ]; then
  695. - gtkIcons=$(awk -F'"' '/^gtk-fallback-icon-theme/ {print $2}' /etc/gtk-2.0/gtkrc)
  696. + gtkIcons=$("${AWK}" -F'"' '/^gtk-fallback-icon-theme/ {print $2}' /etc/gtk-2.0/gtkrc)
  697. fi
  698. if grep -q 'font' /etc/gtk-2.0/gtkrc; then
  699. - gtkFont=$(awk -F'"' '/^gtk-font-name/ {print $2}' /etc/gtk-2.0/gtkrc)
  700. + gtkFont=$("${AWK}" -F'"' '/^gtk-font-name/ {print $2}' /etc/gtk-2.0/gtkrc)
  701. fi
  702. fi
  703. # EXPERIMENTAL gtk3 Theme detection
  704. if [[ "$gtk3Theme" = "Not Found" && -f "$HOME/.config/gtk-3.0/settings.ini" ]]; then
  705. if grep -q 'gtk-theme-name' "$HOME/.config/gtk-3.0/settings.ini"; then
  706. - gtk3Theme=$(awk -F'=' '/^gtk-theme-name/ {print $2}' "$HOME/.config/gtk-3.0/settings.ini")
  707. + gtk3Theme=$("${AWK}" -F'=' '/^gtk-theme-name/ {print $2}' "$HOME/.config/gtk-3.0/settings.ini")
  708. fi
  709. fi
  710. @@ -2859,7 +2874,7 @@ detectgtk () {
  711. # ROX-Filer icon detect only
  712. if [ -a "${XDG_CONFIG_HOME:-${HOME}/.config}/rox.sourceforge.net/ROX-Filer/Options" ]; then
  713. - gtkIcons=$(awk -F'[>,<]' '/icon_theme/ {print $3}' "${XDG_CONFIG_HOME:-${HOME}/.config}/rox.sourceforge.net/ROX-Filer/Options")
  714. + gtkIcons=$("${AWK}" -F'[>,<]' '/icon_theme/ {print $3}' "${XDG_CONFIG_HOME:-${HOME}/.config}/rox.sourceforge.net/ROX-Filer/Options")
  715. fi
  716. # E17 detection
  717. @@ -2872,10 +2887,10 @@ detectgtk () {
  718. # Background Detection (feh, nitrogen)
  719. if [ "$background_detect" == "1" ]; then
  720. if [ -a "$HOME/.fehbg" ]; then
  721. - gtkBackgroundFull=$(awk -F"'" '/feh --bg/{print $2}' "$HOME/.fehbg" 2>/dev/null)
  722. - gtkBackground=$(echo "$gtkBackgroundFull" | awk -F"/" '{print $NF}')
  723. + gtkBackgroundFull=$("${AWK}" -F"'" '/feh --bg/{print $2}' "$HOME/.fehbg" 2>/dev/null)
  724. + gtkBackground=$(echo "$gtkBackgroundFull" | "${AWK}" -F"/" '{print $NF}')
  725. elif [ -a "${XDG_CONFIG_HOME:-${HOME}/.config}/nitrogen/bg-saved.cfg" ]; then
  726. - gtkBackground=$(awk -F"/" '/file=/ {print $NF}' "${XDG_CONFIG_HOME:-${HOME}/.config}/nitrogen/bg-saved.cfg")
  727. + gtkBackground=$("${AWK}" -F"/" '/file=/ {print $NF}' "${XDG_CONFIG_HOME:-${HOME}/.config}/nitrogen/bg-saved.cfg")
  728. fi
  729. fi
  730. @@ -2910,7 +2925,7 @@ detectdroid () {
  731. rom=$(getprop ro.build.display.id)
  732. fi
  733. baseband=$(getprop ro.baseband)
  734. - cpu=$(awk -F': ' '/^Processor/ {P=$2} /^Hardware/ {H=$2} END {print H != "" ? H : P}' /proc/cpuinfo)
  735. + cpu=$("${AWK}" -F': ' '/^Processor/ {P=$2} /^Hardware/ {H=$2} END {print H != "" ? H : P}' /proc/cpuinfo)
  736. }
  737. @@ -6032,7 +6047,7 @@ asciiText () {
  738. #n=${#fulloutput[*]}
  739. for ((i=0; i<${#fulloutput[*]}; i++)); do
  740. # echo "${out_array[@]}"
  741. - case $(awk 'BEGIN{srand();print int(rand()*(1000-1))+1 }') in
  742. + case $("${AWK}" 'BEGIN{srand();print int(rand()*(1000-1))+1 }') in
  743. 411|188|15|166|609)
  744. f_size=${#fulloutput[*]}
  745. o_size=${#out_array[*]}
  746. --
  747. 2.41.0.640.ga95def55d0-goog