Suramya's Blog : Welcome to my crazy life…

March 3, 2012

Configuring Dual monitors in Debian

Filed under: Knowledgebase,Linux/Unix Related,Tech Related,Tutorials — Suramya @ 12:01 AM

[Update 8th Aug 2012: This is an older method of setting up the monitor kept for historic reasons. In the newer version of KDE the process is a lot simpler, please refer to this post for the updated steps – Suramya.

Recently I went ahead and bought two new Dell 20″ monitors for my home system as I had gotten used to working with two monitors at work and wanted the same experience at home as well. The problem started because initially I tried installing another graphics card and hooking up the second monitor to that card using VGA. For some reason maybe because I was to tired and wasn’t thinking clearly, I couldn’t get both the cards to work at the same time. I would get one or the other but not both. To make things even more fun, the monitors are 16:9 aspect ratio and when I used the Opensource driver the only resolution with that aspect ratio I would get was 1600×900 which was too small and the fonts looked kind of jagged at that resolution.

Since I was going to be out of town and was planning on switching to DVI cables anyways I left the system like that (after spending a bit of time experimenting) and left. Once I got back I ordered DVI cables and finally managed to get the dual monitor setup working after spending about an hour one the issue. Below is the sequence I followed to get stuff to work (documenting this so that if I ever have to do this again I have a record of what I did):

  • Removed the second video card to reduce complexity. Might add it back later if required, or if I want to hook my old monitor as a third display.
  • Connected both monitors to the onboard ATI Radeon HD 4250 card, one over DVI and the second using VGA
  • Removed the Proprietary ATI and nVidia drivers (both installed in my previous attempts to get this working). Instructions here
  • Restarted X
  • Installed Catalyst (a.k.a fglrx) a proprietary “blob” (closed source binary) driver, using the following command:
  • apt-get install fglrx-atieventsd fglrx-control  fglrx-driver fglrx-glx fglrx-modules-dkms glx-alternative-fglrx libfglrx libgl1-fglrx-glx libxvbaw

Once the driver was installed I restarted X once again and got both monitors working, but the second monitor’s display was a clone of the first one which is not what I wanted so I had to do some more digging and finally managed to fix that using the following steps:

  • Open a terminal/Command Prompt
  • Disable access control so that clients can connect from any host by issuing the following command as a regular user
  • xhost +

    This is required so that we can start a GUI command from a root shell. If we don’t do this you will get an error similar to the following in the next step:

    No protocol specified
    No protocol specified
    amdcccle: cannot connect to X server :0
  • Run ‘Ati Catalyst Control Center’ as root
  • sudo amdcccle
  • Click on ‘Display Manager’ and configure your monitors (Resolution, location etc)
  • Click on ‘Display Options’ -> ‘Xinerama’ and enable ‘Xinerama’
  • There is a bug in the display manager that prevents it from saving any changes if the xorg.conf file exists, to fix:

  • Run the following command as root:
  • mv /etc/X11/xorg.conf /etc/X11/xorg.conf_original
  • Click ‘Apply’ in the Catalyst Control Center
  • Restart X

That’s it. Once I did all that, my dual monitor setup started working without issues. Well… mostly. For some reason my desktop effects have stopped working (Transparent/Translucent windows etc) but I am not going to worry about it for now. That’s a battle for another day, maybe over the weekend.

Please note, that setting up Dual monitors usually is not this complicated in Linux. When I hooked up my TV to this same system I didn’t have to make any changes to get it to work. In this case since I was fiddling around I had to fist fix the mess I made before I was able to get this to work properly.

For those of you who are interested, the final xorg.conf that the above steps created is listed below:

Section "ServerLayout"
        Identifier     "amdcccle Layout"
        Screen      0  "amdcccle-Screen[1]-0" 0 0
        Screen         "amdcccle-Screen[1]-1" 1440 0
EndSection

Section "ServerFlags"
        Option      "Xinerama" "on"
EndSection

Section "Monitor"
        Identifier   "0-CRT1"
        Option      "VendorName" "ATI Proprietary Driver"
        Option      "ModelName" "Generic Autodetecting Monitor"
        Option      "DPMS" "true"
        Option      "PreferredMode" "1440x900"
        Option      "TargetRefresh" "60"
        Option      "Position" "0 0"
        Option      "Rotate" "normal"
        Option      "Disable" "false"
EndSection

Section "Monitor"
        Identifier   "0-DFP1"
        Option      "VendorName" "ATI Proprietary Driver"
        Option      "ModelName" "Generic Autodetecting Monitor"
        Option      "DPMS" "true"
        Option      "PreferredMode" "1440x900"
        Option      "TargetRefresh" "60"
        Option      "Position" "0 0"
        Option      "Rotate" "normal"
        Option      "Disable" "false"
EndSection

Section "Device"
        Identifier  "amdcccle-Device[1]-0"
        Driver      "fglrx"
        Option      "Monitor-DFP1" "0-DFP1"
        BusID       "PCI:1:5:0"
EndSection

Section "Device"
        Identifier  "amdcccle-Device[1]-1"
        Driver      "fglrx"
        Option      "Monitor-CRT1" "0-CRT1"
        BusID       "PCI:1:5:0"
        Screen      1
EndSection

Section "Screen"
        Identifier "amdcccle-Screen[1]-0"
        Device     "amdcccle-Device[1]-0"
        DefaultDepth     24
        SubSection "Display"
                Viewport   0 0
                Depth     24
        EndSubSection
EndSection

Section "Screen"
        Identifier "amdcccle-Screen[1]-1"
        Device     "amdcccle-Device[1]-1"
        DefaultDepth     24
        SubSection "Display"
                Viewport   0 0
                Depth     24
        EndSubSection
EndSection

Hope all this made sense and helps someone. If not feel free to ask questions.

– Suramya

February 13, 2012

Case of the missing translucent panels

Filed under: Knowledgebase,Linux/Unix Related — Suramya @ 11:39 PM

A couple of days ago I decided to try hooking up my LCD TV to my computer to see if I could use it as an extra monitor (that didn’t work that well because the TV was too big to be comfortable but that is a different story). So while I was connecting the TV over HDMI I also installed the proprietary drivers for my RADEON HD 4250 card (and promptly forgot about doing this).

Didn’t like working with the TV (too big, too close) so put it back and then noticed that my panel was no longer translucent and none of the desktop effects were working. Ignored it for a couple of days and then decided to fix the issue.

Tried disabling and enabling the Desktop effects from the Settings -> Desktop Effects but I kept getting and error stating that the effects could not be activated and that I should check my Xorg.conf for errors. Tried searching for the Xorg.conf file but that file doesn’t exist on my system so was stumped.

Ignored the issue for another day or so but then got irritated enough today to try and fix it again. Searched online for a fix and found some tips, some bug reports but nothing that worked. Then I found a page where this person was asking if the Opensource driver is better than the propitiatory one. This tickled my brain cells and I had a hazy memory of installing the other version, so decided to take a chance and uninstall the propitiatory version and re-install the Opensource version.

Used the following commands to do this:

  apt-get remove --purge fglrx*
  apt-get remove --purge xserver-xorg-video-ati xserver-xorg-video-radeon 
  apt-get install xserver-xorg-video-ati
  apt-get install --reinstall libgl1-mesa-glx libgl1-mesa-dri xserver-xorg-core
  dpkg-reconfigure xserver-xorg

After doing this I restarted my system (had to do it anyways) and got my desktop effects back. Yay me!

Thanks to wiki.Unbuntu.org for the steps to purge the propitiatory driver.

Hope someone else also finds this useful sometime.

-Suramya

January 28, 2012

Rooting the Samsung Galaxy Nexus

Filed under: Knowledgebase,Linux/Unix Related,Tech Related — Suramya @ 1:45 AM

A rooted android device gives you a lot of flexibility so one of the first things I did after I got back home was to root it using the following instructions (modified from Android Forums: [HOW TO] Root the GSM/HSPA+ Samsung Galaxy Nexus):

Note: I am assuming you are using Linux in the instructions below. If not then visit the link above for steps in Windows.

  • Download the Android SDK from here to a folder on your PC.
  • Power down your device
  • Connect the USB cable between the phone and your PC
  • Open a shell session
  • Switch to the directory where you downloaded the SDK (In my case it was Media/Downloads)
  • cd Media/Downloads
  • Extract the SDK Zip and switch to the new directory
  • unzip sdk-tools.zip
    cd sdk-tools
  • Make the applications executable
  • chmod a+x fastboot-linux adb-linux
  • Now, Boot your phone into fastboot mode by pressing and holding the volume-up AND volume-down AND the power buttons UNTIL you see the little green Android laying on his back with door on his chest open
  • Verify that fastboot can “see” your device
  • ./fastboot-linux devices

    You should see something similar to this:

    0146B5030B02100E        fastboot

    If you don’t see anything, try running the command as root.

  • Next we start the unlock process for the bootloader by issuing the following command. Keep in mind that this will completely wipe out all data from the phone so make sure you backup before running the command.
  • ./fastboot-linux oem unlock

    Confirm that you want the bootloader to be unlocked by acknowledging the warning message on the phone. (Please note that this will void your warranty). Use your volume rocker/keys to select the confirmation and press the power button to actually confirm.

At this point you have an unlocked bootloader and now we will start the rooting process.

  • Download the su.zip flashable root package
  • I had to manually copy the su.zip to the Phone because for some reason I kept getting an ‘error: insufficient permissions for device’ when I tried copying the file using adb. I used FTP (as I have SwiFTP on the phone, but you can use any method that you are comfortable with)

  • Download the Clockwork Recovery for Galaxy Nexus (GSM) to the same folder as fastboot and adb
  • Soft boot the ClockworkMod custom recovery by issuing the following command. This method will not replace the currently installed recovery partition on your phone, so you can still receive updates from Google.
  • ./fastboot-linux boot recovery-clockwork-5.5.0.2-maguro.img

    Your phone should now boot into ClockworkMod custom recovery. The next few steps are done on the phone. You shold use the volume key / rocker to navigate and the power button to select an entry.

  • From the main ClockworkMod Recovery screen / menu, select ‘install zip from sdcard
  • Select ‘choose zip from sdcard
  • Select ‘su.zip’
  • Confirm that you want do this.
  • Select ‘*****Go Back*****
  • Select the ‘reboot system now

That’s it. 🙂 Once your phone finishes rebooting, you should now have root. If you hit issues, try reaching out to the folks in the Android Forums for help.

Hope this helps.

Update (14th Feb 2012): As you all know links/stuff tends to disappear over time on the internet so I have updated the post with links to my mirror of the software required to root the Nexus. Original links are still listed below.

Original Download links:

– Suramya

January 3, 2012

Working without Free diskspace in Linux

Filed under: Computer Tips,Linux/Unix Related,Tech Related — Suramya @ 5:52 AM

On linux machines you can fill your root partition to 100% utilization and the system would still continue to function giving you a chance to free up space without downtime, but on Windows machines the same is not possible and if you have managed to fill your C:\ to 100% then the system will go down (Know this for sure for Windows versions up to Vista, not sure about Win7) hard. This is something that has puzzled me a lot over the years but didn’t know how it worked, but now I finally have an explanation:

When you format a partition in Linux , 5% of the total space gets reserved for privileged processes, by default. This is done so that system processes continue to function correctly ,if the filesystem gets full. This is useful for your ‘root’ partition.

The really interesting part is that you can configure this to reduce the percentage of the reserved space using the tune2fs command. e.g. if you wanted to reduce the reserved space for /dev/sda1 to 1% of the total space then issue the following command as root:

tune2fs -m 1  /dev/sda1

Source: Flossstuff’s Blog

Enjoy.

– Suramya

October 26, 2011

Connecting a WordPress blog to Facebook

Filed under: Computer Software,Linux/Unix Related,Tech Related,Tutorials — Suramya @ 5:01 PM

Over the past few months I have been trying to connect my blog to my Facebook account so that whenever a post is made on the blog it automatically gets posted on Facebook to varying degree’s of success. Most of the attempts would work for a while and then stop. I even tried using some of the existing plugins for WordPress but since they required a developer account (which needs a valid phone no or CC#) and for some reason I never get the validation code on my cell I was never able to get them to work.

Then I found an article on Linux Magazine on a Command Line interface for Facebook and decided to build on top of that to get the linkage working. Now this is a very hackey way and is not at all elegant or anything but it gets the work done which is what I wanted, so I am good. 🙂 All the work was done in about 2 hours including testing so that should tell you something on its own.

I had to install this on my local system since my webhost didn’t have all the per-requisites to get this to work. That and the fact that I can’t connect to my MySQL db’s from a machine outside of my hosting provider is why this convoluted method was created. The steps I followed to get this to work are as follows.

Install Facebook Commandline

To install Facebook Commandline, follow the instructions on their site.

Authenticate the Application to be able to talk to Facebook

For some reason there was a difference when I run the application from the commandline and when I run it from the web, in as to where the preferences file and the session details were saved, so all the steps have to be done either from the command line or via the web, you can’t interchange the two.

Creating a Web interface for the FBCMD

Since I wanted to be able to get data from WordPress and pass it on to FBCMD I created a new PHP page called run.php that basically pulls the data from WordPress and then passes it to FBCMD as command line parameters. I know that using passthru is probably not very secure and I should have modified the FBCMD file to accept parameters as a URL but didn’t want to spend that much time trying to get this to work. (Hey! I told you it was a quick and dirty ‘fix’).

The contents of this file are very simple:

error_reporting(E_ALL);
$handle = fopen('https://www.suramya.com/blog/LatestPost.php', 'r');
$current = fopen('/var/www/fbcmd/latest.dat', 'r');
$current_id = fgets($current, 4096);
fclose ($current);

if ($handle) 
{
 $ID = fgets($handle, 4096);
 $link = fgets($handle, 4096);
 $title = fgets($handle, 4096);
 $content = fgets($handle, 596);
 $content = chunk_split(htmlspecialchars(strip_tags($content)), 500) . "...";

 if($ID != $current_id)
 {
  // If we have a new post then call FBCMD to make a post
  $command = '/usr/bin/php /var/www/fbcmd/lib/fbcmd/fbcmd.php POST " " "' . chop($title) . '" "' . 
              chop($link) . '" "' . $content . '"';
  passthru ($command);
  // Write the new PostID to a file
  $current = fopen('/var/www/fbcmd/latest.dat', 'w');
  fputs($current, $ID);
  fclose($current);
 }
}

The file basically calls ‘LatestPost.php’ and gets the latest post details on the blog(see below for details), then it checks if the post made is newer than the last post processed and if so it proceeds to post to Facebook using FBCMD.

‘LatestPost.php’ file looks like this:

< ?php

define('WP_USE_THEMES', true);
require_once( dirname(__FILE__) . '/wp-load.php' );

$month = $_GET['month'];
$year = $_GET['year'];

$args = array( 'numberposts' => 1);
$myposts = get_posts( $args );

//print_r($myposts);

foreach( $myposts as $post ) : setup_postdata($post); 
echo $post->ID . "\n";
the_permalink();
echo "\n";
the_title();
echo "\n";
the_content();
endforeach; ?>

This file need to be put on the server in the WordPress Root directory and when called returns an output in the following format:

Post ID
Post Link
Post Title
Post Content

Once all this is done and the FBCMD has access to post to Facebook all we need is a cron job to run on a frequent basis to run the code. So I created a shell script that contains the following line and have it run every 15 mins.

/usr/bin/curl http://localhost/fbcmd/run.php > /tmp/FBPost.out

That’s it. So far it looks like its working great and if this post shows up on my FB wall then all is well. If not, then its back to the code to see what went wrong this time.

– Suramya

September 20, 2011

New Script Web2Email Released

Filed under: Linux/Unix Related,Software Releases,Tech Related — Suramya @ 2:47 AM

Just released Ver 0.1 of Web2Email. Web2Email is a Perl Script that allows the user to send a message with a list of URL’s to a special mail account and get back a snapshot of the websites as PDF files.

You can download it from Scripts.Suramya.com: Web2Email.

If you want a demo, send an email to: web2email@suramya.com with website URL’s in the email body (one per line) and after about 5 mins you will get an email with the snapshots of the sites listed as PDF files.

Update: The cron job running this on my machine is having issues, will fix it once I get back home and this should be back up again tonight.

Update (22nd Sep 2011): The project wasn’t the cron job, there is an issue with the version of wkhtmltopdf that is available in the Debian repo. Basically if you have both http & https images in a site it goes for a toss. The static built version should fix this issue but haven’t got the time to install and test. Till that is done the demo version will be on hold.

As always I would appreciated any feedback/suggestions you might have.

– Suramya

September 19, 2011

Trouble-Maker: Learn to fix computer issues

Filed under: Computer Software,Linux/Unix Related,Tech Related — Suramya @ 2:38 AM

This interesting app randomly breaks your system so you can learn how to fix it.

Haven’t tried it yet because as of now I only have one working Linux system at home, but as soon as I fix that I will be installing this on my secondary system. Once I do that I will log my experiences here.

You can download it from Trouble-Maker‘s site.

– Suramya

September 18, 2011

How to set different backgrounds for each desktop in KDE 4.6.5

Filed under: Computer Tips,Linux/Unix Related,Tech Related — Suramya @ 11:59 PM

I have talked about How to set different backgrounds for each desktop in KDE4 in a previous post. However in KDE 4.6.5 the previous steps no longer work, so posting the new steps to get different backgrounds in KDE:

  • Click on the ‘Start Menu’ (The K at the bottom Right of the screen)
  • Click on ‘System Settings’ under the Settings menu
  • Double Click on the ‘Workspace Behavior’ under the “Workspace Appearance and Behavior” section
  • Check the “Different widgets for each desktop”
  • Click Apply

That’s it. Now you can change the wallpaper by Right clicking on the desktop and selecting ‘Desktop Settings’. Its good to know that the KDE Developers paid attention to complaints that the users made about their software and addressed it.

– Suramya

September 5, 2011

Getting RTL8111/8168B PCI Express Gigabit Ethernet controller to work in Debian 6

Filed under: Knowledgebase,Linux/Unix Related,Tech Related,Tutorials — Suramya @ 11:28 PM

Once I got Debian 6 installed on my server I needed to connect it to the internet to download updates etc, however my network card wasn’t being detected correctly so I had to perform the following steps to get it to work correctly:

  • Download the latest Linux drivers for the RTL8111 Chipset from the Realtek site on a computer that can connect to the Internet.
  • Copy the file over to your new system via USB or smoke signals
  • Login as root to the server
  • Identify the kernel version that you are running, using the following command:
  • uname -a

    It will give you a result like the following:

    Linux StarKnight 2.6.30-2-686 #1 SMP Sat Aug 27 16:41:03 UTC 2011 i686 GNU/Linux

    Now you need to install the kernel source code for this version on the server. First we need to find the package name of the kernel source code, we do that by running the following command:

    apt-cache search linux |grep header |grep 2.6 

    If you have a 2.4.x kernel, replace grep 2.6 with grep 2.4. Once you have the package name install it using the following command as root:

    apt-get install linux-headers-2.6.30-2-686

    Make sure you replace linux-headers-2.6.30-2-686 with the package name you got.

    Once we have the kernel source installed we can go ahead and install the driver using the following commands:

    tar -jxvf r8168-8.025.00.tar.bz
    cd r8168-8.025.00
    ./autorun.sh 
    

    This will compile the drive and install it. I didn’t get any errors when I ran it, but if you do get errors try searching for the error message on Google, it usually provides a solution.

    After I installed the driver I tried initializing my network but kept getting the following error message:

    StarKnight:~# ifdown eth0
    ifdown: interface eth0 not configured
    StarKnight:~# ifup eth0
    Ignoring unknown interface eth0=eth0.
    

    Fixing it was fairly simple though, all I had to do was edit the /etc/network/interfaces file and add the following lines to it (This assumes you are using DHCP):

    auto eth0
    iface eth0 inet dhcp
    

    Once you add the lines, you can try starting the network again using the command:

    ifup eth0

    If all went well, you will be assigned an IP address and will now be able to successfully browse the net.

    Hope this helped.

    – Suramya

    June 11, 2010

    The first foldable dual screen ebook reader/netbook is out

    Filed under: Computer Hardware,Linux/Unix Related,Tech Related — Suramya @ 2:07 AM

    If I would ever get a ebook reader I think I will go for this one or something similar.

    This is an Android device which has a 9.7″ E-paper Display and a 10.1″ LCD Touchscreen Display. So you can have a book open on one side and surf the web on the other side. Or have a programming manual open on one side and code on the other.

    The enTourage eDGeâ„¢ Specifications are as follows:

    * Dimensions: 8.25″ x 10.75″ by 1.0″ (closed)
    * Weight: approx. 3 lbs.
    * Internal Memory: 4 GB (3 GB for user)
    * E-reader File Formats: ePub, PDF
    * LCD Touchscreen Display Size: 1024 x 600 (10.1″)
    * E-paper Display Size: 9.7″ e-Ink®(1200 x 825), 8 shades of gray
    * E-paper Input: Wacom® Penabled®
    * Operating System: Linux with Google® Android®
    * Screen Rotation: 90 and 180 degrees
    * Connectivity: WiFi 802.11 b/g, Bluetooth capability
    * Battery Life: 16+ hours utilizing the e-reader screen / up to 6 hours running the LCD screen
    * Battery Type: Lithium-ion polymer
    * External Memory: SD card slot, 2 USB ports
    * Audio and Microphone Jack: 3.5 mm each. Includes internal microphone and speakers.
    * Audio playback: MP3, WAV, 3GPP, MP4, AAC, OGG, M4A
    * Video playback: 3GP, MP4, Adobe Flash Lite (H.264)
    * Input: Stylus input on e-paper and touchscreen. Virtual keyboard. USB keyboard (optional)

    The cost is $499.

    – Suramya

    Source: Handle With Linux.

    « Newer PostsOlder Posts »

    Powered by WordPress