9:18 PM

A beautiful header for your Arch Linux!!!


While checking at the various images of Arch Linux KDE, the Arch headers on most terminals caught my eyes. I searched the net for the same so that even my terminal would look geeky!! The one I found was Archey which is available at AUR.https://aur.archlinux.org/packages/archey/ The Archey is a python script that could print the header on your terminal upon installation. I thought of tweaking the same or building a new one. The problem was with designing the logo. So I got into the Archey files and copied the code for generating the logo. And within minutes with my little codes the Arch header with Arch Linux logo and basic system information was up. Thought of sharing the same. Hope that it may be useful to some one.
Happy Hacking!!!



     The script for the header

9:46 AM

My girl.......


In love with Arch Linux.... <3

systemd kde4 3.6.9 kernel.......




3:44 AM

systemd : faster way to boot you system.


The systemd is a new addition to the linux system which is a replacement to the older initscripts. In earlier versions of arch linux (and on all other distros) the various daemons where started sequentially in the order in which the occure in the deamon array in rc.conf file. The systemd is an agressive parallization technique to start various deamons thus reducing you boot up time.Today I tried systemd and it was good.The system booted in less than 10 sec.

The arch community has dropped their support to the older method and insist users to use only systemd. So I gave it a try. The newer installtions come with systemd by default.

systemd can be installed by pacman -S systemd. Once installed the system can be booted using systemd by adding kernel parameter as /usr/lib/systemd/systemd

The systemd provides various tweaking facilites.

for example systemd-analyze returns the boot time of the system

systemd-analyze blame provides a verbose output of time taken by various services.

A simple graph can be ploted as
systemd-analyse plot tem.svg
eog tem.svg to view the graph.

More tips can be found at http://freedesktop.org/wiki/Software/systemd

8:26 AM

Small brightness tweak on laptop....


It was very hard trying all these days to fix the brightness controll on dell xps15.Finally got it corrected....The ACPI controlls the brightness in your laptop wich can be tweaked through a simple file in the folder

    /sys/class/backlight

The folder contains a number of subfolders like acpi_video0,intel_backlight etc. These folders contain a number of file like
brightness : which contains the present brightness value
max_brightness : the maximum possible brightness value

 use intel onboard graphics which controlls the brightness. All I need to do is to change the value of brightness file in intel_backlight.This can be done simply by echo command.

Here is a simple sript to perform the same.The up arrow key can be used to increase the brightness and down arrow key can be used to decrease the brightness.Make sure you run the script as root who has the right to write into the file.

===================================================


#!/bin/sh

folder="/sys/class/backlight/intel_backlight"

cd "$folder"

value=3000
max=4882
min=100

if (($EUID != 0))
then
    echo "You do not have required previlages to run the script!!!"
    exit 1
fi

while true
do
    read -n3 -s  key
    echo -n "$key" | grep "\[B"
    if [ "$?" -eq 0 ]
    then
        if (($value < 100))
        then
            value=100
            continue
        fi
        echo $value
        echo -n $value > brightness 
        value=$[$value-100]
    fi
    echo -n "$key" | grep "\[A" 
    if [ "$?" -eq 0 ]
    then
        if (($value > 4000))
        then
            continue
        fi
        echo $value
        echo -n $value > brightness 
        value=$[$value+100]
    fi
done

===================================================

11:26 PM

Using NTFS drivers on Linux


In Arch Linux the users will not have any read permissions on NTFS drives by difault. It can be resolved using a simple package called ntfs-3g. Apart from Debian the the ntfs usage has to be manually done by editting the /etc/fstab file. Perform the following as root to add the NTFS capabilities.

pacman -S ntfs-3g

add the following line to /etc/fstab

# <file system>   <dir>  <type>    <options>             <dump>  <pass> 
/dev/<NTFS-part>  /mnt/windows  ntfs-3g   defaults    0       0 
 
  
The partition will be mounted at /mnt/windows.If you do not want to mount the partition by default use none instead.
If you want to people in users group access the drive then use

gid=users,umask=0022 
 
instead of default under options.
Reboot the system and enjoy!!!

8:05 AM

Shell script to convert video to mp3

The following shell script takes a video file as input and converts it into mp3 file at users home directory.Ensure that the file name is specified in double quotes if it contains any whitspaces.

====================================================


#!/bin/sh


folder="/home/$USER/Music"
name=""
if [ -z "$1" ]
then
    echo "No file name specified "
    echo "Please provide the absolute path of the file Ensure that the file name is enclosed in single quotes"
    exit 1
fi

echo "Output file name?"
read name
ffmpeg -i "$1" -acodec libmp3lame -ab 160k -ar 44100 -ac 2 "$folder/$name" 
if (($? != 0 ))
then
    pacman -Q lame ffmpeg > /dev/null
    if (($? !=0))
    then
        echo "Please ensure that lame and ffmpeg are installed on your system"
        exit 2
    else
        echo "No such file exists"
        exit 3
    fi
fi
echo "File successfully converted"
exit 0

===================================================

12:55 PM

Hangman game through Python



Simple python code to implement the hangman game.The code assumes that you have a file named 'words.txt' which contains n number of words.The program randomly selects one word from the file. The user is given 8 chances to guess the word.Each word guessed by the user is added to the lettersGuessed list.Procedure isWordGuessed() is used to determine whether the guessed letter is in the secretWord.If not the number of guesses remaining is reduced by one.Procedure getGuessedWord is used to print present correctly guessed words and thier locations...

===================================================import

import random
import string

WORDLIST_FILENAME = "words.txt"

def loadWords():
        print "Loading word list from file..."
    inFile = open(WORDLIST_FILENAME, 'r', 0)
    line = inFile.readline()
        wordlist = string.split(line)
        print "  ", len(wordlist), "words loaded."
       return wordlist

def chooseWord(wordlist):
       return random.choice(wordlist)

def isWordGuessed(secretWord, lettersGuessed):
    for letter in secretWord:
        if letter in lettersGuessed:
            continue
        else:
            return False
    return True

def getGuessedWord(secretWord, lettersGuessed):
    result = ""
    for letter in secretWord:
        if letter in lettersGuessed:
            result += letter
        else:
            result +=  '_ '
    return result
   


def getAvailableLetters(lettersGuessed):
    result = ""
    for letter in string.ascii_lowercase:
        if letter not in lettersGuessed:
            result += letter
    return result
   

def hangman(secretWord):
    lettersGuessed = []
    mistakesMade = 8
    guess=""
    print "Welcome to the game, Hangman!"
    print "I am thinking of a word that is" ,len(secretWord)," letters long."
    while mistakesMade:
        print "--------------------------------------------------------"
        print "You have",mistakesMade," guesses left."
        print "Available letters:",getAvailableLetters(lettersGuessed)
        print "Please guess a letter:"
        guess=raw_input()
        guess=guess.lower()
        if guess in lettersGuessed:
            print "You've already guessed that letter" ,getGuessedWord(secretWord,lettersGuessed)
            continue
        else:
            lettersGuessed.append(guess)
        if isWordGuessed(secretWord,[guess]):
            print "Good guess:",getGuessedWord(secretWord,lettersGuessed)
        else:
            print "Oops! That letter is not in my word:",getGuessedWord(secretWord,lettersGuessed)
            mistakesMade -= 1   
        if  '_' not in getGuessedWord(secretWord,lettersGuessed):
            print "Congratulations, you won!"
    print  "Sorry, you ran out of guesses. The word was ",secretWord,"."

def main():
    wordlist = loadWords()
    secretWord = chooseWord(wordlist)
    hangman(secretWord)

if __name__ == '__main__':
    main()

==================================================