misc: fix awk lint errors

This commit is contained in:
Dylan Araps 2018-06-02 12:28:10 +10:00
parent 6ea186d987
commit 37bb794602
1 changed files with 66 additions and 24 deletions

View File

@ -1682,15 +1682,25 @@ get_wm_theme() {
kdebugrc="${kde_config_dir}/kdebugrc" kdebugrc="${kde_config_dir}/kdebugrc"
if [[ -f "$kwinrc" ]]; then if [[ -f "$kwinrc" ]]; then
wm_theme="$(awk '/theme=/{gsub(/theme=.*qml_|theme=.*svg__/,"",$0);\ wm_theme="$(awk '/theme=/ {
print $0; exit}' "$kwinrc")" gsub(/theme=.*qml_|theme=.*svg__/,"",$0);
print $0;
exit
}' "$kwinrc")"
[[ -z "$wm_theme" ]] && \ [[ -z "$wm_theme" ]] && \
wm_theme="$(awk '/library=org.kde/{gsub(/library=org.kde./,"",$0);\ wm_theme="$(awk '/library=org.kde/ {
print $0; exit}' "$kwinrc")" gsub(/library=org.kde./,"",$0);
print $0;
exit
}' "$kwinrc")"
[[ -z "$wm_theme" ]] && \ [[ -z "$wm_theme" ]] && \
wm_theme="$(awk '/PluginLib=kwin3_/{gsub(/PluginLib=kwin3_/,"",$0);\ wm_theme="$(awk '/PluginLib=kwin3_/ {
print $0; exit}' "$kwinrc")" gsub(/PluginLib=kwin3_/,"",$0);
print $0;
exit
}' "$kwinrc")"
elif [[ -f "$kdebugrc" ]]; then elif [[ -f "$kdebugrc" ]]; then
wm_theme="$(awk '/(decoration)/ {gsub(/\[/,"",$1); print $1; exit}' "$kdebugrc")" wm_theme="$(awk '/(decoration)/ {gsub(/\[/,"",$1); print $1; exit}' "$kdebugrc")"
@ -1764,8 +1774,10 @@ get_cpu() {
;; ;;
*) *)
cpu="$(awk -F ': | @' '/model name|Processor|^cpu model|chip type|^cpu type/\ cpu="$(awk -F ': | @' '/model name|Processor|^cpu model|chip type|^cpu type/ {
{printf $2; exit}' "$cpu_file")" printf $2;
exit
}' "$cpu_file")"
[[ "$cpu" == *"processor rev"* ]] && \ [[ "$cpu" == *"processor rev"* ]] && \
cpu="$(awk -F':' '/Hardware/ {print $2; exit}' "$cpu_file")" cpu="$(awk -F':' '/Hardware/ {print $2; exit}' "$cpu_file")"
@ -2391,9 +2403,15 @@ get_song() {
"cmus"*) "cmus"*)
song="$(cmus-remote -Q | awk 'BEGIN { ORS=" "}; song="$(cmus-remote -Q | awk 'BEGIN { ORS=" "};
/tag artist/ {$1=$2=""; sub(" ", ""); a=$0}\ /tag artist/ {
/tag album / {$1=$2=""; sub(" ", ""); b=$0}\ $1=$2=""; sub(" ", ""); a=$0
/tag title/ {$1=$2=""; sub(" ", ""); t=$0}\ }
/tag album / {
$1=$2=""; sub(" ", ""); b=$0
}
/tag title/ {
$1=$2=""; sub(" ", ""); t=$0
}
END { print a " \n " b " \n " t }')" END { print a " \n " b " \n " t }')"
;; ;;
@ -2448,8 +2466,19 @@ get_song() {
"pogo"*) "pogo"*)
song="$(dbus-send --print-reply --dest=org.mpris.pogo /Player \ song="$(dbus-send --print-reply --dest=org.mpris.pogo /Player \
org.freedesktop.MediaPlayer.GetMetadata | org.freedesktop.MediaPlayer.GetMetadata |
awk -F'"' '/string "artist"/ {getline; a=$2} /string "album"/ {getline; b=$2} \ awk -F'"' '/string "artist"/ {
/string "title"/ {getline; t=$2} END{print a " \n " b " \n " t}')" getline;
a=$2
}
/string "album"/ {
getline;
b=$2
}
/string "title"/ {
getline;
t=$2
}
END{print a " \n " b " \n " t}')"
;; ;;
*) mpc &>/dev/null && song="$(mpc -f '%artist% \n %album% \n %title%' current)" ;; *) mpc &>/dev/null && song="$(mpc -f '%artist% \n %album% \n %title%' current)" ;;
@ -2865,12 +2894,15 @@ END
fi fi
term_font="$(awk '/^([[:space:]]*|[^#_])font_family[[:space:]]+/ \ term_font="$(awk '/^([[:space:]]*|[^#_])font_family[[:space:]]+/ {
{ $1 = ""; gsub(/^[[:space:]]/, ""); font = $0 } \ $1 = "";
/^([[:space:]]*|[^#_])font_size[[:space:]]+/ \ gsub(/^[[:space:]]/, "");
{ size = $2 } \ font = $0
END { print font " " size}' \ }
"${kitty_file}")" /^([[:space:]]*|[^#_])font_size[[:space:]]+/ {
size = $2
}
END { print font " " size}' "${kitty_file}")"
;; ;;
"konsole"*) "konsole"*)
@ -2919,9 +2951,13 @@ END
role="${role//\"}" role="${role//\"}"
profile="$(awk -F '=' -v r="$role" \ profile="$(awk -F '=' -v r="$role" \
'$0~r {getline; if(/Maximized/) getline; \ '$0~r {
if(/Fullscreen/) getline; id=$2"]"} \ getline;
$0~id {if(id) {getline; print $2; exit}}' "$mateterm_config")" if(/Maximized/) getline;
if(/Fullscreen/) getline;
id=$2"]"
} $0~id {if(id) {getline; print $2; exit}}' \
"$mateterm_config")"
rm -f "$mateterm_config" rm -f "$mateterm_config"
@ -3001,8 +3037,14 @@ END
[[ -f "${XDG_CONFIG_HOME}/termite/config" ]] && \ [[ -f "${XDG_CONFIG_HOME}/termite/config" ]] && \
termite_config="${XDG_CONFIG_HOME}/termite/config" termite_config="${XDG_CONFIG_HOME}/termite/config"
term_font="$(awk -F '= ' '/\[options\]/ {opt=1} /^\s*font/ {if(opt==1) a=$2; opt=0} \ term_font="$(awk -F '= ' '/\[options\]/ {
END{print a}' "/etc/xdg/termite/config" "$termite_config")" opt=1
}
/^\s*font/ {
if(opt==1) a=$2;
opt=0
} END{print a}' "/etc/xdg/termite/config" \
"$termite_config")"
;; ;;
"urxvt" | "urxvtd" | "rxvt-unicode" | "xterm") "urxvt" | "urxvtd" | "rxvt-unicode" | "xterm")