move modules to ./modules

This commit is contained in:
koksnuss
2018-05-14 07:49:04 +02:00
parent a43aa795eb
commit 2077f89897
12 changed files with 9 additions and 2 deletions

27
modules/audio Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
amixer get Master | gawk '
match($0, /\[([0-9]+)\%\] \[(on|off)\]/, matches) {
audio=matches[1]
}
END {
if (matches[2]=="off") {
printf("mute\n")
printf("\n")
exit 33
}
printf("%d%", audio)
print("\n")
if (audio < 75) {
print("#04B431\n")
} else if (audio < 80) {
print("#A8FF00\n")
} else if (audio < 85) {
print("#FFF600\n")
} else if (audio < 90) {
print("#FFAE00\n")
} else if (audio < 95) {
print("#FF0000\n")
} else {
exit 33
}
}'

12
modules/backlight Executable file
View File

@ -0,0 +1,12 @@
#!/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"
fi
cat "${DIR}/brightness" "${DIR}/max_brightness" | gawk '
NR==1 { cbr=$1 }
NR==2 { mbr=$1 }
END { printf("%d%", cbr/mbr*100) }
'

39
modules/battery Executable file
View File

@ -0,0 +1,39 @@
#!/bin/bash
[[ ${BLOCK_INSTANCE} == '' ]] && BATTERY=0 || BATTERY=${BLOCK_INSTANCE}
cat /sys/class/power_supply/BAT${BATTERY}/uevent | gawk -F '=' '
/POWER_SUPPLY_STATUS=/ {
status=$2
}
/POWER_SUPPLY_ENERGY_FULL=/ {
efull=$2
}
/POWER_SUPPLY_ENERGY_NOW=/ {
enow=$2
}
END {
charge=enow/efull*100
if (status == "Discharging") {
status="↓"
} else if (status == "Charging") {
status="↑"
} else {
status=""
}
printf("%s%d%", status, charge)
print("\n")
if (charge > 25) {
print("#04B431\n")
} else if (charge > 20) {
print("#A8FF00\n")
} else if (charge > 15) {
print("#FFF600\n")
} else if (charge > 10) {
print("#FFAE00\n")
} else if (charge > 5) {
print("#FF0000\n")
} else {
exit 33
}
}
'

24
modules/cpu Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
top -bn1 | gawk '
/^\%CPU/ {
cpu=100-$8
}
END {
printf("%d%", cpu)
print("\n")
if (cpu < 50) {
print("#04B431\n")
} else if (cpu < 60) {
print("#A8FF00\n")
} else if (cpu < 70) {
print("#FFF600\n")
} else if (cpu < 80) {
print("#FFAE00\n")
} else if (cpu < 90) {
print("#FF0000\n")
} else {
exit 33
}
}
'

5
modules/datetime Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
full=$(date '+%A, %_d.%_m. %_H:%M:%S')
short=$(date '+%_H:%M')
echo $full
echo $short

5
modules/ip Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
ip=$(curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//')
echo $ip
echo ""
echo ""

29
modules/mic Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
amixer get Capture | gawk '
match($0, /\[([0-9]+)\%\] \[(on|off)\]/, matches) {
mic=matches[1]
}
END {
if (matches[2]=="off") {
printf("mute\n")
printf("\n")
exit 33
}
printf("%d%", mic)
print("\n")
if (mic < 75) {
print("#04B431\n")
} else if (mic < 80) {
print("#A8FF00\n")
} else if (mic < 85) {
print("#FFF600\n")
} else if (mic < 90) {
print("#FFAE00\n")
} else if (mic < 95) {
print("#FF0000\n")
} else {
exit 33
}
}
'

29
modules/ram Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
[[ ${BLOCK_INSTANCE} == 'swap' ]] && TYPE="SwapFree" || TYPE="MemAvailable"
gawk -v type="$TYPE" '
$0 ~ type {
mfg=$2/1024^2
mfm=$2/1024
}
END {
if (mfg > 2) {
printf("%.1f GB", mfg)
} else {
printf("%.0f MB", mfm)
}
print("\n")
if (mfg > 5) {
print("#04B431\n")
} else if (mfg > 4) {
print("#A8FF00\n")
} else if (mfg > 3) {
print("#FFF600\n")
} else if (mfg > 2) {
print("#FFAE00\n")
} else if (mfg > 1) {
print("#FF0000\n")
} else {
exit 33
}
}
' /proc/meminfo

28
modules/storage Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
df | gawk '
/\/$/ {
sfg=$4/1024^2
sfm=$4/1024
}
END {
if (sfg > 5) {
printf("%.1f GB", sfg)
} else {
printf("%.0f MB", sfm)
}
print("\n")
if (sfg > 20) {
print("#04B431\n")
} else if (sfg > 15) {
print("#A8FF00\n")
} else if (sfg > 10) {
print("#FFF600\n")
} else if (sfg > 5) {
print("#FFAE00\n")
} else if (sfg > 1) {
print("#FF0000\n")
} else {
exit 33
}
}
'