Slackware 12.1 Follow-Up

To start… My priority was to get my laptop to work at full capacity. So I immediately worked on building the CPU Frequency Daemon. This required me to build the CPU Frequency Utilities. I built versions 2.2.1 and 003 respectively. I have links for the Slackpacks and the bottom of this page. Once I was finished building these, I had to set up my config file for the daemon.

Below is the pertinent sections out of my config file, although you will want to read through the documentation so you can make sure it is set up the way you want.

[code=’xml’]
[Profile]
name=On Demand High
minfreq=600000
maxfreq=1600000
policy=ondemand
[/Profile]

[Profile]
name=On Demand Low
minfreq=600000
maxfreq=1000000
policy=ondemand
[/Profile]

[Profile]
name=Performance High
minfreq=1600000
maxfreq=1600000
policy=performance
#exec_post=echo 8 > /proc/acpi/sony/brightness
[/Profile]

[Profile]
name=Powersave Low
minfreq=600000
maxfreq=600000
policy=powersave
[/Profile]

# Full Power when plugged in
[Rule]
name=AC Rule
ac=on                    # (on/off)
profile=Performance High
[/Rule]

# conservative mode when not AC
[Rule]
name=AC Off – Low Battery
ac=off                   # (on/off)
battery_interval=0-20
profile=Powersave Low
[/Rule]

# conservative mode when not AC
[Rule]
name=AC Off – Medium Battery
ac=off                   # (on/off)
battery_interval=20-50
profile=On Demand Low
[/Rule]

# stay in performance mode for the first minutes
[Rule]
name=AC Off – High Power
ac=off                   # (on/off)
battery_interval=50-100
profile=On Demand High
[/Rule]
[/code]

I was unable to get the default compiz to run without crashing the system. I then figured I would try to get the newer compiz-fusion (CF) installed. I grabbed some packages from here. Installed everything and went to try to get compiz fusion to run.

[code=’bash’]
compiz –loose-binding  –replace   ccp  &
kde-window-decorator –replace&

fusion-icon &
sleep 10
[/code]

I put that in my ~/.kde/Autostart directory and restarted KDE. Almost everything seemed to work except for the multiple desktops. Whatever KDE was set to CF would quadruple that number. So if KDE was set for one desktop, CF would show four, but only one would be usable. With the default on Slackware being 4 desktops, with CF it would show 16 desktops. I read quite a few things online to try and fix this and nothing worked. CF isn’t a big deal to me, I mainly wanted it to show off to other people. As such, I didn’t try very hard to fix this.

Now that KDE 4.1 is out, I would love to give it a shot, but so far I have been unable to find any packages that will co-exist with KDE3. One of these days, I may decide to build it all myself, but I have never built a window manager before.

The last big thing for me is to set up the synaptics driver. The mouse still works, but I like the extra features that the synaptics driver provides. I ended up building the with the aid of SlackBuilds, due to the need of a patch to be able to build it with the current xorg. All the files needed were located there. Once I built and installed the driver, my mouse stopped functioning in KDE. After a lot of digging around, I ended up needing to comment out the last line in the file /etc/modprobe.d/psmouse. I think you could probably just delete the file, but that is up to you. Now I just needed to set up the X options so I could use the scroll and the various other options it provides.

[code=’xml’]
Section “InputDevice”

# Identifier and driver

Identifier    “Mouse1”
Driver      “synaptics”
Option     “Device”      “/dev/mouse”
Option    “Protocol”    “ps2”
Option    “LeftEdge”      “1700”
Option    “RightEdge”     “5300”
Option    “TopEdge”       “1700”
Option    “BottomEdge”    “4200”
Option    “FingerLow”    “25”
Option    “FingerHigh”    “30”
Option    “MaxTapTime”    “180”
Option    “MaxTapMove”    “220”
Option    “VertScrollDelta” “100”
Option    “MinSpeed”    “0.09”
Option    “MaxSpeed”    “0.18”
Option    “AccelFactor”    “0.0015”
Option    “SHMConfig”    “on”
#   Option    “Repeater”    “/dev/ps2mouse”

EndSection
[/code]

Just make sure you load the synaptics driver in the modules section.

[code]Load “synaptics”[/code]

Now come the various packages.
cpufreqd-2.2.1-i486-1_SBo.tgz
cpufrequtils-003-i486-1_SBo.tgz
synaptics-0.14.6-i486-3_SBo.tgz

For the compiz-fusion packages, they can be located here, but you can get them all and install them with these commands:

[code=’bash’]
mkdir compiz-fusion
cd compiz-fusion
wget -rnd http://bassmadrigal.com/packages/compiz-fusion/
installpkg *tgz
[/code]

Bash Thumbnailer Script with Imagemagick

A while ago, I was working on creating a script to create thumbnails of all the pictures I had taken so I could put them up on my personal site for family/friends to view. It started out as a very basic script but as I developed my website, I found new ways to display the photos. Namely using css for the image to come up double sized by mousing over on the picture. Well this created quite a challenge to put all the code for my pictures in the HTML. So I went a step further and adjusted the script to create the php necessary for the galleries. The way I create all my pages is to use a standard header and footer file and include them into my individual pages. So I then changed the script so it created a full blown page ready to be used. The script is below. You may have to modify it slightly for your own needs, but it should work fine. The main requirement is the imagemagick software. In Slackware it is included with the default install. With your own distro you may need to add it yourself.

[code=’bash’]
#!/bin/bash

echo “Resizing Pictures and Creating PHP”
mkdir thumbs previews view
cp ../rhine-river/view.php .
cp ../rhine-river/download.php .

totalcount=0
currentcount=0

if [ $1 = y ]
then
name=$2
picnum=0
for i in *.jpg *.JPG; do

picnum=$(($picnum + 1))

pic=`echo $i | awk -F . ‘{print $1}’`
rename=”${name}-`printf “%03d” $picnum`.jpg”
mv “$i” $rename

done
fi

for i in *.jpg; do

totalcount=$(($totalcount + 1))

done

echo “There are $totalcount pictures to convert.”

# Create the header
echo \<\?php > index.php
echo \$pagetitle \= \”Insert Title Here\”\; >> index.php
echo include_once\(\”../../includes/header.php\”\)\; >> index.php
echo ?\> >> index.php
echo \Page Description Here\ >> index.php
echo \

Disabling Secondary DNS Server in DD-WRT for OpenDNS

I recently read a blog post on the How-To Geek about setting up OpenDNS and the options it gives you to secure your internet browsing. I have found I love the OpenDNS service and the filtering control it gives me. But I tend to try and fight the system. Rather, I try to figure out ways to bypass the filtering service. This way I can find out ways that others would be able to get around services I set up.

Well OpenDNS is fairly straightforward. You add their DNS Server IP’s to your static IP’s in your router, then any computer behind that router will automatically use those DNS servers. So what if you were to change the DNS servers on your local machine? It would bypass your router for those queries and in turn bypass OpenDNS. This doesn’t cut it for me. It is way to easy to change that, and enough people know how to change their IP settings that this is too unsecure for me. So I did some research online and found an easy way to bypass that. Block port 53 on your router.  Some routers may not have this functionality by default, so I can highly recommend checking out if your router is supported by DD-WRT. They support quite a few routers, and I personally love their firmware.

Since I am running DD-WRT that is what this guide will be based on, but it should apply for any router based on linux that you can have it run your own code.

Once you login into your router, go to Administration -> Commands.
From here you just need to paste this in:

[code]iptables -I FORWARD 1 -p tcp –dport 53 -j DROP; iptables -I FORWARD 2 -p udp –dport 53 -j DROP[/code]

Then at the bottom hit the Run Command button. This should block any attempts for the computer to go to another server to resolve names.

This should apply to any router that uses iptables and allows you to run your own code. This is also able to be done through ssh/telnet if your router supports it.

OpenDNS Dynamic IP Update Script through Linux

I recently read a blog post on the How-To Geek about setting up OpenDNS and the options it gives you to secure your internet browsing. They have quite a few filtering options including Phishing sites, along with blocking adult-related sites, and about 50 other categories along with a fully redundant DNS nameserver resolving. I decided to try it and set it up on my home network. The problem is that if you have an internet provider that provides you with a dynamic IP (IP address changes occasionally, if you aren’t sure what you have you probably have a dynamic address), you need to update the IP with OpenDNS. They have a lot of clients out there to do it, but as far as I found there were no linux clients. So I created a short linux script to do just that.

[lang=’bash’]#!/bin/bash

# Copyright (C) 2006 Jeremy Brent Hansen
#
# These are for your OpenDNS username and password. At this time, I do
# not know how to hide this info, so you will need to make sure you have the
# correct file permissions.
username=your_opendns_username
passwd=your_opendns_password

# This is where the log file will be stored. Currently it only logs the current IP
# and the response back from OpenDNS. The log will keep one backup. I
# just used a folder in my home directory (make sure the folder exists).
log_dir=~/.opendns

# Revolves the log file. Keeps one backup.
mv $log_dir/log $log_dir/log.1

while [ 1 ]
do

date >> $log_dir/log
/usr/bin/curl -i -m 60 -k -u $username:$passwd ‘https://updates.opendns.com/account/ddns.php?’ -silent >> $log_dir/log
echo -e “\n” >> $log_dir/log

# Resends the info after 5 minutes. Eventually I plan on changing it,

# so it only updates when your IP changes.
sleep 600

done[/lang]

So, there you have it. No root permissions are required, so I just have it in my .profile for my normal user. Just run it with the & at the end, so it will background the process.