From 8c6f4c4d3e31aa83328e2835fae61f42aa114b4f Mon Sep 17 00:00:00 2001 From: albi Date: Wed, 12 Feb 2020 21:28:59 +0700 Subject: [PATCH 1/4] Fixed slow package counting in macOS --- screenfetch-dev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/screenfetch-dev b/screenfetch-dev index d5d70f0..3399b7d 100755 --- a/screenfetch-dev +++ b/screenfetch-dev @@ -1402,7 +1402,7 @@ detectpkgs () { pkgs=$((pkgs + (port_pkgs - offset))) fi if type -p brew >/dev/null 2>&1; then - brew_pkgs=$(brew list -1 2>/dev/null | wc -l) + brew_pkgs=$(ls -1 /usr/local/Cellar/ | wc -l) pkgs=$((pkgs + brew_pkgs)) fi if type -p pkgin >/dev/null 2>&1; then From 41b98a1a783715c655a7c3f42a823b31babefca4 Mon Sep 17 00:00:00 2001 From: albi Date: Wed, 12 Feb 2020 21:30:59 +0700 Subject: [PATCH 2/4] Fixed disk usage detection in macOS Catalina --- screenfetch-dev | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/screenfetch-dev b/screenfetch-dev index 3399b7d..d5be861 100755 --- a/screenfetch-dev +++ b/screenfetch-dev @@ -1716,9 +1716,14 @@ detectdisk () { /^\// {total+=$2; used+=$3; avail+=$4} END{printf("total %.1fG %.1fG %.1fG %d%%\n", total/1048576, used/1048576, avail/1048576, used*100/total)}') elif [[ "${distro}" == "Mac OS X" ]]; then - totaldisk=$(df -H / 2>/dev/null | tail -1) + minorVers=$(sw_vers | grep "ProductVersion" | cut -d ':' -f 2 | awk -F "." '{print $2}') # Minor version + if [[ "${minorVers}" -ge "15" ]]; then # Catalina or newer + totaldisk=$(df -H /System/Volumes/Data 2>/dev/null | tail -1) + else + totaldisk=$(df -H / 2>/dev/null | tail -1) + fi else - totaldisk=$(df -h -x aufs -x tmpfs -x overlay -x drvfs --total 2>/dev/null | tail -1) + totaldisk=$(df -h -x aufs -x tmpfs -x overlay --total 2>/dev/null | tail -1) fi disktotal=$(awk '{print $2}' <<< "${totaldisk}") diskused=$(awk '{print $3}' <<< "${totaldisk}") From bb58b901c1f235730b7a56b97d4316e060ba30eb Mon Sep 17 00:00:00 2001 From: albi Date: Wed, 12 Feb 2020 21:51:40 +0700 Subject: [PATCH 3/4] Fixed font detection in iTerm2 macOS --- screenfetch-dev | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/screenfetch-dev b/screenfetch-dev index d5be861..a1be634 100755 --- a/screenfetch-dev +++ b/screenfetch-dev @@ -2620,13 +2620,13 @@ detectgtk () { OLD_IFS=$IFS IFS=$'\n' - iterm2_theme_info=($(defaults read com.googlecode.iTerm2 "New Bookmarks" | grep -e 'Guid' -e 'Normal Font')) + iterm2_theme_info=($(defaults read com.googlecode.iTerm2 "New Bookmarks" | grep -e 'Guid\s*=\s*\w+' -e 'Normal Font')) IFS=$OLD_IFS for i in $(seq 0 $((${#iterm2_theme_info[*]}/2-1))); do - found_uuid=$(str1=${iterm2_theme_info[$i*2]};echo "${str1:16:${#str1}-16-2}") - if [[ $found_uuid == $iterm2_theme_uuid ]]; then - gtkFont=$(str2=${iterm2_theme_info[$i*2+1]};echo ${str2:25:${#str2}-25-2}) + found_uuid=$(str1=${iterm2_theme_info[$i*2]};echo "${str1}") + if [[ $found_uuid == $iterm2_theme_info ]]; then + gtkFont=$(str2=${iterm2_theme_info[$i*2+1]};echo ${str2:25:${#str2}-25-2} | sed 's/ [0-9]*$//') break fi done From b5f99a49d1d46ccf3d832e32eb42a4b9e606f0ad Mon Sep 17 00:00:00 2001 From: albi Date: Wed, 12 Feb 2020 21:52:44 +0700 Subject: [PATCH 4/4] Fixed font detection in Terminal.app macOS --- screenfetch-dev | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/screenfetch-dev b/screenfetch-dev index a1be634..bdc548d 100755 --- a/screenfetch-dev +++ b/screenfetch-dev @@ -1723,7 +1723,7 @@ detectdisk () { totaldisk=$(df -H / 2>/dev/null | tail -1) fi else - totaldisk=$(df -h -x aufs -x tmpfs -x overlay --total 2>/dev/null | tail -1) + totaldisk=$(df -h -x aufs -x tmpfs -x overlay -x drvfs --total 2>/dev/null | tail -1) fi disktotal=$(awk '{print $2}' <<< "${totaldisk}") diskused=$(awk '{print $3}' <<< "${totaldisk}") @@ -2637,18 +2637,14 @@ detectgtk () { OLD_IFS=$IFS IFS=$'\n' - termapp_theme_info=($(defaults read com.apple.Terminal "Window Settings" | grep -e 'name = ' -e 'Font = ')) + termapp_theme_info=$(/usr/libexec/PlistBuddy -c \ + "print ':Window Settings:${termapp_theme_name}:Font'" \ + ~/Library/Preferences/com.apple.Terminal.plist \ + | xxd -p |tr -d '\n\t\s') IFS=$OLD_IFS - for i in $(seq 0 $((${#termapp_theme_info[*]}/2-1))); do - found_name=$(str1=${termapp_theme_info[$i*2+1]};echo "${str1:15:${#str1}-15-1}") - if [[ $found_name == $termapp_theme_name ]]; then - gtkFont=$(str2=${termapp_theme_info[$i*2]};echo "${str2:288:${#str2}-288}") - gtkFont=$(echo "${gtkFont%%[dD]2*;}" | xxd -r -p) - gtkFont=$(echo "${gtkFont:21:288}") - break - fi - done + gtkFont=$(echo "${termapp_theme_info:288:60}" | xxd -r -p | perl -pe 'binmode(STDIN, ":bytes"); tr/A-Za-z0-9_\!\@\#\$\%\&\^\*\(\)-+=//dc;') + gtkFont=$(echo "${gtkFont:1}" | sed 's/Z\$.*//') fi fi else