Saturday, October 27, 2012

System Info (Working on 12.10)

Well I got Ubuntu 12.10 on and loaded up conky and some of the scripts from this project. Conky worked fine. My scripts didn't work at all. Huge surprise there. So far I've been able to spend a whopping 20 minutes trying to fix them, so all I have so far is an updated sysinfo script. The main difference here is that instead of using 'cat' to display the relevant data out of /proc/acpi/battery, we can just use the program "acpi," with an output that looks like the following:

jason@kaito:~/bin$ acpi
Battery 0: Discharging, 25%, 00:24:46 remaining


As you can see, this output is a lot better for my purposes then the old method, which didn't display the battery life as a percentage, but as a number out of 4000 (in the case of my old laptop,) requiring me to declare variables in the script that did simple math to calculate the actual percentage. Not terribly difficult, but annoying. Another advantge to this output is the fact that all pertinent data is on one line, making this script quick work with some simple 'awk' parameters. Anyway, without further ado, here's the updated script. A lot cleaner, but outputs exactly the same.

//Begin Script

#!/bin/sh
#
# Script by Jason Gotti (email removed for spambots)
# Written and tested on Ubuntu 12.10.
#
# Developed for use with conky, but also can be used
# for other information related purposes.
#
# Variables: You'll need to install hddtemp (available in the repo's) and
# change the path to match your hard drive.

life=$(acpi | awk '{ print $4 }' | awk -F , '{ print $1 }')
temp=$(sudo hddtemp /dev/sda | awk -F: {' print $3 '} | awk {' print $1 '})
status=$(acpi | awk '{ print $3 }' | awk -F , '{ print $1 }')


echo CPU Temperature: $temp
echo Battery Life: $life
echo "Battery:" $status


//End Script

As always, you're going to call the script in conky the same way:

${color #ffcb48}System Info:
${color #FFFFFF}${execi 5 sysinfo} 


And it will output the following through Conky:

System Info:
CPU Temperature: 38*C
Battery Life: 47%
Battery: Charging 

Alright! Hopefully the other scripts are equally as easy to clean up. Hopefully I'll be posting them in not too much time at all.

(As a side note, I'll be changing the label of the old script to "development" and this one to "scripts," so each one will have to be accessed with it's respective side link. It just wouldn't make sense to have a non working script in the "scripts" section.)


No comments: