diff --git a/README.md b/README.md index 8514210f..02c58bf0 100644 --- a/README.md +++ b/README.md @@ -305,6 +305,8 @@ alias fetch2="fetch \ --cpu_cores on/off Whether or not to display the number of CPU cores --kernel_shorthand on/off Shorten the output of kernel --uptime_shorthand on/off Shorten the output of uptime (tiny, on, off) + --refresh_rate on/off Whether to display the refresh rate of each monitor + Unsupported on Windows --gpu_shorthand on/off Shorten the output of GPU (tiny, on, off) --gtk_shorthand on/off Shorten output of gtk theme/icons --gtk2 on/off Enable/Disable gtk2 theme/icons output diff --git a/config/config b/config/config index 52830009..bb829200 100644 --- a/config/config +++ b/config/config @@ -115,6 +115,13 @@ cpu_cores="on" # --gpu_shorthand on/off/tiny gpu_shorthand="on" +# Resolution + +# Display refresh rate next to each monitor +# Unsupported on Windows +# --refresh_rate on/off +refresh_rate="off" + # Gtk Theme / Icons diff --git a/neofetch b/neofetch index 4b599773..dcc22971 100755 --- a/neofetch +++ b/neofetch @@ -136,6 +136,12 @@ cpu_cores="on" # --gpu_shorthand on/off/tiny gpu_shorthand="on" +# Resolution + +# Display refresh rate next to each monitor +# Unsupported on Windows +# --refresh_rate on/off +refresh_rate="off" # Gtk Theme / Icons @@ -1272,13 +1278,29 @@ getsong () { getresolution () { case "$os" in "Linux" | *"BSD") - type -p xdpyinfo >/dev/null 2>&1 && \ + if type -p xrandr >/dev/null 2>&1; then + case "$refresh_rate" in + "on") resolution=$(xrandr --nograb --current | awk 'match($0,/[0-0]{2,3}.[0-9]{2}\*/) {printf $1 " @ " substr($0,RSTART,RLENGTH) "Hz, "}') ;; + "off") resolution=$(xrandr --nograb --current | awk '/*/ {printf $1 ", "}') ;; + esac + resolution=${resolution//\*} + + elif type -p xdpyinfo >/dev/null 2>&1 && \ resolution=$(xdpyinfo 2>/dev/null | awk '/dimensions:/ {printf $2}') + fi ;; "Mac OS X") - resolution=$(system_profiler SPDisplaysDataType |\ - awk '/Resolution:/ {printf $2"x"$4" "}') + 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 ;; "Windows") @@ -1298,6 +1320,8 @@ getresolution () { resolution="Unknown" ;; esac + + resolution=${resolution%,*} } # }}} @@ -2517,6 +2541,8 @@ usage () { cat << EOF --cpu_cores on/off Whether or not to display the number of CPU cores --kernel_shorthand on/off Shorten the output of kernel --uptime_shorthand on/off Shorten the output of uptime (tiny, on, off) + --refresh_rate on/off Whether to display the refresh rate of each monitor + Unsupported on Windows --gpu_shorthand on/off Shorten the output of GPU (tiny, on, off) --gtk_shorthand on/off Shorten output of gtk theme/icons --gtk2 on/off Enable/Disable gtk2 theme/icons output @@ -2635,6 +2661,7 @@ while [ "$1" ]; do --uptime_shorthand) uptime_shorthand="$2" ;; --cpu_shorthand) cpu_shorthand="$2" ;; --gpu_shorthand) gpu_shorthand="$2" ;; + --refresh_rate) refresh_rate="$2" ;; --gtk_shorthand) gtk_shorthand="$2" ;; --gtk2) gtk2="$2" ;; --gtk3) gtk3="$2" ;; diff --git a/neofetch.1 b/neofetch.1 index 7b8c4b86..cc6379f8 100644 --- a/neofetch.1 +++ b/neofetch.1 @@ -50,6 +50,10 @@ Shorten the output of kernel .B \--uptime_shorthand 'on/off' Shorten the output of uptime (tiny, on, off) .TP +.B \--refresh_rate 'on/off' +Whether to display the refresh rate of each monitor +Unsupported on Windows +.TP .B \--gpu_shorthand 'on/off' Shorten the output of GPU (tiny, on, off) .TP