Monday, December 10, 2012

LINUX Links


If you plan to set your foot in LINUX world, out of the love for LINUX or due to hate for other OSs these links can come really handy for you. In the initial days you will need some assistance on basic stuff like how do I set up my WiFi, how to play Flash, or how to upgrade, update, how to change UNity to KDE & vice-versa. As time progesses you will be able to find your way out, but may need information on some esoteric issues like how to build application, do some kernel programming etc. All through the time, one thing is for sure. Access to GEEK community or otherwise called LINUX support group

Here are a few of them I constantly go to
Want information on LINUX kernels, their releases, logs and more such
http://kernelnewbies.org/

If you have specific questions on LINUX feel free to post it here
http://www.linuxquestions.org/questions/
If you need information on any of the Ubuntu families, these may be more than handy
http://www.itworld.com/software/325974/14-most-useful-linux-websites?page=0,3&source=ITWNLE_nlt_today_2012-12-06
http://www.omgubuntu.co.uk/
http://askubuntu.com/

Informative LINUX sites
I love reading the following sites
http://www.linuxtoday.com/
http://lwn.net/
http://www.linux-magazine.com/
This is a wonderful collection for LINUX geeks
http://www.linuxjournal.com/
This site is not as updated as some of the other sites are
http://www.linux-mag.com/

If you are in the LINUX work and is a games breed, here's one for you. There may be many more too. I am not a games person and I have this for the sake of the BLOG. Many people recommended this site to me when I was composing sites for LINUX
http://www.phoronix.com/scan.php?page=home

One of the best location for LINUX how to's and documentation
http://www.tldp.org/

Information on different trpes of dstro's and their download counts etc 
http://distrowatch.com/

Feel free to add more if you think there are some nice sites I missed









Sunday, September 30, 2012

Convert files to .mp4 format - Python Script

We all download videos of our favorite songs, animation, tutorials, movie, dramas from like's of youtube, blip.tv, vimeo etc.This artical is not about how to download these files, I'll reserve that for later. What I am going to tell you is something more intriguing.

Today is the world of gadgets. Our houses have variety of gadgets like iPhone, iPad, iPod, Android music players, Android phones, W8 laptops/tablets (& sometimes) W8 phones too. If you download video from any of these websites the format of the downloaed file is inconsistent. It can be mp4, avi, webm, flv...etc. Give the diversity of devices, it makes sense to have files in one format so as to maintain some consistency in the apps we downoad and use.

ffmpeg is an excellent utility for such conversions. You can install it with the command
sudo apt-get install ffmpeg

To convert (say) .webm file to .mp4
ffmpeg -i some_file.webm my_fav_file.mp4

That was easy, wasn't it? Yep it is. But imagine if you have to convert an entire collection of files. That will be an arduous task. Won't it be better if we could write a simple utility that will convert all files in a directory. Yep, that's where I am heading to. Here's a simple script that will convert .webm files to .mp4. You can easily customize it to convert any other file to .mp4, if you want to

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#  ConvertToMP4.py


#  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.

#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#  MA 02110-1301, USA.


import glob
import os
from optparse import OptionParser

class ConvertToMP4:
    def __init__(self):
        self.webmFiles = []
       
    def get_all_wbm_files_from_directory(self, directory_name):
        print("Scanning directory: " + directory_name)
        if len(directory_name) == 0:
            print('ERROR: Source directory name cannot be NIL/NULL.')
            print('Provide a valid directory name to proceed!')
            return
        os.chdir(directory_name)
        for files in os.listdir('.'):
            if files.endswith('.webm'):
                print('convert file: ' + files)
                self.webmFiles.append(files)

    def convert_wbm_file_to_mp4_file(self):
        # check to see if the list is empty, if not proceed
        if len(self.webmFiles) <= 0:
            print("No files to convert!")
            return
        for webm_file in self.webmFiles:
            mp4_file = webm_file.replace('.webm','.mp4')
            cmd_string = 'ffmpeg -i "' + webm_file + '" "' + mp4_file + '"'
            print('converting ' + webm_file + ' to ' + mp4_file)
            os.system(cmd_string)

def main():
    usage = "usage: %prog -d <source directory for webm files>"
    parser = OptionParser(usage=usage)
    parser.add_option("-d", "--sourcedirectory", action="store",
        type="string", dest="sourcedirectory", default="./",
          help="source directory where all the webm files are stored!")
    (options, args) = parser.parse_args()
    webm_to_mp4 = ConvertToMP4()
    webm_to_mp4.get_all_wbm_files_from_directory(options.sourcedirectory)
    webm_to_mp4.convert_wbm_file_to_mp4_file()
    return 0

if __name__ == '__main__':
    main()

Even better, if you can provide a link to the utility and the utility download's it for you in mp4 format. That will be my next area of work

Audio issues in Ubuntu

I had some issues with the audio controls in my machine. I was not able to figure out what was going on. However after a restart things were back to normal. I was not able to figure out what was going on. The same thing happened one more time logs did not have much information either or may be I was not looking at the right places. However after witnessing this a couple of times, I noticed this was more a sound card issue

Here are some commands that helped me

Open Terminal and type the following command 'alsamixer'
You will be shown the sound card configuration, follow the help, re-configure  and your sound card will be back in action

Alternatively you can use pavucontrol too
sudo apt-get install pavucontrol

Pavucontrol widget makes it easy for you to setup and identify issues like this. Add it to startup application if needed (especially if you are using old computers)

Sunday, August 12, 2012

Xubuntu desktop for Ubuntu

I had long wanted to try XFCE for my Ubuntu. People had always appreciated XFCE for it's simplicity. For starters, post-installation, XFCE can be intimidating. Home screen after login will have nothing, absolutely nothing.

Right-click on the the desktop and create a panel with applets of your choice. Isn't that simple. If you are tired of looking at UNITY and don't like KDE and Ubuntu classic, XFCE is worth an experience to try. It gives a wonderful blend of customization and default behavior.

How to install Xubuntu desktop in Ubuntu12.04

sudo apt-get install xubuntu-desktop

If you did not like what you see, you can get rid of it in 2 ways. Here's how you can remove the items exclusively. You have a choice of cho0sing what you want to remove

Remove Xubuntu desktop completly from ubuntu 12.04
sudo apt-get remove abiword abiword-common abiword-plugin-grammar abiword-plugin-mathview bison blueman brltty-x11 catfish elementary-icon-theme exo-utils flex gigolo gimp gimp-data gmusicbrowser gnome-icon-theme-full gnome-system-tools gnome-time-admin gnumeric gnumeric-common gnumeric-doc gstreamer0.10-gnomevfs gthumb gthumb-data gtk2-engines-pixbuf gtk2-engines-xfce indicator-application-gtk2 indicator-messages-gtk2 indicator-sound-gtk2 indicator-status-provider-pidgin leafpad libabiword-2.8 libaiksaurus-1.2-0c2a libaiksaurus-1.2-data libaiksaurusgtk-1.2-0c2a libao-common libao4 libaudio-scrobbler-perl libbabl-0.0-0 libclutter-1.0-0 libclutter-1.0-common libclutter-gtk-1.0-0 libcogl-common libcogl5 libconfig-inifiles-perl libencode-locale-perl libept1 libexo-1-0 libexo-common libfile-listing-perl libfont-afm-perl libgarcon-1-0 libgarcon-common libgdome2-0 libgdome2-cpp-smart0c2a libgegl-0.0-0 libgimp2.0 libglade2-0 libgnomevfs2-extra libgoffice-0.8-8 libgoffice-0.8-8-common libgsf-1-114 libgsf-1-common libgstreamer-perl libgtk2-notify-perl libgtk2-trayicon-perl libgtkmathview0c2a libhtml-form-perl libhtml-format-perl libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl libhttp-daemon-perl libhttp-date-perl libhttp-message-perl libhttp-negotiate-perl libid3tag0 libido-0.1-0 libilmbase6 libio-socket-ssl-perl libjpeg-progs libkeybinder0 liblink-grammar4 libloudmouth1-0 liblwp-mediatypes-perl liblwp-protocol-https-perl libmad0 libmailtools-perl libnet-dbus-perl libnet-http-perl libnet-ssleay-perl liboobs-1-5 libopenexr6 libotr2 libots0 libpolkit-gtk-1-0 libsexy2 libtagc0 libthunarx-2-0 libtie-ixhash-perl libtimedate-perl libtumbler-1-0 liburi-perl libwv-1.2-3 libwww-perl libwww-robotrules-perl libxfce4ui-1-0 libxfce4util-bin libxfce4util-common libxfce4util4 libxfcegui4-4 libxfconf-0-2 libxml-parser-perl libxml-twig-perl libxml-xpath-perl libxss1 lightdm-gtk-greeter link-grammar-dictionaries-en m4 mpg321 murrine-themes orage parole pastebinit pidgin pidgin-data pidgin-libnotify pidgin-microblog pidgin-otr plymouth-theme-xubuntu-logo plymouth-theme-xubuntu-text python-configobj python-glade2 quadrapassel ristretto screensaver-default-images synaptic system-tools-backends tango-icon-theme tango-icon-theme-common tcl8.5 thunar thunar-archive-plugin thunar-data thunar-media-tags-plugin thunar-volman ttf-droid ttf-lyx tumbler tumbler-common xchat xchat-common xfburn xfce-keyboard-shortcuts xfce4-appfinder xfce4-cpugraph-plugin xfce4-dict xfce4-fsguard-plugin xfce4-indicator-plugin xfce4-mailwatch-plugin xfce4-mixer xfce4-mount-plugin xfce4-netload-plugin xfce4-notes xfce4-notes-plugin xfce4-notifyd xfce4-panel xfce4-places-plugin xfce4-power-manager xfce4-power-manager-data xfce4-quicklauncher-plugin xfce4-screenshooter xfce4-session xfce4-settings xfce4-smartbookmark-plugin xfce4-systemload-plugin xfce4-taskmanager xfce4-terminal xfce4-utils xfce4-verve-plugin xfce4-volumed xfce4-weather-plugin xfconf xfdesktop4 xfdesktop4-data xfwm4 xfwm4-themes xscreensaver xscreensaver-data xscreensaver-gl xubuntu-artwork xubuntu-default-settings xubuntu-desktop xubuntu-docs xubuntu-icon-theme xubuntu-wallpapers && sudo apt-get install ubuntu-desktop

If that is way complicated for you, here are some other alternatives for you
sudo apt-get autoremove --purge xubuntu-* && sudo apt-get autoremove --purge xfce*
sudo apt-get autoremove --purge $( dpkg-query -l *xubuntu* | grep ii | tr -s " " | cut -d" " -f2; dpkg-query -l *xfce* | grep 'ii' | tr -s " " | cut -d" " -f2 )

Fix repository issues in Ubuntu

If you are experimenting on your LINUX PC chances are highly likely that you will mess up your repository. Then on it will be a pain to do an update, either through command line or from synaptic package manager

I am restless with my LINUX box all the time, I am either installing something in it or changing configurations. Quite recently I installed KDM/XFCE to evaluate it for my friend and I somehow seem to have  messed up my environment. Every time I attempted to execute "sudo apt-get update" I'd see the following message. I tried to go around the issue with Synaptic. But Synaptic will throw this error when I open it. So I was sort of struck and I need to get out soon. Here's what I had to do to fix it

Error
.......
.......
Fetched 2 B in 8s (0 B/s)                                                    
W: Failed to fetch gzip:/var/lib/apt/lists/partial/us.archive.ubuntu.com_ubuntu_dists_precise-updates_main_i18n_Translation-en  Encountered a section with no Package: header
W: Failed to fetch gzip:/var/lib/apt/lists/partial/us.archive.ubuntu.com_ubuntu_dists_precise-updates_universe_i18n_Translation-en
E: Some index files failed to download. They have been ignored, or old ones used instead.

Note: Make sure you close Synaptic/package manager before you attempt to do any of this

After a lot of hunt, I creates a simple shell script "fix_update.sh" with the following contents

sudo fuser -vvv /var/lib/dpkg/lock
sudo rm /var/lib/apt/lists/lock
sudo cp -arf /var/lib/dpkg /var/lib/dpkg.backup
sudo cp /var/lib/dpkg/status-old /var/lib/dpkg/status
sudo cp /var/lib/dpkg/available-old /var/lib/dpkg/available
sudo rm -rf /var/lib/dpkg/updates/*
sudo rm -rf /var/lib/apt/lists
sudo rm /var/cache/apt/*.bin
sudo mkdir /var/lib/apt/lists
sudo mkdir /var/lib/apt/lists/partial
LANG=C;sudo apt-get clean
LANG=C;sudo apt-get autoclean
LANG=C;sudo apt-get --purge autoremove
LANG=C;sudo apt-get update -o APT::Cache-Limit=25165824
sudo dpkg --clear-avail
sudo dpkg --configure -a
LANG=C;sudo apt-get -f install
LANG=C;sudo apt-get --fix-missing install
LANG=C;sudo apt-get update -o APT::Cache-Limit=25165824 && sudo apt-get dist-upgrade


Save the file
Grant execute privilege - chmod +x ./fix_update.sh
Execute the script - ./fix_update.sh
VOILA, you are good to go now
Save the file in your home custom scripts directory, it will always be handy

Saturday, August 4, 2012

Trackpad issues in Ubuntu


If you have problems with your trackpad - issues like right-click, drag etc. Out of the box it does not work because Ubuntu sometimes does not recognize that laptop does not have buttons over the trackpad to differentiate left and right-click's.

Here's a way to get around
Open terminal and do the following

If you are using a "samsung" laptop, do the following else skip this step
sudo add-apt-repository ppa:voria/ppa
sudo apt-get install update && sudo apt-get install upgrade
sudo apt-get install samsung-tools
sudo apt-get install samsung-laptop
sudo reboot

In the command prompt type xinput
You should see something like this along with other output

 ETPS/2 Elantech Touchpad                 id=12 [slave  pointer  (2)]

cd ~
wget "http://people.canonical.com/~cndougla/enable-clickpad.sh"
chmod +x enable-clickpad.sh
wget "http://people.canonical.com/~cndougla/enable-rightbutton.sh"
chmod +x enable-rightbutton.sh

Now that you have the scripts that will do the job for you and you have execute permissions set for them, do the following. Parameter 12 is passed to the script. We got the value from xinput  command's output (id=12). If you see some other value than 12 show up in your output, please use that
~/enable-clickpad.sh 12
~/enable-rightbutton.sh 12

Now you should be able to right-click, drag and drop easily without any external mouse.

Well issue now is when you restart your OS, all these changes are gone. You need this functionality all the time. Here's what you may have to do. Move those scripts to /usr/local/sbin directory

/usr/local/sbin/enable-clickpad.sh 12

sudo mv ~/enable-clickpad.sh /usr/local/sbin/
sudo mv ~/enable-rightbutton.sh /usr/local/sbin/

Open .gnomerc through gedit/vim/vi or editor of  you choice and type in the following
gedit ~/.gnomerc
/usr/local/sbin/enable-rightbutton.sh 12


If you don't like a naive .gnomerc file like the one above, feel free to add some error handlers to do things the way you want


That's pretty much it. Now reboot and enjoy

Wednesday, August 1, 2012

Compiz Settings for Ubuntu 12.04


Install compiz config settings manager from Ubuntu Software center

Animations and installations
In order to have support for all the animations of your choice like explode, Magic lamp, burn, 3D cube, etc, make sure you have done the following
sudo apt-get install compiz-fusion-plugins-extra compiz-fusion-plugins-main compiz-plugins

Make sure all of them are installed with out any errors

Wobbly windows
open Compiz Config Settings Manager from HUD or from terminal type "ccsm"
Select "Effects" from Category list on the left side
check on "Wobbly Windows". Make sure the checkbox is selected
Move the windows around you will see the windows wobble

Animation - Open window
open Compiz Config Settings Manager from HUD or from terminal type "ccsm"
Select checkbox against Animations
Select "Animation Add-on"
Click on Animations, that should show you more options for Animations
Select "Open Animations" tab and choose the first item, change the effect to "Leaf Spread"

Animation - Close Window
open Compiz Config Settings Manager from HUD or from terminal type "ccsm"
Select checkbox against Animations
Click on Animations, that should show you more options for Animations
Select "Close Animations" tab and choose the first item, change the effect to "Burn"

Animation - Workspace switcher
open Compiz Config Settings Manager from HUD or from terminal type "ccsm"
Select "Desktop" category from the left side of the settings manager
Select Checkbox "Desktop Cube"
Select Checkbox "Rotate Cube"
Click on "Rotate Cube", this will take you to more settings for "Rotate Cube"
Select Bindings tab choose keys you wish to use for "Rotate Left" and "Rotate Right"

Add compiz in startup
From HUD open "Startup Application"
Click on the Add button
Give it a name "Compiz" and set command as "compiz --replace"

Some common issues with CCSM and fixes
Non-movable windows
open Compiz Config Settings Manager from HUD or from terminal type "ccsm"
Select "Windows Management" from categories in the left
Make sure you have the following choices selected - "Move Window", "Resize Window", "Place Windows", "Extra Windows", "Extra WM Actions", "Window Rules"

Missing Title Bar
open Compiz Config Settings Manager from HUD or from terminal type "ccsm"
Select "Effects" from categories in the left
Make sure "Windows Decoration" is selected

Restart plugin
compiz --replace

Missing Unity
open Compiz Config Settings Manager from HUD or from terminal type "ccsm"
In the Filter search for "Unity"
Select the unity plugin that shows up in teh right
Make sure "Enable Ubuntu PLugin" is selected

Reset to default settings
open Compiz Config Settings Manager from HUD or from terminal type "ccsm"
Select Preferences
Select "Reset to Defaults"