Archive for the 'Programming' Category

Bash Function to Get Battery Charge

I added these two functions to my bashrc.  The first one is used to get the battery charge, and the second returns the battery’s current capacity.

function bchrg {
      # Returns battery charge as a percentage.
      now=`cat /sys/class/power_supply/BAT0/energy_now`
      full=`cat /sys/class/power_supply/BAT0/energy_full`
      out=`echo $now/$full*100 | bc -l | cut -c 1-5`
      echo "Charge: "$out"%"
  }
  
  function bcap {
      # Returns battery capacity as a percentage.
      design=`cat /sys/class/power_supply/BAT0/energy_full_design`
      current=`cat /sys/class/power_supply/BAT0/energy_full`
      out=`echo $current/$design*100 | bc -l | cut -c 1-5`
      echo "Capacity: "$out"%"
  }

Rpmbuild Tutorial

I used to have a page on this blog for a tutorial I made for constructing rpms.  It didn’t really fit in here, and it was hard for people to read so I decided to give it it’s own site.  By doing this I was able to better organize the information on the tutorial and make it easier to read.  I think the overall reader experience is definitely improved by moving the tutorial, and hopefully the readers agree once they figure out that I moved it.

I’ve also moved some old packages I put together that used to be available on my download page.  The entire page has moved and is basically the same as it was before.  The downloads went with the tutorial since I use the downloads as examples.  If you’re interested here is the link to the tutorial.  Before I changed my blog url this tutorial was very popular.  I suspect people will pick up on it again once google crawls it.

Improved RPMs

Last weekend I greatly improved all of my available rpms.  If you use rpmlint to check the quality of either the specfile or the rpm itself it should return no errors or warnings.  I am also working on putting more information into my rpmbuild tutorial to encompase everything I found useful, and everything in my opinion which may be useful to others, who also are looking to create packages of their own.  All of my rpms are available here.

In addition, the specfiles to these rpms can be found as examples in my rpmbuild tutorial.

Vpython Fedora 9

Vpython , which is also know as visual vpython, is a visual modeling library for python developed at NCSU.  It is useful for modeling physics, and I have also used it for dynamics problems as well.  Ever since Fedora 8 came out visual python did not work well because of name changes with the boost libraries.  A little while ago a member of the vpython mailing list figured out what was wrong, and got vpython to compile on Fedora 9.  I downloaded the tar files, and also rpmdevtools before making rpms for the beta version and the stable 3.2.9 version of vpython.  The stable version never ran sucessfully because of an error with a mutex function.  I have been a little lazy on debugging it.  However, the beta version is stable enough, and the rpm works fine. For more information on visual python go to the vpython website at www.vpython.org.

Download/RPMS

To download vpython go to the vpython homepage.  My rpms for Fedora are also posted there, but I have them available on my download page as well.



Follow

Get every new post delivered to your Inbox.