mirror of
https://github.com/dustinkirkland/byobu
synced 2025-08-21 22:13:19 -07:00
updated status scripts to get working on Mac OS X
This commit is contained in:
parent
8f2c5ab161
commit
8619c84f55
13 changed files with 87 additions and 45 deletions
|
@ -29,7 +29,7 @@ __cpu_freq() {
|
|||
read hz < /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
|
||||
fpdiv $hz "1000000" 1 # 1Ghz
|
||||
freq="$_RET"
|
||||
else
|
||||
elif [ -r "/proc/cpuinfo" ]; then
|
||||
if egrep -q -s -i -m 1 "^cpu MHz|^clock" /proc/cpuinfo; then
|
||||
freq=$(egrep -i -m 1 "^cpu MHz|^clock" /proc/cpuinfo | awk -F"[:.]" '{ printf "%01.1f", $2 / 1000 }')
|
||||
else
|
||||
|
@ -38,6 +38,9 @@ __cpu_freq() {
|
|||
freq=$(egrep -i -m 1 "^bogomips" /proc/cpuinfo | awk -F"[:.]" '{ print $2 }')
|
||||
freq=$(printf "%s %s" "$freq" "$count" | awk '{printf "%01.1f\n", $1/$2/1000}')
|
||||
fi
|
||||
elif hz=$(sysctl -n hw.cpufrequency 2>/dev/null); then
|
||||
fpdiv $hz "1000000000" 1 # 1Ghz
|
||||
freq="$_RET"
|
||||
fi
|
||||
[ -n "$freq" ] || return
|
||||
color b c W; printf "%s" "$freq"; color -; color c W; printf "%s" "$ICON_GHz"; color --
|
||||
|
|
|
@ -25,14 +25,14 @@ __date_detail() {
|
|||
|
||||
__date() {
|
||||
case "$BYOBU_BACKEND" in
|
||||
tmux)
|
||||
date +"%Y-%m-%d "
|
||||
;;
|
||||
screen)
|
||||
bd=$(date "+%m%d")
|
||||
[ "$bd" = "0320" ] && msg="$(printf "%s" SGFwcHkgQmlydGhkYXkgU2NyZWVuIC0tIGh0dHA6Ly9iaXQubHkvc2NyZWVuLWJkYXkK | base64 -di)" && $BYOBU_BACKEND -X -S "byobu" at "*" echo "[$msg]"
|
||||
color none; printf "\005Y-\005m-\005d"; color --
|
||||
;;
|
||||
tmux|*)
|
||||
date +"%Y-%m-%d "
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
|
|
@ -19,13 +19,15 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
__entropy_detail() {
|
||||
cat /proc/sys/kernel/random/entropy_avail
|
||||
cat /proc/sys/kernel/random/entropy_avail 2>/dev/null
|
||||
}
|
||||
|
||||
__entropy() {
|
||||
if [ -r /proc/sys/kernel/random/entropy_avail ]; then
|
||||
local e=$(cat /proc/sys/kernel/random/entropy_avail)
|
||||
[ -n "$e" ] || return
|
||||
color K Y; printf "e%s" "$e"; color --
|
||||
fi
|
||||
}
|
||||
|
||||
# vi: syntax=sh ts=4 noexpandtab
|
||||
|
|
|
@ -301,7 +301,7 @@ get_network_interface() {
|
|||
[ "$Mask" = "00000000" ] && break
|
||||
done < /proc/net/route
|
||||
_RET="$Iface"
|
||||
elif $BYOBU_TEST route >/dev/null; then
|
||||
elif $BYOBU_TEST route >/dev/null 2>&1; then
|
||||
# Route command on path
|
||||
_RET=$(route get default|grep interface:|awk '{print $2}')
|
||||
elif [ -x "/sbin/route" ]; then
|
||||
|
|
|
@ -21,8 +21,10 @@
|
|||
|
||||
__ip_address_detail() {
|
||||
[ -x /sbin/ifconfig ] && /sbin/ifconfig
|
||||
if [ -x /sbin/ip ]; then
|
||||
/sbin/ip -4 addr list
|
||||
/sbin/ip -6 addr list
|
||||
fi
|
||||
}
|
||||
|
||||
__ip_address() {
|
||||
|
@ -44,7 +46,12 @@ __ip_address() {
|
|||
sleep 0.02
|
||||
else
|
||||
# Background an update
|
||||
if [ -x /sbin/ip ]; then
|
||||
LC_ALL=C /sbin/ip -6 addr list dev "$interface" scope global >"$cache" 2>/dev/null &
|
||||
elif $BYOBU_TEST ifconfig >/dev/null 2>&1; then
|
||||
LC_ALL=c ifconfig "$interface" | grep "inet6 " | awk '{print $2}' | sed "s/%.*//" >"$cache" 2>/dev/null &
|
||||
|
||||
fi
|
||||
fi
|
||||
[ -s "$cache" ] && read ipaddr < "$cache"
|
||||
# Print 'None' if we have no global address
|
||||
|
@ -63,9 +70,13 @@ __ip_address() {
|
|||
sleep 0.02
|
||||
[ -s "$cache" ] && read ipaddr < "$cache"
|
||||
else
|
||||
if [ -x /sbin/ip ]; then
|
||||
ipaddr=$(LC_ALL=C /sbin/ip -4 addr list dev "$interface" scope global 2>/dev/null)
|
||||
ipaddr=${ipaddr#* inet }
|
||||
ipaddr=${ipaddr%%/*}
|
||||
elif $BYOBU_TEST ifconfig >/dev/null 2>&1; then
|
||||
ipaddr=$(ifconfig "$interface" | grep "inet " | awk '{print $2}')
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/sh -e
|
||||
#!/bin/sh
|
||||
#
|
||||
# load_average: grab the current load average
|
||||
#
|
||||
|
@ -24,7 +24,11 @@ __load_average_detail() {
|
|||
}
|
||||
|
||||
__load_average() {
|
||||
if [ -r "/proc/loadavg" ]; then
|
||||
read one five fifteen other < /proc/loadavg
|
||||
else
|
||||
one=$(uptime | sed -e "s/.*://" | awk '{print $1}')
|
||||
fi
|
||||
[ -n "$one" ] || return
|
||||
color Y k; printf "$one"; color --
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ __memory() {
|
|||
__memory() {
|
||||
local free="" total="" buffers="" cached=""
|
||||
local kb_main_used=0 buffers_plus_cached=0 fo_buffers=0 fo_cached=0
|
||||
if [ -r /proc/meminfo ]; then
|
||||
while read tok val unit; do
|
||||
case "$tok" in
|
||||
MemTotal:) total=${val};;
|
||||
|
@ -35,6 +36,18 @@ __memory() {
|
|||
esac
|
||||
[ -n "${free}" -a -n "${total}" -a -n "${buffers}" -a -n "${cached}" ] && break;
|
||||
done < /proc/meminfo
|
||||
elif $BYOBU_TEST vm_stat >/dev/null 2>&1; then
|
||||
# MacOS support
|
||||
# calculation borrowed from http://apple.stackexchange.com/a/48195/18857
|
||||
free_blocks=$(vm_stat | grep free | awk '{ print $3 }' | sed 's/\.//')
|
||||
inactive_blocks=$(vm_stat | grep inactive | awk '{ print $3 }' | sed 's/\.//')
|
||||
speculative_blocks=$(vm_stat | grep speculative | awk '{ print $3 }' | sed 's/\.//')
|
||||
free=$((($free_blocks+speculative_blocks)*4))
|
||||
inactive=$(($inactive_blocks*4))
|
||||
total=$((($free+$inactive)))
|
||||
buffers=0
|
||||
cached=0
|
||||
fi
|
||||
kb_main_used=$(($total-$free))
|
||||
buffers_plus_cached=$(($buffers+$cached))
|
||||
# "free output" buffers and cache (output from 'free')
|
||||
|
|
|
@ -35,7 +35,7 @@ __menu() {
|
|||
else
|
||||
key="F9"
|
||||
fi
|
||||
text=$(gettext "Menu")
|
||||
text=$(gettext "Menu" 2>/dev/null) || text="Menu"
|
||||
color k w; printf "%s:<" "$text"; color -; color b k w; printf "%s" "$key"; color k w; printf ">"
|
||||
}
|
||||
|
||||
|
|
|
@ -20,11 +20,16 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
__processes_detail() {
|
||||
ps -ejH
|
||||
ps -ej
|
||||
}
|
||||
|
||||
__processes() {
|
||||
local count=$(ls -d /proc/[0-9]* 2>/dev/null| wc -l)
|
||||
local count=
|
||||
if [ -r /proc ]; then
|
||||
count=$(ls -d /proc/[0-9]* 2>/dev/null| wc -l)
|
||||
else
|
||||
count=$(ps -ef | wc -l | awk '{print $1}')
|
||||
fi
|
||||
[ -n "$count" ] || return
|
||||
color b y w; printf "%s" "$count"; color -; color y w; printf "&"; color --
|
||||
}
|
||||
|
|
|
@ -25,12 +25,12 @@ __time_detail() {
|
|||
|
||||
__time() {
|
||||
case "$BYOBU_BACKEND" in
|
||||
tmux)
|
||||
date +"%H:%M:%S"
|
||||
;;
|
||||
screen)
|
||||
printf "\0050c:\005s"
|
||||
;;
|
||||
tmux|*)
|
||||
date +"%H:%M:%S"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ __time_utc_detail() {
|
|||
|
||||
__time_utc() {
|
||||
d=$(date -u +%H:%M)
|
||||
color invert; printf "%s UTC" "$d"; color --
|
||||
color invert; printf "%sUTC" "$d"; color --
|
||||
}
|
||||
|
||||
# vi: syntax=sh ts=4 noexpandtab
|
||||
|
|
|
@ -26,7 +26,8 @@ __uptime_detail() {
|
|||
}
|
||||
|
||||
__uptime() {
|
||||
local u idle str
|
||||
local u= idle= str=
|
||||
if [ -r /proc/uptime ]; then
|
||||
read u idle < /proc/uptime
|
||||
u=${u%.*}
|
||||
if [ "$u" -gt 86400 ]; then
|
||||
|
@ -38,6 +39,9 @@ __uptime() {
|
|||
else
|
||||
str="${u}s"
|
||||
fi
|
||||
else
|
||||
str=$(uptime | sed -e "s/.* up *//" -e "s/ days, /d/" -e "s/:/h/" -e "s/,.*/m/")
|
||||
fi
|
||||
[ -n "$str" ] || return
|
||||
color w b; printf "%s" "${str}"; color --
|
||||
}
|
||||
|
|
|
@ -26,13 +26,13 @@ __users_detail() {
|
|||
}
|
||||
|
||||
__users() {
|
||||
local count
|
||||
local count=0
|
||||
if [ "$USERS_DISTINCT" = "1" ]; then
|
||||
count=$(pgrep -fl 'sshd:.*@' | cut -f3 -d\ | cut -f1 -d@ | sort -u | wc -l)
|
||||
else
|
||||
# Note: we'd like to use pgrep -c, however, this isn't available in
|
||||
# busybox and some distro's pgrep (and it doesn't exit non-zero).
|
||||
count=$(pgrep -f "^sshd:.*@" | wc -l) || return
|
||||
count=$(pgrep -f "^sshd:.*@|^/usr/sbin/sshd -i" | wc -l) || return
|
||||
fi
|
||||
if [ $count -gt 0 ]; then
|
||||
color b w r; printf "%d" "$count"; color -; color w r; printf "#"; color --
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue