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

Scripted (re)configuration of activities

Tags: None
(comma "," separated)
graphischeda
Registered Member
Posts
1
Karma
0
Dear community and developers,

since Plasma 4 I got somewhat addicted to the use of activities ,-)

However, for several reasons I have to do the setup over and over again, which is quite tedious. Hence, I'd like to find a way to automate this by scripting. The task is simple to describe, as I just want to mimic the action of "Folder settings..." dialog.

After some days of searching, reading and trying to make progress I dare to ask you for assistance. I have to admit that, being just a KDE user, don't get the necessary grip how plasma works in detail in order to find the relevant modules and methods. So meanwhile I only found a way to loop through existing acitivites, but not to read (or write) the settings of interest, which therefore are inserted as comments:

Code: Select all
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
import dbus
from PyKDE4 import kdecore
from PyKDE4.kdecore import KConfig
activity_manager = dbus.SessionBus().get_object('org.kde.ActivityManager', '/ActivityManager/Activities')
current_activity_id = dbus.Interface(activity_manager, 'org.kde.ActivityManager.Activities').CurrentActivity()
kwin = dbus.SessionBus().get_object('org.kde.KWin', '/KWin')
konf_path = os.path.expanduser('~/.config/plasma-org.kde.plasma.desktop-appletsrc')
konf = KConfig(konf_path, KConfig.SimpleConfig)
containments = konf.group('Containments')
for group_name in containments.groupList():
    group = containments.group(group_name)
    print 'Containment ID of current activity:', group_name
    print ' activityId:', group.readEntry('activityId')
   # (1) WALLPAPER: Set an individual Wallpaper.
   # (2) LOCATION: Provide an indivitual folder to display.
   # (3) ICONS: Change the default display order to "by columns"


It would not be a problem to feed the necessary parameters from lists or dictionaries or "by name" (e.g. wallpapers to supply could have an identical naming scheme as the activities: mail.jpg for mail, procurement.jpg for procurement, and so on ).

A solution does not necessarily have to rely on python, it just has to manage the three configuration changes reliably.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Sogou [Bot]