You are not logged in.
HI guys, I have a dwm script that I put together for the status bar but the problem is that the output is huge especially with the battery and sound function... My question is how can I shorten both of them? Here is the code for the script
#/bin/bash
#DWM status bar loop
# \x01 is normal colors \x03 is red \x04 is green \x05 is yellow \x06 is blu$
while true
do
battery(){
level="$(acpi -b)"
printf "%b" "\x04$level\x01"
}
vol(){
level="$(amixer get PCM | egrep Front\ Right:)"
printf "%b" "\x05$level\x01"
}
upd(){
level="$(yaourt -Qua | wc -l)"
printf "%b" "\x06$level\x01"
}
xsetroot -name "$(vol) $(battery) $(upd) $( date '+%D %T')"
sleep 30s
done &
Any help would be greatly appreciated! thx!
Last edited by sesese9 (2015-09-27 20:57:55)
Just trying to figure things out in this world
Offline
Well you can shorted the battery output to only print the last field:
awk '{print $NF}' <(acpi -b)
And for the volume, just print the current level (untested, but you'll get the idea):
awk -F"[][]" '/Front Right/ { print $2 }' <(amixer sget Master)
Offline
hi jason,
I tried both your suggestions and here is the output:
Original battery output:
Battery 0: Discharging, 100%, 02:20:57 remaining
Suggestion:
remaining
Original Sound:
Front Right: Playback 217 [85%] [-7.60dB]
Suggested
nothing was shown....
I just tried something for the sound with
awk '{print $5}' <(amixer sget PCM | egrep Front\ Right:)
Output:
[85%]
maybe I found something?
Just trying to figure things out in this world
Offline
echo "Battery 0: Discharging, 100%, 02:20:57 remaining" | awk '{print +$4}'
echo "Front Right: Playback 217 [85%] [-7.60dB]" | awk -F'[][]' '{print $2}'
Offline
That actually solves it! Thx jason!
Just trying to figure things out in this world
Offline