ACPI Fan Problem After Suspend to Ram on Ubuntu 10.10

March 14, 2011 in Linux / Programming Notes by Christian

This is just a summary of my trials in solving this problem on my new laptop running Ubuntu 10.10

Description of problem: When I would close the laptop which would put it into suspend mode, and then open it up later to resume the fan would run at a high and annoyingly loud speed for no apparent reason. I know very little of ACPI but I hacked my system based on the helpful dialog on an Ubuntu bug post #77370 @ https://bugs.launchpad.net/ubuntu/+source/acpi/+bug/77370 , thanks guys.

So here’s what I did:

If you run:  cat /proc/acpi/fan/FAN*/state you will get a list of on/off states for the fan based on set points that can be seen with: cat /proc/acpi/thermal_zone/CPUZ/trip_points
What I had to do in essence is change the states to turn the fans to low speed or off and then for reasons I don’t have any idea about the proper functioning seems to take over and work fine. I used this little snippet of code to create the echo statements needed to set the states. The output ends up in /tmp/fanstate0 and /tmp/fanstate3 . If I then run the command sh /tmp/fanstate3 than the fan will slow way down.

for x in /proc/acpi/fan/*; do
if [ -f "$x/state" ] && [ "`grep off $x/state`" ]; then
echo "echo -n 0 > $x/state;" >> /tmp/fanstate0;
echo "echo -n 3 > $x/state;" >> /tmp/fanstate3;
fi;
done

In order to automate the process I had to create the file /etc/pm/sleep.d/99fanfix and put in the following code:

#!/bin/sh
#
# 99funguj: sprav co se da
case "$1" in
hibernate|suspend)
# Stopping is not required.
;;
thaw|resume)
# sprav to
for x in /proc/acpi/fan/*; do
if [ -f "$x/state" ] && [ "`grep on $x/state`" ]; then
echo -n 3 > $x/state;
echo -n 0 > $x/state;
fi
done
for x in /proc/acpi/fan/*; do
if [ -f "$x/state" ] && [ "`grep off $x/state`" ]; then
echo "echo -n 0 > $x/state;" >> /tmp/fanstate0
echo "echo -n 3 > $x/state;" >> /tmp/fanstate3
fi
done
sh /tmp/fanstate0
sleep 1
sh /tmp/fanstate3
rm /tmp/fanstate0
rm /tmp/fanstate3
;;
*) exit $NA
;;
esac

So far it seems to have solved the problem for now.

Other useful commands discovered in the process:

dmidecode   — outputs info about memory banks, battery, cpu etc.

lspci   — ouputs info about the devices connected to the pci buss.

cat /proc/acpi/thermal_zone/CPUZ/temperature

cat /proc/acpi/thermal_zone/CPUZ/trip_points

acpi -V   — acpi info.

sensors  — temp sensor outputs

Sauerbraten Lan Server Setup

March 13, 2011 in Linux / Programming Notes by Christian

After installing sauerbraten-server this is the command I ran to start the server.

sauerbraten-server -nTHEBIGGAME -c5 -mmasterserver

Fixing sound loss problem with youtube on ubuntu

January 16, 2011 in Linux / Programming Notes by Christian

I got this info from this website: http://www.ivankristianto.com/os/ubuntu/tips-solving-ubuntu-sound-problem-without-restart/440/

Here are the condensed steps.
1. Open your shell and find all process that currently using sound with this command:
lsof | grep pcm

2. After you get all proceess with the proceess id, kill all that process with this command:
kill -9

3. Restart ALSA (Advanced Linux Sound Architecture) driver with this command:
sudo /etc/init.d/alsa-utils restart

I think this could be automated into a single script with one command.

Use Id3 tags to rename mp3′s

November 27, 2010 in Projects by Christian

This is a use at your own risk bash script I wrote to grab the artist and title from an mp3′s id3 tags using exiftool. The script prompts the user to decide it they want to keep the old file name or rename it with the format: -.mp3.

I’ve written a lot of shell scripts but never posted one for others to use so, users, ye be warned!
Be sure to leave a comment it you try it out, I’d love to get some feedback on this. Thanks.

Here’s a listing of my script:

#!/bin/bash

# id3_convert.sh — Written by Christian Benedict — 11/27/2010
# Dependencies — exiftool, .mp3 files only at this time
# Check if $1 begins with “-” than translate it as a parameter. -f file mode (default), -d directory mode, -n no prompt to skip empty id3 files, –help
# I may add ability to edit id3 artist and title in the future.

SAVEIFS=$IFS
$IFS=$(echo -en “\n\b”)
convert() {
filetoconvert=$1
echo “Old File Name: “$filetoconvert
titlestring=`exiftool -title “$filetoconvert” `
artiststring=`exiftool -artist “$filetoconvert” `

artist=`echo $artiststring | awk ‘{ $1 = “” ; $2 = “” ; print }’`
title=`echo $titlestring | awk ‘{ $1 = “” ; $2 = “” ; print }’`
# remove leading and trailing white space
artist=`echo $artist | awk ‘{gsub(/^[\t]+|[\t]+$/,”");print}’`
title=`echo $title | awk ‘{gsub(/^[\t]+|[\t]+$/,”");print}’`

# Log a list of files with no id3 tag info. Maybe make the script interactive or with an interactive option to decide re-name Y/N .

newname=”$artist-$title.mp3″
echo “New File Name: $newname”
if [ -n "$artist" ] ; then
echo
echo -n “Rename (r), Skip (s) or Quit (q):”
read RENAME
echo
if [ $RENAME = "r" ] ; then
echo “Renaming File: $filetoconvert –> $newname”
mv “$filetoconvert” “$newname”
sleep 1
clear
else
if [ $RENAME = "q" ] ; then
echo “You quit early”
echo
exit
fi
echo “Skipping $filetoconvert”
sleep 1
clear
fi
else
echo
echo “Insufficient id3 info to build new file name. – ENTER to skip and continue.”
read skip
clear
fi
}

clear

if [ -n "$1" ] ; then
echo
filetoconvert=$1
convert “$filetoconvert”
else
yn=” ”
echo “File name not specified. Do you want to switch to directory read mode? y/n”
read yn
if [ "$yn" != "y" ] || [ -z "$yn" ] ; then
echo ; echo “Goodbye” ; echo
exit
else
clear
for musicfiles in *.mp3
do
echo “Current Directory Read Mode”
echo
filetoconvert=$musicfiles
convert “$filetoconvert”
done
fi
fi

echo “FINISHED”
IFS=$SAVEIFS

Open source software to check out…

March 24, 2010 in Linux / Programming Notes by Christian

Here are a few open source programs that look promising. I’ll try to add comments as I try them out.

rosegarden – midi software

fluidsynth – midi

blender 3D – 3D animation software

stopmotion – stopmotion video creator

ardour2 – audio production

hydrogen – drum machine

Helpfull Linux Commands and Info

March 21, 2010 in Linux / Programming Notes by Christian

These are some quick references to commands that I use more or less frequently. These are not complete explanations by any means, please check the official documentation for details on usage. This is more of a quick reference / memory jogging reference.

tail -f — continues to show file (as it is changed)

wmmon — system monitor applet

tar xvf — extract

tar cvf — create

netcfg — network configurator (graphical)

ls -l | grep ‘^d’ — will display only directories

ifconfig — see what the ip address is set to

makewhatis — builds man pages so -k can be used

linuxconf — graphical configuration utility

chmod u+s allows the file to be executed as root by any user

tksysv — runlevel editor – edits /etc/rc.d/ files

env — display environment vars

set — display all vars including local and env

echo $SHELL — displays which shell you are currently using

VI search and replace in whole file — :%s/search_string/replace_string/g
Removing ^M in dos/win source files — :%s/^M//g to make the escape char you need to hit v then m

encryption tool — bcrypt with only file argument encrypts file and adds .bfe extension, if .bfe is argument it decrypts file.

04-13-10 Info taken from nmap.org
nmap A port scanning network utility program (very powerfull)

nmap -sP 195.168.1.0/24 scans network for hosts that are online.

nmap -sS -A 195.168.1.5 shows details for this ip address.

The struggle to plan and prioritize

March 17, 2010 in Projects by Christian

Prioritize a plan to not spend all your time working! Reduce debt and re-occurring expenses so that your financial “need” base is as low as possible, save and then spend what you save using good stewardship principals. You can have financial PEACE!

What are your thoughts??

php condition and loop short tags

March 17, 2010 in Wordpress Howto and Help by Christian

Feel free to put a short explanation of short tags here for those semi familiar with php.

Freedom??

February 25, 2010 in Uncategorized by Christian

“A government big enough to give you everything you want, is strong enough to take everything you have.” -Gerald Ford

“The democracy will cease to exist when you take away from those who are willing to work and give to those who would not.” -Thomas Jefferson

Welcome!

February 24, 2010 in Uncategorized by Christian

[vslider]

Welcome to the website of CIRTECH Enterprises. CIRTECH Enterprises is the central organization that is at the core of all of my technology and business ventures and plans.