From 0b068d2a1f502aa5faf36c9106c299c1d5a931d9 Mon Sep 17 00:00:00 2001 From: Mattia Basaglia Date: Sun, 21 Dec 2014 19:31:10 +0100 Subject: [PATCH] Simplify some stuff --- Makefile | 7 ++++--- systempony | 17 +++++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 4074e43..0069e70 100644 --- a/Makefile +++ b/Makefile @@ -106,7 +106,7 @@ $(BINDIR): install: $(OUT_ALL) install: $(DATADIR) install: $(BINDIR) - $(INSTALL_DIR) $(MAKEFILE_DIR)rendered $(DATADIR) + $(INSTALL_DIR) $(OUT_DIR) $(DATADIR) $(INSTALL_FILE) $(MAKEFILE_DIR)systempony $(BINDIR) uninstall: @@ -116,5 +116,6 @@ uninstall: #touch output files to avoid re-generations (eg: after cloning) touchput: - find $(MAKEFILE_DIR)rendered -exec touch {} \; - find $(MAKEFILE_DIR)rendered -name '*.png' -exec touch {} \; + find $(PONY_DIR) -name '*.txt' -exec touch {} \; + find $(OUT_DIR) -exec touch {} \; + find $(OUT_DIR) -name '*.png' -exec touch {} \; diff --git a/systempony b/systempony index 50c7adb..23ce74d 100755 --- a/systempony +++ b/systempony @@ -28,7 +28,7 @@ function ponyget_RAM() local ramtable=$(free -m) local used_M=$(echo "$ramtable" | sed -n 3p | sed -r "s/ +/\t/g" | cut -f 3) local total_M=$(echo "$ramtable" | sed -n 2p | sed -r "s/ +/\t/g" | cut -f 2) - local percent=$(echo "$used_M * 100 / $total_M " | bc) + let percent="$used_M * 100 / $total_M" local color="32"; if [ "$percent" -gt 66 ] @@ -201,19 +201,20 @@ then lines=$(cat "$ponyfile" | wc -l) # cat to avoid printing file name let info_index=0 let start_line=($lines-${#INFO[@]})/2 - for (( l=1; $l <= $lines; l++ )) + + let l=1 + while IFS= read -r line do - line=$(sed -n "$l{p;q}" "$ponyfile" ) - echo -n "$line" if [ $info_index -lt ${#INFO[@]} -a $l -ge $start_line ] then # TODO take in consideration $COLUMNS - printf " \x1b[31;1m%-${maxkeyl}s\x1b[0m: %s" "${INFO[$info_index]}" "${infoval[$info_index]}" + printf "%s \x1b[31;1m%-${maxkeyl}s\x1b[0m: %s\n" "$line" "${INFO[$info_index]}" "${infoval[$info_index]}" let info_index++ else - echo -ne "\x1b[0m" + echo -n "$line" + echo -e "\x1b[0m" fi - echo - done + let l++ + done < "$ponyfile" fi