This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Installing and applying themes, fonts, etc.

Tags: None
(comma "," separated)
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
Hi,

I have found a plasma themes, icons, fonts, etc. which suite me very well.
I have written a guide how to install them.

I would like to develop a package to install and apply these at once.

I am thinking to write a script in Python and have a folder with themes and settings.

I would like to know the best way to this. I have found some KDE4 transformation packs, but they are too universal.

My ideas are the following:
i1. The script will copy from package folder plasma theme(s), colors settings, qtcurve (which i use) settings, icons to respective folders.
i2. The script will install via apt fonts and other needed packages.
i3. The script will modify global and user-specific KDE settings files for the copied/installed themes, icons, fonts to be used with corresponding settings (font size, etc.)

My questions:
q1. What are the paths for copying plasma themes, icons, colors, etc.?
q2. What are the KDE settings files i need to tweak. I want also to be able to force KDE use my settings as defaults for newly created users?
q3. What is the best way to introduce these tweaks, to able to rollback and not break the KDE?

What i already know - needed more info, confirmations and ideas:
k1. For globally (any user would be able to see it in System Settings -> Application Appearance -> Style -> Widget style -> QtCurve -> Configure -> Import) accessible qtcurve settings, i copy the file with settings (*.qtcurve) to /usr/share/kde4/apps/QtCurve
k2. for a specific user, copy the *.qtcurve file to ~/.kde/share/apps/QtCurve
k3. User icons folder: ~/.kde/share/icons
Colors sets: ~/.kde/share/apps/color-schemes
Plasma theme: ~/.kde/share/apps/desktoptheme
k4. /usr/share/kde4/config/colors - the globally accessible colors
k5. To use installed themes, fonts, widget styles one must edit ~/.kde/share/config/kdeglobals
There is no file /usr/share/kde4/config/kdeglobals - how to i set needed settings as default for all users including root?

Will these paths change in future? For example /usr/share/kde4/ -> /usr/share/kde/
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
Collected some info:

1. to set wallpaper (http://foreverquest.blogspot.com/2010/1 ... round.html):
Code: Select all
kwriteconfig --file plasma-desktop-appletsrc --group Containments --group 1 --group Wallpaper --group image --key wallpaper "$1";

kquitapp plasma-desktop;

sleep 1;

plasma-desktop ;

looks like it's still not possible to set wallpaper using d-bus :(

2. Ask KWin to reread its settings (viewtopic.php?f=22&t=86777#p165882):
Code: Select all
qdbus org.kde.kwin /KWin reconfigure


if i set some settings using kwriteconfig, are there applications that will automatically start using them?

bcooksley wrote:With the right set of parameters given to "kwriteconfig" it is possible to change the behaviour of virtually any KDE application ( for the graphical interface layouts themselves, you will need to take copies of the required *ui.rc files from $KDEHOME/share/apps/<application>/ )

Make sure no KDE applications are running though when you do this, since many will flush their configuration state to disk when closing, overwriting your changes.

How do system settings solve these issues? how do they manage to apply settings immediately?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
The settings which System Settings sets are designed to be changed at runtime, and are not managed by any application specifically (although many apps read them and follow them).

Settings such as the ones specified by Plasma in it's own configuration files (plasma-desktoprc, etc) can be subject to change.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
What are the specifications for rc files? They look like simple ini files, but i faced several problems with them:
1. options must be delimited with '=', not with ' = ', otherwise everything is messed up.
2. There might be nested sections in format of '[setionName][subSection][subSubSection]'

Looks like configObj and ConfigParser modules for Python can not work correctly with these files - they work ok for reading, but not for updating them.

So, what are the specifications for this file, that i would follow to write my own parser in Python?

Thank you
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
I would suggest examining the "KConfig" class, which is written in C++, or calling out to the "kreadconfig" and "kwriteconfig" utilities to interact with the files. Alternately, you could use the KDE Python bindings.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
Right now i am looking for these!
I have found kreadconfig and kwriteconfig sources on https://projects.kde.org/projects/kde/k ... readconfig

THe idea about python bindings is great - thank you.
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
Ok,

i managed to used KConfig - works fine. Here is the sample code for those who might need it:
Code: Select all
#!/usr/bin/env python
import os, sys, datetime
from dbus import SessionBus
from distutils import dir_util
from PyKDE4.kdecore import KConfig, KConfigGroup

# http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/classKConfig.html
# http://api.kde.org/4.x-api/kdelibs-apidocs/kdecore/html/classKConfigGroup.html
# http://api.kde.org/4.x-api/kdelibs-

def updateConfig(srcCfgPath, dstCfgPath, bkpCfgPath=''):
       
    srcCfg = KConfig(srcCfgPath, KConfig.NoGlobals)
    dstCfg = KConfig(dstCfgPath, KConfig.NoGlobals)
    bkpCfg = KConfig(bkpCfgPath, KConfig.NoGlobals) # we keep here original settings of dest
   
    def walkGroup(groupName, srcParentGroup, dstParentGroup, bkpParentGroup):
        print 'Walking group: [' + groupName + ']'
        if not groupName:
            srcGroup = srcParentGroup
            dstGroup = dstParentGroup
            bkpGroup = bkpParentGroup
        else:
            srcGroup = KConfigGroup(srcParentGroup, groupName)
            dstGroup = KConfigGroup(dstParentGroup, groupName)
            bkpGroup = KConfigGroup(bkpParentGroup, groupName)
           
        for entryName in list(srcGroup.entryMap()):
            newEntryValue = unicode(srcGroup.readEntry(entryName))
            oldEntryValue = unicode(dstGroup.readEntry(entryName))
            dstGroup.writeEntry(entryName, newEntryValue)
            if newEntryValue != oldEntryValue and oldEntryValue:
                bkpGroup.writeEntry(entryName, oldEntryValue)
       
        for groupName in list(srcGroup.groupList()):
            walkGroup(groupName, srcGroup, dstGroup, bkpGroup)

    walkGroup('', srcCfg, dstCfg, bkpCfg)
   
    dstCfg.sync() # save the current state of the configuration object
   
    if bkpCfgPath:
        bkpCfg.sync()

def main():
   
    curDir = os.path.abspath(os.path.dirname(__file__))
   
    srcCfgPath = '/home/vic/.kde/share/config/plasma-desktoprc'
    bkpCfgPath = '/home/vic/Desktop/plasma-desktoprc~'
    dstCfgPath = '/home/vic/Desktop/plasma-desktoprc'
   
    updateConfig(srcCfgPath, dstCfgPath, bkpCfgPath)

    os.system("dbus-send --dest=org.kde.kwin /KWin org.kde.KWin.reloadConfig")
   
    bus = SessionBus()

    plasma = bus.get_object('org.kde.plasma-desktop','/MainApplication')
    plasma.reparseConfiguration()

    print 'some apps will see effects later after restarting'

if __name__ == "__main__":
    main()

updateConfig takes 3 parameters: source rc file, destination rc file (where entries from source will be written/updated) and backup rc file path (previous values from destination).

Questions:

1. Don't know how to send signal from Python instead of
Code: Select all
os.system("dbus-send --dest=org.kde.kwin /KWin org.kde.KWin.reloadConfig")


2. Plasma doesn't reload fonts after reparseConfiguration. I don't want to:
Code: Select all
kquitapp plasma-desktop
plasma-desktop
Any way?
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
The lack of change in fonts (assuming it isn't a font installation) is probably a bug in the applet's concerned. If you are installing new fonts, then due to a Qt limitation, applications must restart to detect them.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
But when i change fonts in system settings and apply the changes, plasma changes the fonts immediately. So, i guess, there is a solution.

I think i better look into fonts settings module sources. Would you help me finding them?

P.S. I have the fonts already installed

UPDATE:
found the sources:
https://projects.kde.org/projects/kde/k ... trol/fonts

There is this line:
Code: Select all
KGlobalSettings::self()->emitChange(KGlobalSettings::FontChanged);

http://api.kde.org/4.5-api/kdelibs-apid ... tings.html
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
You will need to look into kdelibs to find the source of KGlobalSettings. My guess is that it sends a signal on D-Bus which applications are listening for, and can thus react to.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
Maybe i missed something, but this is working for now:
Code: Select all
    from PyKDE4.kdeui import KGlobalSettings
    kGlobalSettings = KGlobalSettings.self()
    # tell all KDE apps to recreate their styles to apply the setitngs
    kGlobalSettings.emitChange(KGlobalSettings.StyleChanged)
    kGlobalSettings.emitChange(KGlobalSettings.SettingsChanged)
    kGlobalSettings.emitChange(KGlobalSettings.ToolbarStyleChanged)
    kGlobalSettings.emitChange(KGlobalSettings.PaletteChanged)
    kGlobalSettings.emitChange(KGlobalSettings.FontChanged)
    kGlobalSettings.emitChange(KGlobalSettings.IconChanged)
    kGlobalSettings.emitChange(KGlobalSettings.CursorChanged)

    print 'Telling Kwin to reload its config'
    os.system("dbus-send --dest=org.kde.kwin /KWin org.kde.KWin.reloadConfig")

    print 'Telling plasma to reload its config'
    plasma = SessionBus().get_object('org.kde.plasma-desktop','/MainApplication')
    plasma.reparseConfiguration()

Last edited by blindvic on Mon May 09, 2011 11:17 am, edited 1 time in total.
User avatar
bcooksley
Administrator
Posts
19765
Karma
87
OS
Yes, that looks about right.


KDE Sysadmin
[img]content/bcooksley_sig.png[/img]
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
I tried to find the configuration file in which desktop effects settings are stored - but i couldn't.
Particularly i want to find where settings for shadow effect are stored.
Can anyone help me with this?
airdrik
Registered Member
Posts
1854
Karma
5
OS
look in ~/.kde[4]/share/config/kwinrc for the [Effect-Shadow] section.
Of course all of those settings are changeable via systemsettings.


airdrik, proud to be a member of KDE forums since 2008-Dec.
User avatar
blindvic
Registered Member
Posts
157
Karma
0
OS
thanks! i somehow overlooked this


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], markhm, rblackwell, sethaaaa, Sogou [Bot], Yahoo [Bot]