How to fix a keyboard indicator (in GNOME 3.8)

Recently and occasionally I have discovered a tiny issue, which I was forced to observe, every time I was looking at my desktop. This has happen after I have decided to add a keyboard layout for russian language, which was based on german phonetics. So this is what I ended with:

Quickly I have got slightly frustrated, because I started to mix up things a little bit, so I started to look at gnome’s source code, especially searching for a xml database in gnome-control-center and gnome-desktop, and gave up it this idea, as I was not able to find anything particular useful and started to ask around in the IRC channels. Lucky, as people sometimes say that any initiative can be hardly punished, I have got a response from Rui Matos, one of the GNOME developers working on gnome-desktop. He pointed me out to the right direction:

rtcm, I mean, how this names “de1” and “de2” or “ru” are generated, where can I find the corresponding code?
ibqn: the code is in the gnome-desktop module, but it’s just simply getting what’s defined in xkeyboard-config’s data, see http://cgit.freedesktop.org/xkeyboard-config/tree/rules/base.xml.in#n3223
rtcm, so why is it called “de2” and not “ru” instead? looks like a bug
ibqn: those labels are the elements, if you believe that specific layout should have ‘ru’ as its short description, file a bug (preferably with a patch) in freedesktop’s bugzilla
rtcm, thank you for making it clear to me.
ibqn: no prob, I hope I helped 🙂

The following procedure was almost straightforward, I simply cloned their git repository, modified the corresponding file, I believe should be right, committed it locally and finally created a trivial one liner patch:

From 2cbb166e05eae603a2e640eeb3558942a89ecd7e Mon Sep 17 00:00:00 2001
From: Evgeny Bobkin <evgen.ibqn@gmail.com>
Date: Thu, 16 May 2013 14:15:26 +0200
Subject: [PATCH] Fix keyboard indicator for russian (germany, phonetic)

---
 rules/base.xml.in | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/rules/base.xml.in b/rules/base.xml.in
index 5996738..2735723 100644
--- a/rules/base.xml.in
+++ b/rules/base.xml.in
@@ -3223,6 +3223,8 @@
         <variant>
           <configItem>
             <name>ru</name>
+            <!-- Keyboard indicator for Russian layouts -->
+            <_shortDescription>ru</_shortDescription>
             <_description>Russian (Germany, phonetic)</_description>
             <languageList>
               <iso639Id>rus</iso639Id>
-- 
1.8.1.5

As a gentoo user I also have the ability to test every particular package and change its source code without risking or being afraid of irreparably breaking my system, because, due to this modifications, all broken libraries can be easily tracked down and fixed by recreating their reverse dependencies (with revdep-rebuild for example). Therefore I have copied the xkeyboard-config ebuild to my local overlay and included the created patch to it, so I was able to test it and thus fixed the issue. Afterwards, I have filed a bug report and shortly this patch was included upstream. One more success story.

So, what can you do if you have no ability to apply the patch or use the latest version, or even if you want to fix the similar issue locally on your computer? There is also an easy way: you should try to modify the base.xml file accordingly, probably located here:

$ vim /usr/share/X11/xkb/rules/base.xml

And in the case of a new issue, please also open a bug report (with an attached patch to it), so that other people can also profit from your work done.
Enjoy!!!

PS: By the way my stand alone research was not that vain as I have described above, I finally found after years of looking for it, the source code of the Cyrillic (Transliterated) input method plugin, you observe every time when you right-click the mouse pointing on the text field (or entry box), followed by selecting the bottom menu item “Input Methods”

Вышла новая версия файлового менаджера Thunar 1.6.1

Совсем недавно, пару дней назад вышла в свет новая версия осень быстрого и использующего мало системных ресурсов файлового менеджера thunar версии 1.6.1. Одна из основных добавленных функций в новой версии это возможность использования вкладок, что иллюстрированно на картинке. thunar входит с состав программ быстрой и современной графической поверхности Xfce. Так что если у вас есть старый компьютер пятилетней давности, то у вас появляется уникальная возможность установить на него совершенно бесплатную операционную систему xubuntu, разрабатывающуюся многими тысячами программистов по всему земному шару и конечно при поддержки обширного ряда крупных компаний. Так что не удивляйтесь, если ваш старый компьютер с установленным xubuntu будет работать быстрее, только что купленного ноутбука с Windows 8!!! Добро пожаловать в мир неисчерпанных возможностей))

Turorial for OpenGL and Gtk3+ combined, written in Vala

This post is still work in progress!
The main target of this code sample, even if it’s trivial one, is to run a openGL based application on top of the modern window library Gtk+3 on Gnu/Linux. It must be possible to run this openGL code combined with Gtk+ on windows, but I personally do not know how to do it, as I rarely use windows myself. Well, actually, I use it only to set up it for my girlfriend or to solve the endless number of issues my girlfriend has ran into. If you, by the way, know howto extend this simple example, written in vala, so it can be launched on windows, please share it with me.)) The reason for this incompatibility is that here the X11 related functions calls are used to establish the incorporation between Gtk3, Gdk and OpenGL on the other side.

This sample code for simplicity reasons covers only the openGL 1 API. The example with vertex and fragment shaders, respectively, will be considered in the succeeding posts.
Here, therefore we first create a new custom window by inheriting the Gtk window class functionality and add a drawing area to it. The drawing area afterwards will be responsible for the GL context. Below you can find a class template, which includes the step by step recipe, needed yet to be implemented.

/* here the opengl and X related libraries are included */
using GLX;
using GL;

class GLXSample : Gtk.Window {
    public GLXSample( ) {
        /* 1. adding custom setting for the newly created window */

        /* 2. preparing and intializing the opengl context */

        /* 3. creating the drawing area and adding it to the window */
        var drawing_area = new Gtk.DrawingArea( );
        /* adjusting the drawing area parameters */

        /* adding two events listeners: */
        /* the first handles the opengl content on window resize events */
        /* followed by the event which is responsible for the drawing */
        drawing_area.configure_event.connect( on_configure_event );
        drawing_area.draw.connect( on_draw );

        this.add( drawing_area );
    }

    private bool on_configure_event( Gtk.Widget widget, Gdk.EventConfigure event ) {
        /* adapting the opengl content on window size change */
        return true;
    }

    private bool on_draw( Gtk.Widget widget, Cairo.Context cr ) {
        /* drawing the opengl content here */
        return true;
    }
}

void main( string[] args ) {
    Gtk.init( ref args );

    var sample = new GLXSample( );
    sample.show_all( );

    Gtk.main( );
}

So, after implementing all the introduced steps will result in the following working code sample:

using GLX;
using GL;

class GLXSample : Gtk.Window {

    private unowned X.Display xdisplay;
    private GLX.Context context;
    private GLX.XVisualInfo xvinfo;

    public GLXSample( ) {
        this.title = "OpenGL with GLX";
        this.set_reallocate_redraws( true );
        this.destroy.connect( Gtk.main_quit );

        int[] attrlist = {
            GLX_RGBA,
            GLX_RED_SIZE, 1,
            GLX_GREEN_SIZE, 1,
            GLX_BLUE_SIZE, 1,
            GLX_DOUBLEBUFFER, 0
        };

        this.xdisplay = Gdk.x11_get_default_xdisplay( );
        
        if( !glXQueryExtension( xdisplay, null, null ) ) {
            stderr.printf( "OpenGL not supported\n" );
        }

        this.xvinfo = glXChooseVisual( xdisplay, Gdk.x11_get_default_screen( ), attrlist );
        
        if( xvinfo == null ) {
            stderr.printf( "Error configuring OpenGL\n" );
        }

        var drawing_area = new Gtk.DrawingArea( );
        drawing_area.set_size_request( 300, 300 );
        drawing_area.set_double_buffered( false );

        this.context = glXCreateContext( xdisplay, xvinfo, null, true );

        drawing_area.configure_event.connect( on_configure_event );
        drawing_area.draw.connect( on_draw );

        add( drawing_area );
    }

    private bool on_configure_event( Gtk.Widget widget, Gdk.EventConfigure event ) {
        if( !glXMakeCurrent( xdisplay, Gdk.X11Window.get_xid( widget.get_window( ) ), context ) )
            return false;

        GLsizei width = widget.get_allocated_width( );
        GLsizei height = widget.get_allocated_height( );
        GLsizei size = int.min( width, height );
		
        glViewport( (width - size ) / 2, (height - size ) / 2, size , size );

        return true;
    }

    private bool on_draw( Gtk.Widget widget, Cairo.Context cr ) {
        if( !glXMakeCurrent( xdisplay, Gdk.X11Window.get_xid( widget.get_window( ) ), context ) )
            return false;

        glClear( GL_COLOR_BUFFER_BIT );

        glBegin( GL_TRIANGLES );
            glIndexi( 0 );
            glColor3f( 1.0f, 0.0f, 0.0f );
            glVertex2i( 0, 1 );
            glIndexi( 0 );
            glColor3f( 0.0f, 1.0f, 0.0f );
            glVertex2i( -1, -1 );
            glIndexi( 0 );
            glColor3f( 0.0f, 0.0f, 1.0f );
            glVertex2i( 1, -1 );
        glEnd( );

        glXSwapBuffers( xdisplay, Gdk.X11Window.get_xid( widget.get_window( ) ) );

        return true;
    }
}

void main( string[] args ) {
    Gtk.init( ref args );

    var sample = new GLXSample( );
    sample.show_all( );

    Gtk.main( );
}

Here you can find a working makefile, which should make the compilation process easier.

all:
	valac --pkg gtk+-3.0 --pkg gdk-x11-3.0 --vapidir ../vapi --pkg gl --pkg glx glx-sample.vala -o glx-sample

Öfnen von ISO Image-Dateien in Ubuntu GNU/Linux

Um in Gnu/Linux Image-Dateien, inbesondere mit der ISO-Endung, zu öffnen, benötigt man, im Gegensatz zu Windows, keine externe kostenpflichtige Anwendungen, wie zum Beispiel DEAMON Tools. Die auf Gnu/Linux basierende und Windows weit überlegende Betriebssysteme, wie das frei verfügbare Ubuntu bieten auch in diesem Fall sehr einfache Lösungen an.
Man erstellt dafür einen neuen Ordner, falls noch nicht vorhanden, mit dem Befehl:

sudo mkdir /media/iso_image

und bindet die Image-Datei, hier genannt als filename.iso

sudo mount filename.iso /media/iso_image -t iso9660 -o loop

Dieser Prozess wird als Mount bezeichnet. Schon, es ist erledigt. Man braucht nun nur zu diesem Ordner zu navigieren, um den Inhalt der gerade eingebundenen ISO-Datei anzuschauen.
Wenn der Inhalt der Image-Datei nicht mehr benötigt wird, lässt sich diese mit dem ausführen vom Befehl

sudo umount /media/iso

wieder schließen.

Syntaxunterstützung für die Programmiersprache Vala in Emacs-Editor

Vala ist eine sehr moderne und eine auf Open-Source-Konzepte bassierende Programmiersprache mit einer sehr vergleichbaren mit Java- bzw. C#-Syntax und ist damit immer eine gute Wahl für jeden Programmierer. Jedoch ist deren Synteaxunterstützung noch nicht in vielen bekannten Editoren wie Emacs standartmäßig eingerichtet. Manuell aber lässt sich das sehr leicht beheben.

Seit Version 24 kommt Emacs mit dem preintallierten Packet “package.el” und bietet somit die Option andere Funktionserweiterungen aus den verschiedenen Repositorien nachzurüsten. Marmalade ist zum Beispiel so ein Package-Archieve, welches auch die Erweiterung “vala-mode” enthält. Um diese zu aktivieren benötigt man folgende Schritte:

  1. Die “~/.emacs“-Datei wird mit dem folgenden Inhalt bereichert:
    (require 'package)
    (add-to-list 'package-archives
        '("marmalade" . "http://marmalade-repo.org/packages/"))
    (package-initialize)
  2. Danach werden die eben hinzugefügte Funktionen mit dem Befehl “M-x eval-buffer” ausgeführt und die Liste der Erweterungen mit dem Befehl “M-x package-refresh-contents” aktualisiert.
  3. Anschließend kann man die Unterstützung von Vala-Syntax mit dem Befehl “M-x package-install vala-mode” freischalten.

Für die älteren Versionen von Emacs kann man entweder das Packet “package.el” nachinstallieren, um die oben erwähneten Schritte machen zu können oder die vala-mode-Datei manuall in den Ordner “~/.emacs.d/” zu verschieben und die “~/.emacs“-Datei mit den folgenden Funktionen zu erweitern.

 (add-to-list 'load-path (expand-file-name "~/.emacs.d"))
(autoload 'vala-mode "vala-mode" "Major mode for editing Vala code." t)
(add-to-list 'auto-mode-alist '("\\.vala$" . vala-mode))
(add-to-list 'auto-mode-alist '("\\.vapi$" . vala-mode))
(add-to-list 'file-coding-system-alist '("\\.vala$" . utf-8))
(add-to-list 'file-coding-system-alist '("\\.vapi$" . utf-8))

Nun sollte einem erfolgreichen Vala-Projekt nichts im Wege stehen!

Referenz: Vala syntax support for Emacs

Updating boot loader to the stable grub-2.00

As the Grub2 ebuild has been updated to the stable version 2.00 and appeared keyworded as testing (~) in portage, I have finally decided to update my system. The steps I have done for that were based on official gentoo guides: a short one (Grub2 quick start) I basically followed and the detailed one(Grub2) I also considered. The basic update was rather trivial as whole procedure consists of small number of commands needed to be issued:

# emerge -av1 grub os-prober

I have also emerged os-prober to enable the automatic detection of my secondary operation system: Windows, I rarely use. After the compilation and installation as been finished I have installed it to MBR on the standard location.

 # grub2-install /dev/sda

At this stage I have to say, that the gentoo team has done a great job in providing the best possible configuration, so all the necessary settings were already set up in /etc/default/grub. I just generated the grub.cfg file and the system started to work out of the box.

# grub2-mkconfig -o /boot/grub2/grub.cfg

And that was it!!!
As the whole updating process was completed faster as I was expected I started to tweak the setting to gain the best possible result. After briefly reading the official grub2’s documentation and receiving help from the #grub IRC channel, located on freenode server, I have managed to get what I wanted. My intend was to increase the resolution of the boot loader and the followed verbose kernel loading process. Additionally to that, I wanted to hide the grub’s menu entirely, which should only appear, when the shift button is pressed, during the grub’s loading process. This will just allow, to boot up gentoo by default, after the turn on button is pressed, as this is almost always my primary choice. Alternatively, after the “Welcome to Grub” output, the shift button can be hold, which should bring up the boot menu, where I can tell the system otherwise.

To activate the shift keyboard listener, the file custom.cfg should be created, contaning the following line of code:

$ cat /boot/grub2/custom.cfg 
if keystatus --shift; then timeout=-1; fi

The possibility of creating this custom.cfg file is mentioned here; the description of the keystatus command and the purpose of the timeout variable, respectively. Therefore all two …_TIMEOUT=0 variables were set to zero.

$ cat /etc/default/grub 
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-boot/grub/files/grub.default-2,v 1.2 2012/06/28 22:36:53 floppym Exp $
#
# To populate all changes in this file you need to regenerate your
# grub configuration file afterwards:
#     'grub2-mkconfig -o /boot/grub2/grub.cfg'
#
# See the grub info page for documentation on possible variables and
# their associated values. 

GRUB_DISTRIBUTOR="Gentoo"

GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=0

GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX=""
#GRUB_CMDLINE_LINUX="video=vesafb:mtrr:3,ywrap vga=865"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal.
# Note that you can use only modes which your graphic card supports via VBE.
# You can see them in real GRUB with the command `vbeinfo'.
#GRUB_GFXMODE=640x480
GRUB_GFXMODE=1280x800
GRUB_GFXPAYLOAD_LINUX=keep

# Path to theme spec txt file.
# The starfield is by default provided with use truetype.
# NOTE: when enabling custom theme, ensure you have required font/etc.
#GRUB_THEME="/boot/grub2/themes/starfield/theme.txt"

# Background image used on graphical terminal.
# Can be in various bitmap formats.
#GRUB_BACKGROUND="/boot/grub2/mybackground.png"
GRUB_BACKGROUND="/boot/grub2/gentoo.png"

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to kernel
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY=true

In Grub-legacy I was passing the following options “video=vesafb:mtrr:3,ywrap vga=865” to the kernel to squeeze the better resolution than 640×480. However doing so over the GRUB_CMDLINE_LINUX variable has not brought the desired affect. Luckily, it was enough to modify the GRUB_GFXMODE and GRUB_GFXPAYLOAD_LINUX to get the same.

ошибка монтирования /dev на /root/dev

Однажды при включении одного из старых лэптопов появилась похожая ошибка:

mount: mounting /dev/disk/by-uuid/c6060118-cc51-439d-9a03-ad971a9de4cc on /root
failed: Invalid argument
mount: mounting /dev on /root/dev failed: No such file or directory
mount: mounting / sys/ on root/sys failed: No such file or directory
mount: mounting /proc on /root/proc failed: No such file or dirctory
Target filesystem doesn’t have /sbin/init.
No init found. Try passing init= boot arg

BusyBox v1.10.2 (Ubuntu 1:1.10.2.2ubuntu7) built-in shell (ash)

(initramfs)

что конечно мгновенно вызвало у меня “панику, панику”. Ведь это скорее всего означает, что полетел винчестер и полет этот будет не долгим.

Если повезет, то может все оказаться не так уж и плохо и если есть “ubuntu live cd” под рукой, то систему возможно удастся восстановить. Для этого достаточно загрузить “живую сессию” с диска, открыть терминал(в гноме: alt+f2 и набор gnome-terminal) и ввести следующую команду:

sudo fdisk -l

которая не смотря на провалы в памяти и отчаянные попытки пользователя вспомнить, где же была им установлена его система, выведет на экран эту весьма полезную информацию (что-то вроде этой).

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b7921

Device Boot Start End Blocks Id System
/dev/sda1 * 1 18709 150274048 83 Linux
/dev/sda2 18709 19458 6013953 5 Extended
/dev/sda5 18709 19458 6013952 82 Linux swap / Solaris

После чего можно попытаться восстановить файловую систему (ext3 или ext4), воспользовавшись журналом, про помощи следующей команды, и в случае успеха системой снова можно пользоваться.

sudo e2fsck -fyv /dev/sda1

ps: ну а если даже и диска под рукой рядом не оказалось, то и тут не стоит окончательно отчаиваться. По идее, достаточно постоянно пытаться загрузить компьютер, и где-то на сороковой попытке монтирования, система сжалится над вами и включится автоматическая проверка файловой системы на ошибки, которая вероятней всего восстановит диск и систему можно будет запустить;) удачи!