You are not logged in.

#1 2015-09-27 19:12:08

sesese9
Member
From: California, United States
Registered: 2015-04-01
Posts: 75
Website

[Solved] DWM status bar help (shortening output)

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

#2 2015-09-27 19:47:36

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [Solved] DWM status bar help (shortening output)

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)

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2015-09-27 20:51:15

sesese9
Member
From: California, United States
Registered: 2015-04-01
Posts: 75
Website

Re: [Solved] DWM status bar help (shortening output)

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

#4 2015-09-27 20:54:58

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: [Solved] DWM status bar help (shortening output)

echo "Battery 0: Discharging, 100%, 02:20:57 remaining" | awk '{print +$4}'
echo "Front Right: Playback 217 [85%] [-7.60dB]" | awk -F'[][]' '{print $2}'

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2015-09-27 20:57:17

sesese9
Member
From: California, United States
Registered: 2015-04-01
Posts: 75
Website

Re: [Solved] DWM status bar help (shortening output)

That actually solves it! Thx jason!


Just trying to figure things out in this world

Offline

Board footer

Powered by FluxBB