add vertical box bar as default visual representaion for percentages
This commit is contained in:
parent
33dd3a4168
commit
8a2b50249b
@ -9,9 +9,9 @@ This is a simple collection of i3blocks-modules accompagnied by a config file wi
|
||||
- module *datetime*: A left click will toggle long and short displays. The short version is displayed in the format `HH:MM`. The long version also shows the day of the week, weeknumber, date and seconds.
|
||||
- module *audio*: `instance=mic` will show the microphone level instead. With a left mouse click the device is muted/unmuted.
|
||||
- module *ram*: by default free ram and swap are shown in the format `a+b G` where `a` is ram and `b` is swap. If you want to show ram and swap seperatly, use `instance=ram` or `instance=swap`. If you left click on the block, `top` will be openend.
|
||||
- *cpu*: by default total idle cpu time of all cores together is displayed. If you left click on the block, `top` will be openend.
|
||||
- module *battery*: By default the total energy left of all batteries is shown. Use `instance=x` to show the status of `BATx` in case you have more than one battery in `/sys/class/powersupply`.
|
||||
- module *backlight*: By default the brightness level is shown in the default font color (depending on your i3 config). Use `instance="color"` to print the brightness level colored which is nice when using a device in battery mode.
|
||||
- *cpu*: by default total idle cpu time of all cores together is displayed using a vertical block symbol. Use `instance=long` to show the percentage instead. If you left click on the block, `top` will be openend.
|
||||
- module *battery*: By default the total energy left of all batteries is shown using a vertical block symbol. Use `instance=x` to show the status of `BATx` in case you have more than one battery in `/sys/class/powersupply`. On Left click, the long percentage is shown.
|
||||
- module *backlight*: By default the brightness level is shown in the default font color (depending on your i3 config). Use `instance=long` to show the brightness percentage. Use `instance="color"` to print the brightness level colored which is nice when using a device in battery mode. On left click the brightness in percent will be shown.
|
||||
|
||||
# Requirements
|
||||
Install [i3 window manager](https://i3wm.org) alongside with [i3blocks](https://github.com/vivien/i3blocks) and `git`. The following shows the requirements for each module:
|
||||
|
5
config
5
config
@ -9,6 +9,7 @@ interval=5
|
||||
label=☼
|
||||
# label=☀,☼,✱,✲,✳,✴,✵,✺
|
||||
instance=color
|
||||
# instance=color,long
|
||||
|
||||
# [iface]
|
||||
# label=iface
|
||||
@ -21,12 +22,14 @@ label=⛁
|
||||
# with instance=ram or instance=swap
|
||||
[ram]
|
||||
label=⚟
|
||||
# instance=long
|
||||
# instance=ram
|
||||
# [ram]
|
||||
# instance=swap
|
||||
|
||||
[cpu]
|
||||
label=☷
|
||||
# instance=long
|
||||
|
||||
[ip]
|
||||
# label=ip
|
||||
@ -54,7 +57,7 @@ label=⎋
|
||||
[audio]
|
||||
label=◍
|
||||
# label=♩,♪,♫,♬
|
||||
separator_block_width=0
|
||||
# separator_block_width=0
|
||||
[audio]
|
||||
label=◎
|
||||
# label=⋓ℹ⋒ⅈ
|
||||
|
@ -1,30 +1,55 @@
|
||||
#!/bin/bash
|
||||
|
||||
[[ $BLOCK_INSTANCE == "mic" ]] && DEV="Capture" || DEV="Master"
|
||||
[[ "$BLOCK_INSTANCE" == "mic" ]] && DEV="Capture" || DEV="Master"
|
||||
|
||||
[[ $BLOCK_BUTTON == 1 ]] && amixer set $DEV toggle &> /dev/null
|
||||
[[ "$BLOCK_BUTTON" == 1 ]] && LONG=true
|
||||
|
||||
amixer get $DEV | gawk '
|
||||
|
||||
[[ "$BLOCK_BUTTON" == 2 ]] && amixer set $DEV toggle &> /dev/null
|
||||
|
||||
amixer get $DEV | gawk -v LONG="$LONG" '
|
||||
match($0, /\[([0-9]+)\%\] \[(on|off)\]/, matches) {
|
||||
audio=matches[1]
|
||||
load=matches[1]
|
||||
}
|
||||
END {
|
||||
if (matches[2] == "off") {
|
||||
print(" off \n")
|
||||
print("off\n")
|
||||
exit 33
|
||||
print("X\n")
|
||||
print("#CCCCCC")
|
||||
}
|
||||
printf("%d% \n", audio)
|
||||
printf("%d%\n", audio)
|
||||
if (audio < 75) {
|
||||
if (LONG == "true") {
|
||||
printf("%d% \n", load)
|
||||
printf("%d%\n", load)
|
||||
} else {
|
||||
if (load < 100 / 9) {
|
||||
printf("▁\n▁\n")
|
||||
} else if (load < 100 / 9 * 2 ) {
|
||||
printf("▁\n▁\n")
|
||||
} else if (load < 100 / 9 * 3 ) {
|
||||
printf("▂\n▂\n")
|
||||
} else if (load < 100 / 9 * 4 ) {
|
||||
printf("▃\n▃\n")
|
||||
} else if (load < 100 / 9 * 5 ) {
|
||||
printf("▄\n▄\n")
|
||||
} else if (load < 100 / 9 * 6 ) {
|
||||
printf("▅\n▅\n")
|
||||
} else if (load < 100 / 9 * 7 ) {
|
||||
printf("▆\n▆\n")
|
||||
} else if (load < 100 / 9 * 8 ) {
|
||||
printf("▇\n▇\n")
|
||||
} else {
|
||||
printf("█\n█\n")
|
||||
}
|
||||
}
|
||||
if (load < 75) {
|
||||
print("#04B431\n")
|
||||
} else if (audio < 80) {
|
||||
} else if (load < 80) {
|
||||
print("#A8FF00\n")
|
||||
} else if (audio < 85) {
|
||||
} else if (load < 85) {
|
||||
print("#FFF600\n")
|
||||
} else if (audio < 90) {
|
||||
} else if (load < 90) {
|
||||
print("#FFAE00\n")
|
||||
} else if (audio < 95) {
|
||||
} else if (load < 95) {
|
||||
print("#FF0000\n")
|
||||
} else {
|
||||
exit 33
|
||||
|
@ -2,7 +2,8 @@
|
||||
|
||||
DIR="/sys/class/backlight"
|
||||
|
||||
[[ "${BLOCK_INSTANCE}" == "color" ]] && MODE="color" || MODE="bw"
|
||||
[[ "$BLOCK_INSTANCE" =~ "color" ]] && MODE="color" || MODE="bw"
|
||||
[[ "$BLOCK_INSTANCE" =~ "long" || "$BLOCK_BUTTON" == 1 ]] && LONG=true
|
||||
|
||||
if [[ -d "$DIR/acpi_video0" ]]; then
|
||||
DIR="$DIR/acpi_video0"
|
||||
@ -14,26 +15,45 @@ else
|
||||
exit 33
|
||||
fi
|
||||
|
||||
cat "$DIR/brightness" "$DIR/max_brightness" | gawk -v MODE="$MODE" '
|
||||
NR==1 { current_brightness = $1 }
|
||||
NR==2 { max_brightness = $1 }
|
||||
cat "$DIR/brightness" "$DIR/max_brightness" | gawk -v MODE="$MODE" -v LONG="$LONG" '
|
||||
NR==1 { cbr = $1 }
|
||||
NR==2 { mbr = $1 }
|
||||
END {
|
||||
relative_brightness = ( current_brightness / max_brightness ) * 100
|
||||
printf("%d%\n", relative_brightness)
|
||||
printf("%d\n", relative_brightness)
|
||||
if (MODE == "color") {
|
||||
if (relative_brightness < 50) {
|
||||
print("#04B431\n")
|
||||
} else if (relative_brightness < 60) {
|
||||
print("#A8FF00\n")
|
||||
} else if (relative_brightness < 70) {
|
||||
print("#FFF600\n")
|
||||
} else if (relative_brightness < 80) {
|
||||
print("#FFAE00\n")
|
||||
} else if (relative_brightness < 90) {
|
||||
print("#FF0000\n")
|
||||
load = ( cbr / mbr ) * 100
|
||||
if (LONG == "true") {
|
||||
printf("%d%\n", load)
|
||||
} else {
|
||||
if (load < 100 / 9) {
|
||||
printf("▁\n▁\n")
|
||||
} else if (load < 100 / 9 * 2 ) {
|
||||
printf("▁\n▁\n")
|
||||
} else if (load < 100 / 9 * 3 ) {
|
||||
printf("▂\n▂\n")
|
||||
} else if (load < 100 / 9 * 4 ) {
|
||||
printf("▃\n▃\n")
|
||||
} else if (load < 100 / 9 * 5 ) {
|
||||
printf("▄\n▄\n")
|
||||
} else if (load < 100 / 9 * 6 ) {
|
||||
printf("▅\n▅\n")
|
||||
} else if (load < 100 / 9 * 7 ) {
|
||||
printf("▆\n▆\n")
|
||||
} else if (load < 100 / 9 * 8 ) {
|
||||
printf("▇\n▇\n")
|
||||
} else {
|
||||
exit 33
|
||||
printf("█\n█\n")
|
||||
}
|
||||
}
|
||||
if (MODE == "color") {
|
||||
if (load < 60) {
|
||||
print("#04B431\n")
|
||||
} else if (load < 50) {
|
||||
print("#A8FF00\n")
|
||||
} else if (load < 80) {
|
||||
print("#FFF600\n")
|
||||
} else if (load < 90) {
|
||||
print("#FFAE00\n")
|
||||
} else {
|
||||
print("#FF0000\n")
|
||||
}
|
||||
} else {
|
||||
printf("\n")
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
DIR="/sys/class/power_supply"
|
||||
|
||||
[[ "$BLOCK_BUTTON" == "1" ]] && LONG=true || LONG=false
|
||||
[[ "$BLOCK_BUTTON" == "1" ]] && LONG=true
|
||||
|
||||
if [[ "$BLOCK_INSTANCE" == "" ]]; then
|
||||
for BAT in $DIR/BAT*/; do
|
||||
@ -41,8 +41,9 @@ cat $BATS | gawk -F '=' -v LONG="$LONG" '
|
||||
}
|
||||
END {
|
||||
charge = enow / efull * 100
|
||||
|
||||
if (LONG == "false") {
|
||||
if (LONG == "true") {
|
||||
printf("%s%d%\n", status, charge)
|
||||
} else {
|
||||
if (charge < 100 / 9) {
|
||||
printf("\n")
|
||||
} else if (charge < 100 / 9 * 2 ) {
|
||||
@ -62,8 +63,6 @@ cat $BATS | gawk -F '=' -v LONG="$LONG" '
|
||||
} else {
|
||||
printf("%s█\n", status)
|
||||
}
|
||||
} else {
|
||||
printf("%s%d%\n", status, charge)
|
||||
}
|
||||
printf("%s%d\n", status, charge)
|
||||
if (charge > 25) {
|
||||
|
42
modules/cpu
42
modules/cpu
@ -1,22 +1,46 @@
|
||||
#!/bin/bash
|
||||
|
||||
[[ "$BLOCK_INSTANCE" =~ "long" ]] && LONG=true
|
||||
|
||||
[[ "$BLOCK_BUTTON" == 1 ]] && i3-sensible-terminal -e htop
|
||||
top -bn1 | gawk '
|
||||
|
||||
top -bn1 | gawk -v LONG="$LONG" '
|
||||
/^\%CPU/ {
|
||||
cpu = 100 - $8
|
||||
load = 100 - $8
|
||||
}
|
||||
END {
|
||||
printf("%d%\n", cpu)
|
||||
printf("%d\n", cpu)
|
||||
if (cpu < 50) {
|
||||
if (LONG == "true") {
|
||||
printf("%d%\n%d%\n", load, load)
|
||||
} else {
|
||||
if (load < 100 / 9) {
|
||||
printf("▁\n▁\n")
|
||||
} else if (load < 100 / 9 * 2 ) {
|
||||
printf("▁\n▁\n")
|
||||
} else if (load < 100 / 9 * 3 ) {
|
||||
printf("▂\n▂\n")
|
||||
} else if (load < 100 / 9 * 4 ) {
|
||||
printf("▃\n▃\n")
|
||||
} else if (load < 100 / 9 * 5 ) {
|
||||
printf("▄\n▄\n")
|
||||
} else if (load < 100 / 9 * 6 ) {
|
||||
printf("▅\n▅\n")
|
||||
} else if (load < 100 / 9 * 7 ) {
|
||||
printf("▆\n▆\n")
|
||||
} else if (load < 100 / 9 * 8 ) {
|
||||
printf("▇\n▇\n")
|
||||
} else {
|
||||
printf("█\n█\n")
|
||||
}
|
||||
}
|
||||
if (load < 50) {
|
||||
print("#04B431\n")
|
||||
} else if (cpu < 60) {
|
||||
} else if (load < 60) {
|
||||
print("#A8FF00\n")
|
||||
} else if (cpu < 70) {
|
||||
} else if (load < 70) {
|
||||
print("#FFF600\n")
|
||||
} else if (cpu < 80) {
|
||||
} else if (load < 80) {
|
||||
print("#FFAE00\n")
|
||||
} else if (cpu < 90) {
|
||||
} else if (load < 90) {
|
||||
print("#FF0000\n")
|
||||
} else {
|
||||
exit 33
|
||||
|
87
modules/ram
87
modules/ram
@ -2,17 +2,25 @@
|
||||
|
||||
[[ "$BLOCK_BUTTON" == 1 ]] && i3-sensible-terminal -e htop
|
||||
|
||||
case "${BLOCK_INSTANCE}" in
|
||||
swap) TYPE="swap";;
|
||||
ram) TYPE="ram";;
|
||||
*) TYPE="";;
|
||||
esac
|
||||
[[ "$BLOCK_INSTANCE" =~ "long" ]] && LONG=true
|
||||
|
||||
gawk -v TYPE="$TYPE" '
|
||||
if [[ "$BLOCK_INSTANCE" =~ "ram" ]]; then
|
||||
TYPE='swap'
|
||||
elif [[ "$BLOCK_INSTANCE" =~ "swap" ]]; then
|
||||
TYPE='swap'
|
||||
fi
|
||||
|
||||
gawk -v TYPE="$TYPE" -v LONG="$LONG" '
|
||||
/^MemTotal/ {
|
||||
rtg = $2 / 1024^2
|
||||
}
|
||||
/^MemAvailable/ {
|
||||
rfg = $2 / 1024^2
|
||||
rfm = $2 / 1024
|
||||
}
|
||||
/^SwapTotal/ {
|
||||
stg = $2 / 1024^2
|
||||
}
|
||||
/^SwapFree/ {
|
||||
sfg = $2 / 1024^2
|
||||
sfm = $2 / 1024
|
||||
@ -21,31 +29,56 @@ gawk -v TYPE="$TYPE" '
|
||||
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)
|
||||
}
|
||||
mtg = rtg + stg
|
||||
} 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)
|
||||
}
|
||||
mfg = rfg
|
||||
mfm = rfm
|
||||
mtg = rtg
|
||||
} else if (TYPE == "swap") {
|
||||
if (sfg > 2) {
|
||||
printf("%d G\n", sfg)
|
||||
printf("%dG\n", sfg)
|
||||
mfg = sfg
|
||||
mfg = sfg
|
||||
mfm = sfm
|
||||
rtg = stg
|
||||
}
|
||||
if (LONG == "true") {
|
||||
if (TYPE == "") {
|
||||
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 {
|
||||
printf("%d M\n", sfm)
|
||||
printf("%dM\n", sfm)
|
||||
if (mfg > 2) {
|
||||
printf("%d G\n", mfg)
|
||||
printf("%dG\n", mfg)
|
||||
mfg = rfg
|
||||
} else {
|
||||
printf("%d M\n", mfm)
|
||||
printf("%dM\n", mfm)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
load = mfg / mtg
|
||||
if (load < 100 / 9) {
|
||||
printf("▁\n▁\n")
|
||||
} else if (load < 100 / 9 * 2 ) {
|
||||
printf("▁\n▁\n")
|
||||
} else if (load < 100 / 9 * 3 ) {
|
||||
printf("▂\n▂\n")
|
||||
} else if (load < 100 / 9 * 4 ) {
|
||||
printf("▃\n▃\n")
|
||||
} else if (load < 100 / 9 * 5 ) {
|
||||
printf("▄\n▄\n")
|
||||
} else if (load < 100 / 9 * 6 ) {
|
||||
printf("▅\n▅\n")
|
||||
} else if (load < 100 / 9 * 7 ) {
|
||||
printf("▆\n▆\n")
|
||||
} else if (load < 100 / 9 * 8 ) {
|
||||
printf("▇\n▇\n")
|
||||
} else {
|
||||
printf("█\n█\n")
|
||||
}
|
||||
}
|
||||
if (mfg > 5) {
|
||||
print("#04B431\n")
|
||||
|
@ -1,4 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
df | gawk '
|
||||
/\/$/ {
|
||||
free_storage=$4/1024^2
|
||||
|
Reference in New Issue
Block a user