Another Alternative to Conky

Forum rules
Share your brain ;)
User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Another Alternative to Conky

Unread post by dkeg » Sun Jan 19, 2014 10:17 pm

So I've been experimenting with LemonBar boy. Check it out here. Easy enough to get set up. I at first just piped a simple one-liner conky through it, but then thought, I could use like osd_cat. I have the variables set, just needs some fine tuning. So as DJ wrote up, another nice conky alternative.
*Disclaimer, I'm absolutely positive that there is a better way to do this, but it works, and does what I need ... for now.*

This is the script I'm using. Name it whatever.

Code: Select all

#! /bin/bash

temp() {
    tempstat=$(cat /sys/class/thermal/thermal_zone0/temp | awk '{print $1/1000}') 
    echo "$tempstat"
}
cpu() {
    cpustat=$(top -bn 2 -d 0.01 | grep '^%Cpu' | tail -n 1 | awk '{print $2+$4+$6}')
    echo "$cpustat"
}
mem() {
    memstat=$(free -m | grep buffers/cache | sed -e 's/[buffers/cache -+ :]//g' | sed 's/.\{4\}$//')
    echo "$memstat"
}
clock() {
    clockstat=$(date | sed -e 's/EST 2014//g')
    echo "$clockstat"
}
batt() {
    battstat=$(cat /sys/class/power_supply/BAT0/capacity)
    echo "$battstat"
}
mail() {
    mailstat=$($HOME/mail) 
    echo "$mailstat"
}
music() {
    musicstat=$($HOME/music) 
    echo "$musicstat"
}
vol() {
    volstat=$(amixer get Master | tail -1 | sed 's/.*\[\([0-9]*%\)\].*/\1/')
    echo "$volstat"
}

#OUTPUT=

while true; do
    echo  "     \f5m$(mail)  b$(batt)  r$(mem)  c$(cpu)  t$(temp)  v$(vol) \c\f9$(clock) \r\f9$(music)     "
    sleep 10s;
done
Place in .xinitrc

Code: Select all

/path/to/script | bar -p &
P.S. I did borrow your volume string Joe, thanks!

http://postimg.org/image/sixymv9tr/

Work hard; Complain less

User avatar
wuxmedia
Grasshopper
Posts: 6454
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: Another Alternative to Conky

Unread post by wuxmedia » Sun Jan 19, 2014 10:25 pm

Nice.
I'm slowly getting fed up with i3bar...
No shame in promoting something as great as your site dkeg!
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
DebianJoe
Frame Buffer
Posts: 1915
Joined: Mon Jul 01, 2013 5:41 am
Location: emacs.d

Re: Another Alternative to Conky

Unread post by DebianJoe » Mon Jan 20, 2014 6:26 am

Very cool. There are 1.5 billion ways to skin an osd_cat, but new ways are always a welcome sight.
|>>BBQ Roaster, Alpha Branch<< | >> clinky << | >> X11 must die << |
Thanks BASIC

User avatar
johnraff
Sperminator
Posts: 199
Joined: Wed Oct 17, 2012 6:38 pm
Location: Japan
Contact:

Re: Another Alternative to Conky

Unread post by johnraff » Thu Jan 23, 2014 6:39 am

Thanks dkeg - alternatives to conky are always welcome! Is bar lighter/have more features?

Wonder if you could simplify those functions, like perhaps

Code: Select all

temp() {
    tempstat=$(cat /sys/class/thermal/thermal_zone0/temp | awk '{print $1/1000}')
    echo "$tempstat"
}
could be

Code: Select all

temp() {
    cat /sys/class/thermal/thermal_zone0/temp | awk '{print $1/1000}'
}
and still give the same result? I haven't yet installed bar to try this, so just guessing...
All code is one.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Another Alternative to Conky

Unread post by machinebacon » Thu Jan 23, 2014 11:37 am

^ Why using cat anyway? :D
..gnutella..

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: Another Alternative to Conky

Unread post by dkeg » Thu Jan 23, 2014 1:36 pm

check it out on github. Actually comes with a paletter script similar to Rho's to pull your xcolors to use within bar. it's very light for sure.

Just one of those things you find and want to get it working. As far as the script 'cleanliness'. I'm sure its bloated up a bit. I don't know what I'm doing. Tbh, once I got it working, I just let it be. The improvements and perfecting is for all of you guys!

and why use cat? I dunno. I literally just took what I was using for osd_cat, hence calling it osdbar, and tuned it to work here. Of course, that doesn't mean I need it in the osd_cat either.

Work hard; Complain less

User avatar
DebianJoe
Frame Buffer
Posts: 1915
Joined: Mon Jul 01, 2013 5:41 am
Location: emacs.d

Re: Another Alternative to Conky

Unread post by DebianJoe » Thu Jan 23, 2014 2:54 pm

Code: Select all

temp() {
    awk '{print $1/1000}' /sys/class/thermal/thermal_zone0/temp
}
Should do exactly what MB is suggesting.
|>>BBQ Roaster, Alpha Branch<< | >> clinky << | >> X11 must die << |
Thanks BASIC

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Another Alternative to Conky

Unread post by machinebacon » Thu Jan 23, 2014 4:25 pm

cats are bloat :D thanks joe!
..gnutella..

User avatar
johnraff
Sperminator
Posts: 199
Joined: Wed Oct 17, 2012 6:38 pm
Location: Japan
Contact:

Re: Another Alternative to Conky

Unread post by johnraff » Fri Jan 24, 2014 6:15 am

cat-killing is a time-homoured geek sport of course.
All code is one.

User avatar
DebianJoe
Frame Buffer
Posts: 1915
Joined: Mon Jul 01, 2013 5:41 am
Location: emacs.d

Re: Another Alternative to Conky

Unread post by DebianJoe » Fri Jan 24, 2014 6:32 am

Side note on cat and pipe killing:

My awk if pretty sketchy yet, but I like breaking these guys down. You can also totally avoid grep for searching with regexps using awk. For example:

Code: Select all

awk '/(^Mary)|(^Elizabeth)/{ print $3 }' /home/joe/blackbook
Assuming that I have a file called "blackbook", this one will find lines starting with either "Mary" or "Elizabeth" and give me the 3rd column of info on that line. (Which, for the sake of discussion and staying 'on-topic' we'll assume is going to be sent to by lemonboy bar. For even more fun in theory, let's assume that's where I keep the phone numbers of people in ~/blackbook and that I'm trying to simplify the process of making booty-calls while drunk by not even having to open a file.)

awk is nuts with what all you "can" do with it, such as in-line iterating, but I'll just leave it at that.
|>>BBQ Roaster, Alpha Branch<< | >> clinky << | >> X11 must die << |
Thanks BASIC

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: Another Alternative to Conky

Unread post by machinebacon » Fri Jan 24, 2014 6:53 am

..gnutella..

User avatar
johnraff
Sperminator
Posts: 199
Joined: Wed Oct 17, 2012 6:38 pm
Location: Japan
Contact:

Re: Another Alternative to Conky

Unread post by johnraff » Fri Jan 24, 2014 5:09 pm

DebianJoe wrote:You can also totally avoid grep for searching with regexps using awk. For example:

Code: Select all

awk '/(^Mary)|(^Elizabeth)/{ print $3 }' /home/joe/blackbook
...awk is nuts with what all you "can" do with it, such as in-line iterating, but I'll just leave it at that.
Yes! Awk (and Dillo) fan here. You so often see grep 'something' | cut something to pull a bit of data out of a file when a single call to awk could have done it.

A couple of days ago, however, I ran into how you can use sed to search for a certain line then pull out a bit of it that fits a certain regex, all in one command. Use -n option to suppress normal output, /p switch at the end of a s/a/b/ substitution to print only that line, and so s/regex\(bit\)moreregex/\1/p to print only the bit inside the ( ).
The specific example was to extract as a 3-character string the audio format inside a container file (eg mp4) from the output of ffprobe:

Code: Select all

ffprobe "$file" 2>&1 | sed -n 's/.*Audio: \(...\), .*/\1/p'
All code is one.

Post Reply