Merge pull request #160 from iandrewt/refresh_rate

display refresh rate after each monitor (optional)
This commit is contained in:
Dylan Araps 2016-03-26 11:38:07 +11:00
commit d8fa3824e4
4 changed files with 43 additions and 3 deletions

View file

@ -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

View file

@ -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

View file

@ -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" ;;

View file

@ -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