Sunday, July 20, 2008

Replacing the SD Card popup dialog at startup

Info from the following URLs:
Examples of awk:

If you are like me who leaves his SD card permanently in the SD Card slot, you would probably be annoyed at having to close the popup dialog everytime the Eee PC starts up, asking you what action to take.

That will happen if you plug in a USB device permanently as well, as I have read. The Wiki URL above teaches how to disable the PlugNPlay popups permanently or during startup only. I don't recommend the former as the popups are a convenient way to access the device, especially given that the Linux file/device structure is different from Windows which some of us are used to.

The latter totally skips it, for about 40 seconds. What I have done is to use KDialog to create a passive popup (one without buttons) that will go away in 5 seconds. This is to reassure me that it has been loaded while still removing the hassle of clicking the popup away.

Disabling the SD Card popup dialog requires the renaming of /usr/bin/xandros_device_detection_dialog and creating a script in its place which will still redirect to it after 40 seconds. NOTE that the original file is a BINARY file and should not be opened in any text editor. If opened and saved, the file will be corrupted.
  1. Press Ctrl-Alt-T to open the terminal console.

  2. Type "cd /usr/bin" to go to the directory. This will save us from typing out all the paths.

  3. Create a backup of the original file by typing
    "sudo cp xandros_device_detection_dialog xandros_device_detection_dialog.backup"

  4. Rename the original file by typing
    "sudo mv xandros_device_detection_dialog xandros_device_detection_dialog.copy"

  5. Create a new file in place of the old one by typing
    "sudo kwrite xandros_device_detection_dialog"

  6. Copy and paste the following into the file (both awk commands are continuous lines):

    #awk '$1 < 40 { exit 1 }' /proc/uptime && xandros_device_detection_dialog.copy "$@" &

    awk '$1 < 40 { system("kdialog --title \"SD Card / USB device loaded at startup\" --passivepopup \"This passive popup will disappear after 5 seconds.\" 5"); exit 1; }' /proc/uptime && xandros_device_detection_dialog.copy "$@" &

  7. Save and exit.

  8. Set the permissions to execute by typing
    "sudo chmod 755 xandros_device_detection_dialog"

  9. Restart your Eee PC and you should see the popup at the top-lefthand corner:

In the script above, the 1st awk command which is commented out, will simply skip the popup dialog. For the awk command, the only single quotes allowed are the two at the beginning and end, not even inside the curly braces. This got me stuck for a while. In the end I used \". system() is to run commands from the command line. KDialog cannot be run without it. There are basically 2 lines of code inside the curly braces, separated by the semicolon. The "exit 1" is to make sure the program exits gracefully.

(^ v ^)

No comments: