If it won't be simple, it simply won't be. [Hire me, source code] by Miki Tebeka, CEO, 353Solutions

Wednesday, December 30, 2009

Making TeamSpeak 3 work on Ubuntu

 TeamSpeak 3, you can download the Linux client from their site. The only problem is that currently (beta8) the client don't play nice with pulseaudio.

EDIT: Seems like beta-20 is working well with Ubuntu 10.4. Use the ts3client_runscript.sh (make sure you change directory to the TeamSpeak directory first).

After digging in the Ubuntu forums (can't find the exact post link), I came with the following solution:
  • Extract the client (cd /opt && sh ~/Downloads/TeamSpeak3-Client-linux_amd64-3.0.0-beta8.run)
  • Create the following script
#!/bin/bash

# Make teamspeak work on Ubuntu (basically disable pulseaudio before launching)

conf=$HOME/.pulse/client.conf
backup="${conf}.bak"

if [ -f "$conf" ]; then
    mv "$conf" "$backup"
fi
echo "autospawn = no" > "$conf"
pulseaudio --kill

cleanup() {
rm "$conf"
if [ -f "$backup" ]; then
        mv "$backup" "$conf"
fi
    pulseaudio -D
}

cd /opt/TeamSpeak3-Client-linux_amd64/
./ts3client_linux_amd64&
pid=$!
trap "kill -9 $pid; cleanup" SIGINT SIGTERM
wait $pid
cleanup
Good luck! (The other option is to use mumble.)

Tuesday, December 29, 2009

Multi VCS status

Since I use mercurial, git, subversion and sometimes bzr. I use the following script (called st) to find the status of the current directory.

#!/bin/bash

# Repository status

root=$PWD
while [ "$root" != "/" ];
do
if [ -d "$root/.hg" ]; then
hg status
break
fi
if [ -d "$root/.git" ]; then
git status --untracked-files=no
break
fi
if [ -d "$root/.svn" ]; then
svn status
break
fi
if [ -d "$root/.bzr" ]; then
bzr status
break
fi
root=$(dirname "$root")
done

if [ "$root" == "/" ]; then
echo "error: can't find a repository here"
exit 1
fi

Friday, December 11, 2009

Add Subversion files to git

I you need to start a git repository from a Subversion one, and you don't care about history. Then the following should be helpful.

#!/usr/bin/env python

# Add subversion repsotory to a git one
# Run (at top of svn repository)
# git init
# git-add-svn
# git ci -a -m "Initial import from svn $(svn info | grep Revision)"

__author__ = "Miki Tebeka <miki@mikitebeka.com>"

from os import walk
from os.path import join
from fnmatch import fnmatch
from itertools import ifilter
from subprocess import call
from sys import stdout
import re

is_vcs = re.compile("\.(git|svn)", re.I).search

def make_pred(exclude):
def is_ok(name):
return not any((fnmatch(name, ext) for ext in exclude))
return is_ok

def all_files():
for root, dirs, files in walk("."):
if is_vcs(root):
continue
for name in files:
yield join(root, name)

def git_add_svn(exclude):
pred = make_pred(exclude)
for filename in ifilter(pred, all_files()):
print filename
stdout.flush()
call(["git", "add", "-f", filename])

def main(argv=None):
import sys
from optparse import OptionParser

argv = argv or sys.argv

parser = OptionParser("%prog [options]")
parser.add_option("-e", "--exclude", dest="exclude", action="append",
help="extension to exclude")

opts, args = parser.parse_args(argv[1:])
if args:
parser.error("wrong number of arguments") # Will exit

git_add_svn(opts.exclude or [])


if __name__ == "__main__":
main()

Friday, December 04, 2009

Making GMail The Default Email Application On Ubuntu

  • Open System->Preferences->Preferred Applications
  • Change "Mail Reader" to "Custom"
  • Write bash -c 'to="%s"; gnome-open "https://mail.google.com/mail?view=cm&tf=0&to=${to#mailto:}"' in the "Command:" box

Blog Archive