
I'm very new to linux too, and am just starting to learn to hack my way around a bit so I thought this would be a nice chance for me to learn a bit more bash and a little perl. There's possibly a really easy way to do this, but anyway, here's my quite nasty solution. Apologies for badness of code etc etc.reksav wrote:this is going to be an easy fix question for you guys... im VERY new to linux (a few days) and found torsmo pretty interesting so ive been playing with it... a simple feature ive been trying to put together takes the fs_free function and sums it with 2 or 3 other fs_free function results... basically giving a total of all the free space i have on the drives torsmo checks... if someone could help me out on this thatd be great... thanks
Code: Select all
#!/bin/bash
index=0
for arg in "$@"
do
if [ "$index" != 0 ]
then
if [ "$1" = -f ]
then
export fs${index}=`df -k | grep $arg |awk '{print $4}'`
fi
if [ "$1" = -u ]
then
export fs${index}=`df -k | grep $arg |awk '{print $3}'`
fi
export fs${index}t=`df -k | grep $arg |awk '{print $2}'`
fi
let "index+=1"
done
export index
perl -e '
$fs=0;
for (my $i=1; $i<$ENV{index}; $i++)
{
$fs+=$ENV{fs.$i};
$fstotal+=$ENV{fs.$i.t};
}
$fs=$fs/1024/1024;
$fstotal=$fstotal/1024/1024;
printf ("%.2fG/%.2fG\n",$fs, $fstotal);
'
Code: Select all
./filename.sh (-f | -u) (filesystems)Code: Select all
${execi 1.0 /path/to/fs.sh -f hda3 hdb1}
Code: Select all
/home/reksav/applications/torsmo-0.18/sumfs.sh: line 10: export: `257796': not a valid identifier
/home/reksav/applications/torsmo-0.18/sumfs.sh: line 10: export: `82658': not a valid identifier
/home/reksav/applications/torsmo-0.18/sumfs.sh: line 10: export: `11720964': not a valid identifier
/home/reksav/applications/torsmo-0.18/sumfs.sh: line 16: export: `257816': not a valid identifier
/home/reksav/applications/torsmo-0.18/sumfs.sh: line 16: export: `101105': not a valid identifier
/home/reksav/applications/torsmo-0.18/sumfs.sh: line 16: export: `61440560': not a valid identifier
Code: Select all
Line 9 - export fs${index}="`df -k | grep $arg |awk '{print $4}'`"
Line 13 - export "fs${index}="`df -k | grep $arg |awk '{print $3}'`"
Line 15 - export "fs${index}t="`df -k | grep $arg |awk '{print $2}'`"

Code: Select all
crontab -e
0 6 * * * emerge -pU world > /tmp/emergeUpgradeList
Code: Select all
#!/bin/bash
#Show Packages that need updating and you are interested in
# To add new packages just continue in the order '|foo|bar|zip|it|dot|com'
# always leave the end free of '|'
file=/tmp/emergeUpgradeList
showNr=15
intPackages="licq|amarok|fluxbox|firefox|xchat"
head -n $showNr $file | grep -e "\[ebuild *[U]* *\]" | egrep "($intPackages)" | awk '{print $4}'
Code: Select all
${execi 1800 whereTO/showUpgrades.sh}
Code: Select all
# when both batteries are present
if grep -q yes /proc/acpi/battery/BAT2/state ; then
# get battery info
bat1cap=`cat /proc/acpi/battery/BAT1/info | grep last`
bat1rem=`cat /proc/acpi/battery/BAT1/state | grep remaining`
bat2cap=`cat /proc/acpi/battery/BAT2/info | grep last`
bat2rem=`cat /proc/acpi/battery/BAT2/state | grep remaining`
# strip text
bat1cap=${bat1cap%' mWh'}
bat1rem=${bat1rem%' mWh'}
bat1cap=${bat1cap#'last full capacity: '}
bat1rem=${bat1rem#'remaining capacity: '}
bat2cap=${bat2cap%' mWh'}
bat2rem=${bat2rem%' mWh'}
bat2cap=${bat2cap#'last full capacity: '}
bat2rem=${bat2rem#'remaining capacity: '}
# make totals
batscap=`echo "($bat1cap+$bat2cap)" | bc`
batsrem=`echo "($bat1rem+$bat2rem)" | bc`
# make percentage
batsperc=`echo "scale=2; ($batsrem/$batscap)*100" | bc`
batsperc=${batsperc%'.00'}
# when just one battery is present
else
# get battery info
bat1cap=`cat /proc/acpi/battery/BAT1/info | grep last`
bat1rem=`cat /proc/acpi/battery/BAT1/state | grep remaining`
# strip text
bat1cap=${bat1cap%' mWh'}
bat1rem=${bat1rem%' mWh'}
bat1cap=${bat1cap#'last full capacity: '}
bat1rem=${bat1rem#'remaining capacity: '}
# make percentage
bat1perc=`echo "scale=2; ($bat1rem/$bat1cap)*100" | bc`
bat1perc=${bat1perc%'.00'}
fi
# when plugged in
if grep -q on-line /proc/acpi/ac_adapter/ADP1/state ; then
if grep -q yes /proc/acpi/battery/BAT2/state ; then
echo "plugged-in | Bat: $batsperc%"
else
echo "plugged-in | Bat: $bat1perc%"
fi
# when running on batteries
else
if grep -q yes /proc/acpi/battery/BAT2/state ; then
echo "Bat: $batsperc%"
else
echo "Bat: $bat1perc%"
fi
fiCode: Select all
torsmo -c configfileI have this in my .torsmorcilythiiri wrote:how do i change the i2c location that .torsmorc reads by default ???
torsmo: can't open '/sys/bus/i2c/devices/0-0050/temp1_input': No such file or directory
but i want it to read in this location "/sys/class/i2c-adapter/i2c-1/device/1-0290/temp2_input"
a sym link wont work i've tryed that.
Thx in advance.
/*EDIT*/
if i put thi in .torsmorc
${exec cat /sys/class/i2c-adapter/i2c-1/device/1-0290/temp2_input}
the output is 34500 and i want it to be this way 34.5 :D
Code: Select all
${color grey90}CPU temp: ${color}${execi 0.5 echo "scale=1; `cat /sys/bus/i2c/devices/0-0290/temp2_input`/1000" | bc}°C ${color grey90}MB temp: ${color}${execi 0.5 echo "scale=1; `cat /sys/bus/i2c/devices/0-0290/temp1_input`/1000" | bc}°C
Code: Select all
double_buffer noCode: Select all
own_window yes
Code: Select all
Can't locate XMMS/InfoPipe.pm in @INC (@INC contains: /etc/perl /usr/lib/perl5/site_perl/5.8.5/i686-linux /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.5/i686-linux /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.5/i686-linux /usr/lib/perl5/5.8.5 /usr/local/lib/site_perl .) at /home/mark/xmmsinfopl/xmms.pl line 6.
BEGIN failed--compilation aborted at /home/mark/xmmsinfopl/xmms.pl line 6.Code: Select all
# perl Build.PL
Can't locate Module/Build.pm in @INC (@INC contains: /etc/perl /usr/lib/perl5/site_perl/5.8.5/i686-linux /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.5/i686-linux /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.5/i686-linux /usr/lib/perl5/5.8.5 /usr/local/lib/site_perl .) at Build.PL line 1.I have a problem with this one! When I start torsmo bash says :Arainach wrote:Sure, we've got a problems thread, but why not a tips and tricks thread? For posting useful ideas.
First, never underestimate the power of the execi command. I've used it for things like checking on Folding@Home unit Status, System Logs, etc. I've seen other people use it for things like monitoring weather. Incredibly powerful command.
Here's my current .torsmorc file - It's almost entirely borrowed from the Forums user who I give credit to at the top. I'm in the process of tweaking it to my liking, but when I first saw it I was like "This is what I've been trying to do for a few months", so when he posted his I decided to scrap my homemade .torsmorc and modify his (with credit, of course)
.torsmorc:And here's tweather.sh:Code: Select all
# torsmo configuration # Arainach's revisions, borrowed from Revisions by grad_guy from Gentoo Forums # set to yes if you want tormo to be forked in the background background no # X font used, you can pick one with program xfontsel #font 6x10 #font 7x13 #font 8x13 #font -*-clean-medium-r-*-*-12-*-*-*-*-*-*-* #font -artwiz-kates-medium-*-*-*-14-*-*-*-*-*-*-* #font -artwiz-kates-medium-*-normal-*-17-120-*-*-*-*-*-* #font -*-webby caps-*-*-*-*-7-*-*-*-*-*-*-* font -xos4-terminus-medium-r-normal--14-140-72-72-c-80-iso8859-1 #font -*-terminus-*-*-*-*-*-*-*-*-*-*-*-* #font -*-bitstream vera sans mono-medium-r-*-*-12-*-*-*-*-*-*-* # mail spool mail_spool $MAIL # Update interval in seconds update_interval 3.0 # Create own window instead of using desktop (required in nautilus) own_window no # Minimum size of text area minimum_size 80 5 # Draw shades? draw_shades yes # Draw outlines? draw_outline no # Draw borders naround text draw_borders no # Stippled borders? stippled_borders 0 # border margins border_margin 4 # border width border_width 1 # Default colors and also border colors #default_color spring green default_color light blue default_shade_color black default_outline_color black # Text alignment, other possible values are commented #alignment top_left alignment top_right #alignment bottom_left #alignment bottom_right # Gap between borders of screen and text gap_x 10 gap_y 100 # Subtract file system buffers from used memory? no_buffers yes # set to yes if you want all text to be in uppercase uppercase no # Possible variables to be used: # # Variable Arguments Description # acpiacadapter ACPI ac adapter state. # acpifan ACPI fan state # acpitemp ACPI temperature. # battery (name) Remaining capasity in ACPI or APM # battery. ACPI battery name can be # given as argument (default is BAT0). # buffers Amount of memory buffered # cached Amount of memory cached # color (color) Change drawing color to color # cpu CPU usage in percents # cpubar (height) Bar that shows CPU usage, height is # bar's height in pixels # downspeed net Download speed in kilobytes # downspeedf net Download speed in kilobytes with one # decimal # exec shell command Executes a shell command and displays # the output in torsmo. warning: this # takes a lot more resources than other # variables. I'd recommend coding wanted # behaviour in C and posting a patch :-). # execi interval, shell Same as exec but with specific interval. # command Interval can't be less than # update_interval in configuration. # fs_bar (height), (fs) Bar that shows how much space is used on # a file system. height is the height in # pixels. fs is any file on that file # system. # fs_free (fs) Free space on a file system available # for users. # fs_free_perc (fs) Free percentage of space on a file # system available for users. # fs_size (fs) File system size # fs_used (fs) File system used space # hr (height) Horizontal line, height is the height in # pixels # i2c (dev), type, n I2C sensor from sysfs (Linux 2.6). dev # may be omitted if you have only one I2C # device. type is either in (or vol) # meaning voltage, fan meaning fan or temp # meaning temperature. n is number of the # sensor. See /sys/bus/i2c/devices/ on # your local computer. # kernel Kernel version # loadavg (1), (2), (3) System load average, 1 is for past 1 # minute, 2 for past 5 minutes and 3 for # past 15 minutes. # machine Machine, i686 for example # mails Mail count in mail spool. You can use # program like fetchmail to get mails from # some server using your favourite # protocol. See also new_mails. # mem Amount of memory in use # membar (height) Bar that shows amount of memory in use # memmax Total amount of memory # memperc Percentage of memory in use # new_mails Unread mail count in mail spool. # nodename Hostname # outlinecolor (color) Change outline color # pre_exec shell command Executes a shell command one time before # torsmo displays anything and puts output # as text. # processes Total processes (sleeping and running) # running_processes Running processes (not sleeping), # requires Linux 2.6 # shadecolor (color) Change shading color # stippled_hr (space), Stippled (dashed) horizontal line # (height) # swapbar (height) Bar that shows amount of swap in use # swap Amount of swap in use # swapmax Total amount of swap # swapperc Percentage of swap in use # sysname System name, Linux for example # temp1 Temperature #1 from i2c-sensors, same as # ${i2c temp 1} # temp2 Temperature #2 from i2c-sensors, same as # ${i2c temp 2} # time (format) Local time, see man strftime to get more # information about format # totaldown net Total download, overflows at 4 GB on # Linux with 32-bit arch and there doesn't # seem to be a way to know how many times # it has already done that before torsmo # has started. # totalup net Total upload, this one too, may overflow # updates Number of updates (for debugging) # upspeed net Upload speed in kilobytes # upspeedf net Upload speed in kilobytes with one # decimal # uptime Uptime # uptime_short Uptime in a shorter format # variable is given either in format $variable or in ${variable}. Latter # allows characters right after the variable and must be used in network # stuff because of an argument # stuff after 'TEXT' will be formatted on screen # ${color}$hr # ${color}Mails: ${color slategrey}$mails${color} New: ${color slategrey}$new_mails${color} | ${color}Battery:${color slategrey} ${battery} % #${color white}$nodename #${color white}${time %A,%e %B %G %Z %H:%M:%S} ${color}UpTime: ${color white}$uptime${color} #${color white}$sysname $kernel on $machine${color} ${color}Network:${color} Up:${color white} ${upspeed eth0} k/s${color} - Down:${color white} ${downspeed eth0} k/s #$hr #${color}CPU:${color white} $cpu%${color} (${color white}${loadavg 1} ${loadavg 2} ${loadavg 3}${color}) ${cpubar 5} #${color}RAM: ${color white} $mem/$memmax - $memperc%${color} ${membar 5} #${color}Swap:${color white} $swap/$swapmax - $swapperc%${color} ${swapbar 5} #${color}hdb1: ${color white}${fs_used /}/${fs_size /}${color} (${color white}${fs_free_perc /}%${color} free) ${fs_bar 5/} #${color}hda5: ${color white}${fs_used /mnt/ehdd}/${fs_size /mnt/ehdd}${color} (${color white}${fs_free_perc /mnt/ehdd}%${color} free) ${fs_bar 5/mnt/ehdd} #${color}hdb6: ${color white}${fs_used /mnt/fhdd}/${fs_size /mnt/fhdd}${color} (${color white}${fs_free_perc /mnt/fhdd}%${color} free) ${fs_bar 5/mnt/fhdd} TEXT ${color slate blue}${time %a, }${color }${time %B %e %G} ${color slate blue}${time %Z, }${color }${time %H:%M:%S} $hr ${execi 40000 cal}$hr ${color slate blue}UpTime: ${color }$uptime $hr ${color slate blue}Net : ${color}Up :${color } ${upspeed eth0} k/s ${color}Down:${color } ${downspeed eth0} k/s ${color} $hr ${color slate blue}CPU :${color } $cpu% $cpubar ${color slate blue}RAM :${color } $memperc% $mem/$memmax $membar ${color slate blue}SWAP:${color } $swapperc% $swap/$swapmax $swapbar $hr ${color slate blue}ROOT: ${color }${fs_free_perc /}% ${fs_free /}/${fs_size /} ${fs_bar /} ${color slate blue}STUFF: ${color }${fs_free_perc /mnt/ehdd}% ${fs_free /stuff}/${fs_size /mnt/ehdd} ${fs_bar /stuff} $hr ${color slate blue}Weather :${color} ${execi 1800 tweather.sh Today} $hr ${color slate blue}Tomorrow :${color} ${execi 1800 tweather.sh Tomorrow} $hrCode: Select all
#!/bin/bash city="DeWitt" link=USMI0231.html file=/tmp/weather.txt location=http://weather.yahoo.com/forecast/$link lynx -accept_all_cookies -dump $location > $file begin=`cat -n $file | grep "Currently" | cut -d ' ' -f5` end=`expr $begin + 40` head -n $end $file > tmp.t tail -n 41 tmp.t > $file case $1 in Today) head -n 6 $file | sed '3d' ;; Tomorrow) begin=`cat -n $file | grep 'Today Tomorrow' | cut -d ' ' -f5` end=`cat -n $file | grep 'Extended' | cut -d ' ' -f5` num=`expr $end - $begin - 1` end2=`expr $begin + 7` head -n $end2 $file > tmp.t tail -n 3 tmp.t | sed 's/sky/\n sky/' | sed '4d' ;; *) exit ;; esac rm tmp.t rm $file
Code: Select all
/bin/torsmo-0.18/tweather.sh: line 7: lynx: command not found
/bin/torsmo-0.18/tweather.sh: line 7: lynx: command not found

heres a hint. _INSTALL LYNX_!!!!pre__ wrote:I have a problem with this one! When I start torsmo bash says :Arainach wrote:**snip**ist that because of the Distribution (Fedora Core 3)? please help!Code: Select all
/bin/torsmo-0.18/tweather.sh: line 7: lynx: command not found /bin/torsmo-0.18/tweather.sh: line 7: lynx: command not found
Code: Select all
${color slate blue}Upcoming birthdays:${color }
${execi 40000 hsbirthdays --noyear -d 21}
$hr
