Tuesday, July 27, 2010

Nice New Battery Charger From Apple

Here's a nice little new product from Apple today that you might have missed amongst the other, bigger updates:

Nice, slim AA battery charger that comes with 6 rechargeable AA batteries - not a bad deal!

Monday, July 26, 2010

Quick Volvo A/C Fix

From the quick and dirty hack dept... Many 7xx/9xx Volvos experience the "Fan slows down when accelerating" issue.  What is really happening is not that the fan is slowing down, but that the vacuum servos that control the flaps start leaking.  Since there is little to no vacuum available while accelerating, these cars use a check-valve to ensure that the vacuum available to the climate control vacuum solenoids doesn't leak back out to the manifold during acceleration.  Assuming that the one-way check valve (mounted on the firewall) checks out OK, the most likely culprit is a leaking vacuum servo.  These are located under the dashboard on the drivers side (plus a hard to access one for recirc behind the glove box.)  These are easy to test with a hand-held vacuum pump and gauge.  If the servo doesn't hold vacuum, it's bad.  The one that went bad on mine was the servo with the "double" diaphragm - the only one that has 2 vacuum hoses attached.  This had a orange vacuum hose attached to the side and a blue vacuum hose on top.  The diaphragm that the orange hose connected to was the one that was bad on mine.  All I had to do was plug the hose with a rubber plug, and I'm a happy (and much cooler) camper in this heat.  I did lose the "floor only" fan setting (can only get floor + defrost now,) but for me, that is much better than attempting the extremely labor-intensive operation to replace the vacuum servo.  (Either via the "proper" way that involves removing basically the entire dash, or the "quick" way here: http://www.swedishbricks.net/700900FAQ/Heating-Vacuum%20Servo%20Replacement.htm#Replacing%20Vacuum%20Serhttp://www.swedishbricks.net/700900FAQ/Heating-Vacuum%20Servo%20Replacement.htm#Replacing%20Vacuum%20Servos%20in%20ACC-Equippe%20700/900vos%20in%20ACC-Equipped%20700/900 )  Here's a picture of this quick fix:

...then I just stuck the vacuum line back on the tab on the servo to keep it in place:

Not bad for free and about 30 minutes of testing/removing & replacing panels!

Tuesday, July 13, 2010

Set Up Unison on Ubuntu to Sync 2 Laptops

Unison Sync Between Two Machines Part 1

The problem:

You have two laptops (or desktops, whatever) that you switch between or have multiple users share.  You want your data to sync between the two machines in both directions (you can save a file on either machine and it will sync to the other.)

Answer Number 1:

You can use Ubuntu one if you have less than 2 GB of data to keep up with (or are willing to pay to sync more data.)  Ubuntu One is nice since you can also access the files you are syncing via a web interface.  My biggest problem with Ubuntu One is the sync delay, it seems to sync whenever it feels like it (or sometimes not.)

Answer Number 2:

Unison (http://www.cis.upenn.edu/~bcpierce/unison/) lets you sync directories much easier than setting up rsync, especially in this use case.  (On Ubuntu, installation is as simple as "aptitude install unison".)  There is a graphical UI - you can start it once to create the $HOME/.unison/ directory and $HOME/.unison/default.prf file if you wish, or create those by hand.   (The default.prf file is empty to start with.)  I don't bother with the UI, but it's pretty self explanatory to use if you desire.  Let's say we want to keep our $HOME/Documents/, $HOME/Music/, $HOME/Pictures/, and $HOME/Desktop/ directories synchronized.  Install unison on both machines, then add the following to the $HOME/.unison/default.prf file:

# Unison preferences file
root = /home/alex
root = ssh://

terse = true
perms = -1
owner = true
group = true
times = true
batch = true

path = Desktop
path = Documents
path = Music
path = Pictures

(I would recommend creating some test directories to test all of this with before you use it on any important data.)  Once you've got the default.prf file set up on both machines, all you need to do is run the unison command to sync.  You will want to be sure to run it manually once before running it from CRON or in any other automated way since you'll have to confirm some things.  Automating unison is then as simple as adding a CRON entry such as:

# m h  dom mon dow   command
0 3 * * * /usr/bin/unison 2>&1 >> /home/$USER/.unison/unison_cron.log

Coming up in future parts of this article:
  • Setting up a root CRON for shared or other non-user directories
  • Setting up unison to sync at login and logout on Ubuntu

Thursday, July 1, 2010

Quick Linux Idle Time Hack

Here's an excerpt from a post I made about a bug on the Timekpr project (https://bugs.launchpad.net/timekpr/+bug/306584).  This, or some variation on it could come in handy if you need to keep track of idle time on a Linux X session:

I found the code for an executable named idle at http://coderrr.wordpress.com/2008/04/20/getting-idle-time-in-unix/ - I modified it somewhat to just return the number of seconds of idle time for that display. Here's the C code:

#include <scrnsaver.h>
#include <stdio.h>
main() {
  XScreenSaverInfo *info = XScreenSaverAll
  Display *display = XOpenDisplay(NULL);
  if (display != NULL) {
rQueryInfo(display, DefaultRootWindow(display), info);
    printf("%lu", info->idle/1000);
  } else {
    puts ("error");

I compiled that with the command "gcc -o idle idle.c -lXss" and put the resulting binary in /usr/local/sbin/idle. You call that by first exporting the display that you want to query idle time for as $DISPLAY, then you run idle. For example, say that you have users logged in to displays :5 and :6, then you can run the following commands (as root):

export DISPLAY=:5.0;/usr/local/sbin/idle
export DISPLAY=:6.0;/usr/local/sbin/idle

to find the number of seconds that those users have been idle (no keyboard/mouse activity.) For timekpr, what we really need to find are the users that are active (the normal users command returns all users that are logged in, active or not.) For this, I wrote a shell script and put that in /usr/local/sbin/active_users.sh - here's the code for that:

if [ "$(id -u)" != "0" ]; then
   echo "This script must be run as root" 1>&2
   exit 1
for i in `w | grep tty | awk '{print $2 $3 ":" $1}' | sed 's/^tty[0-9]*\://g'`; do
    display=`echo $i | awk -F ':' '{print $1}'`
    user=`echo $i | awk -F ':' '{print $2}'`
`export DISPLAY=$display;/usr/local/sbin/idle`
    case "$1" in
      echo "$user is on display $display with idletime $idletime"
            if [ $idletime -lt 10 ]; then
      echo -n "$user "

As root, when you run /usr/local/sbin/active_users.sh, you will get only a listing of users that are currently active (in a gnome session only - this doesn't help you are trying to limit time for ssh users...)