Better status bar
This commit is contained in:
21
batterystatus.sh
Executable file
21
batterystatus.sh
Executable file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
# Get battery status
|
||||||
|
STATUS=$(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E "state|to full|percentage" | awk -F': +' '
|
||||||
|
/state:/{s=$2}
|
||||||
|
/time to full:/{split($2,a,",");h=int(a[1])}
|
||||||
|
/percentage:/{gsub(",",".",$2);p=$2}
|
||||||
|
END{if(s=="charging") printf("%dh - %.2f%%\n",h,p)}
|
||||||
|
')
|
||||||
|
|
||||||
|
# Get current date and time
|
||||||
|
DATE=$(date +'%Y-%m-%d %X')
|
||||||
|
|
||||||
|
# Get volume of the default sink
|
||||||
|
VOLUME=$(pactl get-sink-volume @DEFAULT_SINK@ | awk '{print $5}')
|
||||||
|
|
||||||
|
# Combine the output
|
||||||
|
echo "$STATUS | Volume: $VOLUME | $DATE"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
4
config
4
config
@@ -227,7 +227,9 @@ bar {
|
|||||||
|
|
||||||
# When the status_command prints a new line to stdout, swaybar updates.
|
# When the status_command prints a new line to stdout, swaybar updates.
|
||||||
# The default just shows the current date and time.
|
# The default just shows the current date and time.
|
||||||
status_command while echo "$(cat /sys/class/power_supply/BAT0/capacity)% \| $(date +'%Y-%m-%d %X') ; do sleep 1; done
|
#status_command while echo $(upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E "state|to full|percentage" | awk -F': +' '/state:/{s=$2}/time to full:/{split($2,a,",");h=int(a[1])}/percentage:/{gsub(",",".",$2);p=$2} END{if(s=="charging") printf("%dh - %.2f%%\n",h,p)}') \| $(date +'%Y-%m-%d %X') ; do sleep 1; done
|
||||||
|
status_command /home/user/.config/sway/batterystatus.sh
|
||||||
|
|
||||||
colors {
|
colors {
|
||||||
background $base
|
background $base
|
||||||
statusline $text
|
statusline $text
|
||||||
|
|||||||
Reference in New Issue
Block a user