Inspirated

 
 

October 31, 2009

HOWTO: Use PyS60’s Bluetooth Console on Fedora/Ubuntu/Debian Linux

Filed under: Blog — krkhan @ 11:03 pm

While developing PyS60 apps is one of the most fun things you could do with your Nokia phone, debugging them isn’t as zippy as one would hope for in a Py development environment. To make up for that, PyS60 gives the developers an option for directly connecting to the interpreter through Bluetooth. Doesn’t sound very appealing? How about this: You connect your laptop with the cellphone, jump in at some place in the code while your app is executing and then use lappy’s big keyboard for exploiting different code and values in the interpreter. Sounds better?

To accomplish this on a Linux distro, you will need the following packages installed on your system:

Name Links
gnome-bluetooth
uucp/cu

After making sure that both are present on your system, install PyS60 on your phone if you haven’t already done so.

Now the fun part:

  1. Switch on Bluetooth in the cellphone.

    PyS60 Bluetooth HOWTO, Mobile screenshot #1

  2. Launch bluetooth-properties and click on “Setup New Device”.

    PyS60 Bluetooth HOWTO, PC screenshot #1

  3. Select your cellphone.

    PyS60 Bluetooth HOWTO, PC screenshot #2

  4. You will be shown a pin.

    PyS60 Bluetooth HOWTO, PC screenshot #3

  5. Enter the pin when queried on the cellphone.

    PyS60 Bluetooth HOWTO, Mobile screenshot #2

  6. The phone should be successfully paired.

    PyS60 Bluetooth HOWTO, PC screenshot #4

  7. Authorize your Linux system to make automatic connections to the phone.

    PyS60 Bluetooth HOWTO, Mobile screenshot #3

  8. As root, run this shell script:
    [root@orthanc ~]# ./rfcomm-listen.sh

    Serial Port service registered
    Waiting for connection on channel 2

  9. Launch PyS60 interpreter and select “Bluetooth Console” from the application menu.

    PyS60 Bluetooth HOWTO, Mobile screenshot #4

  10. Select your Linux machine.

    PyS60 Bluetooth HOWTO, Mobile screenshot #5

    The command you ran in previous step should have new output:

    [root@orthanc ~]# ./rfcomm-listen.sh

    Serial Port service registered
    Waiting for connection on channel 2
    Connection from 00:17:4B:B6:35:31 to /dev/rfcomm0
    Press CTRL-C for hangup

    The cellphone screen should be showing something like this:

    PyS60 Bluetooth HOWTO, Mobile screenshot #6

  11. As root again, open a new terminal and run:
    [root@orthanc ~]# cu -l /dev/rfcomm0

    Connected.

  12. Hit Enter till prompt (>>>) appears, then type:

    >>> import appuifw
    >>> appuifw.query(u'Hello World', 'text')

  13. Viola, you should have an input box on the mobile screen:

    PyS60 Bluetooth HOWTO, Mobile screenshot #7

  14. Enter any text and press the OK key. It should be show up in the terminal you were using to type in code:

    >>> import appuifw
    >>> appuifw.query(u'Hello World', 'text')
    u’Finally’

  15. Exit the interpreter by typing CTRL+D on an empty line:

    >>> import appuifw
    >>> appuifw.query(u'Hello World', 'text')
    u’Finally’
    >>>
    Interactive interpreter finished.
    cu: Got hangup signal

    Disconnected.

Pat yourself on the back. Now, you can use your Bluetooth console to import your modules, execute some stuff and then jump in the middle to test some extra lines or values. In fact, I found it to be a pretty darned good way of learning about PyS60’s API. Res secundae!

Tags: , , , , , , , , , , , , , , , ,

October 17, 2009

HOWTO: Integrate Compiz Fusion with Xfce the right way

Filed under: Blog — krkhan @ 10:03 pm

In past, I had always struggled to find the “correct” way of launching Compiz Fusion while starting Xfce. For a while, I had resorted to the easiest — and not perhaps the prettiest — way of launching Fusion Icon with the desktop autostart files. The problem with this method lied in the fact that Xfwm was launched before Fusion, and the most glaring workaround was to write my own xinitrc files for X startup, which was just uglier anyway.

Xfce’s own documentation is as bare as my memory while running it, so the right way was not actually obvious until I was fiddling around my configuration directory a few days ago. There, I found an interesting file named xfce4-session.xml. To truly exploit this lovely thing, I first copied it into my home configuration directory:

[krkhan@orthanc ~]$ cp /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml ~/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-session.xml

And then edited the file with a text-editor, making it look something like:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?xml version="1.0" encoding="UTF-8"?>
<channel name="xfce4-session" version="1.0">
  <property name="general" type="empty">
    <property name="FailsafeSessionName" type="string" value="Failsafe"/>
    <property name="SessionName" type="string" value="Default"/>
    <property name="SaveOnExit" type="bool" value="false"/>
  </property>
  <property name="sessions" type="empty">
    <property name="Failsafe" type="empty">
      <property name="IsFailsafe" type="bool" value="true"/>
      <property name="Count" type="int" value="5"/>
      <property name="Client0_Command" type="array">
        <value type="string" value="fusion-icon"/>
        <value type="string" value="--force-compiz"/>
      </property>
      <property name="Client0_PerScreen" type="bool" value="false"/>
      <property name="Client1_Command" type="array">
        <value type="string" value="xfce4-panel"/>
      </property>
      <property name="Client1_PerScreen" type="bool" value="false"/>
      <property name="Client2_Command" type="array">
        <value type="string" value="Thunar"/>
        <value type="string" value="--daemon"/>
      </property>
      <property name="Client2_PerScreen" type="bool" value="false"/>
      <property name="Client3_Command" type="array">
        <value type="string" value="xfdesktop"/>
      </property>
      <property name="Client3_PerScreen" type="bool" value="false"/>
      <property name="Client4_Command" type="array">
        <value type="string" value="xfce4-settings-helper"/>
      </property>
      <property name="Client4_PerScreen" type="bool" value="false"/>
    </property>
  </property>
  <property name="splash" type="empty">
    <property name="Engine" type="string" value=""/>
  </property>
</channel>

Lines 13-15 initially referred to Xfwm’s commands, but replacing them with the Fusion Icon ones worked like a charm. This way, Fusion is always guaranteed a launch, which actually wasn’t the case with other workarounds.

Tags: , , , , , , ,

August 28, 2009

Brace yourself and join the euphoria: Nokia N900 has been announced

Filed under: Blog — krkhan @ 10:18 pm

Rarely do I feel the urge to jump on the buzzword bandwagon. This time, however, the product deserves the hype. Before you hear me any further, jump straightaway to the Nokia 900 website and stagger yourself into oblivion. Cliff notes:

  • First Linux-based cellphone from Nokia — world’s largest manufacturer of mobile phones. The previous Linux tablets from the Finnish giants (e.g., N810) were nice but lacked the basic phone functionality.
  • A plethora of insane mouth-watering features that are just too many to list here in their entirety.
  • S**.

If you still aren’t convinced, let me be lazy and shamelessly copy some items from the linked page:

  • ARM Cortex – A8 superscalar microprocessor core running at 600 MHz
  • Up to 1 GB of application memory (256 MB RAM, 768 MB virtual memory)
  • 3D graphics accelerator with OpenGL ES 2.0 support
  • 32 GB internal storage
  • 3.5G and WLAN connectivity
  • Quadband GSM with GPRS and EDGE
  • 5-megapixel digital camera
  • Carl Zeiss optical lens
  • Touch-sensitive screen
  • Assisted-GPS receiver

Essentially, that’s iPhone+N810+N96+Neo FreeRunner for you. An year ago, I did have a feeling that Nokia was planning big things with Linux when it acquired Trolltech but I had absolutely no idea that the definition of “big” would be this exotic.

Can’t. Wait.

Tags: , , , , ,

August 18, 2009

Fedora Software Patents FAQ

Filed under: Blog — krkhan @ 8:48 pm

Going through the Planet Fedora feed, I spotted this excellent write-up which tries to explain Fedora-related patent questions such as “why the $*#@ won’t Red Hat give us MP3 playback support“. I would be straight-down lying if I said that the article offered nothing new to me. In fact, some answers, such as this one … :

Patent licenses are usually granted via payment of royalty based on the number of users. Since Fedora is free and open source software, the effective number of users is essentially unrestricted. Patent holders are generally unwilling to give a blanket patent license for unlimited use, and the royalty payments for these licenses would be too high to purchase them outright. Proprietary operating systems like Microsoft Windows include the cost of the patent license as part of the product being sold to the end users. Fedora is not sold commercially, so there is no way to recoup these substantial expenses. Even assuming funds are available to do so, licenses such as the GPL require a written patent grant (in regions where software patents are enforced) compatible with royalty free distribution and modification. Since meeting this requirement effectively nullifies the effect of a patent, patent holders are also generally unwilling to do this.

… clarified in my mind a few long-held confusions about Fedora’s reluctance regarding patent infringement. For the general user, RPM Fusion works around all that crap; but a read of the linked FAQ is recommended nevertheless for having an idea about the issues inherently involved with seemingly simple tasks such as playing DVDs.

Tags: , , , ,

July 23, 2009

Microsoft’s open-source contribution traced back to GPL violation

Filed under: Blog — krkhan @ 11:36 pm

(Or: Things still make sense.)

Last week — just as Wayne Rosso stopped comparing RIAA to Stalin — M$ did its own volte-face and not only stopped calling GPL a “cancer” but decided to release some 20,000 lines of code carrying the plague itself. Pigs started flying. Some of the open-source evangelists started fantasizing about Microsoft as an ally suddenoutbreakofcommonsense and the cautious ones — who suspected some ulterior motive behind the move — were declared by them to be paranoid and rabid haters.

The storm didn’t last long though, as it was later reported that the change of heart was prompted by a GPL violation in Hyper-V. Some see this as a win for GPL. Some see this as a perfect backdrop for FUD against open-source (“it’s so goddamned viral it even infected us when we wanted interoperablity”) while some see this as a failure at M$’ part for not honestly explaining the reasons behind the code release. Whichever category you belong to, it’s nice to know that swine still have their feet firmly on ground.

Tags: , , , ,

July 5, 2009

The top 5 worst mistakes on command-line

Filed under: Blog — krkhan @ 10:58 pm

I could start off with an intro paragraph here but I’ll prefer keeping it sweet and simple: command-line is addictive.

For many kinds of tasks — ranging from system administration to organizing folders — I find CLI to be extraordinarily more productive than GUI clicking. For example, vim-ing through a code, if I decide I need to lookup a particular symbol in the current directory, I can quickly do a recursive grep without even taking my hands off the keyboard. Similarly, I find utilities such as mv or cp to be significantly faster than GUI file managers’ equivalent features. The learning curve is definitely steep and I also am not implying that everyone should find it equally productive but for me at least, it works like a charm.

It wouldn’t be an exaggeration to say that CLI provides a terrible amount of power at fingertips of its users. While that power is tremendous fun, it also can be a source of epic fails if not handled with caution. The fact of the matter is, as one grows accustomed to quickly doing work through text-based input, overlooking those cautions almost becomes second nature. It’s not uncommon to find a commandaholic holding his head in his hands while staring at the screen in disbelief. GUI does get credit for being a little more prone to accidental mistakes by consistently providing a visual view of what’s about to happen.

Moving on from the ill-starred mischief that I posted about last week, I thought I should compile a list of all time worst incidents of me cursing my fingers for being so familiar with the CLI. Here they are:

  1. Ctrl-C

    Sometimes, I blame Christopher Sholes for putting the Z and C keys so close on the keyboard. ‘Nuff said.

  2. Deleting the wrong partition in parted

    (parted) help rm                                                          
      rm NUMBER                                delete partition NUMBER
    
    	NUMBER is the partition number used by Linux.  On MS-DOS disk labels,
            the primary partitions number from 1 to 4, logical partitions from 5
            onwards.

    If you’re wondering why deleting a partition is placed so low on the list, the answer is TestDisk. Mere seconds after I deleted my primary partition containing all my data, I stopped all activities, booted into a rescue mode and used the God-sent utility to restructure my partition table like before with a cumulative data-loss of 0%.

  3. e2fscking e2fucking a mounted file-system

    [root@orthanc ~]# e2fsck /dev/sda2
    e2fsck 1.41.4 (27-Jan-2009)
    /dev/sda2 is mounted.  
    
    WARNING!!!  Running e2fsck on a mounted filesystem may cause
    SEVERE filesystem damage.
    
    Do you really want to continue (y/n)? 

    See that SHOUTING WARNING? I did too. But back then, I ignored it as casually as anyone ignores licensing agreements. Needless to say, the results weren’t as inconsequential as clicking “I accept” and moving on without a hint of doing something legally binding.

  4. rm -rfing the wrong directory

           -f, --force
                  ignore nonexistent files, never prompt
    
           -r, -R, --recursive
                  remove directories and their contents recursively
    

    If the last tool had the F-word in its title as the warning, this one should be read as rm --recursive-f***. The H-bomb of command-line tools, once you detonate it on a directory you didn’t mean to set it upon, even CTRL-C won’t be able keep you in one piece because of rm‘s ruthless speed and efficiency. The only ray of hope is ext3grep, but depending on numerous factors (partition structure, number of files, file types, alignment of stars etc.) your recovery prospects would range anywhere from ±100% to ±100%. You read that right.

  5. mkfsing the wrong partition

           mkfs  is  used to build a Linux file system on a device, usually a hard
           disk partition.  filesys is either the device  name  (e.g.   /dev/hda1,
           /dev/sdb2).   blocks  is  the  number of blocks to be used for the file
           system.

    The granddaddy of all command-line fuckups. If you have confused /dev/sdb for /dev/sda (an easy slip up — as I learned the hard way), it’s time to move on. Sure, you will find people selling tools for recovering data from formatted Ext3 partitions; expecting those tools to work would be a lot like expecting the King of Pop to miraculously pop up from his coffin on Tuesday and perform a ground-breaking reenactment of 83’s Motown performance.

“Blessed are the forgetful; for they get the better even of their blunder.” — Friedrich Nietzsche

Tags: , , , , , ,

July 2, 2009

Workaround for autostarting applications in a particular order on Xfce/GNOME/KDE

Filed under: Blog — krkhan @ 11:04 pm

Among many of freedesktop.org’s vital contributions to GUI computing on POSIX platforms, a divine one has been the uniform specification for automatically launching programs at initiation of a desktop session. Informally put (or theoretically at least), it means that you can add programs to startup in the appropriate settings, and they will be launched automatically at initiation of your session regardless of which desktop environment you use.

It’s been about 4 years since I migrated to Xfce for everyday work and it does come with a basic tool for managing startup entries (accessed through Application Menu > Preferences > Session and Startup). Still, if you need anything more than rudimentary addition/deletion of the entries you’re pretty much out of luck. For example, I wanted to start the applications in a particular order. I don’t know whether GNOME or KDE have the feature yet, but Xfce lacked the support for maintaining any such arrangement. The proper way to deal with the issue would have been to code the feature in the session manager myself, but since I barely get time to even read fortune-mod these days I instead had to rely on an ugly workaround. If you’re in the same sticky situation, here it is: Go to the autostart directory (usually ~/.config/autostart), open the startup script you’re concerned with, and edit the Exec line like this:

Before:
Exec=awn-autostart

After:
Exec=bash -c "sleep 3 && awn-autostart"

The ugliness arises from the fact that the new Exec line is merely launching the program with a delay of 3 seconds. Now, you can add another program with a delay of 4 and it will almost be guaranteed to start after the 3 seconds’ one across all desktop environments. I really hope that the specification itself would be revised soon to provide a uniform way of setting the startup order. But until that gets done, I can thank sleep for making my life simpler.

Tags: , , , , , ,

June 27, 2009

The highs and lows of Leonidas — This. Is. Fedora!

Filed under: Blog — krkhan @ 12:43 am

There is a reason why I never evangelize Fedora much: it’s far from perfect. There is also a reason why I use Fedora for my everyday Linux-ing: it’s good when it starts working. The two seemingly conflicting viewpoints are not mutually exclusive, since Fedora’s instability as well as its appeal can be termed in one word: bleeding-edge.

The biannual cycle of backup-reinstall-reconfigure for each new Fedora release works fine for me. It takes a day or two to get everything back to the way want them to be, but the trade-off is almost always worth it. Consider this, upgrading from a Fedora version to the next will almost never work seamlessly. Nevertheless, the re-installation mantra allowed me to use PulseAudio’s “perfect” setup much before most of the other distros’ users. The fact that I got a clean start for the new sound architecture also explains why I never had any incompatibility issues with it and consequently, my status as one of its huge fans.

Another reason why I’m still hanging on to Fedora is because of the familiarity factor, as I no longer have the ample time for trying out newer distributions just for the sake of it. Linux From Scratch was a mighty fun experience, but keeping it up-to-date was nothing short of a Herculean task. Gentoo sounds very appealing, but I don’t want to download a DVD, go through the hassle of installing and getting familiar with the new distro and then emerge a whole universe of updates on an internet connection as reliable as Fedora on Hurd. The perfect solution would be to install a new release of Gentoo but unfortunately, it’s been over an year now since I started waiting for one.

Which brings us to Fedora 11 — lovingly nicknamed after everyone’s favorite Spartan king.

The predominant aspects of the new release which affect me as a user are the Ext4 filesystem and the Kernel Modesetting feature. So far, I am not even using the former. Yes, yes, I know I bragged about bleeding-edge before, but let me explain why I did not go for it in this particular case:

  • Filesystem is the most critical aspect of a system for me. I can toy around and experiment with everything but this holy grail. If my audio fails, I can try fixing it. If X stops working, ditto. If my data is corrupted, I’m FUBAR.
  • Anaconda crashed when I tried to update the boot-loader configuration for a system with Ext4 partitions.
  • I couldn’t find a way to use Ext4 without using the Logical Volume Manager. I like my partitions as /dev/sdaX and entries such as /dev/mapper/yourmom/blahblahblah/finallythedrive in the fstab file turn me off.

Nevertheless, KMS made up for the Ext4 — or lack thereof.

  • Booting is now prettier.
  • Working in runlevel 3 is so much more efficient because of all the extra space provided by higher resolution.
  • Switching virtual terminals and X sessions is a breeze.
  • Suspend/Resume is a bit more stable.

Other significant changes include Xfce 4.6, Firefox 3.5 and the reworked volume management in Pulse. Overall, I’m pretty satisfied with my decision to upgrade, and here’s to the hoping that the next 6 months will go as smooth as the previous ones.

Tags: , , , , , ,

April 7, 2009

HOWTO: Log Pidgin conversations selectively

Filed under: Blog — krkhan @ 7:32 pm

Pidgin is a multi-protocol instant-messaging client which I use for all my MSN/Google Talk/IRC communication. Apart from offering adept support for all of these protocols (and plenty others as well), Pidgin also provides decent logging support. However, I’m not at all interested in having my daily MSN conversations recorded. On the other hand, I prefer having my previous IRC chats with me for reference. Right now, Pidgin does not support any options in the Preferences which would allow me to selectively turn on logging based on the protocols I’m using. If I turn it on for chat windows, it also starts producing logs for every MSN chat I participate in.

Most of the people wouldn’t/don’t see any issue with this behavior. For those who do want to keep a history of their conversations only for particular protocols, here’s a quick workaround for doing it:

  • Check the appropriate options under the “Logging” tab in Preferences window.
  • Have a few chats the likes of which you’d prefer being logged.
  • Go to the directory containing Pidgin logs (default is ~/.purple/logs):
    [user@host ~]$ cd ~/.purple/logs/
  • See whether the protocols you want to be logged have a directory named for them:
    [user@host logs]$ ls

    irc msn

  • Remove the protocols you do not want to have logs for (in my case, MSN):
    [user@host logs]$ rm -rf msn
  • Change directory permissions to stop new protocols from getting logged:
    [user@host logs]$ chmod 500 .

And you’re done. Now, whenever you start a conversation in a protocol which does not have a respective directory in ~/.purple/logs, you’ll see a “Logging failed” error message in the conversation window. For other (allowed) protocols, logging will work as expected. To turn off selective logging, reset directory permissions with:

[user@host ~]$ chmod 600 ~/.purple/logs/

It is also possible to apply the same workaround on contacts. For example … :

  • [user@host ~]$ cd ~/.purple/logs/msn/
    [user@host msn]$  ls

    bestbuddy@live.com ignorantmoron@live.com

  • [user@host msn]$ rm -rf ignorantmoron@live.com
  • [user@host msn]$ chmod 500 .

… will disable logging for all MSN contacts including ignorantmoron@live.com, but will record everything communicated with bestbuddy@live.com. Like the previous example, you just have to reset directory permissions to re-enable nondiscriminatory logging:

[user@host ~]$ chmod 600 ~/.purple/logs/msn/
Tags: , , , , , , , , , ,

March 19, 2009

Video: The Centenary Rant — X11tasy

Filed under: Blog — krkhan @ 7:10 pm

The 100th post, and considering that the most popular ones on the blog so far have been screencasts, there wouldn’t have been a better way to commemorate the occasion than editing a short music-video which would demonstrate the prowess of Linux on desktop.

Tags: , , , , , , , , , ,
« Previous PageNext Page »