Wednesday, June 26, 2013

The KDE mess


How KDE infactuation messed my desktop

After much adieu and drool about MINT KDE15, I was tempted to try KDE desktop and installed it
sudo add-apt-repository ppa:kubuntu-ppa/backports
sudo apt-get update && sudo apt-get install kubuntu-desktop
sudo apt-get upgrade && sudo did apt-get update

KDE did comeup well, but my Cinnamon, GNOME and Mint got totally messed up. This meant that the default display manager became kdm and all other display managers - gdm, mdm, lightdm were messed up by something that happened during the installation. All attempts to fix it did not help. The only choice I thought I was left with was to reinstall the OS. But then I have done that so many times in the past, I was not excited anymore to do that. Instead I thought how about removing KDE-Desktop and get back to how things were before. Well, its's much easily said than done. Here's what I did to start with

sudo service lightdm start

Tried to manually start lightdm. That did not help a bit. It was an endless wait.

After much adieu and drool about MINT KDE15, I was tempted to try kde desktop and installed it
sudo add-apt-repository ppa:kubuntu-ppa/backports
sudo apt-get update && sudo apt-get install kubuntu-desktop
sudo apt-get upgrade && sudo apt-get update

KDE did comeup well, but my Cinnamon, GNOME and Mint got totally messed up. This meant that the default display manager became kdm and all other display managers - gdm, mdm, lightdm were messed up by something that happened during the installation. All attempts to fix it did not help. The only choice I thought I was left with was to reinstall the OS. But then I have done that so many times in the past, I was not excited anymore to do that. Instead I thought how about removing KDE-Desktop and get back to how things were before. Well, its's much easily said than done. Here's what I did to start with

sudo service lightdm start

Tried to manually start lightdm. That did not help a bit. It was an endless wait.


Opened the file /etc/x11/default-display-manager and manually det the default display manager to gdm

All hell cut loose and the system won't show me even the login screen now. After a ,couple of re-start, even KDM would not start. Now this was the worst point and I was totally struck. So I logged in to the command prompt mode and wanted to reconfigure lightdm and here's what I did

sudo dpkg-reconfigure lightdm
sudo apt-get upgrade && sudo apt-get update

That did help a bit. Now I was able to login to a default session and things started to get better, but still my gdm and mdm were not working. So I decided to totally remove gdm, mdm, kdm and reinstall what I wanted

sudo gnome-session quit #logout from the current session
sudo apt-get purge gdm
sudo reboot

sudo apt-get --purge remove kubuntu-desktop
sudo apt-get autoremove
sudo apt-get install gdm
sudo apt-get upgrade && sudo apt-get update
sudo dpkg-reconfigure gdm

Nope, this also did not help. The only choice I had was to manually remove every kdm package

#Remove all KDE and QT packages individually
sudo apt-get remove $(dpkg --get-selections | grep kde | awk '{ print $1 }')
sudo apt-get remove $(dpkg --get-selections | grep qt | awk '{ print $1 }')
# Remove the bin, if it was left hanging around
sudo apt-get remove kdebase-bin
# make sure you root the entire family out
sudo apt-get autoremove

sudo reboot

Now you are safe and finally, back to sane world. Hope this helps you guys too

Customize Linux Mint


Linux Mint customization
Some of the customizations I do

If Cinnamon theme is installed, I open Cinnamon "System settings". Browse into Themes and download more custom themes. These are the following themes I downloaded
1. Adwaita Classic
2. Ambiance Minty
3. Dark void
4. Elegance
5. Minty
6. Spearmint
7. Void
8. White Aqua
9. Zorin
10. Cinnamon classic

I prefer "void", Minty and Cinnamon Classic, although I love all of the above themes

If you want to install a theme manually, here's how you do it.
1. Download the theme of your choice from http://cinnamon-spices.linuxmint.com/themes
2. Unpack it into a local direcotry
3. Move the unpacked file into ~/.themes
4. Open Cinnamon settings, new theme should show up for selection

e.g. I installed mountain lion theme
cd ~/Downloads
wget http://cinnamon-spices.linuxmint.com/uploads/themes/RXU6-3BU1-D8AG.zip
This command downloaded a file (RXU6-3BU1-D8AG.zip). Now unzip it with command
unzip RXU6-3BU1-D8AG.zip
This would have created a directory "Mountain-Lion" with all files extracted.
Move this directory "Mountain-Lion" into ~/.themes
Open System setting and change you current theme to "Mountain-Lion"

Now that we have the choice of basic themes, out next objkective is to make sure if all of the themes render the way we want it. If you are not happy with the icons in the theme or with the window border, fonts, you can customize each of them for your need. Lets start with start menu

Star Menu
Linux Mint 15 (MATE) Start menu seems to have some weird disappearence issue. I wass not able to find out waht was causing it. That's when moved into Linux Cinnamon. I did not like the Star Menu icon and wanted to change it. Here's how I did it. Downloaded a PNG image of my choice (size 22*22 or 24*24) moved the file into the location /usr/lib/linuxmint/mintMenu/. Right-click on the start menu and select "Menu Settings". Changed the test "Menu" to "Start Linux" and changed the default settings image to the one I downloaded. Job done

Customize a theme
Open "System Settings"
Select a theme
Tap on "Other Settings" tab
Make your customization from the list for controls, window border, icon, mouse pointer and key bindings
I choose "Mint-X" for controls, "Neu" for icons, "eOS" for Window border, DMZ-White for mouse pointer, "Default" for keybindings

/usr/lib/linuxmint/mintMenu/search_engines/ideas.png


Install GNOME 3.8 in Ubuntu/Mint

The first repository is the Gnome 3 Team repo that contains all things missing from Ubuntu’s default repositories. You should add this one before the other two and run the usual update on your system. You can do this by typing the following commands on a terminal:

sudo add-apt-repository ppa:gnome3-team/gnome3
sudo apt-get update
sudo apt-get upgrade
Then you need to add the Ricotz testing repository that contains cutting edge git versions for the shell, gtk, glib, clutter and many Gnome applications and utilities.

sudo add-apt-repository ppa:ricotz/testing
sudo apt-get update
sudo apt-get upgrade
If you want to get some more latest Gnome components and risk the stability of the system even further, then you can use the Ricotz staging repository that can be correctly used only if you added the previous two.

sudo add-apt-repository ppa:ricotz/staging
sudo apt-get update
sudo apt-get upgrade

Setup new OS automatically


Install packages/applications from command prompt
Every once in a while we like to clean our OSs. But the problem doing that is the fear of loosing something you may need that you have not accounted for. If you are going to take a complete backup of your OS and restore it after the new installation, it defeats the cleanup purpose.

What I love to do is backup my data and then reinstall the OS, and through scripts install all the necessary s/w. This way if I miss any s/w I needed, I will know it in advance, and will add it to the list. No clutter in terms of adding garbage s/w.

In addition to the above, I love to try every upgrade that comes along with Mint, Cinnamon, Ubuntu (Unity), Kubuntu. In the process I sometimes mess up my local copy in the process. Hence I decided to put in a script that will automatically reinstall all the needed s/w. Remembering them is not going to help, writing them in a piece of paper is a joke. I save this command in the cloud. Everytime I install Ubuntu in my machine or for someone else, I just run these commands, sit back and relax, until these are done

First things first
Do an upgrade and update as soon as you install the OS. That's the first most important thing you need to do
sudo apt-get upgrade && sudo apt-get update

Install packages you need (I need all of this, if you don't need any of them, feel free to remove)
sudo apt-get install synaptic vlc p7zip-full gimp shutter chromium-browser bluefish wireshark vim calibre mono-complete idle3 idle3-tools eclipse smplayer cheese ruby1.9.3 mongodb monodevelop artha nemo-dropbox


Install Django
sudo apt-get install python-django python-django-doc python-mako python-openstack-auth django-ajax-selects django-filter django-tables python-django-app-plugins python3-dexml

Ruby for Rails
sudo apt-get install rubygems ruby-rails-3.2 rails3 rails-doc ruby-activesupport-3.2 ruby-activeresource-3.2 ruby-activemodel-3.2 ruby-actionpack-3.2 ruby-actionmailer-3.2

Install Aptana Studio for DJango, RoR
cd ~/Downloads
wget http://download.aptana.com/studio3/standalone/3.4.2/linux/Aptana_Studio_3_Setup_Linux_x86_3.4.2.zip
unzip Aptana_Studio_3_Setup_Linux_x86_3.4.2.zip
sudo mv ~/downloads/Aptana_studio_3 /etc/Aptna
sudo ln -s /etc/Aptana/AptanaStudio3 /bin/AptanaStudio

Install Cinnamon
sudo apt-get install cinnamon

Install Skype
sudo dpkg --add-architecture i386
sudo add-apt-repository "deb http://archive.canonical.com/ $(lsb_release -sc) partner"
sudo apt-get update && sudo apt-get install skype

Installing applications manually
Sometimes few applications in LINUX do not come with nice installers .deb, .dpkg. You may have to either download and install them or they may not have any installation piece at all. Copy them over to a directory of your choice and use them. This is the most confusing part for LINUX beginners. Where should I move these applications and how do I make it accessible. There are a lot of ways to do that, I 'll share what I was told by my seniors, and it is up to you to handle things the way you want it

These are some applications you will need as a developer and they may or may not be available in the software center. Like
1. Sublime Text
2. Eclipse
3. JDK
4. ADT for Android development
5. Android SDK
6. Ruby

Each of these will have to be downloaded from http/ftp location. I download all of these and dump them in my Downloads directory
Then extract them into /opt/<<package name>>
Then identify, locate executable, create an alias in /usr/local/bin

Here is an example of the same

Install sublime text
cd ~/Download
wget http://c758482.r82.cf2.rackcdn.com/sublime-text_build-3047_i386.deb
sudo dpkg -i sublime-text_build-3047_i386.deb

Now that was easy, because it was an executable. How about library files, should we do the same. Not really
Take the case of JDK or Android SDK. In this case,
I download the files into ~/Download directory
Unzip them into /usr/local/lib directory

Download an install ADT (32-bit)
cd ~/Downloads
wget http://dl.google.com/android/adt/adt-bundle-linux-x86-20130522.zip
unzip adt-bundle-linux-x86-20130522.zip
sudo mv ./adt-bundle-linux-x86-20130522 /usr/local/lib
cd /usr/local/lib/adt-bundle-linux-x86-20130522/sdk
chmod -R 755 ./tools ./build-tools ./platforms ./platform-tools

Follow the same procedure for both JDK, Android SDK and others

APT for Debian Linux


APT (Advanced Packaging tool) help
apt is the packaging tool used in debian based applications and does a great job in maintaining the repository. It is very important to understand and be comfortable with this packaging tool if you are a command line freak in Debian based world. Here are some command examples of different pieces in apt you may use in the daily worl. This is not the complete list of commands. There are more to it....make sure you read complete manual to get totally comfortable.

Why APT?
APT has proven its worth over the years. It is fast, responsive and stable, but most importantly, it is reliable. Should you lose Internet connection while updating your system or break the current operating, APT will gracefully pick up where you left the next time. Quite a few other management tools tend to remain in a broken state when the update process gets interrupted.

APT will manage the software dependencies in a smart way, both when installing and removing software. This includes maintaining a higher level revision control and topological sorting, in order to make sure your system will remain in a consistent state after numerous updates and uninstallations.

APT has many other smart features, all of which make it a very useful candidate for software management. It is not without a reason among the most popular choices in many Linux distributions.

Search for a package
You wish to know the name of the package you need to use for installation, here's how you do it
apt-cache search vlc

To know more information about a package
apt-cache show vlc

Install a package
apt-get install <<>>

To upgrade your distro
sudo apt-get dist-upgrade

To clean up cache
sudo apt-get clean && sudo apt-get autoclean

To remove a specific package 
apt-get remove <<package name>>

To do a auto remove of all packages, if some of them were not removed properly
apt-get autoremove

Do an update or upgrade
sudo apt-get update && sudo apt-get upgrade

A nice website to read about apt, if you want to know more http://www.dedoimedo.com/computers/aptitude.html

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)