You are not logged in.

#1 2010-03-28 01:01:35

lasu1
Member
Registered: 2010-02-10
Posts: 83

*noob* bash scripting question (i'm somehow crashing X hehe)

Hey guys,

I hope that you don't mind me asking a question.

I'm a newbie when it comes to bash scripting, but I'm really liking it so far because it's allowing me to more fully grasp the Linux environment.

Anyway, I've become quite fond of the i3 window manager. It doesn't have a "status" bar, by default, so I've put one together using dzen.

I've gotten all the info that I've wanted to display up; however, when I stop the script...I um...crash X....hard...also, if I switch to tty2 while the script is running...I crash X...

So, could someone point out what I'm doing wrong (I'm sure its obvious...but I'm a noob)

Here is my magnum opus:

while true;
do
#variables and get information
DATE=$(date)
MEMINFO=$(cat /proc/meminfo | sed -e '3d' | sed -e '4,50d' | xargs | cut -d" " -f2,5,8)
UPTIME=$(uptime | sed 's/.*://; s/,//g')
QUALITY=$(cat /proc/net/wireless | sed -e '1,2d' | cut -d" " -f6,7)
UNAME=$(uname -a | cut -d" " -f1,2,3)
TEMPS=$(sensors | awk '/C/ { print $3}' | xargs | cut -d" " -f1,2,3,4)

#print it out
echo "^fg(white)$DATE^fg(grey) | $UNAME | ^fg(white)^i(mem.xbm)^fg(grey) T/F/C $MEMINFO | ^fg(white)^i(net-wifi.xbm) $QUALITY ^fg(grey)| ^fg(white)^i(cpu.xbm)^fg(grey) $UPTIME | ^fg(white)^i(temp.xbm)^fg(grey) $TEMPS"

sleep 5

done | dzen2 -x 150 -y 1006 -w 1000 -bg black -fg grey -fn fixed -u

I've got a feeling I'm screwing up that while loop somehow.

Anyway, thanks for your help, and please be nice because this is like, my first script, lol.

Offline

#2 2010-03-28 02:11:46

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: *noob* bash scripting question (i'm somehow crashing X hehe)

Ahhh the pipes! The pipes!!

Bash lesson #574: cat is 99% of the time not necessary in scripting.

MEMINFO=$(sed -n -e '3d' -e '1,4p' /proc/meminfo | awk '{printf "%d ", $2 }')
QUALITY=$(sed -e '1,2d' /proc/net/wireless | cut -d" " -f6,7)

I'd help with the others but I can't replicate their output on this machine. Your loop looks fine. What's the error message from X crashing? Anything in /var/log/Xorg.0.log?

Last edited by falconindy (2010-03-28 02:13:29)

Offline

#3 2010-03-28 03:11:11

lasu1
Member
Registered: 2010-02-10
Posts: 83

Re: *noob* bash scripting question (i'm somehow crashing X hehe)

omg your my hero....I *knew* there had to be a better way to do that. I see that your way avoids the "xargs," also.

So, I checked the xorg log. It seems to be a dzen2 notes (the log points to the "dzen" line of the script), lots of stuff about xinerama. I'm thinking now that it has to do with the screen placement of the dzen field, and that i3 doesn't know how to redraw it. I remember reading that dzen didn't fully support xinerama yet, so maybe that is it.

As it is now, its sort of like a "log out" button, because I can right-click close dzen and leave X :-)

Offline

Board footer

Powered by FluxBB