Saturday, February 9, 2013

Clean Uninstaller for Mac OS X packages

This will automate the uninstallation process of an installed Mac OS X packages [.pkg]. It utilizes the functionalities provided by pkgutil.

#!/bin/bash
# Copyright (C) 2008 Nayanajit Mahendra Laxaman mail: nmlaxaman@gmail.com

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
LOG=/var/log/uninstall.log

#Verify the arguments
if [[ $# -ne 1 ]]
then
 echo "Usage:"
 echo "$0 "
 echo "NOTE:The PKGID should be as in 'pkgutile --pkgs' list."
 echo "Eg:"
 echo "$0 com.apple.pkg.JavaForMacOSX107"
 exit 1
fi

#Check the availability of the package
if [[ $( pkgutil --pkgs | grep "$1" ) == ''  ]]
then
 echo "Package $1 not installed!"
 exit 1
else
 echo "Following package will be uninstalled:"
 pkgutil --info $1
 sudo pkgutil --info $1 >> $LOG
 echo "The files removed will be archived at /tmp/$1.tar"
fi

#Confirm UNINSTALLTION
echo -n "Proceed with UNINSTALLTION [y/N]:"
read ans
if [[ $ans == 'y' || $ans == 'Y' ]]
then
 echo "Uninstalling $1"
else
 echo "Uninstalltion aborted!"
 exit 0;
fi

#Do it from root
cd /

#Generating the list of files
FILES=$(pkgutil --only-files --files $1 | tr '\n' ' ' )
sudo echo $FILES >> $LOG

#Generating the list of directories
DIRS=$(pkgutil --only-dirs --files $1 | tr '\n' ' ')
sudo echo $DIRS >> $LOG

#Archive  all the files
echo "Creating archive at /tmp/$1.tar ..."
tar -cf /tmp/$1.tar  $FILES

echo "Deleting files ..."
for file in $FILES
do
 if [[ $(pkgutil --file-info $file | grep pkgid | wc -l) -ne 1 ]]
 then
  echo "$file is used by another package and not removing!"
 else
  sudo rm -f $file
 fi
done

echo "Deleting dirs ..."
for dir in $DIRS
do
 if [[ $(pkgutil --file-info $dir | grep pkgid | wc -l) -ne 1 ]]
 then
  echo "$dir is used by another package and mot removing!"
 else
  sudo rm -fr $dir
 fi
done

#Forgetting the package from pkg database
echo "Forgetting the package $1..."
sudo pkgutil --forget $1

Sunday, July 15, 2012

Ubuntu 12.04 install ffmpeg with amr support

1)Install the source package
apt-get source ffmpeg


2) install dependencies to build the package
apt-get build-dep ffmpeg


3) Install dependencies for custom options (confflags)
apt-get install libopencore-amrnb-dev libopencore-amrwb-dev

4) ffmpeg is on of the components of libav so apt-get source ffmpeg will create /usr/src/libav-0.8.3 with the source so cd to that location
cd /usr/src/libav-0.8.3

4) change confflags to enable some extra options for ffmpeg
vim debian/confflags
add following lines in '# Common configuration flags' section
confflags += --enable-libopencore-amrwb
confflags += --enable-libopencore-amrnb
confflags += --enable-version3

5) Build the package
dpkg-buildpackage -rfakeroot -uc -b

6) Install the resulting deb package(s)
cd /usr/src
dpkg -i ffmpeg_0.8.3-0ubuntu0.12.04.1_all.deb

7) Using ffmpeg to convert mp3 to amr
ffmpeg -y -vn -i in_file.mp3 -y -acodec libvo_amrwbenc -ac 1 -ar 16000 -ab 7.4k -f amr -map_metadata  -o out_file.amr

Friday, July 13, 2012

Generate wallpaper slideshow xml for gnome/Unity


#!/bin/bash

start='<background><starttime><year>2009</year><month>08</month><day>04</day><hour>00</hour><minute>00</minute><second>00</second></starttime>';
end='</background>';
static='<static><duration>1000.0</duration><file>%s</file></static>';
transition='<transition><duration>5.0</duration><from>%s</from><to>%s</to></transition>';

echo $start
echo
prev_file='';
ls | grep -i -e .jpg -e .png | while read line
do
   file=$PWD/$line;
   if [[ $prev_file == '' ]]
   then
      printf $static "$file";
      echo
   else
      printf $transition "$prev_file" "$file";
      echo
      printf $static "$file";
      echo
   fi
   prev_file=$file;
done
echo $end

1) In ubuntu precise the xml which provides the wallpaper slideshow is located here
/usr/share/backgrounds/contest/precise.xml

2) In order to create your own xml file you have to cd to the directory which contains the images and run this script and recirect the output to an xml file

3) After createing the xml file (eg: myshow.xml) backup the original file comes with precise and replace the newly created file to its place with the same name (precise.xml)

4) Go to system settings > appearance and select your slide show there

NOTE: make sure to keep your image filenames without spaces or use following script to replace spaces with underscores

#!/bin/bash

ls | grep '[a-zA-Z0-9]\ [a-zA-Z0-9]' | while read line
do
mv "$line" $( echo $line | sed s/' '/'_'/g )
done

Wednesday, June 6, 2012

How to retrieve contacts from android CWM backup

1) Connect the phone to PC in USB storage mode and get the data.img from the cwm backup
 cp /media/clockworkmod/data.img . 

2) compile and build unyaffs which is need to retrieve the files from data.img 
download unyaffs.c, unyaffs.h from http://code.google.com/p/unyaffs/downloads/list 
wget http://unyaffs.googlecode.com/files/unyaffs.c
wget http://unyaffs.googlecode.com/files/unyaffs.h
gcc -o unyaffs unyaffs.c 
unyaffs data.img 

3) after extracting the image browse the contact database location
cd data/com.android.providers.contacts/databases 

4) use sqlite3 command line client to read the table of contacts 
sqlite3 contacts2.db 
sqlite> select number,name from view_v1_phones;

Wednesday, June 2, 2010

Light weight gnome mac os x leopard look & feel (for Debian sid and other compatible)


Themes and fonts
imetal gtk+metacity theme
MacUltimate_Leopard icon theme
Lucida Grande, Bitstream Vera fonts

deb packages
xcompmgr
docky
cairo-clock
gnome-applet-globalmenu
REPO: deb http://ppa.launchpad.net/globalmenu-team/ppa/ubuntu/ lucid main
deskbar-applet

apt-get install  xcompmgr docky cairo-clock gnome-applet-globalmenu deskbar-applet


add xcompmgr docky cairo-clock to 'Startup Applications'

xcompmgr could start with:
xcompmgr -c -I 0.02 -O 0.02 -D 3  -f -F -r 15 -o .3 -l -18 -t -18
for more beauty...

add gnome-applet-globalmenu and deskbar-applet to your panel

Tuesday, April 28, 2009

[solved] PROLINK PHS100 HSDPA workout for Debian lenny and Ubuntu intrepid


* check wethre system is up-to-date ( apt-get update && apt-get upgrade)
1. wget http://www.draisberghof.de/usb_modeswitch/usb_modeswitch-0.9.7.tar.bz2
2. tar xjvf usb_modeswitch-0.9.7.tar.bz2 && cd usb_modeswitch-0.9.7 && make install
3. Edit /etc/usb_modeswitch.conf and add following section (similar to iCON 210 section) to end of the file
########################################################
# Option PROLINK PHS100
#
# Contributor: laxaman

DefaultVendor= 0x1e0e
DefaultProduct= 0xf000

TargetVendor= 0x1e0e
TargetProduct= 0x9000

# Not really necessary because IDs of target device are different
TargetClass= 0xff

MessageEndpoint=0x1
MessageContent="555342431234567800000000000006bd000000020000000000000000000000"

ResponseEndpoint=0x1


4. Create /usr/sbin/prolink_hsdpa.sh with the content given bellow and make it executable (chmod +x /usr/sbin/prolink_hsdpa.sh)
#!/bin/bash
# Copyright (C) 2008 Nayanajit Mahendra Laxaman mail: nmlaxaman@gmail.com

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

PATH=/usr/bin:/bin:/usr/sbin:/sbin
modprobe -r usbserial
sleep 1
modprobe usbserial vendor=0x1e0e product=0x9000


5. Create /etc/udev/rules.d/45-prolink_hsdpa.rules with the content given bellow
# Copyright (C) 2008 Nayanajit Mahendra Laxaman mail: nmlaxaman@gmail.com

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.


ACTION=="add", SUBSYSTEMS=="scsi", DRIVERS=="sr", \
ATTR{manufacturer}=="PROLINK ", \
RUN:=""

SUBSYSTEM=="usb", SYSFS{idProduct}=="f000", SYSFS{idVendor}=="1e0e", \
RUN:="/usr/sbin/usb_modeswitch"

SUBSYSTEM=="usb", SYSFS{idProduct}=="9000", SYSFS{idVendor}=="1e0e", \
RUN:="/usr/sbin/prolink_hsdpa.sh"


6. Thats it now you can plug your PROLINK PHS100 hsdpa dongle you will see some devices in /dev/ such as ttyUSB0 ttyUSB1 ttyUSB2 ttyUSB3 ttyUSB3 will the working one for data connection

7. You can use wvdial to dial your connection. If you don't have wvdial then install it (apt-get install wvdial). copy following content to /etc/wvdial.conf and type wvdial in your terminal to connect.


[Dialer Defaults]
Modem = /dev/ttyUSB3
Baud = 1843200
Modem Type = Analog Modem
Init2 = ATZ
Init3 = ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0
Init4 = AT+CGDCONT=1,"IP",""
Dial Command = ATDT
Phone = *99***1#
Username = ''
Password = ''
Stupid Mode = yes

Intel Corporation XMM7360 LTE Advanced Modem in ArchLinux

The required packages are available in ArchLinux User Repository (AUR) so it will be easier if you can use an AUR helper package like yay . ...