handle err
This commit is contained in:
parent
52a7798bbe
commit
9d271de53e
5 changed files with 35 additions and 2 deletions
|
@ -3,8 +3,19 @@
|
||||||
# 'https://stackoverflow.com/questions/9229333/how-to-get-overall-cpu-usage-e-g-57-on-linux'
|
# 'https://stackoverflow.com/questions/9229333/how-to-get-overall-cpu-usage-e-g-57-on-linux'
|
||||||
# – Yeti Oct 21, 2017 at 9:21
|
# – Yeti Oct 21, 2017 at 9:21
|
||||||
|
|
||||||
cat "$XDG_CACHE_HOME"/cpustat
|
if [ -n "$XDG_CACHE_HOME" ] ; then
|
||||||
|
cache_file="$XDG_CACHE_HOME"/cpustat
|
||||||
|
elif [ -n "$HOME" ] ; then
|
||||||
|
mkdir -p "$HOME/.local/cache"
|
||||||
|
cache_file="$HOME/.local/cache"/cpustat
|
||||||
|
else
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$cache_file" ] ; then
|
||||||
|
cat "$cache_file"
|
||||||
|
fi
|
||||||
|
|
||||||
load=$({ head -n1 /proc/stat;sleep 0.3;head -n1 /proc/stat; } | awk '/^cpu /{u=$2-u;s=$4-s;i=$5-i;w=$6-w}END{print int(0.5+100*(u+s+w)/(u+s+i+w))}')
|
load=$({ head -n1 /proc/stat;sleep 0.3;head -n1 /proc/stat; } | awk '/^cpu /{u=$2-u;s=$4-s;i=$5-i;w=$6-w}END{print int(0.5+100*(u+s+w)/(u+s+i+w))}')
|
||||||
|
|
||||||
echo "$load%" > "$XDG_CACHE_HOME"/cpustat
|
echo "$load%" > "$cache_file"
|
||||||
|
|
|
@ -3,5 +3,10 @@
|
||||||
|
|
||||||
layout="$(setxkbmap -query | awk '/layout/{ print $2 }' | sed 's/latam/la/')"
|
layout="$(setxkbmap -query | awk '/layout/{ print $2 }' | sed 's/latam/la/')"
|
||||||
|
|
||||||
|
if [ "$?" != 0 ] ; then
|
||||||
|
echo "Failed to get layout"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "$layout"
|
echo "$layout"
|
||||||
# notify-send -u low --replace-id=12 " Layout" "$layout"
|
# notify-send -u low --replace-id=12 " Layout" "$layout"
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
|
|
||||||
info=$(amixer get Capture | grep -m 1 '[0-9]*%')
|
info=$(amixer get Capture | grep -m 1 '[0-9]*%')
|
||||||
|
|
||||||
|
if [ "$?" != 0 ] ; then
|
||||||
|
echo "Failed to get Master volume"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "${info##*\[off\]}" ] ; then
|
if [ -z "${info##*\[off\]}" ] ; then
|
||||||
echo " ──────────"
|
echo " ──────────"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -22,11 +22,18 @@ int() { # Type of interface & status
|
||||||
# If down interfaces, exit with icon
|
# If down interfaces, exit with icon
|
||||||
grep -xq 'down' /sys/class/net/w*/operstate 2>/dev/null && echo "" && return 0
|
grep -xq 'down' /sys/class/net/w*/operstate 2>/dev/null && echo "" && return 0
|
||||||
grep -xq 'down' /sys/class/net/e*/operstate 2>/dev/null && echo "" && return 0
|
grep -xq 'down' /sys/class/net/e*/operstate 2>/dev/null && echo "" && return 0
|
||||||
|
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Run 'int'
|
# Run 'int'
|
||||||
icon=$(int)
|
icon=$(int)
|
||||||
|
|
||||||
|
if [ "$?" != 0 ] ; then
|
||||||
|
echo "Failed to get interface type"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Check if a VPN is enabled
|
# Check if a VPN is enabled
|
||||||
vpn="$( \
|
vpn="$( \
|
||||||
sed "s/.*//" /sys/class/net/tun*/operstate 2>/dev/null
|
sed "s/.*//" /sys/class/net/tun*/operstate 2>/dev/null
|
||||||
|
|
|
@ -4,6 +4,11 @@
|
||||||
|
|
||||||
info=$(amixer get Master | grep -m 1 '[0-9]*%')
|
info=$(amixer get Master | grep -m 1 '[0-9]*%')
|
||||||
|
|
||||||
|
if [ "$?" != 0 ] ; then
|
||||||
|
echo "Failed to get Master volume"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "${info##*\[off\]}" ] ; then
|
if [ -z "${info##*\[off\]}" ] ; then
|
||||||
echo " ──────────"
|
echo " ──────────"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in a new issue