Deployment: How to import KDE Desktop Layout? CLI or Script

Hi,
I am deploying Leap15.3 with KDE in my organization.

I need to import the desktop layout while deployment. Until now I am able to copy the *.desktop entries on the desktop. But they are now in wrong order/layout.
How can I import a existing layout like “Trash in upper right corner” and so on. The file

cat ~/.config/plasma-org.kde.plasma.desktop-appletsrc

contains some sort of of grid layout.

Any ideas to do this via cli?

Greetings and thanks,
Hendrik

I assume that KDE (including it’s most often used tools Dolphin, the KDE-PIM suite, etc.) have configuration files in as well as ~/.config as in ~/.kde4. So copying them from a pristine user (only desktop layout adapted to need, but nothing really used) may work.

But OTOH, I assume that those are all seen by the KDE people as internal to the KDE design. And as thus they will feel free to alter the place/significance/internal connections/names/etc. at will at every new version. So you may find yourself overtaken just when you think you got it.

There’s not much left that uses ~/.kde4. Most of what used to be there is no in ~/.config and ~/.local/share

Hi,
thanks for all your answers. I wrote a small script that injects the grid layout in the

~/.config/plasma-org.kde.plasma.desktop-appletsrc

config. After that it is necessary to restart plasma.

My “hacky” script:

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

""" Author:        

    inject desktop grid layout to plama config

    restart plasma
"""

import sys
import subprocess
import os
import re

plasma_file="/home/student/.config/plasma-org.kde.plasma.desktop-appletsrc"
plasma_restart_cmd="sudo -H -u student bash -c 'killall plasmashell && DISPLAY=:0 plasmashell &' >/dev/null 2>&1"

def get_containment_number():
        with open (plasma_file, "r") as myfile:
            data=myfile.readlines()
            for line in data:
                if "[Containments]" not in line:
                    continue
                else:
                    for number in re.findall(r'\d+', line):
                        return number

def check_for_existing_position_entry(containment_number):
    with open (plasma_file, "r") as myfile:
        data=myfile.readlines()
        for line in data:
            if "[Containments]" + containment_number + "][General]" not in line:
                continue
            else:
                return True
    return False

def remove_existing_position_entry(containment_number):
    with open(plasma_file,'r') as file:
        lines = file.readlines()

    with open(plasma_file,'w') as file:
        for line in lines:
        # find() returns -1 if no match is found
            if line.find("positions") != -1:
                pass
            elif line.find("[Containments]" + containment_number + "][General]") != -1:
                pass
            elif line.find("sortMode=") != -1:
                pass
            else:
                file.write(line)

def add_poition_entry(containment_number):
    with open(plasma_file, "a") as myfile:
        #myfile.write("
")
        myfile.write("[Containments]" + containment_number + "][General]
")
        myfile.write("positions=5,17,desktop:/CISCO_Reference_Card.pdf,0,7,desktop:/Wireshark_Display_Filters.pdf,0,6,desktop:/Abgabe_Hinweise.pdf,0,4,desktop:/Kcalc.desktop,3,1,desktop:/Firefox.desktop,1,0,desktop:/Konsole.desktop,3,0,desktop:/Trash.desktop,0,17,desktop:/Kate.desktop,2,1,desktop:/HSOVPN.desktop,4,1,desktop:/Home.desktop,0,0,desktop:/Idle.desktop,2,0,desktop:/spectacle.desktop,4,0,desktop:/Python_Reference_Card.pdf,0,11,desktop:/C_Lang_Reference_Card.pdf,0,10,desktop:/Unix_Reference_Card.pdf,0,8
")
        myfile.write("sortMode=-1
")

def restart_plasma():
    os.system(plasma_restart_cmd)
    print("Restarting Plasma ...")

def main():
    containment_number = get_containment_number()
    print(containment_number)

    if check_for_existing_position_entry(containment_number):
        print("existing position entry found!")
        remove_existing_position_entry(containment_number)
    else:
        print("NO existing position entry found!")

    add_poition_entry(containment_number)
    restart_plasma()

    print("finished script 
")

if __name__ == "__main__":
    main()



Greetings Hendrik