Conky <3 MOC

I used linux for a while before I ever became interested in messing with it. Really, the impetus was getting an OLPC XO. Suddenly I had this cute little computer that was absolutely unusable with Sugar! I installed XFCE but found that too a little heavy. Some more searching, a lot of reading of k.mandla and urukrama, and I had a speedy Openbox XO. The difference that my intent and effort had made astounded me.

Fast forward past some experimentation with Puppy Linux on my primary, and I was setting up a new Ubuntu install (having killed my old one messing with GRUB). Xubuntu and kmandla’s speed tips were obviously the way to go.

So, why the blog? Well, I was messing around with moc and conky, combined the two with the help of Treadstone, and had something rather beautiful, if you ask me, and worth the 4 hours messing with conkyrc.

But htop wasn’t so happy about my constantly calling mocp -Q, so I thought a bit and mucked around a bit and came up with a script that got moc’s info only once and wrote it to a file for quick reading. Only 30% faster for the script calling mocp, but three times as fast for the other two! I realized that I wanted to share this to (hopefully) help others with this and to encourage me to muck around a bit more.

So, the scripts:

==================================================================================================

#/home/user/Documents/conky_moc.sh:
#!/bin/sh

mocp -i > mocpinfo

STATE="`cat /home/user/mocpinfo | grep 'State:' | sed -e 's/^.*: //'`";
TITLE="`cat /home/user/mocpinfo | grep -m 1 'Title:' | sed -e 's/^.*: //'`";
if [ "$STATE" = "STOP" ]; then echo "                                            ";
elif [ "$TITLE" = "" ]; then
  FILE="`cat /home/user/mocpinfo | grep 'File:' | sed -e 's/^.*: //'`";
  echo "  $FILE  ";
else echo "  $TITLE  ";
fi
=================================================================================================
#./moc_state.sh
#!/bin/sh

STATE="`cat /home/user/mocpinfo | grep 'State:' | sed -e 's/^.*: //'`";
if [ "$STATE" = "PAUSE" ]; then STATE="---------------|PAUSED|----------------";
elif [ "$STATE" = "PLAY" ]; then STATE="";
elif [ "$STATE" = "STOP" ]; then STATE="----------|no music playing|-----------";
fi
echo "$STATE"

==================================================================================================

#./conky_moctime.sh
#!/bin/sh

STATE="`cat /home/user/mocpinfo | grep 'State:' | sed -e 's/^.*: //'`";
if [ "$STATE" != "STOP" ]; then
  TOTALTIME="`cat /home/user/mocpinfo | grep 'TotalSec:' | sed -e 's/^.*: //'`";
  CURRENTTIME="`cat /home/user/mocpinfo | grep 'CurrentSec:' | sed -e 's/^.*: //'`";
  if [ "$TOTALTIME" != "" ]; then
    if [ "$CURRENTTIME" != "" ]; then
      CURRENTTIME=`expr $CURRENTTIME \* 100`;
      TIMEBAR=`expr $CURRENTTIME \/ $TOTALTIME`;
    fi
  fi
  echo $TIMEBAR
else echo ""
fi

==================================================================================================

#/home/user/.conkyrc

alignment bottom_left
background no
border_width 0
cpu_avg_samples 2
default_color white
default_outline_color white
default_shade_color white
draw_borders no
draw_graph_borders yes
draw_outline no
draw_shades no
font 6x10
gap_x 2
gap_y 1
#minimum_size 5 1
net_avg_samples 2
double_buffer yes
out_to_console no
own_window no
#own_window_class Conky
#own_window_type normal
stippled_borders 0
update_interval 3.0
uppercase no
use_spacer no
show_graph_scale no
show_graph_range no

TEXT
     ${color lightgrey}${top name 1}${top cpu 1}%   (${top name 2}${top cpu 2}%)          #NO
BREAK#${top_mem name 1}${top_mem mem 1}%   (${top_mem name 2}${top_mem mem 2}%)         #NO
BREAK#${fs_free /mnt/sda2}                  ${fs_free /mnt/sda1}   ${fs_free /}          #NO
BREAK#${scroll 37 ${exec /home/user/Documents/conky_moc.sh}}
CPU ${cpubar 5, 300}     MEM ${membar 5, 300}     FS ${fs_bar 5, 20 /mnt/sda2}#NO
BREAK#${fs_bar 5, 180 /mnt/sda1}${fs_bar 5, 60 /}     MOC #NO
BREAK#${exec /home/user/Documents/conky_mocstate.sh}#NO
BREAK#${execibar 3 /home/user/Documents/conky_moctime.sh}

===================================================================================================

Sorry about that awful conkyrc formatting. Just delete the #NOBREAK#s and note that there is an actual line break after conky_moc.sh.

Also, pretty screenshots!

Edit: Evidently some conkys support moc but I’m afraid ubuntu’s default doesn’t seem to.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.