Upload files to ".local/bin"
This commit is contained in:
parent
bafdbf9041
commit
e8a5ca8103
5 changed files with 97 additions and 0 deletions
25
.local/bin/sb-battery
Normal file
25
.local/bin/sb-battery
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#Prints battery percentage
|
||||||
|
|
||||||
|
_bsd() {
|
||||||
|
PERCENT="$(apm | grep -o '[0-9].*%' | head -n 1)"
|
||||||
|
[ "$PERCENT" = "" ] && printf "None" && exit
|
||||||
|
echo "$PERCENT"
|
||||||
|
}
|
||||||
|
|
||||||
|
_linux() {
|
||||||
|
if ! [ -d /sys/class/power_supply/BAT* ]; then
|
||||||
|
printf "None\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
for battery in /sys/class/power_supply/BAT?*; do
|
||||||
|
[ -n "${capacity+x}" ] && printf " "
|
||||||
|
capacity="$(cat "$battery/capacity" 2>&1)"
|
||||||
|
printf "%s%s%d%%" "$status" "$warn" "$capacity"; unset warn
|
||||||
|
done && printf "\\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
case $(uname) in
|
||||||
|
Linux) _linux ;;
|
||||||
|
*BSD) _bsd ;;
|
||||||
|
esac
|
20
.local/bin/sb-cputemp
Normal file
20
.local/bin/sb-cputemp
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
_linux() {
|
||||||
|
sensors $1 | awk '/^temp1/ {print $2}' | sed 's/+//'
|
||||||
|
}
|
||||||
|
|
||||||
|
_openbsd() {
|
||||||
|
[ "$1" = "-f" ] && printf "$(expr $(sysctl | grep hw.sensors.cpu0.temp0 | sed 's/\.00.*//' | sed 's/.*=//') \* 9 / 5 + 32 2> /dev/null)°F" || sysctl | grep hw.sensors.cpu0.temp0 | sed 's/.*=//' | sed 's/\.00//' | sed 's/ deg/°/'
|
||||||
|
}
|
||||||
|
|
||||||
|
_freebsd() {
|
||||||
|
C_TEMP=$(sysctl hw.acpi.thermal.tz0.temperature | sed 's/^.* //' )
|
||||||
|
[ "$1" = "-f" ] && printf "$(expr $(printf $C_TEMP | sed 's/\..C//') \* 9 / 5 + 32)°F" || printf "$C_TEMP" | sed 's/C/°C/'
|
||||||
|
}
|
||||||
|
|
||||||
|
case $(uname) in
|
||||||
|
Linux) _linux "$@" ;;
|
||||||
|
OpenBSD) _openbsd "$@" ;;
|
||||||
|
FreeBSD) _freebsd "$@" ;;
|
||||||
|
esac
|
30
.local/bin/sb-cpuusage
Normal file
30
.local/bin/sb-cpuusage
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#Display CPU usage percentage
|
||||||
|
|
||||||
|
_openbsd() {
|
||||||
|
CPUS=$(sysctl | grep 'hw.ncpuonline' | sed 's/^.*=//')
|
||||||
|
TOTALUSAGE=$(ps aux | awk '{print $3}' | sed '1d' | sort | paste -s -d+ - | bc)
|
||||||
|
USAGE=$(printf "$TOTALUSAGE / $CPUS\n" | bc -l)
|
||||||
|
printf "$USAGE" | grep "^\.[0-9]" > /dev/null && printf "0$(printf $USAGE | cut -c1-3)%%" || printf "$(printf "$USAGE" | cut -c1-4)%%\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
_freebsd() {
|
||||||
|
CPUS="$(sysctl hw.ncpu | sed 's/^.*: //')"
|
||||||
|
FREE=$(ps -o %cpu -p $(pgrep -S idle) | tail -n 1)
|
||||||
|
TPP=$(expr $CPUS \* 100)
|
||||||
|
TOTALUSAGE=$(printf "$TPP - $FREE" | bc -l)
|
||||||
|
USAGE=$(printf "$TOTALUSAGE / $CPUS" | bc -l | cut -c -4)
|
||||||
|
printf "$USAGE" | egrep "\.[0-9]{3}" > /dev/null && printf "0$(printf $USAGE | cut -c -3)%%\n" || printf -- "$USAGE%%\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
_linux() {
|
||||||
|
TOTALUSAGE="$(ps axch -o cmd,%cpu --sort=-%cpu | sed 's/ //' | grep -E -o " [0-9].*" | sed 's/ //' | paste -s -d+ - | bc)"
|
||||||
|
USAGE="$(printf "$(printf "$TOTALUSAGE / $(nproc)\n" | bc -l | cut -c1-4)%%\n")"
|
||||||
|
printf -- "$USAGE%" | grep "^\.[0-9]" > /dev/null && printf -- "0$(printf -- $USAGE% | cut -c1-3)%%" || printf -- "$(printf -- "$USAGE%" | cut -c1-4)%%\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
case $(uname) in
|
||||||
|
Linux) _linux ;;
|
||||||
|
OpenBSD) _openbsd ;;
|
||||||
|
FreeBSD) _freebsd ;;
|
||||||
|
esac
|
8
.local/bin/sb-network
Normal file
8
.local/bin/sb-network
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# Show local IP and transfer if connected to the internet. Opens $NETWORKMANAGER on click
|
||||||
|
NETWORKMANAGER=connman-gtk
|
||||||
|
ifconfig | grep ".*inet.*netmask" | tail -n 1 | sed 's/inet //g' | sed 's/ netmask.*//g' | sed 's/ //g' | sed 's/ //g'
|
||||||
|
|
||||||
|
case $BLOCK_BUTTON in
|
||||||
|
1) $NETWORKMANAGER ;;
|
||||||
|
esac
|
14
.local/bin/sb-volume
Normal file
14
.local/bin/sb-volume
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
_bsd() {
|
||||||
|
sndioctl -n output.level | sed 's/0\.//' | sed 's/.$/%/' | sed 's/\.//'
|
||||||
|
}
|
||||||
|
|
||||||
|
_linux() {
|
||||||
|
printf "$(pamixer --get-volume)%%\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
case $(uname) in
|
||||||
|
Linux) _linux ;;
|
||||||
|
*BSD) _bsd ;;
|
||||||
|
esac
|
Loading…
Add table
Reference in a new issue