https://wiki.archlinux.org/api.php?action=feedcontributions&user=Miezebieze&feedformat=atomArchWiki - User contributions [en]2024-03-28T20:07:44ZUser contributionsMediaWiki 1.41.0https://wiki.archlinux.org/index.php?title=Uniform_look_for_Qt_and_GTK_applications&diff=263955Uniform look for Qt and GTK applications2013-06-23T11:36:00Z<p>Miezebieze: /* Changing styles in each toolkit */</p>
<hr />
<div>[[Category:Desktop environments]]<br />
[[Category:Eye candy]]<br />
[[es:Uniform Look for Qt and GTK Applications]]<br />
[[it:Uniform Look for Qt and GTK Applications]]<br />
[[ru:Uniform Look for Qt and GTK Applications]]<br />
[[uk:Uniform Look for Qt and GTK Applications]]<br />
[[zh-CN:Uniform Look for Qt and GTK Applications]]<br />
{{Article summary start}}<br />
{{Article summary text|This articles details theme configuration of GTK+ at Qt applications to ensure a uniform style. This article will cover configuration, theme engines, tricks and troubleshooting.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|GTK+}}<br />
{{Article summary wiki|Qt}}<br />
{{Article summary end}}<br />
<br />
[[Qt]] and [[GTK+]] based programs both use a different widget toolkit to render the graphical user interface. Each come with different themes, styles and icon sets by default, among other things, so the "look and feel" differ significantly. This article will help you make your Qt and GTK+ applications look similar for a more streamlined and integrated desktop experience.<br />
<br />
To get a similar look between the two you will most likely have to modify the following:<br />
* '''Theme''': The custom appearance of an application, widget set, etc. It usually consists of a style, an icon theme and a color theme.<br />
* '''Style''': The graphical layout and look of the widget set.<br />
* '''Icon Theme''': A set of global icons.<br />
* '''Color Theme''': A set of global colors that are used in conjunction with the style.<br />
<br />
You can choose various approaches:<br />
<br />
* Modify [[Uniform Look for QT and GTK Applications#Styles for both Qt and GTK+|GTK+ and Qt styles]] separately with the tools listed below for each toolkit and aim for choosing similarly looking themes (style, colors, icons, cursors, fonts).<br />
* Use a special [[Uniform Look for QT and GTK Applications#Theme Engines|theme engine]], which intermediates the modification of the other graphical toolkit to match your main toolkit:<br />
** if you work in KDE 4 desktop environment then a GTK-Qt engine is available, which updates GTK+ configuration files automatically so that GTK+ appearance is similar to the Qt one;<br />
** if you work in other desktop environments, you can choose the QGtkStyle engine (built in Qt), which forces Qt apps to use your GTK+ 2.x theme.<br />
<br />
Should you use also GTK+ 3.x toolkit, follow the [[GTK+#GTK+ 3.x|GTK+ 3.x]] wiki article to find out how to make it look similar to GTK+ 2.x themes.<br />
<br />
== Styles for both Qt and GTK+ ==<br />
<br />
There are widget style sets available for the purpose of integration, where builds are written and provided for both Qt and GTK+, all major versions included. With these, you can have one look for all applications regardless of the toolkit they had been written with.<br />
<br />
=== KDE4 Oxygen ===<br />
<br />
[http://www.oxygen-icons.org/ Oxygen] is a Qt style that comes by default with KDE4. There are various ways of mimicking its appearance that are described below.<br />
<br />
==== oxygen-gtk ====<br />
<br />
[http://kde-look.org/content/show.php/?content&#61;136216 oxygen-gtk] is a port of the Oxygen Qt Style to GTK+ done by the Oxygen developers. Unlike other attempts, it is a native GTK+ style that does not depend on Qt (via some Qt to GTK+ conversion engine) nor does it render widget appearances via hard coded pixmaps. The style has the primary goal to ensure visual consistency between GTK+ 2.x/3.x and Qt-based applications running under KDE with a secondary objective to also have a standalone, nice looking GTK+ theme that behaves well in other desktop environments.<br />
<br />
The style has GTK+ 2.x and GTK+ 3.x variants which can be [[Pacman|installed]] with the {{Pkg|oxygen-gtk2}} or {{Pkg|oxygen-gtk3}} packages, available in the [[official repositories]].<br />
<br />
{{Note|Before KDE 4.10, you needed to create the file {{ic|~/.kde4/share/config/gtkrc-2.0}}, or let it automatically create like described below. But that is actually counter-productive with KDE 4.10’s oxygen-gtk, and you should delete this file after upgrading to prevent it from messing with your colors. Cleanup-removal of {{ic|~/.kde4/share/config/gtkrc}} might be necessary, too.}}<br />
<br />
===== Automatic procedure =====<br />
<br />
A few [[#GTK2 styles|dedicated applications]] are available in the official repositories that are able to change the GTK+ theme.<br />
<br />
You can also install {{Pkg|kde-gtk-config}}. After installation, it can be found in ''System Settings > Application Appearance > GTK Configuration''. It allows you to configure the look and feel for both GTK+ 2.x and GTK+ 3.x applications and is integrated with the KDE add-on installer (Get Hot New Stuff), so you can also download and install other GTK+ themes.<br />
<br />
===== Manual procedure =====<br />
<br />
To manually change the GTK+ theme to '''oxygen-gtk''', you need to create the file {{ic|~/.kde4/share/config/gtkrc-2.0}} with the following content:<br />
{{hc|~/.kde4/share/config/gtkrc-2.0|<nowiki><br />
include "/usr/share/themes/oxygen-gtk/gtk-2.0/gtkrc"<br />
include "~/.themes/oxygen-gtk/gtk-2.0/gtkrc"<br />
<br />
style "user"<br />
{ <br />
fg[NORMAL] = "#1b1918"<br />
bg[NORMAL] = "#d5d1cf"<br />
text[NORMAL] = "#181615"<br />
base[NORMAL] = "#ffffff"<br />
fg[ACTIVE] = "#1b1918"<br />
bg[ACTIVE] = "#d5d1cf"<br />
text[ACTIVE] = "#181615"<br />
base[ACTIVE] = "#ffffff"<br />
fg[PRELIGHT] = "#1b1918"<br />
bg[PRELIGHT] = "#d5d1cf"<br />
text[PRELIGHT] = "#ffffff"<br />
base[PRELIGHT] = "#43ace8"<br />
fg[SELECTED] = "#1b1918"<br />
bg[SELECTED] = "#d5d1cf"<br />
text[SELECTED] = "#ffffff"<br />
base[SELECTED] = "#43ace8"<br />
fg[INSENSITIVE] = "#8d8a88"<br />
bg[INSENSITIVE] = "#ccc7c5"<br />
text[INSENSITIVE] = "#a6a5a5"<br />
base[INSENSITIVE] = "#f4f4f4"<br />
GtkTreeView::odd_row_color="#ffffff"<br />
GtkTreeView::even_row_color="#f8f7f6"<br />
}<br />
<br />
widget_class "*" style "user"<br />
<br />
style "tooltips"<br />
{ <br />
bg[NORMAL] = "#bedfff"<br />
fg[NORMAL] = "#252321"<br />
}<br />
<br />
widget "gtk-tooltips" style "tooltips"<br />
#gtk-theme-name="qt4"<br />
gtk-font-name="Sans Serif 9"<br />
gtk-icon-theme-name="gk4ico"<br />
gtk-icon-sizes = "panel-menu=16,16:panel=16,16:gtk-button=22,22:gtk-large-toolbar=22,22"<br />
</nowiki><br />
}}<br />
<br />
Then you need to create the symbolic link {{ic|~/.kde4/share/config/gtkrc}}:<br />
$ ln -s ~/.kde4/share/config/gtkrc-2.0 ~/.kde4/share/config/gtkrc<br />
<br />
==== Oxygen icons ====<br />
<br />
If you are using Oxygen icons and want a consistent look in GTK+ dialogs, you can install the {{AUR|oxygenrefit2-icon-theme}} icon theme from [[AUR]] and set it as your GTK+ icon theme. To apply the theme you can use {{ic|lxappearance}} (or a similar program) or set it manually by adding the following line to {{ic|~/.kde4/share/config/gtkrc-2.0}}:<br />
gtk-icon-theme-name="OxygenRefit2"<br />
<br />
Another version of the Oxygen icon theme for GTK+ applications can be installed with the {{AUR|oxygen-gtk-icons}} package from [[AUR]].<br />
<br />
=== QtCurve ===<br />
<br />
QtCurve is a highly popular and configurable set of widget styles for Qt4/KDE4, KDE3 and GTK+ 2.x. QtCurve can be installed with the packages {{Pkg|qtcurve-kde4}}, {{Pkg|qtcurve-kde3}} or {{Pkg|qtcurve-gtk2}}, all available in the official repositories. It has many controls for various options, ranging from the appearance of buttons to the shape of sliders.<br />
<br />
To manually change the GTK+ theme to '''QtCurve''', you need to create the file {{ic|~/.gtkrc-2.0-kde4}} with the following content:<br />
include "/usr/share/themes/QtCurve/gtk-2.0/gtkrc"<br />
include "/etc/gtk-2.0/gtkrc"<br />
<br />
style "user-font"<br />
{<br />
font_name="Sans Serif"<br />
}<br />
widget_class "*" style "user-font" <br />
gtk-theme-name="QtCurve"<br />
<br />
Then you need to create the symbolic link {{ic|~/.gtkrc-2.0}}:<br />
ln -s .gtkrc-2.0-kde4 .gtkrc-2.0<br />
If you want also specify a font, you can add (and adapt) the following line to the file:<br />
gtk-font-name="Sans Serif 9"<br />
<br />
=== Others ===<br />
<br />
Similar style sets are those that look like each other - written and provided for both Qt and GTK+ - but are not necessarily from the same developers. You may have to do some minor tweaking to make them look the same (e.g. {{AUR|kdestyle-klearlook}} for Qt4/KDE4 and the Clearlooks GTK+ theme).<br />
<br />
== Changing styles in each toolkit ==<br />
<br />
You can use the following methods to change the theme used in each environment.<br />
<br />
=== Qt4 styles ===<br />
<br />
Qt4 styles cand be changed in a similar way:<br />
* Using the ''KDE4 System Settings'' (systemsettings), the settings can be found in ''Common Appearance and Behavior > Application Appearance > Style > Widget Style''<br />
* Using the command-line tool {{ic|$ kwriteconfig --file kdeglobals --group General --key widgetStyle [name of style]}}.<br />
* Using the ''Qt Configuration'' ('''qtconfig-qt4''') application, the settings can be found in ''Appearance > Select GUI Style''.<br />
<br />
Note that while Qt Configuration allows you to choose the theme, font, etc. for Qt apps, you can modify more settings with KDE4 System Settings (e.g. font antialiasing and hinting).<br />
<br />
=== Qt3 styles ===<br />
<br />
Qt3 styles can be changed in the following ways:<br />
* Using the ''KDE3 Control Center'' ('''kcontrol'''), the settings can be found in ''Appearance & Themes > Style > Widget Style''.<br />
* Using the command-line tool {{ic|kde-config --style [name of style]}}.<br />
* Using the default ''Qt Configuration'' ('''qt3config''') application, the settings can be found in ''Appearance > Select GUI Style''.<br />
<br />
=== GTK+3 styles ===<br />
<br />
Some applications and methods are available to change the GTK+ 3.x styles:<br />
* {{App|kde-gtk-config|Application that allows you to change style and font of GTK+2 and Gtk+3 applications.|https://projects.kde.org/kde-gtk-config|{{Pkg|kde-gtk-config}}}}<br />
:After installation, {{ic|kde-gtk-config}} can also be found in ''System Settings > Application Appearance > GTK''.<br />
* {{App|LXAppearance|Desktop independent GTK+2 and GTK+3 style configuration tool from the LXDE project (it does not require other parts of the LXDE desktop).|http://wiki.lxde.org/en/LXAppearance|{{Pkg|lxappearance}}}}<br />
<br />
=== GTK+2 styles ===<br />
<br />
Various applications and methods are available to change the GTK+ 2.x styles:<br />
(See GTK+3 section above for more.)<br />
* {{App|gtk-kde4|Application that allows you to change style and font of GTK+2 applications in KDE4.|http://kde-look.org/content/show.php?content&#61;74689|{{Aur|gtk-kde4}}}}<br />
:After installation, {{ic|gtk-kde4}} can also be found in ''System Settings > Lost and Found > GTK style''.<br />
* {{App|GTK+ Change Theme|Little program that lets you change your GTK+ 2.0 theme (considered a better alternative to ''switch2'').|http://plasmasturm.org/code/gtk-chtheme/|{{Pkg|gtk-chtheme}}}}<br />
* {{App|GTK+ Preference Tool|GTK+ theme selector and font switcher.|http://gtk-win.sourceforge.net/home/index.php/Main/GTKPreferenceTool|{{Pkg|gtk2_prefs}}}}<br />
* {{App|GTK+ Theme Switch|Simple GTK+ theme switcher.|http://muhri.net/nav.php3?node&#61;gts|{{Pkg|gtk-theme-switch2}}}}<br />
* For manual configuration see the [[GTK%2B#GTK.2B_2.x|GTK+ page]].<br />
<br />
=== GTK+1 styles ===<br />
<br />
To change GTK1 styles you can install the {{AUR|gtk-theme-switch}} package from the [[AUR]].<br />
<br />
== Theme engines ==<br />
A Theme Engine can be thought of as a thin layer API which translates themes (excluding icons) between one or more toolkits. These engines add some extra code in the process and it is arguable that this kind of a solution is not as elegant and optimal as using native styles.<br />
<br />
=== GTK+-Qt engine ===<br />
<br />
This one is for use by GTK+ applications running in KDE, which basically means this does not work in other desktop environments. It applies all Qt settings (styles, fonts, not icons though) to the GTK+ applications and uses the style plugins directly. This engine can be installed with the {{Aur|gtk-qt-engine}} package, available in the AUR.<br />
<br />
{{Note|There are rendering issues with some Qt styles.}}<br />
<br />
You can access it from the ''KDE System Settings'' under ''Lost and Found > GTK Styles and Fonts''.<br />
<br />
If you want to remove the engine entirely you need to uninstall it and also delete the following files:<br />
$ rm ~/.gtkrc2.0-kde<br />
$ rm ~/.kde4/env/gtk-qt-engine.rc.sh<br />
$ rm ~/gtk-qt-engine.rc<br />
<br />
=== QGtkStyle ===<br />
<br />
This is a Qt style which intends to make applications blend perfectly into the GNOME desktop environment by using GTK+ to render all components. To use this style you must have at least GTK+ 2.0 and Qt 4.3, although Qt 4.4 or higher is preferred. To enable this style, use:<br />
* ''Qt Configuration'': choose "GTK+" under ''Appearance > GUI Style''.<br />
* ''KDE4 System Settings'': choose "GTK+ Style" under ''Application Appearance > Style > Applications''.<br />
* the command-line: edit the {{ic|~/.config/Trolltech.conf}} file by adding:<br />
<br />
{{hc|~/.config/Trolltech.conf|<nowiki><br />
...<br />
[Qt]<br />
style=GTK+<br />
...</nowiki>}}<br />
<br />
{{Note|Beginning with version 4.5 this style is included in Qt and does not require a separate package anymore.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== KDE file dialogs for GTK+ applications ===<br />
<br />
[http://kde-apps.org/content/show.php?content&#61;36077 KGtk] is a wrapper script that uses LD_PRELOAD to force KDE file dialogs (open, save, etc.) in GTK+ 2.x apps. If you use KDE and prefer its file dialogs over GTK+'s then you can install {{AUR|kgtk}} from the [[AUR]] (a KDE3 version is also available in the {{AUR|kde3-kgtk}} package). Once installed you can run GTK+ 2.x applications with {{ic|kgtk-wrapper}} in two ways (using [[Gimp]] in the examples):<br />
* Calling {{ic|kgtk-wrapper}} directly and using the GTK+ 2.x binary as an argument:<br />
$ /usr/bin/kgtk-wrapper gimp<br />
* Creating a symbolic link to {{ic|kgtk}} using the name of the GTK+ 2.x binary:<br />
$ ln -s /usr/bin/kgtk-wrapper /usr/local/bin/gimp<br />
:To run the version of Gimp with KDE dialogs, make sure you have {{ic|/usr/local/bin/}} before {{ic|/usr/bin/}} in your {{ic|PATH}}.<br />
{{Note|Some GTK+ applications may not be compatible with KGtk.}}<br />
<br />
=== aMSN with GTK+ or KDE dialogs ===<br />
<br />
aMSN's uses the Tk toolkit for its user interface. To make it use GTK+ or KDE dialogs install the {{AUR|amsn-plugins-desktopintegration}} plugin available in the [[AUR]]. Other plugins can be found on [http://www.amsn-project.net/plugins.php aMSN's Plugin Page].<br />
<br />
=== Run an application with a specific theme ===<br />
<br />
You can use custom styles for specific GTK+ 2.x applications. To run an application with a specific theme use:<br />
GTK2_RC_FILES=/usr/share/themes/QtCurve/gtk-2.0/gtkrc firefox<br />
<br />
This will launch Firefox with the QtCurve theme.<br />
<br />
=== Using a GTK+ icon theme in Qt apps ===<br />
<br />
If you are not using GNOME, run {{ic|gconf-editor}}, look under ''desktop > gnome > interface'' for the {{ic|icon_theme}} key and change it to your preference.<br />
<br />
=== Improve subpixel rendering of GTK apps under KDE ===<br />
<br />
If the subpixel rendering in GTK apps is not as sharp as in native KDE Qt applications, try to add the following lines to your {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}} (between the {{ic|<fontconfig>}} tags):<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== gtk-qt-engine does not work with OpenOffice ===<br />
<br />
To make OpenOffice respect the Qt theme chosen with the GTK+-Qt Engine you need to add the following line to {{ic|/etc/profile}} (as root):<br />
export SAL_GTK_USE_PIXMAPPAINT=1<br />
<br />
Also make sure to select "Use my KDE style in GTK applications" in ''KDE4 System Settings'' under ''Lost and Found > GTK Styles and Fonts''.<br />
<br />
=== Qt applications do not use QGtkStyle ===<br />
<br />
Qt will not apply QGtkStyle correctly if GTK+ is using the [[#GTK+-Qt Engine|GTK+-Qt Engine]]. Qt determines whether the GTK+-Qt Engine is in use by reading the GTK+ configuration files listed in the environmental variable {{ic|GTK2_RC_FILES}}. If the environmental variable is not set properly, Qt assumes you are using the engine, sets QGtkStyle to use the style GTK+ style ''Clearlooks'', and outputs an error message:<br />
<br />
QGtkStyle cannot be used together with the GTK_Qt engine.<br />
<br />
Another error you may get after launching {{ic|qtconfig}} from a shell and selecting the GTK+ style is:<br />
<br />
QGtkStyle was unable to detect the current GTK+ theme.<br />
<br />
According to [https://bbs.archlinux.org/viewtopic.php?id&#61;99175&p&#61;1 this thread], you may simply have to install {{Pkg|libgnomeui}} to solve this issue. This has the added benefit that you don't need to edit a file every time you change your theme via a graphical tool, like the one provided by xfce.<br />
<br />
Users of [[Openbox]] and other non-GNOME environments may encounter this problem. To solve this, first add the following to your {{ic|.xinitrc}} file:<br />
{{hc|.xinitrc|<nowiki><br />
...<br />
export GTK2_RC_FILES="$HOME/.gtkrc-2.0"<br />
...<br />
</nowiki>}}<br />
<br />
{{Note|<br />
* Make sure to add this line before invoking the window manager.<br />
* You can add multiple paths by separating them with colons.<br />
* Make sure to use {{ic|$HOME}} instead of {{ic|~}} as it will not properly expand to the user's home directory.<br />
}}<br />
<br />
Then specify the theme you want in the {{ic|~/.gtkrc-2.0}} file using a [[#GTK2 styles|dedicated application]] or manually, by adding:<br />
{{hc|.gtkrc-2.0|<nowiki><br />
...<br />
gtk-theme-name="[name of theme]"<br />
...<br />
</nowiki>}}<br />
<br />
Some tools only insert the following include directive in {{ic|~/.gtkrc-2.0}}:<br />
{{hc|.gtkrc-2.0|<br />
...<br />
include "/usr/share/themes/SomeTheme/gtk-2.0/gtkrc"<br />
...<br />
}}<br />
<br />
which apparently is not recognized by all versions of QGtkStyle. You can hotfix this problem by inserting the {{ic|gtk-theme-name}} manually in your {{ic|~/.gtkrc-2.0}} file like above.<br />
<br />
{{Note|Style-changing applications will most probably rewrite the {{ic|~/.gtkrc-2.0}} file the next time you change themes.}}<br />
<br />
If these steps do not work, install {{Pkg|gconf}} and run this command:<br />
<br />
gconftool-2 --set --type string /desktop/gnome/interface/gtk_theme [name of theme]<br />
<br />
If you further want to set the same icon and cursor theme, then you have to specify them, too.<br />
<br />
gconftool-2 --set --type string /desktop/gnome/interface/icon_theme Faenza-Dark<br />
<br />
This sets the icon theme to Faenza-Dark located in {{ic|/usr/share/icons/Faenza-Dark}}. For the cursor theme you first have to set the gconf value.<br />
<br />
gconftool-2 --set --type string /desktop/gnome/peripherals/mouse/cursor_theme Adwaita<br />
<br />
Then you will have to create the file {{ic|/usr/share/icons/default/index.theme}} with the following lines:<br />
<br />
[Icon Theme]<br />
Inherits=Adwaita<br />
<br />
=== Themes not working in GTK+ apps ===<br />
<br />
If the style or theme engine you set up is not showing in your GTK applications then it's likely your GTK+ settings files are not being loaded for some reason. You can check where your system expects to find these files by doing the following..<br />
$ export | grep gtk<br />
<br />
Usually the expected files should be {{ic|~/.gtkrc}} for GTK1 and {{ic|~/.gtkrc2.0}} or {{ic|~/.gtkrc2.0-kde}} for GTK+ 2.x.<br />
<br />
Newer versions of {{Aur|gtk-qt-engine}} use {{ic|~/.gtkrc2.0-kde}} and set the export variable in {{ic|~/.kde/env/gtk-qt-engine.rc.sh}}.<br />
If you recently removed '''gtk-qt-engine''' and are trying to set a GTK+ theme then you must also remove {{ic|~/.kde/env/gtk-qt-engine.rc.sh}} and reboot. Doing this will ensure that GTK+ looks for it's settings in the standard {{ic|~/.gtkrc2.0}} instead of the {{ic|~/.gtkrc2.0-kde}} file.</div>Miezebiezehttps://wiki.archlinux.org/index.php?title=Uniform_look_for_Qt_and_GTK_applications&diff=263954Uniform look for Qt and GTK applications2013-06-23T11:34:39Z<p>Miezebieze: /* Changing styles in each toolkit */ added Gtk+3 section</p>
<hr />
<div>[[Category:Desktop environments]]<br />
[[Category:Eye candy]]<br />
[[es:Uniform Look for Qt and GTK Applications]]<br />
[[it:Uniform Look for Qt and GTK Applications]]<br />
[[ru:Uniform Look for Qt and GTK Applications]]<br />
[[uk:Uniform Look for Qt and GTK Applications]]<br />
[[zh-CN:Uniform Look for Qt and GTK Applications]]<br />
{{Article summary start}}<br />
{{Article summary text|This articles details theme configuration of GTK+ at Qt applications to ensure a uniform style. This article will cover configuration, theme engines, tricks and troubleshooting.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|GTK+}}<br />
{{Article summary wiki|Qt}}<br />
{{Article summary end}}<br />
<br />
[[Qt]] and [[GTK+]] based programs both use a different widget toolkit to render the graphical user interface. Each come with different themes, styles and icon sets by default, among other things, so the "look and feel" differ significantly. This article will help you make your Qt and GTK+ applications look similar for a more streamlined and integrated desktop experience.<br />
<br />
To get a similar look between the two you will most likely have to modify the following:<br />
* '''Theme''': The custom appearance of an application, widget set, etc. It usually consists of a style, an icon theme and a color theme.<br />
* '''Style''': The graphical layout and look of the widget set.<br />
* '''Icon Theme''': A set of global icons.<br />
* '''Color Theme''': A set of global colors that are used in conjunction with the style.<br />
<br />
You can choose various approaches:<br />
<br />
* Modify [[Uniform Look for QT and GTK Applications#Styles for both Qt and GTK+|GTK+ and Qt styles]] separately with the tools listed below for each toolkit and aim for choosing similarly looking themes (style, colors, icons, cursors, fonts).<br />
* Use a special [[Uniform Look for QT and GTK Applications#Theme Engines|theme engine]], which intermediates the modification of the other graphical toolkit to match your main toolkit:<br />
** if you work in KDE 4 desktop environment then a GTK-Qt engine is available, which updates GTK+ configuration files automatically so that GTK+ appearance is similar to the Qt one;<br />
** if you work in other desktop environments, you can choose the QGtkStyle engine (built in Qt), which forces Qt apps to use your GTK+ 2.x theme.<br />
<br />
Should you use also GTK+ 3.x toolkit, follow the [[GTK+#GTK+ 3.x|GTK+ 3.x]] wiki article to find out how to make it look similar to GTK+ 2.x themes.<br />
<br />
== Styles for both Qt and GTK+ ==<br />
<br />
There are widget style sets available for the purpose of integration, where builds are written and provided for both Qt and GTK+, all major versions included. With these, you can have one look for all applications regardless of the toolkit they had been written with.<br />
<br />
=== KDE4 Oxygen ===<br />
<br />
[http://www.oxygen-icons.org/ Oxygen] is a Qt style that comes by default with KDE4. There are various ways of mimicking its appearance that are described below.<br />
<br />
==== oxygen-gtk ====<br />
<br />
[http://kde-look.org/content/show.php/?content&#61;136216 oxygen-gtk] is a port of the Oxygen Qt Style to GTK+ done by the Oxygen developers. Unlike other attempts, it is a native GTK+ style that does not depend on Qt (via some Qt to GTK+ conversion engine) nor does it render widget appearances via hard coded pixmaps. The style has the primary goal to ensure visual consistency between GTK+ 2.x/3.x and Qt-based applications running under KDE with a secondary objective to also have a standalone, nice looking GTK+ theme that behaves well in other desktop environments.<br />
<br />
The style has GTK+ 2.x and GTK+ 3.x variants which can be [[Pacman|installed]] with the {{Pkg|oxygen-gtk2}} or {{Pkg|oxygen-gtk3}} packages, available in the [[official repositories]].<br />
<br />
{{Note|Before KDE 4.10, you needed to create the file {{ic|~/.kde4/share/config/gtkrc-2.0}}, or let it automatically create like described below. But that is actually counter-productive with KDE 4.10’s oxygen-gtk, and you should delete this file after upgrading to prevent it from messing with your colors. Cleanup-removal of {{ic|~/.kde4/share/config/gtkrc}} might be necessary, too.}}<br />
<br />
===== Automatic procedure =====<br />
<br />
A few [[#GTK2 styles|dedicated applications]] are available in the official repositories that are able to change the GTK+ theme.<br />
<br />
You can also install {{Pkg|kde-gtk-config}}. After installation, it can be found in ''System Settings > Application Appearance > GTK Configuration''. It allows you to configure the look and feel for both GTK+ 2.x and GTK+ 3.x applications and is integrated with the KDE add-on installer (Get Hot New Stuff), so you can also download and install other GTK+ themes.<br />
<br />
===== Manual procedure =====<br />
<br />
To manually change the GTK+ theme to '''oxygen-gtk''', you need to create the file {{ic|~/.kde4/share/config/gtkrc-2.0}} with the following content:<br />
{{hc|~/.kde4/share/config/gtkrc-2.0|<nowiki><br />
include "/usr/share/themes/oxygen-gtk/gtk-2.0/gtkrc"<br />
include "~/.themes/oxygen-gtk/gtk-2.0/gtkrc"<br />
<br />
style "user"<br />
{ <br />
fg[NORMAL] = "#1b1918"<br />
bg[NORMAL] = "#d5d1cf"<br />
text[NORMAL] = "#181615"<br />
base[NORMAL] = "#ffffff"<br />
fg[ACTIVE] = "#1b1918"<br />
bg[ACTIVE] = "#d5d1cf"<br />
text[ACTIVE] = "#181615"<br />
base[ACTIVE] = "#ffffff"<br />
fg[PRELIGHT] = "#1b1918"<br />
bg[PRELIGHT] = "#d5d1cf"<br />
text[PRELIGHT] = "#ffffff"<br />
base[PRELIGHT] = "#43ace8"<br />
fg[SELECTED] = "#1b1918"<br />
bg[SELECTED] = "#d5d1cf"<br />
text[SELECTED] = "#ffffff"<br />
base[SELECTED] = "#43ace8"<br />
fg[INSENSITIVE] = "#8d8a88"<br />
bg[INSENSITIVE] = "#ccc7c5"<br />
text[INSENSITIVE] = "#a6a5a5"<br />
base[INSENSITIVE] = "#f4f4f4"<br />
GtkTreeView::odd_row_color="#ffffff"<br />
GtkTreeView::even_row_color="#f8f7f6"<br />
}<br />
<br />
widget_class "*" style "user"<br />
<br />
style "tooltips"<br />
{ <br />
bg[NORMAL] = "#bedfff"<br />
fg[NORMAL] = "#252321"<br />
}<br />
<br />
widget "gtk-tooltips" style "tooltips"<br />
#gtk-theme-name="qt4"<br />
gtk-font-name="Sans Serif 9"<br />
gtk-icon-theme-name="gk4ico"<br />
gtk-icon-sizes = "panel-menu=16,16:panel=16,16:gtk-button=22,22:gtk-large-toolbar=22,22"<br />
</nowiki><br />
}}<br />
<br />
Then you need to create the symbolic link {{ic|~/.kde4/share/config/gtkrc}}:<br />
$ ln -s ~/.kde4/share/config/gtkrc-2.0 ~/.kde4/share/config/gtkrc<br />
<br />
==== Oxygen icons ====<br />
<br />
If you are using Oxygen icons and want a consistent look in GTK+ dialogs, you can install the {{AUR|oxygenrefit2-icon-theme}} icon theme from [[AUR]] and set it as your GTK+ icon theme. To apply the theme you can use {{ic|lxappearance}} (or a similar program) or set it manually by adding the following line to {{ic|~/.kde4/share/config/gtkrc-2.0}}:<br />
gtk-icon-theme-name="OxygenRefit2"<br />
<br />
Another version of the Oxygen icon theme for GTK+ applications can be installed with the {{AUR|oxygen-gtk-icons}} package from [[AUR]].<br />
<br />
=== QtCurve ===<br />
<br />
QtCurve is a highly popular and configurable set of widget styles for Qt4/KDE4, KDE3 and GTK+ 2.x. QtCurve can be installed with the packages {{Pkg|qtcurve-kde4}}, {{Pkg|qtcurve-kde3}} or {{Pkg|qtcurve-gtk2}}, all available in the official repositories. It has many controls for various options, ranging from the appearance of buttons to the shape of sliders.<br />
<br />
To manually change the GTK+ theme to '''QtCurve''', you need to create the file {{ic|~/.gtkrc-2.0-kde4}} with the following content:<br />
include "/usr/share/themes/QtCurve/gtk-2.0/gtkrc"<br />
include "/etc/gtk-2.0/gtkrc"<br />
<br />
style "user-font"<br />
{<br />
font_name="Sans Serif"<br />
}<br />
widget_class "*" style "user-font" <br />
gtk-theme-name="QtCurve"<br />
<br />
Then you need to create the symbolic link {{ic|~/.gtkrc-2.0}}:<br />
ln -s .gtkrc-2.0-kde4 .gtkrc-2.0<br />
If you want also specify a font, you can add (and adapt) the following line to the file:<br />
gtk-font-name="Sans Serif 9"<br />
<br />
=== Others ===<br />
<br />
Similar style sets are those that look like each other - written and provided for both Qt and GTK+ - but are not necessarily from the same developers. You may have to do some minor tweaking to make them look the same (e.g. {{AUR|kdestyle-klearlook}} for Qt4/KDE4 and the Clearlooks GTK+ theme).<br />
<br />
== Changing styles in each toolkit ==<br />
<br />
You can use the following methods to change the theme used in each environment.<br />
<br />
=== Qt4 styles ===<br />
<br />
Qt4 styles cand be changed in a similar way:<br />
* Using the ''KDE4 System Settings'' (systemsettings), the settings can be found in ''Common Appearance and Behavior > Application Appearance > Style > Widget Style''<br />
* Using the command-line tool {{ic|$ kwriteconfig --file kdeglobals --group General --key widgetStyle [name of style]}}.<br />
* Using the ''Qt Configuration'' ('''qtconfig-qt4''') application, the settings can be found in ''Appearance > Select GUI Style''.<br />
<br />
Note that while Qt Configuration allows you to choose the theme, font, etc. for Qt apps, you can modify more settings with KDE4 System Settings (e.g. font antialiasing and hinting).<br />
<br />
=== Qt3 styles ===<br />
<br />
Qt3 styles can be changed in the following ways:<br />
* Using the ''KDE3 Control Center'' ('''kcontrol'''), the settings can be found in ''Appearance & Themes > Style > Widget Style''.<br />
* Using the command-line tool {{ic|kde-config --style [name of style]}}.<br />
* Using the default ''Qt Configuration'' ('''qt3config''') application, the settings can be found in ''Appearance > Select GUI Style''.<br />
<br />
=== GTK+3 styles ===<br />
<br />
Some applications and methods are available to change the GTK+ 2.x styles:<br />
* {{App|kde-gtk-config|Application that allows you to change style and font of GTK+2 and Gtk+3 applications.|https://projects.kde.org/kde-gtk-config|{{Pkg|kde-gtk-config}}}}<br />
:After installation, {{ic|kde-gtk-config}} can also be found in ''System Settings > Application Appearance > GTK''.<br />
* {{App|LXAppearance|Desktop independent GTK+2 and GTK+3 style configuration tool from the LXDE project (it does not require other parts of the LXDE desktop).|http://wiki.lxde.org/en/LXAppearance|{{Pkg|lxappearance}}}}<br />
<br />
=== GTK+2 styles ===<br />
<br />
Various applications and methods are available to change the GTK+ 2.x styles:<br />
* {{App|gtk-kde4|Application that allows you to change style and font of GTK+2 applications in KDE4.|http://kde-look.org/content/show.php?content&#61;74689|{{Aur|gtk-kde4}}}}<br />
:After installation, {{ic|gtk-kde4}} can also be found in ''System Settings > Lost and Found > GTK style''.<br />
* {{App|GTK+ Change Theme|Little program that lets you change your GTK+ 2.0 theme (considered a better alternative to ''switch2'').|http://plasmasturm.org/code/gtk-chtheme/|{{Pkg|gtk-chtheme}}}}<br />
* {{App|GTK+ Preference Tool|GTK+ theme selector and font switcher.|http://gtk-win.sourceforge.net/home/index.php/Main/GTKPreferenceTool|{{Pkg|gtk2_prefs}}}}<br />
* {{App|GTK+ Theme Switch|Simple GTK+ theme switcher.|http://muhri.net/nav.php3?node&#61;gts|{{Pkg|gtk-theme-switch2}}}}<br />
* For manual configuration see the [[GTK%2B#GTK.2B_2.x|GTK+ page]].<br />
(See GTK+3 section above for more.)<br />
<br />
=== GTK+1 styles ===<br />
<br />
To change GTK1 styles you can install the {{AUR|gtk-theme-switch}} package from the [[AUR]].<br />
<br />
== Theme engines ==<br />
A Theme Engine can be thought of as a thin layer API which translates themes (excluding icons) between one or more toolkits. These engines add some extra code in the process and it is arguable that this kind of a solution is not as elegant and optimal as using native styles.<br />
<br />
=== GTK+-Qt engine ===<br />
<br />
This one is for use by GTK+ applications running in KDE, which basically means this does not work in other desktop environments. It applies all Qt settings (styles, fonts, not icons though) to the GTK+ applications and uses the style plugins directly. This engine can be installed with the {{Aur|gtk-qt-engine}} package, available in the AUR.<br />
<br />
{{Note|There are rendering issues with some Qt styles.}}<br />
<br />
You can access it from the ''KDE System Settings'' under ''Lost and Found > GTK Styles and Fonts''.<br />
<br />
If you want to remove the engine entirely you need to uninstall it and also delete the following files:<br />
$ rm ~/.gtkrc2.0-kde<br />
$ rm ~/.kde4/env/gtk-qt-engine.rc.sh<br />
$ rm ~/gtk-qt-engine.rc<br />
<br />
=== QGtkStyle ===<br />
<br />
This is a Qt style which intends to make applications blend perfectly into the GNOME desktop environment by using GTK+ to render all components. To use this style you must have at least GTK+ 2.0 and Qt 4.3, although Qt 4.4 or higher is preferred. To enable this style, use:<br />
* ''Qt Configuration'': choose "GTK+" under ''Appearance > GUI Style''.<br />
* ''KDE4 System Settings'': choose "GTK+ Style" under ''Application Appearance > Style > Applications''.<br />
* the command-line: edit the {{ic|~/.config/Trolltech.conf}} file by adding:<br />
<br />
{{hc|~/.config/Trolltech.conf|<nowiki><br />
...<br />
[Qt]<br />
style=GTK+<br />
...</nowiki>}}<br />
<br />
{{Note|Beginning with version 4.5 this style is included in Qt and does not require a separate package anymore.}}<br />
<br />
== Tips and tricks ==<br />
<br />
=== KDE file dialogs for GTK+ applications ===<br />
<br />
[http://kde-apps.org/content/show.php?content&#61;36077 KGtk] is a wrapper script that uses LD_PRELOAD to force KDE file dialogs (open, save, etc.) in GTK+ 2.x apps. If you use KDE and prefer its file dialogs over GTK+'s then you can install {{AUR|kgtk}} from the [[AUR]] (a KDE3 version is also available in the {{AUR|kde3-kgtk}} package). Once installed you can run GTK+ 2.x applications with {{ic|kgtk-wrapper}} in two ways (using [[Gimp]] in the examples):<br />
* Calling {{ic|kgtk-wrapper}} directly and using the GTK+ 2.x binary as an argument:<br />
$ /usr/bin/kgtk-wrapper gimp<br />
* Creating a symbolic link to {{ic|kgtk}} using the name of the GTK+ 2.x binary:<br />
$ ln -s /usr/bin/kgtk-wrapper /usr/local/bin/gimp<br />
:To run the version of Gimp with KDE dialogs, make sure you have {{ic|/usr/local/bin/}} before {{ic|/usr/bin/}} in your {{ic|PATH}}.<br />
{{Note|Some GTK+ applications may not be compatible with KGtk.}}<br />
<br />
=== aMSN with GTK+ or KDE dialogs ===<br />
<br />
aMSN's uses the Tk toolkit for its user interface. To make it use GTK+ or KDE dialogs install the {{AUR|amsn-plugins-desktopintegration}} plugin available in the [[AUR]]. Other plugins can be found on [http://www.amsn-project.net/plugins.php aMSN's Plugin Page].<br />
<br />
=== Run an application with a specific theme ===<br />
<br />
You can use custom styles for specific GTK+ 2.x applications. To run an application with a specific theme use:<br />
GTK2_RC_FILES=/usr/share/themes/QtCurve/gtk-2.0/gtkrc firefox<br />
<br />
This will launch Firefox with the QtCurve theme.<br />
<br />
=== Using a GTK+ icon theme in Qt apps ===<br />
<br />
If you are not using GNOME, run {{ic|gconf-editor}}, look under ''desktop > gnome > interface'' for the {{ic|icon_theme}} key and change it to your preference.<br />
<br />
=== Improve subpixel rendering of GTK apps under KDE ===<br />
<br />
If the subpixel rendering in GTK apps is not as sharp as in native KDE Qt applications, try to add the following lines to your {{ic|$XDG_CONFIG_HOME/fontconfig/fonts.conf}} (between the {{ic|<fontconfig>}} tags):<br />
<br />
{{bc|<nowiki><br />
<match target="font"><br />
<edit mode="assign" name="lcdfilter"><br />
<const>lcddefault</const><br />
</edit><br />
</match><br />
</nowiki>}}<br />
<br />
== Troubleshooting ==<br />
<br />
=== gtk-qt-engine does not work with OpenOffice ===<br />
<br />
To make OpenOffice respect the Qt theme chosen with the GTK+-Qt Engine you need to add the following line to {{ic|/etc/profile}} (as root):<br />
export SAL_GTK_USE_PIXMAPPAINT=1<br />
<br />
Also make sure to select "Use my KDE style in GTK applications" in ''KDE4 System Settings'' under ''Lost and Found > GTK Styles and Fonts''.<br />
<br />
=== Qt applications do not use QGtkStyle ===<br />
<br />
Qt will not apply QGtkStyle correctly if GTK+ is using the [[#GTK+-Qt Engine|GTK+-Qt Engine]]. Qt determines whether the GTK+-Qt Engine is in use by reading the GTK+ configuration files listed in the environmental variable {{ic|GTK2_RC_FILES}}. If the environmental variable is not set properly, Qt assumes you are using the engine, sets QGtkStyle to use the style GTK+ style ''Clearlooks'', and outputs an error message:<br />
<br />
QGtkStyle cannot be used together with the GTK_Qt engine.<br />
<br />
Another error you may get after launching {{ic|qtconfig}} from a shell and selecting the GTK+ style is:<br />
<br />
QGtkStyle was unable to detect the current GTK+ theme.<br />
<br />
According to [https://bbs.archlinux.org/viewtopic.php?id&#61;99175&p&#61;1 this thread], you may simply have to install {{Pkg|libgnomeui}} to solve this issue. This has the added benefit that you don't need to edit a file every time you change your theme via a graphical tool, like the one provided by xfce.<br />
<br />
Users of [[Openbox]] and other non-GNOME environments may encounter this problem. To solve this, first add the following to your {{ic|.xinitrc}} file:<br />
{{hc|.xinitrc|<nowiki><br />
...<br />
export GTK2_RC_FILES="$HOME/.gtkrc-2.0"<br />
...<br />
</nowiki>}}<br />
<br />
{{Note|<br />
* Make sure to add this line before invoking the window manager.<br />
* You can add multiple paths by separating them with colons.<br />
* Make sure to use {{ic|$HOME}} instead of {{ic|~}} as it will not properly expand to the user's home directory.<br />
}}<br />
<br />
Then specify the theme you want in the {{ic|~/.gtkrc-2.0}} file using a [[#GTK2 styles|dedicated application]] or manually, by adding:<br />
{{hc|.gtkrc-2.0|<nowiki><br />
...<br />
gtk-theme-name="[name of theme]"<br />
...<br />
</nowiki>}}<br />
<br />
Some tools only insert the following include directive in {{ic|~/.gtkrc-2.0}}:<br />
{{hc|.gtkrc-2.0|<br />
...<br />
include "/usr/share/themes/SomeTheme/gtk-2.0/gtkrc"<br />
...<br />
}}<br />
<br />
which apparently is not recognized by all versions of QGtkStyle. You can hotfix this problem by inserting the {{ic|gtk-theme-name}} manually in your {{ic|~/.gtkrc-2.0}} file like above.<br />
<br />
{{Note|Style-changing applications will most probably rewrite the {{ic|~/.gtkrc-2.0}} file the next time you change themes.}}<br />
<br />
If these steps do not work, install {{Pkg|gconf}} and run this command:<br />
<br />
gconftool-2 --set --type string /desktop/gnome/interface/gtk_theme [name of theme]<br />
<br />
If you further want to set the same icon and cursor theme, then you have to specify them, too.<br />
<br />
gconftool-2 --set --type string /desktop/gnome/interface/icon_theme Faenza-Dark<br />
<br />
This sets the icon theme to Faenza-Dark located in {{ic|/usr/share/icons/Faenza-Dark}}. For the cursor theme you first have to set the gconf value.<br />
<br />
gconftool-2 --set --type string /desktop/gnome/peripherals/mouse/cursor_theme Adwaita<br />
<br />
Then you will have to create the file {{ic|/usr/share/icons/default/index.theme}} with the following lines:<br />
<br />
[Icon Theme]<br />
Inherits=Adwaita<br />
<br />
=== Themes not working in GTK+ apps ===<br />
<br />
If the style or theme engine you set up is not showing in your GTK applications then it's likely your GTK+ settings files are not being loaded for some reason. You can check where your system expects to find these files by doing the following..<br />
$ export | grep gtk<br />
<br />
Usually the expected files should be {{ic|~/.gtkrc}} for GTK1 and {{ic|~/.gtkrc2.0}} or {{ic|~/.gtkrc2.0-kde}} for GTK+ 2.x.<br />
<br />
Newer versions of {{Aur|gtk-qt-engine}} use {{ic|~/.gtkrc2.0-kde}} and set the export variable in {{ic|~/.kde/env/gtk-qt-engine.rc.sh}}.<br />
If you recently removed '''gtk-qt-engine''' and are trying to set a GTK+ theme then you must also remove {{ic|~/.kde/env/gtk-qt-engine.rc.sh}} and reboot. Doing this will ensure that GTK+ looks for it's settings in the standard {{ic|~/.gtkrc2.0}} instead of the {{ic|~/.gtkrc2.0-kde}} file.</div>Miezebiezehttps://wiki.archlinux.org/index.php?title=GTK&diff=263953GTK2013-06-23T11:19:19Z<p>Miezebieze: /* GTK+ 3.x */ added lxappearance</p>
<hr />
<div>[[Category:Development]]<br />
[[Category:Eye candy]]<br />
[[Category:Desktop environments]]<br />
[[cs:GTK+]]<br />
[[de:GTK+]]<br />
[[es:Improve GTK Application Looks]]<br />
[[it:GTK+]]<br />
[[uk:GTK+]]<br />
[[zh-CN:GTK+]]<br />
{{Article summary start}}<br />
{{Article summary text|This articles details theme configuration of GTK+ applications. GTK+ (GIMP Toolkit) is a cross-platform widget toolkit for creating graphical user interfaces. This article will explore the tools used to configure the GTK+ theme, style, icon, font and font size, and also detail manual configuration.}}<br />
{{Article summary heading|Related}}<br />
{{Article summary wiki|Uniform Look for Qt and GTK Applications}}<br />
{{Article summary wiki|Qt}}<br />
{{Article summary wiki|GNU Project}}<br />
{{Article summary end}}<br />
<br />
From the [http://www.gtk.org GTK+ website]:<br />
:''GTK+, or the GIMP Toolkit, is a multi-platform toolkit for creating graphical user interfaces. Offering a complete set of widgets, GTK+ is suitable for projects ranging from small one-off tools to complete application suites.''<br />
<br />
GTK+, The GIMP Toolkit, was initially made by the [[GNU Project]] for the [[GIMP]] but is now a very popular toolkit with bindings for many languages. <br />
<br />
== Configuration programs ==<br />
<br />
These GUI programs allow theme selection and at least customising of a font. They generally overwrite the {{ic|~/.gtkrc-2.0}} file.<br />
<br />
* {{Pkg|lxappearance}}: A configuration tool from the [[LXDE]] project, which does not require any other parts of LXDE or other desktop environment. More flexible customisation than the other programs.<br />
* {{Pkg|gtk-chtheme}}<br />
* {{Pkg|gtk-theme-switch2}}<br />
* {{Pkg|gtk2_prefs}}<br />
<br />
Example install command:<br />
# pacman -S gtk-theme-switch2<br />
<br />
See also [[Uniform Look for Qt and GTK Applications#Changing styles in each toolkit]].<br />
<br />
== Themes ==<br />
<br />
=== GTK+ 1.x ===<br />
Old GTK+ 1 apps (like xmms) often do not look very nice at first. This is because they use ugly themes by default.<br />
To change this, you need to:<br />
# download and install some nice themes<br />
# change the theme<br />
<br />
Some nice themes are in the [[Arch User Repository|AUR]]. To install them, see {{AUR|gtk-smooth-engine}}.<br />
<br />
To change the theme you can use ''gtk-theme-switch2''. Run it with the 'switch' command.<br />
<br />
=== GTK+ 2.x ===<br />
<br />
Major [[Desktop Environment|desktop environments]] provide tools to configure the GTK+ theme, icons, font and font size. Alternatively, tools such as those mentioned above may be used.<br />
<br />
It is recommended to [[pacman|install]] some GTK+ 2 themes as well. The popular ''Clearlooks'' theme is included within the {{Pkg|gtk-engines}} package.<br />
<br />
Further themes can be found in the [[Arch User Repository|AUR]]:<br />
*https://aur.archlinux.org/packages.php?O=0&K=gtk2-theme&do_Search=Go<br />
*https://aur.archlinux.org/packages.php?O=0&K=gtk-theme&do_Search=Go<br />
<br />
Alternatively, GTK+ settings can be configured manually by editing {{ic|~/.gtkrc-2.0}}. A list of GTK+ settings can be found in the [http://library.gnome.org/devel/gtk/stable/GtkSettings.html GNOME library]. To manually change the GTK+ theme, icons, font and font size, add the following to {{ic|~/.gtkrc-2.0}}:<br />
<br />
{{hc|~/.gtkrc-2.0|2=<br />
gtk-icon-theme-name = "[name-of-icon-theme]"<br />
gtk-theme-name = "[name-of-theme]"<br />
gtk-font-name = "[font-name] [size]"<br />
}}<br />
<br />
For example:<br />
{{hc|~/.gtkrc-2.0|2=<br />
gtk-icon-theme-name = "Tango"<br />
gtk-theme-name = "Murrine-Gray"<br />
gtk-font-name = "DejaVu Sans 8"<br />
}}<br />
<br />
{{Note| The above example requires the packages {{Pkg|ttf-dejavu}}, {{Pkg|tangerine-icon-theme}}, {{Pkg|gtk-engine-murrine}} from the [[Official Repositories|official repositories]], and {{AUR|murrine-themes-collection}} from the AUR.}}<br />
<br />
=== GTK+ 3.x ===<br />
<br />
If you use GNOME 3, the theme can be changed with the {{pkg|gnome-tweak-tool}}.<br />
<br />
If you use [[Xfce]] 4.8, both GTK+ 3.x and GTK+ 2.x themes can be managed by Appearance tool. Go to Settings-->Appearance. If selected style has both GTK+ 2.x and GTK+ 3.x themes, they will be used. If selected style has only GTK+ 2.x theme, it will be used for GTK+ 2.x applications and (ugly) defaults will be used for GTK+ 3.x applications. If selected style has only GTK+ 3.x theme, it will be used for GTK+ 3.x applications and (ugly) defaults will be used for GTK+ 2.x applications. Thus for uniform UI appearance and best experience one can use style that has both GTK+ 2.x and GTK+ 3.x themes. Search packages and [[AUR]]. One example of this is theme {{AUR|clearlooks-phenix-gtk-theme-git}}.<br />
<br />
An alternative without huge dependencies is {{pkg|lxappearance}}.<br />
<br />
If you prefer not to install {{pkg|gnome-tweak-tool}}, your theme can be set manually in {{ic|$XDG_CONFIG_HOME/gtk-3.0/settings.ini}} (this is usually {{ic|~/.config/gtk-3.0/settings.ini}}). An example {{ic|settings.ini}} file:<br />
{{hc|$XDG_CONFIG_HOME/gtk-3.0/settings.ini|2=<br />
[Settings]<br />
gtk-application-prefer-dark-theme = false<br />
gtk-theme-name = Zukitwo<br />
gtk-fallback-icon-theme = gnome<br />
gtk-icon-theme-name = [icon theme name]<br />
gtk-font-name = [font name] [font size]<br />
<br />
}}<br />
<br />
If it still does not change, delete old {{ic|gtk-3.0}} folder in {{ic|$XDG_CONFIG_HOME}} and copy {{ic|gtk-3.0}} folder from /path/to/theme to {{ic|$XDG_CONFIG_HOME}}. Example: <br />
<br />
$ rm -r ~/.config/gtk-3.0/<br />
$ cp -r /usr/share/themes/Zukitwo/gtk-3.0/ ~/.config/ <br />
<br />
<br />
After this, you need to set the same theme in your DE's appearance configuration tool. There are only a few themes which provide a uniform look for GTK+ 3.x and GTK+ 2.x apps. A few examples:<br />
#Adwaita (part of {{pkg|gnome-themes-standard}})<br />
#Newlooks for GTK+ 3 and Clearlooks for GTK+ 2<br />
#Zukitwo<br />
#Elegant Brit<br />
#Atolm<br />
#Hope<br />
<br />
{{Note|Some themes may require {{pkg|librsvg}} to display correctly, but not all specify it as a dependency. Try installing it if the chosen theme looks broken.}}<br />
<br />
{{Note|There probably are other themes. Some of these themes are available in the AUR. Also, some of them are not usable as-is for displaying a GTK+ 2.x panel (light text over light background), so you need to use the provided [http://i.imgur.com/QmeyN.png panel background].}}<br />
<br />
You could find what themes installed on your system have both an GTK+ 2.x and GTK+ 3.x version by using this command (don't work with names containing spaces):<br />
find $(find ~/.themes /usr/share/themes/ -wholename "*/gtk-3.0" | sed -e "s/^\(.*\)\/gtk-3.0$/\1/")\<br />
-wholename "*/gtk-2.0" | sed -e "s/.*\/\(.*\)\/gtk-2.0/\1"/<br />
<br />
=== GTK+ and Qt ===<br />
If you have GTK+ and Qt (KDE) applications on your desktop then you know that their looks do not blend well. If you wish to make your GTK+ styles match your Qt styles please read [[Uniform Look for Qt and GTK Applications]].<br />
<br />
== Configuration file ==<br />
<br />
{{Note|See the [http://library.gnome.org/devel/gtk/stable/GtkSettings.html#GtkSettings.properties ''GtkSettings'' properties] in the GTK+ programming reference manual for the full list of GTK configuration options.}}<br />
<br />
The purpose of this section is to collect GTK+ configuration settings which can e.g. be used within {{Ic|~/.gtkrc-2.0}}. <br />
<br />
=== Enabling Customizable Keyboard Shortcuts ===<br />
<br />
You can customize your GTK+ applications' keyboard shortcuts (those are called ''accelerators'' in GTK+ terminology) by hovering your mouse over a menu item and pressing your desired key combination. However, this feature is disabled by default. To enable it, set <br />
gtk-can-change-accels = 1<br />
<br />
=== Speed up your GNOME menu ===<br />
<br />
This setting controls the delay between you pointing the mouse at a menu and that menu opening in GNOME. Change this to a setting you prefer. I guess the number is in milliseconds, e.g. 250 being a quarter of a second.<br />
gtk-menu-popup-delay = 0<br />
<br />
=== Reduce widget sizes ===<br />
<br />
If you have a small screen or you just do not like big icons and widgets, you can resize things easily. <br />
To have icons without text in toolbars, use<br />
gtk-toolbar-style = GTK_TOOLBAR_ICONS<br />
To use smaller icons, use a line like this:<br />
gtk-icon-sizes = "panel-menu=16,16:panel=16,16:gtk-menu=16,16:gtk-large-toolbar=16,16\<br />
:gtk-small-toolbar=16,16:gtk-button=16,16"<br />
Or to remove icons from buttons completely:<br />
gtk-button-images = 0<br />
You can also remove icons from menus:<br />
gtk-menu-images = 0<br />
<br />
There is some more tweaking to do in your themes gtkrc like explained [http://martin.ankerl.com/2008/10/10/how-to-make-a-compact-gnome-theme/ here] and there's another [http://gnome-look.org/content/show.php/Simple+eGTK?content=119812 theme] that does it all.<br />
<br />
== Development ==<br />
<br />
When writing a start-from-scratch GTK+ 3 program with C, it's necessary to add CFLAGS for gcc:<br />
gcc -g -Wall `pkg-config --cflags --libs gtk+-3.0` -o base base.c<br />
-g and -Wall parameters are not necessary since they are only for verbose debugging outputs.<br />
You may try out the official [http://developer.gnome.org/gtk-tutorial/stable/c39.html#SEC-HELLOWORLD Hello World example].<br />
<br />
=== Write a simple message dialog app ===<br />
You can write your own GTK+ 3 message dialog easily in many programming languages through GObject-Introspection or bindings, or you can simply use bash.<br />
<br />
The following examples display a simple "Hello world" in a message dialog.<br />
<br />
====Bash====<br />
*Dependency: {{Pkg|zenity}}<br />
{{hc|hello_world.sh|<nowiki>#!/bin/bash<br />
zenity --info --title='Hello world!' --text='This is an example dialog.'</nowiki>}}<br />
<br />
====Boo====<br />
*Dependency: {{AUR|gtk-sharp-git}} from AUR ({{Pkg|boo}})<br />
*Makedependency: {{Pkg|boo}}<br />
*Build with: {{ic|booc hello_world.boo}}<br />
*Run with: {{ic|mono hello_world.exe}} (or {{ic|booi hello_world.boo}})<br />
<br />
{{hc|hello_world.boo|<nowiki>import Gtk from "gtk-sharp"<br />
Application.Init()<br />
Hello = MessageDialog(null, DialogFlags.Modal, MessageType.Info, ButtonsType.Close, "Hello world!")<br />
Hello.SecondaryText = "This is an example dialog."<br />
Hello.Run()</nowiki>}}<br />
<br />
====C====<br />
*Dependency: {{Pkg|gtk3}} and {{Pkg|pkg-config}}<br />
*Build with: {{Ic|gcc -o hello_world `pkg-config --cflags --libs gtk+-3.0` hello_world.c}}<br />
{{hc|hello_world.c|<nowiki>#include <gtk/gtk.h><br />
void main (int argc, char *argv[]) {<br />
gtk_init (&argc, &argv);<br />
GtkWidget *hello = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, "Hello world!");<br />
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (hello), "This is an example dialog.");<br />
gtk_dialog_run(GTK_DIALOG (hello));<br />
}</nowiki>}}<br />
<br />
====C++====<br />
*Dependency: {{Pkg|gtkmm3}}<br />
*Build with: {{Ic|g++ -o hello_world `pkg-config --cflags --libs gtkmm-3.0` hello_world.cc}}<br />
{{hc|hello_world.cc|<nowiki>#include <gtkmm/main.h><br />
#include <gtkmm/messagedialog.h><br />
int main(int argc, char *argv[]) {<br />
Gtk::Main kit(argc, argv);<br />
Gtk::MessageDialog Hello("Hello world!", false, Gtk::MESSAGE_INFO, Gtk::BUTTONS_OK);<br />
Hello.set_secondary_text("This is an example dialog.");<br />
Hello.run();<br />
}</nowiki>}}<br />
<br />
====C#====<br />
*Dependency: {{AUR|gtk-sharp-git}} from AUR<br />
*Build with: {{ic|mcs -pkg:gtk-sharp-3.0 hello_world.cs}}<br />
*Run with: {{ic|mono hello_world.exe}}<br />
{{hc|hello_world.cs|<nowiki>using Gtk;<br />
public class HelloWorld {<br />
static void Main() {<br />
Application.Init ();<br />
MessageDialog Hello = new MessageDialog (null, DialogFlags.Modal, MessageType.Info, ButtonsType.Close, "Hello world!");<br />
Hello.SecondaryText="This is an example dialog.";<br />
Hello.Run ();<br />
}<br />
}</nowiki>}}<br />
<br />
====Genie====<br />
*Dependency: {{Pkg|gtk3}}<br />
*Makedependency: {{Pkg|vala}}<br />
*Build with: {{Ic|valac --pkg gtk+-3.0 hello_world.gs}}<br />
{{hc|hello_world.gs|<nowiki>uses <br />
Gtk<br />
init<br />
Gtk.init (ref args)<br />
var Hello=new MessageDialog (null, Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Hello world!")<br />
Hello.format_secondary_text ("This is an example dialog.")<br />
Hello.run ()</nowiki>}}<br />
<br />
====Java====<br />
*Dependency: {{AUR|java-gnome}} from AUR<br />
*Makedependency: java-environment<br />
*Build with: {{ic|mkdir HelloWorld && javac -classpath /usr/share/java/gtk.jar -d HelloWorld HelloWorld.java}}<br />
*Run with: {{ic|java -classpath /usr/share/java/gtk.jar:HelloWorld HelloWorld}}<br />
<br />
{{hc|HelloWorld.java|<nowiki>import org.gnome.gtk.Gtk;<br />
import org.gnome.gtk.Dialog;<br />
import org.gnome.gtk.InfoMessageDialog;<br />
<br />
public class HelloWorld<br />
{<br />
public static void main(String[] args) {<br />
Gtk.init(args);<br />
Dialog Hello = new InfoMessageDialog(null, "Hello world!", "This is an example dialog.");<br />
Hello.run();<br />
}<br />
}</nowiki>}}<br />
<br />
====JavaScript====<br />
*Dependencies: {{Pkg|gtk3}}, {{Pkg|gjs}} (works also with {{Pkg|seed}})<br />
{{hc|hello_world.js|<nowiki>#!/usr/bin/gjs<br />
Gtk = imports.gi.Gtk<br />
Gtk.init(null, null)<br />
Hello = new Gtk.MessageDialog({type: Gtk.MessageType.INFO,<br />
buttons: Gtk.ButtonsType.OK,<br />
text: "Hello world!",<br />
"secondary-text": "This is an example dialog."})<br />
Hello.run()</nowiki>}}<br />
<br />
====Perl====<br />
*Dependency: {{AUR|perl-gtk3}} from AUR<br />
{{hc|hello_world.pl|<nowiki>#!/usr/bin/perl<br />
use Gtk3 -init;<br />
my $hello = Gtk3::MessageDialog->new (undef, 'modal', 'info', 'ok', "Hello world!");<br />
$hello->set ('secondary-text' => 'This is an example dialog.');<br />
$hello->run;</nowiki>}}<br />
<br />
====Python====<br />
*Dependencies: {{Pkg|gtk3}}, {{Pkg|python-gobject}}<br />
{{hc|hello_world.py|<nowiki>#!/usr/bin/python<br />
from gi.repository import Gtk<br />
Gtk.init(None)<br />
Hello=Gtk.MessageDialog(None, Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.CLOSE, "Hello world!")<br />
Hello.format_secondary_text("This is an example dialog.")<br />
Hello.run()</nowiki>}}<br />
<br />
====Vala====<br />
*Dependency: {{Pkg|gtk3}}<br />
*Makedependency: {{Pkg|vala}}<br />
*Build with: {{Ic|valac --pkg gtk+-3.0 hello_world.vala}}<br />
{{hc|hello_world.vala|<nowiki>using Gtk;<br />
public class HelloWorld {<br />
static void main (string[] args) {<br />
Gtk.init (ref args);<br />
var Hello=new MessageDialog (null, Gtk.DialogFlags.MODAL, Gtk.MessageType.INFO, Gtk.ButtonsType.OK, "Hello world!");<br />
Hello.format_secondary_text ("This is an example dialog.");<br />
Hello.run ();<br />
}<br />
}</nowiki>}}<br />
<br />
====Visual Basic .NET====<br />
*Dependency: {{AUR|gtk-sharp-git}} from AUR<br />
*Makedependency: {{Pkg|mono-basic}}<br />
*Build with: {{ic|vbnc -r:/usr/lib/mono/gtk-sharp-3.0/gio-sharp.dll -r:/usr/lib/mono/gtk-sharp-3.0/glib-sharp.dll -r:/usr/lib/mono/gtk-sharp-3.0/gtk-sharp.dll hello_world.vb}}<br />
*Run with: {{ic|mono hello_world.exe}}<br />
<br />
{{hc|hello_world.vb|<nowiki>Imports Gtk<br />
Public Class Hello<br />
Inherits MessageDialog<br />
Public Sub New<br />
MyBase.New(Me, DialogFlags.Modal, MessageType.Info, ButtonsType.Close, "Hello world!")<br />
Me.SecondaryText = "This is an example dialog."<br />
End Sub<br />
Public Shared Sub Main<br />
Application.Init<br />
Dim Dialog As New Hello<br />
Dialog.Run<br />
End Sub<br />
End Class</nowiki>}}<br />
<br />
== Resources ==<br />
* [http://www.gtk.org/ The official GTK+ website]<br />
* [[wikipedia:GTK+|Wikipedia article about GTK+]]<br />
* [http://developer.gnome.org/gtk-tutorial/stable/ GTK+ 2.0 Tutorial]<br />
* [http://developer.gnome.org/gtk3/stable/ GTK+ 3 Reference Manual]<br />
* [http://developer.gnome.org/gtkmm-tutorial/stable/ gtkmm Tutorial]<br />
* [http://developer.gnome.org/gtkmm/stable/ gtkmm Reference Manual]</div>Miezebiezehttps://wiki.archlinux.org/index.php?title=LVM&diff=131009LVM2011-02-15T09:16:13Z<p>Miezebieze: deleted a space in a path</p>
<hr />
<div>[[Category:Getting and installing Arch (English)]]<br />
[[Category:File systems (English)]]<br />
[[Category:HOWTOs (English)]]<br />
{{i18n|LVM}}<br />
<br />
=Introduction=<br />
<br />
LVM is a Logical Volume Manager for the Linux kernel. With LVM you can abstract your storage space and have "virtual partitions" which are easier to modify. The basic building blocks of LVM are:<br />
<br />
* '''Physical volume (PV)''': Partition on hard disk (or even hard disk itself or loopback file) on which you can have volume groups. It has a special header and is divided into physical extents. Think of physical volumes as big building blocks which can be used to build your hard drive.<br />
* '''Volume group (VG)''': Group of physical volumes that are used as storage volume (as one disk). They contain logical volumes. Think of volume groups as hard drives.<br />
* '''Logical volume (LV)''': A "virtual/logical partition" that resides in a volume group and is composed of physical extents. Think of logical volumes as normal partitions.<br />
* '''Physical extent (PE)''': A small part of a disk (usually 4MB) that can be assigned to a logical Volume. Think of physical extents as parts of disks that can be allocated to any partition.<br />
<br />
With LVM you can more easily handle your partitions (logical volumes) than normal hard drive partitions. For example, you can:<br />
<br />
* Use ''any number'' of disks as one big disk(VG)<br />
* Have partitions(LV) stretched ''over'' several disks (they can be as big as all of your disk storage together)<br />
* Resize/create/delete partitions(LV) and disks(VG) ''as you like'' (it doesn't depend on position of the logical volumes within volume groups as with normal partitions)<br />
* Resize/create/delete partitions(LV) and disks(VG) ''online'' (filesystems on them still need to be resized, but some support online resizing)<br />
* ''Name'' your disks(VG) and partitions(LV) as you like<br />
* Create small partitions(LV) and resize them "''dynamically''" as they get more filled (growing must be still done by hand, but you can do it online with some filesystems)<br />
* ...<br />
<br />
Example: <br />
'''Physical disks'''<br />
<br />
Disk1 (/dev/sda):<br />
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _<br />
|Partition1 50GB (Physical volume) |Partition2 80GB (Physical volume) |<br />
|/dev/sda1 |/dev/sda2 |<br />
|_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |<br />
<br />
Disk2 (/dev/sdb):<br />
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _<br />
|Partition1 120GB (Physical volume) |<br />
|/dev/sdb1 |<br />
| _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ __ _ _|<br />
<br />
'''LVM logical volumes'''<br />
<br />
Volume Group1 (/dev/MyStorage/ = /dev/sda1 + /dev/sda2 + /dev/sdb1):<br />
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ <br />
|Logical volume1 15GB |Logical volume2 35GB |Logical volume3 200GB |<br />
|/dev/MyStorage/rootvol|/dev/MyStorage/homevol |/dev/MyStorage/mediavol |<br />
|_ _ _ _ _ _ _ _ _ _ _ |_ _ _ _ _ _ _ _ _ _ _ _ _ |_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |<br />
<br />
To sum it all up: With LVM you can use all your storage space as one big disk (volume group) and have more flexibility over your partitions (logical volumes).<br />
<br />
=Installation=<br />
<br />
Before doing anything we need to load the appropriate module:<br />
# modprobe dm-mod<br />
If you already have Arch Linux installed and you just want to add/try a partition with LVM, jump to [[Lvm#Partition_disks|partition disks]].<br />
<br />
====Installing Arch Linux on LVM====<br />
Prior to running Arch Linux install scripts (/arch/setup) to install Arch Linux, you need to partition your disk with {{Codeline|cfdisk}} (or any other tool of your liking). Because grub legacy (grub with version less than 1.0) can't boot from LVM logical volumes you can't have {{Filename|/boot}} in LVM, so you need to create a boot partition. 100MB should be enough. The other solution would be to use lilo or grub with version 1.95 or newer.<br />
<br />
====Partition disks====<br />
Next you need to create a partition for LVM. Its filesystem type should be 'Linux LVM', so use a partition id 0x8e (filesystem type: 8e). You need to create only one LVM partition on each disk you want to use with LVM. Your logical volumes will reside inside these partitions so size them accordingly. If you will use only LVM and no other external partitions, use all the free space on each disk.<br />
<br />
{{Warning|/boot can't reside in an LVM partition because grub (version<1.95) does not support LVM.}}<br />
<br />
{{Tip|All LVM partitions on all disks can be configured to appear as one big disk.}}<br />
<br />
====Create Physical volumes====<br />
<br />
Now you need to initialize these partitions so they can be used by LVM. Use {{Codeline|fdisk -l}} to find out which partitions have filesystem type 'Linux LVM' and create a physical volume on them:<br />
# pvcreate /dev/sda2<br />
Substitute {{Filename|/dev/sda2}} with all your partitions to create physical volumes on all of them. This command creates a header on each partition so it can be used for LVM.<br />
You can track created physical volumes with:<br />
# pvdisplay<br />
<br />
====Create Volume group(s)====<br />
Next step is to create a volume group on this physical volume. First you need to create a volume group on one of the new partitions and then add to it all other physical volumes you want to have in it:<br />
# vgcreate VolGroup00 /dev/sda2<br />
# vgextend VolGroup00 /dev/sdb1<br />
Also you can use any other name you like instead of VolGroup00 for a volume group when creating it. You can track how your volume group grows with:<br />
# vgdisplay<br />
<br />
{{Note|You can create more than one volume group if you need to, but then you won't have all your storage presented as one disk.}}<br />
<br />
====Create Logical Volumes====<br />
Now we need to create logical volumes on this volume group. You create a logical volume with the next command by giving the name of a new logical volume, its size, and the volume group it will live on:<br />
# lvcreate -L 10G VolGroup00 -n lvolhome<br />
This will create a logical volume that you can access later with {{Filename|/dev/mapper/Volgroup00-lvolhome}} or {{Filename|/dev/VolGroup00/lvolhome}}. Same as with the volume groups, you can use any name you want for your logical volume when creating it.<br />
<br />
To create swap on a logical volume, an additional argument is needed:<br />
# lvcreate -C y -L 10G VolGroup00 -n lvolswap<br />
The {{Codeline|-C y}} is used to create a contiguous partition, which means that your swap space doesn't get partitioned over one or more disks nor over non-contiguous physical extents.<br />
<br />
If you want to fill all the free space left on a volume group, use the next command:<br />
# lvcreate -l +100%FREE VolGroup00 -n lvolmedia<br />
<br />
You can track created logical volumes with:<br />
# lvdisplay<br />
<br />
{{Note|You may need to load the ''device-mapper'' kernel module ('''modprobe dm-mod''') for the above commands to succeed:}}<br />
<br />
{{Tip|You can start out with relatively small logical volumes and expand them later if needed. For simplicity, leave some free space in the volume group so there is room for expansion.}}<br />
<br />
====Create filesystem and mount logical volumes====<br />
Your logical volumes should now be located in {{Filename|/dev/mapper/}} and {{Filename|/dev/YourVolumeGroupName}}. If you can't find them, use the next commands to bring up the module for creating device nodes and to make volume groups available:<br />
# modprobe dm-mod<br />
# vgchange -ay<br />
Now you can create filesystems on logical volumes and mount them as normal partitions (if you are installing Arch linux, skip this step. Use the arch installer to pick the LVM partitions that you have created):<br />
# mkfs.ext3 /dev/mapper/VolGroup00-lvolhome<br />
# mount /dev/mapper/VolGroup00-lvolhome /home<br />
If you are installing Arch linux, start /arch/setup, go to ''Prepare Hard Drive'' directly to step 3 ''Set Filesystem Mountpoints'' and '''''read the [[Lvm#Important|Important]] section below before proceeding with installation!'''''<br />
<br />
===Important===<br />
There are just a few things you need to be careful with while using/installing Arch Linux with LVM (in brackets are the corresponding menus during installation):<br />
* When choosing mountpoints, just select your newly created logical volumes (use: {{Filename|/dev/mapper/Volgroup00-lvolhome}}).<br>Do NOT select the actual partitions on which logical volumes were created (don't use: {{Filename|/dev/sda2}}). (''Set Filesystem Mountpoints'')<br />
* Make sure you change ''USELVM="no"'' to ''USELVM="yes"'' in {{Filename|/etc/rc.conf}} (''Configure System'')<br />
* Make sure that ''lvm2'' is in the HOOKS section of {{Filename|/etc/mkinitcpio.conf}} just before the ''filesystems'' so that your kernel will find LVM volumes at boot time. Also, if you wish to use LVM snapshots, add ''dm-snapshot'' to the MODULES variable. (''Configure System'')<br />
* If your root filesystem ( "/" ) is put onto a logical volume, make sure regenerate kernel image (''/boot/kernel26.img'') based on above modified {{Filename|/etc/mkinitcpio.conf}} by using below command so that bootloader can find your root during booting (''Configure System'') <br />
mkinitcpio -g /boot/kernel26.img <br />
* Make sure {{Filename|/boot/grub/menu.lst}} uses the right volumes for root. It should look something like this: (''Install Bootloader'')<br />
...<br />
(0) Arch Linux<br />
title Arch Linux<br />
root (hd0,0)<br />
kernel /vmlinuz26 '''root=/dev/mapper/VolGroup00-lvolroot''' resume=/dev/mapper/VolGroup00-lvolswap ro<br />
initrd /kernel26.img<br />
...<br />
* If you are using LILO check {{Filename|/etc/lilo.conf}}:<br />
image=/boot/vmlinuz26<br />
label=arch<br />
append="'''root=/dev/mapper/VolGroup00-lvolroot''' resume=/dev/mapper/VolGroup00-lvolswap ro"<br />
initrd=/boot/kernel26.img<br />
<br />
= Configuration =<br />
<br />
== Grow logical volume ==<br />
To grow a logical volume you first need to grow the logical volume and then the filesystem to use the newly created free space. Let's say we have a logical volume of 15GB with ext3 on it and we want to grow it to 20G. We need to do the following steps: <br />
# lvextend -L 20G VolGroup00/lvolhome (or lvresize -L +5G VolGroup00/lvolhome)<br />
# resize2fs /dev/VolGroup00/lvolhome<br />
You may use {{Codeline|lvresize}} instead of {{Codeline|lvextend}}.<br />
<br />
If you want to fill all the free space on a volume group, use the next command:<br />
# lvextend -l +100%FREE VolGroup00/lvolhome<br />
<br />
{{Warning|Not all filesystems support growing without loss of data and/or growing online.}}<br />
<br />
{{Note|If you don't resize your filesystem, you will still have a volume with the same size as before (volume will be bigger but partly unused).}}<br />
<br />
== Shrink logical volume ==<br />
Because your filesystem is probably as big as the logical volume it resides on, you need to shrink the filesystem first and then shrink the logical volume. Depending on your filesystem, you may need to unmount it first. Let's say we have a logical volume of 15GB with ext3 on it and we want to shrink it to 10G. We need to do the following steps: <br />
# resize2fs /dev/VolGroup00/lvolhome 9G<br />
# lvreduce -L 10G VolGroup00/lvolhome (or lvresize -L -5G VolGroup00/lvolhome)<br />
# resize2fs /dev/VolGroup00/lvolhome<br />
Here we shrunk the filesystem more than needed so that when we shrunk the logical volume we didn't accidentally cut off the end of the filesystem. After that we normally grow the filesystem to fill all free space left on logical volume. You may use {{Codeline|lvresize}} instead of {{Codeline|lvreduce}}.<br />
<br />
{{Warning|Don't reduce the filesystem size to less than the amount of space occupied by data or you risk data loss.}}<br />
<br />
{{Warning|Not all filesystems support shrinking without loss of data and/or shrinking online.}}<br />
<br />
{{Note|It is better to reduce the filesystem to a smaller size than the logical volume, so that after resizing the logical volume, we don't accidentally cut off some data from the end of the filesystem.}}<br />
<br />
== Add partition to a volume group ==<br />
To add a partition to your volume group you must first make its type 'Linux LVM' (for example with {{Codeline|cfdisk}}). Then you need to create a physical volume on it and extend the volume group over it:<br />
# pvcreate /dev/sdb1<br />
# vgextend VolGroup00 /dev/sdb1<br />
Now you have free space in your volume group that can be used by logical volumes in this group.<br />
<br />
{{Tip|You can add partitions from any disks to volume groups.}}<br />
<br />
== Remove partition from a volume group ==<br />
All of the data on that partition needs to be moved to another partition. Fortunately, LVM makes this easy:<br />
# pvmove /dev/sdb1<br />
If you want to have the data on a specific physical volume, specify that as the second argument to {{Codeline|pvmove}}:<br />
# pvmove /dev/sdb1 /dev/sdf1<br />
Then the physical volume needs to be removed from the volume group:<br />
# vgreduce myVg /dev/sdb1<br />
Or remove all empty physical volumes:<br />
# vgreduce --all vg0<br />
<br />
And lastly, if you want to use the partition for something else, and want to avoid LVM thinking that the partition is a physical volume:<br />
# pvremove /dev/sdb1<br />
<br />
== Snapshots ==<br />
====Introduction====<br />
LVM allows you to take a snapshot of your system in a much more efficient way than a traditional backup. It does this efficiently by using a COW (copy-on-write) policy. The initial snapshot you take simply contains hard-links to the inodes of your actual data. So long as your data remains unchanged, the snapshot merely contains its inode pointers and not the data itself. Whenever you modify a file or directory that the snapshot points to, LVM automatically clones the data, the old copy referenced by the snapshot, and the new copy referenced by your active system. Thus, you can snapshot a system with 35GB of data using just 2GB of free space so long as you modify less than 2GB (on both the original and snapshot).<br />
<br />
====Configuration====<br />
You create snapshot logical volumes just like normal ones.<br />
<br />
# lvcreate --size 100M --snapshot --name snap01 /dev/mapper/vg0-pv<br />
With that volume, you may modify less than 100M of data, before the snapshot volume fills up.<br />
<br />
It is important to have the ''dm-snapshot'' module listed in the MODULES variable of {{Filename|/etc/mkinitcpio.conf}}, otherwise the system will not boot. If you do this on an already installed system, make sure to rebuild the image with<br />
# mkinitcpio -g /boot/kernel26.img<br />
<br />
Todo: scripts to automate snapshots of root before updates, to rollback... updating {{Filename|menu.lst}} to boot snapshots (separate article?)<br />
<br />
snapshots are primarily used to provide a frozen copy of a filesystem to make backups; a backup taking two hours provides a more consistent image of the filesystem than directly backing up the partition.<br />
<br />
= Troubleshooting =<br />
====LVM commands don't work====<br />
*Load proper module:<br />
# modprobe dm-mod<br />
*Try preceding commands with ''lvm'' like this:<br />
# lvm pvdisplay<br />
<br />
==== Set Filesystem Mountpoints page doesn't show logical volumes ====<br />
If you are installing on a system where there is an existing volume group, you may find that even after doing "modprobe dm-mod" you don't see the list of logical volumes.<br />
<br />
In this case, you may also need to do:<br />
# vgchange -ay <volgroup><br />
<br />
in order to activate the volume group and make the logical volumes available.<br />
<br />
= Tips & Tricks =<br />
Todo<br />
<br />
= More Resources =<br />
Other LVM articles on the Archwiki:<br />
* [[Installing_with_Software_RAID_or_LVM|Installing with software RAID or LVM]]<br />
* [[RAID_Encryption_LVM|RAID encryption LVM]]<br />
External resources:<br />
* [http://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux) LVM on wikipedia]<br />
* [http://tldp.org/HOWTO/LVM-HOWTO/ LVM HOWTO on tldp.org ]<br />
* [http://www.gentoo.org/doc/en/lvm2.xml Gentoo LVM2 installation at gentoo.org ]<br />
* [http://en.gentoo-wiki.com/wiki/LVM LVM at en.gentoo-wiki.com]<br />
* [http://www.joshbryan.com/blog/2008/01/02/lvm2-mirrors-vs-md-raid-1 LVM2 mirrors vs MD raid 1]</div>Miezebiezehttps://wiki.archlinux.org/index.php?title=Connecting_your_MP3_Player&diff=129538Connecting your MP3 Player2011-02-01T03:30:53Z<p>Miezebieze: Conversion to blkid.</p>
<hr />
<div>[[Category:Other hardware (English)]]<br />
[[Category:General (English)]]<br />
<br />
There are different kinds of MP3-Players around.<br />
<br />
====Players Accessible as usb-storage====<br />
*creative<br />
**Creative MuVo<br />
***Note that with some (older) models of MuVo deleting settings.dat from the stick renders it useless, newer models don't have the file.<br />
*iriver<br />
**All iriver players with "UMS Mode" firmware are recognized as usb-storage<br />
*Cowon<br />
**iAudio U2 MP3 Player<br />
*NextCom<br />
**flash drive + mp3-player<br />
*MPIO<br />
**MPIO HD300<br />
<br />
====Players Accessible With Native Protocols====<br />
*iriver<br />
**all iriver players with "Manager Mode" firmware need the [[ifp-line iRiver Manager]]<br />
<br />
*creative<br />
**creative players, probably all that don't support usb-storage, should be supported by [http://aur.archlinux.org/packages.php?ID=9899 gnomad2]<br />
<br />
==UUID Player Mounting==<br />
<br />
Mounting your mp3 player(in this example an ipod) is very easy. But without the "proper" set up, it can be problematic. The following steps can be used for any mp3 player or usb mass storage device.<br />
<br />
* Every drive creates a [http://en.wikipedia.org/wiki/UUID UUID] (Universally Unique Identifier), these identifiers can be used to track individual drive no matter their device node (ie {{filename|/dev/sda}}).<br />
<br />
To find the current UUIDs execute:<br />
# blkid<br />
<br />
''' At this point you should see a list of your system drives and a long strings of characters. These long strings are the uuids.'''<br />
<br />
* Now plug in your mp3 player to a usb port . . . wait for a few seconds . . . <br />
<br />
* Reexecute '''blkid'''<br />
''' Notice a new device and UUID? That's your mp3 player!'''<br />
<br />
* The player likely has a label. If not use the device node path. Execute '''as superuser''':<br />
# blkid | grep YOURLABEL >> /etc/fstab<br />
<br />
* Now create an easy to remember directory listing for the device:<br />
# mkdir /media/ipod<br />
<br />
''If you don't have an ipod or have Your drives somewhere else, just rename the directory to something that you like. ({{filename|/mnt/mp3player}})''<br />
<br />
* And now edit the last line in {{filename|/etc/fstab}} from someting like:<br />
/dev/sdd: LABEL="Ipod" UUID="E8F1-5438" TYPE="vfat"<br />
to<br />
UUID=E8F1-5438 /media/ipod vfat user,noauto,noexec 0 0<br />
<br />
''Further questions can be answered with the man page for fstab.''<br />
''The autor does not own any Idevices, so the Label could be wrong.''<br />
<br />
* Remove your device from the usb port . . . wait a second . . .<br />
* Reinsert your device<br />
* Mount with the following command<br />
# mount /media/ipod<br />
<br />
'''Now no matter what, your device will always mount under the same directory!'''<br />
<br />
===Alternative way===<br />
If 'blkid' doesn't work as aspected, You can look for the UUIDs in {{filename|/dev/disk/by-uuid/}}.<br />
# ls -lF /dev/disk/by-uuid/<br />
<br />
==udev Player Mounting==<br />
''Alternatively you can use udev to do the same thing. I have not tried this yet (the above works fine for me), but here's the basics:<br />
<br />
* Edit your {{filename|/etc/udev/rules.d/00.rules}}<br />
## iPod<br />
BUS="scsi", SYSFS{model}="iPod*", NAME="ipod"</div>Miezebiezehttps://wiki.archlinux.org/index.php?title=Deluge&diff=127860Deluge2011-01-12T17:07:38Z<p>Miezebieze: </p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
<br />
{{i18n|Deluge}}<br />
[[de:Deluge Installation]]<br />
<br />
This article will show you how to set up Deluge also for daemon-based torrenting.<br />
<br />
==Base Install==<br />
Deluge is available in the official repositories:<br />
# pacman -S deluge<br />
<br />
==Graphical Clients==<br />
===Web ui===<br />
The Web-ui runs on the server and the clients only need a Web-Browser.<br />
You need to install '''python-mako''' on the server:<br />
# pacman -S python-mako<br />
<br />
===Gtk ui===<br />
The Gtk ui needs to have '''pygtk''' and '''librsvg''' installed on the clients:<br />
# pacman -S pygtk librsvg<br />
<br />
==Configuration==<br />
If You want to run Deluge as user just run:<br />
# deluge -u [gtk|web|console]<br />
<br />
===daemon===<br />
The default user for deluged, the Deluge daemon, is "deluge". You can change this in {{filename|/etc/conf.d/deluged}}. Of course, the user needs to exist. In the case of the default "deluge" user, no manual user creation is necessary as the package script has done that for you.<br />
<br />
The rest of this guide will assume you use the default "deluge" user. This user's default home dir and therefore its configuration location is in ''/srv/deluge''. This should be fine under most circumstances. Note that this is NOT the default download location, it only holds its configuration and ssl certificates. You will be able to change all other options later on once you get a client working.<br />
<br />
Next, start the daemon to generate its default configuration in its homedir:<br />
# /etc/rc.d/deluged start<br />
<br />
And add it to Your {{filename|/etc/rc.conf}}, so it gets convieniently autostarted:<br />
DAEMONS=( ... network '''deluged''' ... )<br />
<br />
===Gtk ui===<br />
Stop the Deluge daemon:<br />
# /etc/rc.d/deluged stop<br />
<br />
If You want to connect remotely via the Gtk ui, there should be something like this in {{filename|/srv/deluge/.config/deluge/core.conf}}:<br />
"allow_remote": true,<br />
<br />
Now add yourself to the authentification file:<br />
# echo "yourusername:yourpassword:10" >> /srv/deluge/.config/deluge/auth<br />
<br />
'''10''', the authentification level is not used at this time. Read [http://dev.deluge-torrent.org/wiki/UserGuide/Authentication more] about that.<br />
<br />
Start the Deluge daemon again.<br />
<br />
Now start the Gtk ui. If You prefer, You can edit the preferences in {{filename|~/.config/deluge/gtkui.conf}}, but there's also a nice configuration tool in the ui.<br />
<br />
Look for '''classic mode''' and disable it. Have You seen an icon just pop up? Hit it! If not go to Edit -> Connection Manager and add Your daemon.<br />
<br />
===Web ui===<br />
First, start the web ui daemon:<br />
# /etc/rc.d/deluge-web start<br />
<br />
and login in on ''http://deluge-machine:8112''. Where 'deluge-machine' is name of your deluge server or its private or public IP address. When asked for a password, enter "deluge" as it's the default password.<br />
<br />
The preferences in the web ui should be rather self explanatory and the first obvious thing to do is to change your password.<br />
<br />
As usual, you should add the daemons to your {{filename|/etc/rc.conf}}:<br />
DAEMONS=( ... network deluged '''deluge-web''' ... )<br />
<br />
Just make sure your network connection is up at the time you start either of those Deluge daemons.<br />
<br />
====SSL====<br />
In case you want SSL for the web ui, you need to generate a new cert/key set. To do this, first stop the web ui:<br />
<br />
# /etc/rc.d/deluge-web stop<br />
<br />
then go to ''/srv/deluge/.config/deluge/ssl/'' and issue:<br />
<br />
# openssl req -new -x509 -nodes -out deluge.cert.pem -keyout deluge.key.pem<br />
<br />
Next you need to edit {{filename|/srv/deluge/.config/deluge/web.conf}} and change the '''pkey''' and '''cert''' configuration directives to use your new self-signed certificates and also enable SSL:<br />
...<br />
"pkey": "ssl/deluge.key.pem",<br />
...<br />
"cert": "ssl/deluge.cert.pem",<br />
...<br />
"https": true,<br />
<br />
Afterwards just start the web ui again and you should be good to go:<br />
<br />
# /etc/rc.d/deluge-web start<br />
<br />
==Ressources==<br />
[http://deluge-torrent.org/ Deluge Homepage]</div>Miezebiezehttps://wiki.archlinux.org/index.php?title=Deluge&diff=127859Deluge2011-01-12T17:06:35Z<p>Miezebieze: Added Gtk ui and many other stuff.</p>
<hr />
<div>[[Category:Networking (English)]]<br />
[[Category:HOWTOs (English)]]<br />
<br />
{{i18n|Deluge}}<br />
[[de:Deluge Installation]]<br />
<br />
This article will show you how to set up Deluge also for daemon-based torrenting.<br />
<br />
==Base Install==<br />
Deluge is available in the official repositories:<br />
# pacman -S deluge<br />
<br />
==Graphical Clients==<br />
===Web ui===<br />
The Web-ui runs on the server and the clients only need a Web-Browser.<br />
You need to install '''python-mako''' on the server:<br />
# pacman -S python-mako<br />
<br />
===Gtk ui===<br />
The Gtk ui needs to have '''pygtk''' and '''librsvg''' installed on the clients:<br />
# pacman -S pygtk librsvg<br />
<br />
==Configuration==<br />
If You want to run Deluge as user just run:<br />
# deluge -u [gtk|web|console]<br />
<br />
===daemon===<br />
The default user for deluged, the Deluge daemon, is "deluge". You can change this in {{filename|/etc/conf.d/deluged}}. Of course, the user needs to exist. In the case of the default "deluge" user, no manual user creation is necessary as the package script has done that for you.<br />
<br />
The rest of this guide will assume you use the default "deluge" user. This user's default home dir and therefore its configuration location is in ''/srv/deluge''. This should be fine under most circumstances. Note that this is NOT the default download location, it only holds its configuration and ssl certificates. You will be able to change all other options later on once you get a client working.<br />
<br />
Next, start the daemon to generate its default configuration in its homedir:<br />
# /etc/rc.d/deluged start<br />
<br />
And add it to Your {{filename|/etc/rc.conf}}, so it gets convieniently autostarted:<br />
DAEMONS=( ... network '''deluged''' ... )<br />
<br />
===Gtk ui===<br />
Stop the Deluge daemon:<br />
# /etc/rc.d/deluged stop<br />
<br />
If You want to connect remotely via the Gtk ui, in {{filename|/srv/deluge/.config/deluge/core.conf}} there should be something like this:<br />
"allow_remote": true,<br />
<br />
Now add yourself to the authentification file:<br />
# echo "yourusername:yourpassword:10" >> /srv/deluge/.config/deluge/auth<br />
<br />
'''10''', the authentification level is not used at this time. Read [http://dev.deluge-torrent.org/wiki/UserGuide/Authentication more] about that.<br />
<br />
Start the Deluge daemon again.<br />
<br />
Now start the Gtk ui. If You prefer, You can edit the preferences in {{filename|~/.config/deluge/gtkui.conf}}, but there's also a nice configuration tool in the ui.<br />
<br />
Look for '''classic mode''' and disable it. Have You seen an icon just pop up? Hit it! If not go to Edit -> Connection Manager and add Your daemon.<br />
<br />
===Web ui===<br />
First, start the web ui daemon:<br />
# /etc/rc.d/deluge-web start<br />
<br />
and login in on ''http://deluge-machine:8112''. Where 'deluge-machine' is name of your deluge server or its private or public IP address. When asked for a password, enter "deluge" as it's the default password.<br />
<br />
The preferences in the web ui should be rather self explanatory and the first obvious thing to do is to change your password.<br />
<br />
As usual, you should add the daemons to your {{filename|/etc/rc.conf}}:<br />
DAEMONS=( ... network deluged '''deluge-web''' ... )<br />
<br />
Just make sure your network connection is up at the time you start either of those Deluge daemons.<br />
<br />
====SSL====<br />
In case you want SSL for the web ui, you need to generate a new cert/key set. To do this, first stop the web ui:<br />
<br />
# /etc/rc.d/deluge-web stop<br />
<br />
then go to ''/srv/deluge/.config/deluge/ssl/'' and issue:<br />
<br />
# openssl req -new -x509 -nodes -out deluge.cert.pem -keyout deluge.key.pem<br />
<br />
Next you need to edit {{filename|/srv/deluge/.config/deluge/web.conf}} and change the '''pkey''' and '''cert''' configuration directives to use your new self-signed certificates and also enable SSL:<br />
...<br />
"pkey": "ssl/deluge.key.pem",<br />
...<br />
"cert": "ssl/deluge.cert.pem",<br />
...<br />
"https": true,<br />
<br />
Afterwards just start the web ui again and you should be good to go:<br />
<br />
# /etc/rc.d/deluge-web start<br />
<br />
==Ressources==<br />
[http://deluge-torrent.org/ Deluge Homepage]</div>Miezebieze