From 9779e91672ce113c12d1ddc69b6eb2a764b9acbb Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Sun, 27 Mar 2016 19:50:09 +1100 Subject: [PATCH 1/2] made resolution way faster on OS X --- .travis.yml | 4 ++++ README.md | 2 +- neofetch | 29 +++++++++++++++++++---------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 352bd92d..4f7cd3ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,10 @@ os: - linux - osx +before_install: + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install screenresolution; fi + script: - sudo make install - neofetch --test --ascii --color_blocks off --config off --ascii_distro travis diff --git a/README.md b/README.md index 178ae47d..90af6bdb 100644 --- a/README.md +++ b/README.md @@ -95,7 +95,7 @@ your distro's logo or any ascii art of your choice! ##### OSX -- Current Song: `itunes` +- Resolution (quicker): `screenresolution \[1\] See **[#79](https://github.com/dylanaraps/neofetch/issues/79)** about why this is now a required dependency. diff --git a/neofetch b/neofetch index 95eef80a..4fdeb620 100755 --- a/neofetch +++ b/neofetch @@ -12,10 +12,12 @@ # Optional Dependencies: (You'll lose these features without them) # Displaying Images: w3m + w3m-img # Image Cropping: ImageMagick +# Displaying song with Google Play Music: gpmdp-bash # [ Linux / BSD ] Wallpaper Display: feh, nitrogen or gsettings # [ Linux / BSD ] Current Song: mpc, cmus, moc # [ Linux ] Current Song: spotify # [ Linux / BSD ] Resolution detection: xorg-xdpyinfo +# [ OS X ] Getting screen resolution (faster): screenresolution # # Created by Dylan Araps # https://github.com/dylanaraps/ @@ -1251,16 +1253,23 @@ getresolution () { ;; "Mac OS X") - case "$refresh_rate" in - "on") - resolution=$(system_profiler SPDisplaysDataType |\ - awk '/Resolution:/ {printf $2"x"$4" @ "$6"Hz, "}') - ;; - "off") - resolution=$(system_profiler SPDisplaysDataType |\ - awk '/Resolution:/ {printf $2"x"$4", "}') - ;; - esac + if type -p screenresolution >/dev/null 2>&1; then + resolution=$(screenresolution get 2>&1 | awk '/Display/ {printf $6"Hz, "}') + resolution=${resolution//x??@/ @ } + [[ "$refresh_rate" == "off" ]] && resolution=${resolution// @ +([0-9])Hz} + + else + case "$refresh_rate" in + "on") + resolution=$(system_profiler SPDisplaysDataType |\ + awk '/Resolution:/ {printf $2"x"$4" @ "$6"Hz, "}') + ;; + "off") + resolution=$(system_profiler SPDisplaysDataType |\ + awk '/Resolution:/ {printf $2"x"$4", "}') + ;; + esac + fi ;; "Windows") From a0d409f15e39cc4430c3c4d53a4d743777a15ba8 Mon Sep 17 00:00:00 2001 From: Andrew Titmuss Date: Sun, 27 Mar 2016 20:13:32 +1100 Subject: [PATCH 2/2] made OS X resolution block smaller --- neofetch | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/neofetch b/neofetch index 4fdeb620..c8669bab 100755 --- a/neofetch +++ b/neofetch @@ -1254,22 +1254,16 @@ getresolution () { "Mac OS X") if type -p screenresolution >/dev/null 2>&1; then - resolution=$(screenresolution get 2>&1 | awk '/Display/ {printf $6"Hz, "}') + resolution=$(screenresolution get 2>&1 | awk '/Display/ {printf $6 "Hz, "}') resolution=${resolution//x??@/ @ } - [[ "$refresh_rate" == "off" ]] && resolution=${resolution// @ +([0-9])Hz} else - case "$refresh_rate" in - "on") - resolution=$(system_profiler SPDisplaysDataType |\ - awk '/Resolution:/ {printf $2"x"$4" @ "$6"Hz, "}') - ;; - "off") - resolution=$(system_profiler SPDisplaysDataType |\ - awk '/Resolution:/ {printf $2"x"$4", "}') - ;; - esac + resolution=$(system_profiler SPDisplaysDataType |\ + awk '/Resolution:/ {printf $2"x"$4" @ "$6"Hz, "}') fi + + [[ "$refresh_rate" == "off" ]] && \ + resolution=${resolution// @ +([0-9])Hz} ;; "Windows")