dwm and rotating info on bar.

A section for Window Manager configurations. If the WM doesn't exist yet, simply start a new thread.
Forum rules
Configurations, tips, questions and answers related to window managers only.
User avatar
DebianJoe
Frame Buffer
Posts: 1915
Joined: Mon Jul 01, 2013 5:41 am
Location: emacs.d

dwm and rotating info on bar.

Unread post by DebianJoe » Tue Jan 14, 2014 8:18 am

I've been playing with my bounty hunter theme and thought, "You know what would look cool? Changing info on the little dwm bar." So I hacked out this little (very crude, but once it worked I just left it alone) script at the bottom of my .xinitrc.

Code: Select all

KERNEL=$(uname -smr)
while true
do
	VOL=$(amixer get Master | tail -1 | sed 's/.*\[\([0-9]*%\)\].*/\1/')
	LOCALTIME=$(date | sed -e 's/CST//' -e 's/\(.*\)/\L\1/')
	TEMP="$(($(cat /sys/class/thermal/thermal_zone0/temp) / 1000))C"
	if [ $marquis -eq "0" ];then
	    xsetroot -name "temp $TEMP >> $LOCALTIME"
	    marquis=1
	elif [ $marquis -eq "1" ]; then
	    xsetroot -name "vol $VOL >> $LOCALTIME"
	    marquis=2
	elif [ $marquis -eq "2" ]; then
	    xsetroot -name "shell $SHELL >> $LOCALTIME"
	    marquis=3
	elif [ $marquis -eq "3" ]; then
	    xsetroot -name "$KERNEL >> $LOCALTIME"
	    marquis=0
	else
	    xsetroot -name "Your indexer is broken"
	    marquis=0
	fi
	sleep 15s
done &
exec dwm
I'm sure there's great room for improvement, but the concept is there. The sed lines in the date are just because I really like lowercase lettering and know sed better than anything else. I'm sure there are better ways to do that too.
|>>BBQ Roaster, Alpha Branch<< | >> clinky << | >> X11 must die << |
Thanks BASIC

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

Re: dwm and rotating info on bar.

Unread post by wuxmedia » Tue Jan 14, 2014 9:03 am

cool, I wonder if i could implement that neat xsetroot marquis thing on i3...

I got to use 'tr' in my crappy script, it should perform a upper to lower easy.
humph - but I've just spent 10 mins on how to do using the man page, i going to have googleit now. 8(

Code: Select all

 tr [:upper:] [:lower:]
not saying it's better.
apparently bash v4 lets you do the same thing;
http://www.cyberciti.biz/faq/linux-unix ... uppercase/
"Seek, and Ye shall find"
"Github | Chooons | Site"

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

Re: dwm and rotating info on bar.

Unread post by machinebacon » Tue Jan 14, 2014 9:30 am

neat! so stuff like ansiweather could be piped in there, too. die, conky, die :D
..gnutella..

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

Re: dwm and rotating info on bar.

Unread post by DebianJoe » Tue Jan 14, 2014 10:03 am

You could put whatever you want in there. If it can be scripted, it can be displayed in this manner.
|>>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: dwm and rotating info on bar.

Unread post by machinebacon » Tue Jan 14, 2014 10:11 am

yeah, just teasing Sector11 ;)
..gnutella..

User avatar
mrneilypops
Bad Advice Dog
Posts: 143
Joined: Wed Oct 17, 2012 9:15 pm
Location: Luxembourg
Contact:

Re: dwm and rotating info on bar.

Unread post by mrneilypops » Tue Jan 14, 2014 1:40 pm

@DebianJoe
Really cool script!
I might use this in my dwmX distrolette.
It would be cool to 'abuse' (lol) your programming skills and add another couple of gizmos to the list...

One small niggle...when I start dwm I get the message 'your indexer is broken" for 15 seconds and then the script starts fine...
Is it possible to change this?
Why is it there anyway? - I guess I could chop it out of the script...

EDIT: I just noticed that Debian kernel info is not printed out.
Temp,Vol,Shell work.

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

Re: dwm and rotating info on bar.

Unread post by DebianJoe » Tue Jan 14, 2014 2:52 pm

@neilypops
Sure, feel free to do whatever with it.

I added an awk one-liner to mine to print the GHz from each core as in (cpu 2.2 : 1.6). I'll leave it up to you to figure that one out, it took me a few tries before I got it right. :D

Edit: I declared the KERNEL variable outside of the loop so that it wouldn't poll each time. I think I used a KERNEL=$(uname -smr) above the loop, because it's not like your kernel will be changing while running. My mistake for not including that. I will edit the first post to reflect it.
|>>BBQ Roaster, Alpha Branch<< | >> clinky << | >> X11 must die << |
Thanks BASIC

User avatar
mrneilypops
Bad Advice Dog
Posts: 143
Joined: Wed Oct 17, 2012 9:15 pm
Location: Luxembourg
Contact:

Re: dwm and rotating info on bar.

Unread post by mrneilypops » Tue Jan 14, 2014 2:55 pm

^Thanks!
What am I missing to get the kernel info printing out?

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

Re: dwm and rotating info on bar.

Unread post by DebianJoe » Tue Jan 14, 2014 2:58 pm

See the above edit, and the edit to the original. I cut out a needed functional part when I copied to the forum post. Sorry for any confusion there.
|>>BBQ Roaster, Alpha Branch<< | >> clinky << | >> X11 must die << |
Thanks BASIC

User avatar
mrneilypops
Bad Advice Dog
Posts: 143
Joined: Wed Oct 17, 2012 9:15 pm
Location: Luxembourg
Contact:

Re: dwm and rotating info on bar.

Unread post by mrneilypops » Tue Jan 14, 2014 3:23 pm

^Got it now. Working - Thanks.

User avatar
rust collector
Motörhead
Posts: 535
Joined: Mon Jan 13, 2014 3:56 pm
Location: no_nb

Re: dwm and rotating info on bar.

Unread post by rust collector » Sat Jan 18, 2014 10:53 pm

I just found this, so I use it now.
If nothing else, I will have to learn...stuff to make it work as I want it.

Thank you!

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

Re: dwm and rotating info on bar.

Unread post by DebianJoe » Sun Jan 19, 2014 6:32 am

@rust: Little things like this are as much of a practice at writing "bash one-liners" as they are about getting the output working. Best of luck, and there are some truly brilliant scriptwriters here (not me, I am still a noob) who can help you if you get stuck.
|>>BBQ Roaster, Alpha Branch<< | >> clinky << | >> X11 must die << |
Thanks BASIC

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: dwm and rotating info on bar.

Unread post by rhowaldt » Wed Jun 25, 2014 7:52 am

looks good DJ!
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

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

Re: dwm and rotating info on bar.

Unread post by dkeg » Sat Dec 17, 2016 6:52 pm

*bump*
using dwm now, and remembered this. Happy I was able to remember enough to find it.

Work hard; Complain less

arnold
Window Manager
Posts: 51
Joined: Fri Jul 10, 2015 5:21 pm

Re: dwm and rotating info on bar.

Unread post by arnold » Sat Dec 17, 2016 8:39 pm

It will great great to see some nice dwm scrots from you. I use Joe's idea also.

Post Reply