Friday 9 September 2016

Installing megatools on CentOS 6

In case you wanted to install the megatools command line client for Mega.co.nz and you've run into this error:

checking for GLIB - version >= 2.32.0... no
*** Could not run GLIB test program, checking why...
*** The test program failed to compile or link. See the file config.log for the
*** exact error that occured. This usually means GLIB is incorrectly installed.
configure: error: Glib 2.32.0 or later is required to build megatools


this is what you need to do (kudos should go to: Mike Miao) :

1. Make sure you have all the dependencies needed for MegaTools installed:

yum install gcc make  libcurl-devel openssl-devel gmp-devel tar libffi-devel gettext-devel



2. Install the 2.32 version of the glib:

1:  mkdir glib-source  
2:  cd glib-source/  
3:  wget http://ftp.gnome.org/pub/GNOME/sources/glib/2.32/glib-2.32.4.tar.xz  
4:  tar zxf glib-2.32.4.tar.xz  
5:  cd glib-2.32.4/  
6:  ./configure --prefix=/usr/local/glib-2.32
8:  make  
9:  make install  

As you can see, I preferred to install Glib 2.32 all in one directory, to avoid any mixing with the main Glib version that is shipped with CentOS. So, all files belonging to this library were installed in /usr/local/glib-2.32

3. Then, retry configuring and installing megatools, as follows:

1:  cd megatools-source  
2:  export LD_LIBRARY_PATH=/usr/local/glib-2.32/lib/  
3:  export PKG_CONFIG_PATH=/usr/local/glib-2.32/lib/pkgconfig  
4:  ./configure  
5:  make  
6:  make check  
7:  make install  



You are all set !

More instructions in the help pages of the command tools or even on: Mike Miao's page that inspired this )

Tuesday 23 February 2016

Ubuntu linux: how to restrict a graphic tablet to only one monitor (in a dual monitor setup ;)



I have 2 monitors that are placed on top of each other, like this:

My graphical tablet (Genius EasyPen i405X) is covering by default the entire (summed-up) area, which means that only about half of the tablet is usable for a MyPaint drawing that is opened only on the Benq monitor.


What I want to do is to restrict the tablet movement only to Benq, ie: tablet's physical margins should correspond to Benq ones.

Let's get the needed parameters. The monitors resolution and offset can be seen by launching xrandr in command line:

optimus:~$ xrandr
Screen 0: minimum 320 x 200, current ...
LVDS connected (normal left inverted right x axis y axis)
   1366x768      60.02 +
   1280x720      59.86 
   ... 

480 x 1142, maximum 16384 x 16384HDMI-0 connected primary 1920x1080+338+1080 (normal left inverted right x axis y axis) 598mm x 336mm
   1920x1080     60.00*+  50.00    59.94 
   1920x1080i    60.00    50.00    59.94 
   1680x1050     59.88 
   ...
VGA-0 connected 2560x1080+0+0 (normal left inverted right x axis y axis) 673mm x 284mm
   2560x1080     59.98*+
   1920x1080     60.00 
   1680x1050     59.95 
   ... 
The first screen is laptop's one that is inactive. Then, each monitor can be found based on the cable/socket it's on. In my case Benq is on HDMI and AOC is on VGA.

Xrandr displays all possible resolutions for each monitor but we need only the one that is active, marked with * (btw, the "+" means it is the recommended resolution). I have trimmed many of those for brevity and in fact we need only the first line of each, the long one where we have the resolution and also the offset.
As you can see (see also the picture) AOC (on VGA) has a resolution of 2560x1080 and it has offset 0 and 0 (it's top left corner is in the zero of the axis system).
More interesting for me, BenQ has resolution of 1920x1080 and horizontal offset 338, while the vertical one is 1080, i.e. Benq is lower that the 0 axis point with exactly the height of AOC.
(There are some distances in reality between monitor margins, but obviously these are not taken into account.)

So, let's write all down:


TotalHsize: 2560 (i.e. the Horizontal resolution of AOC, that "includes" BenQ)
TotalVsize: 2160 (i.e. the summed up Vertical resolution of both, as they are stacked: 1080+1080)
BenqHsize: 1920
BenqVsize: 1080
BenqHoffset: 338
BenqVoffset: 1080

These are all the input data we need. Now, let's calculate the proportions (or relative values):

BenqRelHsize = BenqHsize / TotalHsize = 1920 / 2560 = 0.75
BenqRelVsize = BenqVsize / TotalVsize = 1080 / 2160 = 0.5
BenqRelHoffset = BenqHoffset / TotalHsize = 338 / 2560 = 0.13203125
BenqRelVoffset = BenqVoffset / TotalVsize = 1080 / 2160 = 0.5


So, finally, the command we should launch looks like this:

xinput set-prop "Tablet name as detected by xinput --list" --type=float "Coordinate Transformation Matrix" RelHsize 0 RelHoffset 0 RelVsize RelVoffset 0 0 1

which in my case, for Benq, is:

xinput set-prop "Genius EasyPen i405X" --type=float "Coordinate Transformation Matrix" 0.75 0 0.13203125 0 0.5 0.5 0 0 1

Launch it and it's working!

This will not survive a reboot so you should do something about it if you care. Personally, I have just added the above line in a script that I run each time I use the tablet (which is quite rare in my case).

For more info see the sources I used:


http://ubuntuforums.org/showthread.php?t=1656089&s=ca2da10a736e5ce13dcd20da11fdd854&p=10330180#post10330180

http://ubuntuforums.org/archive/index.php/t-1571365.html