mittags sprint

This commit is contained in:
koksnuss
2018-05-14 14:08:47 +02:00
parent 7b368aba19
commit 2f1e471eb1
9 changed files with 156 additions and 89 deletions

View File

@ -1,21 +1,21 @@
#!/bin/bash
case ${BLOCK_INSTANCE} in
mic) DEV="Capture";;
*) DEV="Master";;
esac
[[ ${BLOCK_BUTTON} == 1 ]] && amixer set $DEV toggle &> /dev/null
[[ $BLOCK_INSTANCE == "mic" ]] && DEV="Capture" || DEV="Master"
[[ $BLOCK_BUTTON == 1 ]] && amixer set $DEV toggle &> /dev/null
amixer get $DEV | gawk '
match($0, /\[([0-9]+)\%\] \[(on|off)\]/, matches) {
audio=matches[1]
}
END {
if (matches[2]=="off") {
print("off \n")
print("off \n")
if (matches[2] == "off") {
print(" off \n")
print("off\n")
exit 33
}
printf("%d% \n", audio)
printf("%d\n", audio)
printf("%d%\n", audio)
if (audio < 75) {
print("#04B431\n")
} else if (audio < 80) {

View File

@ -1,19 +1,23 @@
#!/bin/bash
DIR="/sys/class/backlight/"
if [[ -d "${DIR}acpi_video0" ]]; then
DIR="${DIR}acpi_video0"
elif [[ -d "${DIR}intel_backlight" ]]; then
DIR="${DIR}intel_backlight"
DIR="/sys/class/backlight"
if [[ -d "$DIR/acpi_video0" ]]; then
DIR="$DIR/acpi_video0"
elif [[ -d "$DIR/intel_backlight" ]]; then
DIR="$DIR/intel_backlight"
else
echo "not found "
echo " no backlight "
echo "n/a"
exit 33
fi
cat "${DIR}/brightness" "${DIR}/max_brightness" | gawk '
NR==1 { cbr=$1 }
NR==2 { mbr=$1 }
cat "$DIR/brightness" "$DIR/max_brightness" | gawk '
NR==1 { cbr = $1 }
NR==2 { mbr = $1 }
END {
printf("%d%\n", cbr/mbr*100)
printf("%d\n", cbr/mbr*100)
printf("%d%\n", cbr / mbr * 100)
printf("%d\n", cbr / mbr * 100)
print("\n")
}
'

View File

@ -1,31 +1,47 @@
#!/bin/bash
[[ ${BLOCK_INSTANCE} == '' ]] && BAT=0 || BAT=${BLOCK_INSTANCE}
DIR="/sys/class/power_supply/BAT"
if [ ! -f "${DIR}${BAT}/uevent" ]; then
echo " not found "
DIR="/sys/class/power_supply"
if [[ "$BLOCK_INSTANCE" == "" ]]; then
for BAT in $DIR/BAT*/; do
[[ -f "${BAT}uevent" ]] && BATS+="$BAT/uevent "
done
else
[[ -f "$DIR/BAT$BLOCK_INSTANCE/uevent" ]] && BATS="$DIR/BAT$BLOCK_INSTANCE/uevent"
fi
if [[ "${BATS}" == "" ]]; then
echo " no battery "
echo "n/a"
exit 33
fi
cat /sys/class/power_supply/BAT${BAT}/uevent | gawk -F '=' '
cat $BATS | gawk -F '=' '
BEGIN {
efull = 0
enow = 0
status = ""
}
/POWER_SUPPLY_STATUS=/ {
status=$2
if (status == "") {
status = $2
if (status == "Discharging") {
status = "↓"
} else if (status == "Charging") {
status = "⚡"
} else {
status = ""
}
}
}
/POWER_SUPPLY_ENERGY_FULL=/ {
efull=$2
efull += $2
}
/POWER_SUPPLY_ENERGY_NOW=/ {
enow=$2
enow += $2
}
END {
charge=enow/efull*100
if (status == "Discharging") {
status="↓"
} else if (status == "Charging") {
status="↑"
} else {
status=""
}
charge = enow / efull * 100
printf("%s%d%\n", status, charge)
printf("%s%d\n", status, charge)
if (charge > 25) {

View File

@ -1,12 +1,13 @@
#!/bin/bash
[[ "$BLOCK_BUTTON" == 1 ]] && i3-sensible-terminal -e htop
top -bn1 | gawk '
/^\%CPU/ {
cpu=100-$8
cpu = 100 - $8
}
END {
printf("%d%", cpu)
print("\n")
printf("%d%\n", cpu)
printf("%d\n", cpu)
if (cpu < 50) {
print("#04B431\n")
} else if (cpu < 60) {

View File

@ -1,9 +1,13 @@
#!/bin/bash
SHORT=$(date '+%_H:%M')
FULL=$(date '+%A, %_d.%_m. %_H:%M:%S')
case ${BLOCK_INSTANCE} in
short) LONG=false ;;
*) LONG=true ;;
esac
[[ ${BLOCK_BUTTON} == 1 ]] && LONG=true
[[ "$LONG" == "true" ]] && echo $FULL || echo $SHORT
SHORT=$(date '+%_H:%M')
a=$I3_LONG_DATETIME/1
[[ "$BLOCK_INSTANCE" == "short" ]] && export I3_LONG_DATETIME=false
a+=$I3_LONG_DATETIME/2
[[ "$BLOCK_BUTTON" == "1" && $I3_LONG_DATETIME == "true" ]] && echo a; export I3_LONG_DATETIME=false;
a+=$I3_LONG_DATETIME/3
[[ "$BLOCK_BUTTON" == "1" && $I3_LONG_DATETIME == "false" ]] && echo b; export I3_LONG_DATETIME=true;
a+=$I3_LONG_DATETIME/4
echo $a
[[ "$I3_LONG_DATETIME" == "true" ]] && echo $FULL || echo $SHORT

View File

@ -1,17 +1,52 @@
#!/bin/bash
[[ ${BLOCK_INSTANCE} == 'swap' ]] && TYPE="SwapFree" || TYPE="MemAvailable"
[[ "$BLOCK_BUTTON" == 1 ]] && i3-sensible-terminal -e htop
case ${BLOCK_INSTANCE} in
swap) TYPE="swap";;
ram) TYPE="ram";;
*) TYPE="";;
esac
gawk -v type="$TYPE" '
$0 ~ type {
mfg=$2/1024^2
mfm=$2/1024
}
/^MemAvailable/ {
rfg = $2 / 1024^2
rfm = $2 / 1024
}
/^SwapFree/ {
sfg = $2 / 1024^2
sfm = $2 / 1024
}
END {
if (mfg > 2) {
printf("%.1f GB", mfg)
} else {
printf("%.0f MB", mfm)
if (type == "") {
mfg = rfg + sfg
mfm = rfm + sfm
if (mfg > 2) {
printf("%d+%d G\n", rfg, sfg)
printf("%d+%dG\n", rfg, sfg)
} else {
printf("%d+%d M\n", rfm, sfm)
printf("%d+%dM\n", rfm, sfm)
}
} else if (type == "ram") {
if (rfg > 2) {
printf("%d G\n", rfg)
printf("%dG\n", rfg)
mfg = rfg
} else {
printf("%d M\n", rfm)
printf("%dM\n", rfm)
}
} else if (type == "swap") {
if (sfg > 2) {
printf("%d G\n", sfg)
printf("%dG\n", sfg)
mfg = sfg
} else {
printf("%d M\n", sfm)
printf("%dM\n", sfm)
}
}
print("\n")
if (mfg > 5) {
print("#04B431\n")
} else if (mfg > 4) {

View File

@ -5,12 +5,17 @@ df | gawk '
sfm=$4/1024
}
END {
if (sfg > 5) {
printf("%.1f GB", sfg)
if (sfg < 1) {
printf(" full \n")
printf("full\n")
exit 33
} else if (sfg > 5) {
printf("%.1f G \n", sfg)
printf("%dG\n", sfg)
} else {
printf("%.0f MB", sfm)
printf("%.0f M \n", sfm)
printf("%dG\n", sfm)
}
print("\n")
if (sfg > 20) {
print("#04B431\n")
} else if (sfg > 15) {
@ -21,8 +26,6 @@ df | gawk '
print("#FFAE00\n")
} else if (sfg > 1) {
print("#FF0000\n")
} else {
exit 33
}
}
'