26 November 2011

21. Current Bug -- gnome applications unresponsive to keyboard input

UPDATE 02/02/2012:
It seems like whatever the problem was, it's gone now. An up-to-date testing system with ibus runs smoothly.

26/11/2011
For some reason, after updating today I'm having a hard time entering input in various gnome applications, whereas non-gnome applications work fine.
E.g. I can't type certain letters, and in general it's difficult to provide any inpurt, in gnome-terminal and gnome-session-properties. lxterm and guake work completely normal though.

No sure what is causing this, but it's happening on my Thinkpad SL410 as well as on my Optiplex 910. The only thing they have in common is the operating system (up-to-date debian testing 64 bit).

Don't know enough about it to file a bug report.

Edit: the problem is present in Evolution as well. Still present as of 28/11/2011. Problem exists on a home-built six-core AMD with 1 GB graphics card.

Edit 2: It sounds a bit like this, which was reported in June (!).
 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=631116
It seems to be related to iBus/SCIM


Edit 3: Evolution is also affected, as is gEdit. Turning off iBus 'solves' the problem. Now, why does it affect the standard gnome applications, but not other packages?

At any rate, this bug has given me the incentive to leave gnome-terminal for guake, and to give alpine and thunderbird a try instead of evolution.

I tried
sudo apt-get install ibus-gtk3
sudo apt-get autoremove ibus-gtk

iBus still works. But unfortunately evolution is still way too slow to be useful.

25 November 2011

20. Is there no molecular weight calculator in the Debian repos?

UPDATE: see here for an isotopic calculator written in python -- it calculates mass as well: http://verahill.blogspot.com.au/2012/10/isotopic-pattern-caculator-in-python.html

The best molecular weight calculator which I've encountered is Matthew Monroe's Molecular Weight Calculator, which can be found at http://ncrr.pnnl.gov/software/

It does everything. Molecular weights. Isotopic patterns. And so, so, so much more.

It has one major drawback though - it's written for Windows. Luckily, it sort of works under Wine after you've done a bit of wine-trick-ery.

As great as the calculator is, sometimes you only need to calculate the molecular weight of something, and nothing else. Searching the debian repos I can' t find a single dedicated molecular weight calculator. In particular, a command-line driven calculator would be nice.

Seriously - it's a crying shame that the distribution with the largest repos, i.e. Debian, does not have a single passable molecular weight calculator. It is even more surprising given the number of chemistry-related packages which are present.

So, here's what I did:
a quick google on "python molecular weight calculator" brought me to http://pygments.org

A little bit of editing gave the code below, which was saved as molcalc, copied to /usr/bin, followed by sudo chmod +x /usr/bin/molcalc. It can now be called using
molcalc "(Co(CO)5)2"
and returns
The mass of (Co(CO)5)2 is 257.916890.

Here's the code, which is 99.9% the original and 0.1% my modification. All credit thus due to Lee, Freitas and Tucker.

NOTE: it doesn't handle layered parentheses. (Al(NO3)3)2 gets interpreted as Al2(NO3)3.

#!/usr/bin/python2.6
#########################################################################
# Author: Toni Lee with the help of Guilherme Freitas and Becky Tucker. Minor changes by Lindqvist
# Copyright: This module has been placed in the public domain
#########################################################################

#Import regular expressions
import re
import sys
try:
test=sys.argv[1]
except:
quit()

#Create the dictionary (From Becky with a value of 0 inserted for Uus(mass not measurable))
TableofElements ={ 'H':1.00794,'He':4.002602,'Li':6.941,'Be':9.012182,
                        'B':10.811,'C':12.0107,'N':14.0067,'O':15.9994,'F':18.9984032,'Ne':20.1797,
                        'Na':22.98976928,'Mg':24.3050,'Al':26.9815386,'Si':28.0855,
                        'P':30.973762,'S':32.065,'Cl':35.453,'Ar':39.948,'K':39.0983,'Ca':40.078,
                        'Sc':44.955912,'Ti':47.867,'V':50.9415,'Cr':51.9961,'Mn':54.938045,
                        'Fe':55.845,'Ni':58.6934,'Co':58.933195,'Cu':63.546,'Zn':65.38,'Ga':69.723,
                        'Ge':72.64,'As':74.92160,'Se':78.96,'Br':79.904,'Kr':83.798,'Rb':85.4678,
                        'Sr':87.62,'Y':88.90585,'Zr':91.224,'Nb':92.90638,'Mo':95.96,'Tc':98,
                        'Ru':101.07,'Rh':102.90550,'Pd':106.42,'Ag':107.8682,'Cd':112.411,
                        'In':114.818,'Sn':118.710,'Sb':121.760,'Te':127.60,'I':126.90447,
                        'Xe':131.293,'Cs':132.9054519,'Ba':137.327,'La':138.90547,'Ce':140.116,
                        'Pr':140.90765,'Nd':144.242,'Pm':145,'Sm':150.36,'Eu':151.964,'Gd':157.25,
                        'Tb':158.92535,'Dy':162.500,'Ho':164.93032,'Er':167.259,'Tm':168.93421,
                        'Yb':173.054,'Lu':174.9668,'Hf':178.49,'Ta':180.94788,'W':183.84,
                        'Re':186.207,'Os':190.23,'Ir':192.217,'Pt':195.084,'Au':196.966569,
                        'Hg':200.59,'Tl':204.3833,'Pb':207.2,'Bi':208.98040,'Po':210,'At':210,
                        'Rn':220,'Fr':223,'Ra':226,'Ac':227,'Th':232.03806,'Pa':231.03588,
                        'U':238.02891,'Np':237,'Pu':244,'Am':243,'Cm':247,'Bk':247,'Cf':251,
                        'Es':252,'Fm':257,'Md':258,'No':259,'Lr':262,'Rf':261,'Db':262,'Sg':266,
                        'Bh':264,'Hs':277,'Mt':268,'Ds':271,'Rg':272, 'Uus':0
}


#######################################
#Computes the MW of an atom-number pair
#######################################
def getMass(x):
    atom=re.findall('[A-Z][a-z]*',x)
    number=re.findall('[0-9]+', x)
    if len(number) == 0:
        multiplier = 1
    else:
        multiplier = float(number[0])
    atomic_mass=TableofElements[atom[0]]
    return (atomic_mass*multiplier)

################################################################
#Segments formula into atom-number sections (i.e. 'H3' or 'N10')
################################################################
def parseFormula(fragment):
    segments=re.findall('[A-Z][a-z]*[0-9]*',fragment)
    return (segments)

##################################################################################
#Computes total mass of both parenthetical and nonparenthetical formula components
##################################################################################
def molmass(formula):
    parenMass=0
    nonparenMass=0
    while (len(formula)>0):
        #First computes the molecular weight of all parenthetical formulas from left to right
        while (len(re.findall('\(\w*\)[0-9]+', formula))!=0):
            parenthetical=re.findall('\(\w*\)[0-9]+',formula)
            for i in range(0,len(parenthetical)):
                parenMult1 = re.findall('\)[0-9]+', parenthetical[i])
                parenMult2 = re.findall('[0-9]+', parenMult1[0])
                segments =parseFormula(parenthetical[i])
                for i in range(0, len(segments)):
                    parenMass= parenMass + ((getMass(segments[i]))*(float(parenMult2[0])))
            formula=re.sub('\(\w*\)[0-9]+', '', formula)
        #Sums nonparenthetical molecular weights when all parenthetical molecular weights have been summed
        segments = parseFormula(formula)
        for i in range(0, len(segments)):
            nonparenMass=nonparenMass + getMass(segments[i])
        formula=re.sub(formula, '', formula)

    Mass=parenMass+nonparenMass
    return Mass
     
if __name__ == '__main__':
test=test.split(',')
for element in test:
print ('The mass of %(substance)s is %(Mass)f.' % {'substance': \
element, 'Mass': molmass(element)})
 

22 November 2011

19. Gnome3/gnome-shell -- 11 days later

So, I stuck it out. The new gnome-shell is fairly functional for me, finally.
The lack of system indicator applets was solved by using conky to overlay information on the desktop.
Frippery's gnome-shell extensions also make the experience less frustrating.

However, it still feels like everything I've done have been finding /work-arounds/ rather than /customisation/. In the end the whole idea of an application-centric desktop is unsuitable for me -- I would expect this to be true for the majority of established linux users.


Edit (25/11/2011):The screengrab shows what my heavily modified desktop looks like.

10 November 2011

18. Gnome 3/Gnome-shell -- first impressions. Rant.

Debian testing has now transitioned to gnome-shell/gnome3. It's...different...from gnome 2.32, so be warned. While I'm as frustrated as anyone else who feels that they are being forced to move to a new desktop metaphor for no good reason, I'm trying to keep an open mind. The lack of a bottom panel is pissing me off and disorienting me enormously though. I also would like all my panel applets back - I used to have a good overview over how my computer hardware was doing, and now I have no clue anymore.

<RANT>
Essentially, at this point it seems like gnome-shell is fine for people who do their work in a specific application - like a browser, word processor etc. It absolutely blows if you're using your COMPUTER. I edit code in gedit, render figures in the terminal, inspect them using evince, include them in documents using LaTeX etc. Suddenly I feel I have no overview what's going on. The lack of a bottom panel showing me which applications are open on a specific virtual desktop is very confusing. Using alt+tab to check before I switch is a great time-waster.

For those who haven't used gnome-shell -- yes, you can still have windows side-by-side. You just can't see if you're hiding a window behind another one.

Seriously. I don't see why I can't customise my desktop anymore. Gnome has always (I do realise that this isn't entirely true - functionality is being removed and re-added all the time in most desktop environments) been a bit more restrictive than KDE in terms of granular control and I do understand that this is on purpose -- it's a design philosophy. I guess I just violently disagree with it.

Finally, even though I can't put my finger on WHY, I feel that I suddenly have a tiny screen. It's 23 inches. It's huge. It's made for having lots of windows open side-by-side.

I admit that I'm as resistant to change as anyone, but since I use my computer as part of my work, I need a damned good reason for changing. Few people can afford a few weeks downtime in productivity while learning the ropes if they feel that the change isn't justified.

I'll stick with gnome for a while longer. You can't bitch if you don't give it a chance. But I'll spend those weeks looking closer at the alternatives - XFCE, LXDE, KDE etc.

The point here -- and which was seen with the defections to OSX caused by Windows Vista -- is that if people are forced to learn a new way of working, they might as well explore ALL the options.

Prediction: I'll either stay with gnome-shell (which will hopefully improve as functionality and control is returned), or move to xmonad (another extreme)

I obviously appreciate the fact that I'm using a free and open source collection of software - in theory no-one is forcing me to keep on using GNOME. Nor was I forced to upgrade. In reality, it's not so easy.

Given that gnome 3/gnome-shell is more than just an iterative update, I think it would've have made sense to allow for the installation of gnome 2.32 and gnome3 side-by-side. After all, there's nothing preventing you from running KDE, gnome, xfce and lxde side-by-side. Sure, uptake would be slower - but 'forcing' people to move from one version to another isn't really a good idea either. The way it is now you have no easy way of reverting back to 'normal' if you accidentally, or misguidedly, upgrade to gnome3.

Oh well, ranting is easy. A better use of my time would probably have been to learn how to write gnome-shell-extensions to provide the functionality which I feel is missing.
</RANT>

<How to deal with it>
So, there are a few things which can be done to make the transitions a bit easier to handle -  do an online search for gnome-shell-extensions and download the ones which you think will help. For me, I've got the following installed and active:
Bottom Panel
windowNavigator
Gajim IM integration
Alternative Status Menu
Shut Down Menu
User Themes
Break Dynamic Workspaces
Panel Favorites
Weather
Applications Menu
Move Clock
Auto Move Windows

Make sure that you get the right version of the extension for your version of gnome-shell (gnome-shell --version; currently it's on 3.0.2) since extensions for 3.2 won't necessarily work with 3.0.2 (e.g. the bottom panel extension).

You will also want to install the gnome-tweak-tool and explore what it does. At least you can choose your preferred icon theme, set nautilus to handle the desktop space, bring back maximize/minimize buttons etc.

You may also want to add keyboard shortcuts to the most commonly used application since it's a PITA having to go back to the Activities every time you open e.g. a terminal, nautilus or gedit  instance. I've mapped terminal to ctral+shift+up, google chrome to ctrl+shift+down, nautilus to ctrl+shift+left and gedit to ctrl+shift+right.


If you find that you can't run gnome-shell but only use the fallback mode, check that you haven't got 'compiz --replace' in your start-up programs (gnome-session-properties)