segunda-feira, 6 de agosto de 2012

Deuglifying KDE on Ubuntu 12.04 Precise

Growing and maintaining a consistent Linux distribution like Ubuntu up to date is a very serious job. Making money from it to support further developments is another one. Canonical chose GNOME at first and pushed Unity afterwards. They made a beautiful and well integrated desktop that is a pleasure to use. We are certainly thankful.

What if you like KDE? Oh well, we can't all be happy. Or can we?

The integration of KDE on Ubuntu (in fact even Kubuntu) is not exactly the most polished thing in the world (let's not mention the default wallpaper... :-) . But that can be fixed and once done doesn't seem that difficult.

The fix is made of two steps, on top of the default Ubuntu 12.04 installation:

1) Choose your KDE based applications. Remove redundant GNOME based applications
apt-get install kde-plasma-desktop khelpcenter4 kdeartwork kdeartwork-style plasma-desktopthemes-artwork kde-artwork-active kde-wallpapers kdewallpapers plasma-widgets-addons kde-l10n-pt ksnapshot gtk2-engines-oxygen gtk3-engines-oxygen libreoffice-kde kontact okular smplayer gwenview ark
apt-get remove totem empathy evince brasero evolution rhythmbox shotwell konqueror file-roller nautilus eog
This will bring you a desktop with a set of applications that work well together and nicely fit a KDE desktop.

2) Prepare the contents of .kde and install them on /etc/skel

Note: it you don't know what /etc/skel is please read a correct explanation here.

This is a surgical step that will ensure you only have to customize users once. Proceed as follows: 2.1 )backup your default .kde
cp -R .kde dot_kde
2.2) Change whatever has to be changed in the GUI (menus, panels, desktop, etc) 2.3) Detect configuration file changes
diff -qr .kde dot_kde
2.4) Sanitize the content of your configuration files

This not an algorithmic step but something to learn from inspection, trial and error. In the cleanup process is important to remove any references to the specific user you are logged in with (ex: references to Recent Files), and unnecessary geometry related references (ex: absolute dimensions of a panel) that should be calculated on the first login.

2.5) Install the modified files from .kde/share/config and .kde/share/apps under /etc/skel/.kde ...

2.6) Create a new user and login. If it's not as you want it go back to step 2.2)


3) Other configuration files

Follow the same logic for all other application configuration files. For example, if you use SMPlayer as a media player you may want  to preconfigure it on

/etc/skel/.config/smplayer/smplayer.ini. 

You may also want to configure GTK so that GTK base applications look good under KDE

/etc/skel/.gtkrc-2.0
/etc/skel/.config/gtk-3.0/settings.ini
Here is an example of settings.ini

[Settings]
gtk-theme-name=oxygen-gtk
gtk-icon-theme-name=oxygen-old
gtk-font-name=Sans 10
gtk-cursor-theme-name=DMZ-White
gtk-cursor-theme-size=0
gtk-toolbar-style=GTK_TOOLBAR_BOTH_HORIZ
gtk-toolbar-icon-size=GTK_ICON_SIZE_LARGE_TOOLBAR
gtk-button-images=1
gtk-menu-images=1
gtk-enable-event-sounds=1
gtk-enable-input-feedback-sounds=1
gtk-xft-antialias=1
gtk-xft-hinting=1
gtk-xft-hintstyle=hintfull
Once done, this will make GTK based applications use a theme that somewhat matches the looks of KDE applications, unlike the default theme that doesn't look good at all under KDE.


4) Enjoy effortless KDE installations

If things went right you can now add/remove the packages and install the skel configuration files on a post-install script. The result could look like this.




1 comentário:

DarkLord disse...

Só mais umas achegas que podem ajudar outras pessoas.

Além de colocar no /etc/skel, o KDE também permite configurações usando um pseudo javascript para ser executado qd um utilizador entra no KDE.

Para isso existe este ficheiro (este é para Caixa Mágica 18, para Kubuntu deve ser semelhante):

/usr/share/caixamagicakde-default-settings/kde4-profile/default/share/apps/plasma-desktop/init/

Os scripts aqui colocados são executados por ordem alfabética.

Se quisermos que existam scripts a serem corridos após os iniciais (e em todos os arranques, mas tenho de confirmar) colocamos em:

/usr/share/caixamagicakde-default-settings/kde4-profile/default/share/apps/plasma-desktop/updates/

A configuração para usar este scripts em primeiro lugar está em:

/etc/kde4rc

Depois de serem corridos são executados os scrips por omissão do sistema que estão em:

/usr/share/kde4/apps/plasma-desktop/init/

e depois são executados estes (e em todos os arranques, mas tenho de confirmar)

/usr/share/kde4/apps/plasma-desktop/updates/

MUITO IMPORTANTE - estes scripts emulam o comportamente de um utilizador, logo temos de ter o widgets desbloqueados para eles fazerem alguma coisa.

Exemplos
Alterar o tipo de desktop por omissão

Se por exemplo quisermos alterar o tipo de desktop por omissão para o folderview sempre que um novo utilizador é criado basta editar-mos o ficheiro "/usr/share/caixamagicakde-default-settings/kde4-profile/default/share/apps/plasma-desktop/init/00-defaultLayout.js" e comentar as linhas (com // no inicio) ou remover:

var activity = new Activity("desktop");

folderview = activity.addWidget("folderview");
folderview.writeConfig("url", "desktop:/");

E substituir por:

var activity = new Activity("folderview");

Passar a ter os widgets bloqueados por omissão

ATENÇÃO - isto tem de ser a última coisa a fazer de tudo o que é executado senão as outras configurações não funcionam... e é melhor ainda fazer um pequeno timeout just in case.

Criamos o ficheiro /usr/share/kde4/apps/plasma-desktop/updates/zz-lock.js com o seguinte conteúdo:

sleep(2);
locked = true;

Links importantes

http://techbase.kde.org/KDE_System_Administration/PlasmaDesktopScripting http://forum.kde.org/viewtopic.php?f=67&t=92001 http://forum.kde.org/viewtopic.php?f=67&t=93789


Espero que ajude