I have wriiten (with the help of the internet) a bash scirpt for my debian ppc 5.0 laptop to display battery remaining in a panel on the xfce desktop environment. echo `hal-device | grep battery.remaining_time | awk '{print $3/3600}' `-battery and this nicely spits out 4.95 hours in the panel. This is fine except it is a snow day and I have some extra time on my hands. I was wondering if I could write a little program that would take 4.95 and convert it into 4: (.95*6) in other words 4:57 in R and then use that in a shell script to tweak the battery remaining script. I am sure there is a better way, but I am a noob to linux and have a couple of years with R. thanks -- Stephen Sefick Let's not spend our time and resources thinking about things that are so little or so large that all they really do for us is puff us up and make us feel like gods. We are mammals, and have not exhausted the annoying little problems of being mammals. -K. Mullis
Make suitable changes for Linux (this was done in Windows Vista) but you should be able to do without R. In particular the double echo 4.95 | gawk "{print int($1) "":"" 60*($1-int($1))}" On Mon, Mar 2, 2009 at 9:48 AM, stephen sefick <ssefick at gmail.com> wrote:> I have wriiten (with the help of the internet) a bash scirpt for my > debian ppc 5.0 laptop to display battery remaining in a panel on the > xfce desktop environment. > > echo `hal-device | grep battery.remaining_time | awk '{print $3/3600}' `-battery > > and this nicely spits out ?4.95 hours in the panel. ?This is fine > except it is a snow day and I have some extra time on my hands. ?I was > wondering if I could write a little program that would take 4.95 and > convert it into 4: (.95*6) in other words 4:57 in R and then use that > in a shell script to tweak the battery remaining script. ?I am sure > there is a better way, but I am a noob to linux and have a couple of > years with R. > thanks > > -- > Stephen Sefick > > Let's not spend our time and resources thinking about things that are > so little or so large that all they really do for us is puff us up and > make us feel like gods. ?We are mammals, and have not exhausted the > annoying little problems of being mammals. > > ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?-K. Mullis > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
stephen sefick wrote:> I have wriiten (with the help of the internet) a bash scirpt for my > debian ppc 5.0 laptop to display battery remaining in a panel on the > xfce desktop environment. > > echo `hal-device | grep battery.remaining_time | awk '{print $3/3600}' `-battery > > and this nicely spits out 4.95 hours in the panel. This is fine > except it is a snow day and I have some extra time on my hands. I was > wondering if I could write a little program that would take 4.95 and > convert it into 4: (.95*6) in other words 4:57 in R and then use that > in a shell script to tweak the battery remaining script. I am sure > there is a better way, but I am a noob to linux and have a couple of > years with R. > thanks >This is one for little r (http://dirk.eddelbuettel.com/code/littler.html) $ echo "4.95" | r -e "x <- as.numeric(readLines()); cat( floor(x),':', round( ( x - floor( x ) ) * 60 ),'\n',sep='') " 4:57 Romain -- Romain Francois Independent R Consultant +33(0) 6 28 91 30 30 http://romainfrancois.blog.free.fr