[Tip] Save your Plasma configurations and easily switch between them

As many of you have in the meantime painfully come to experience, KDE Plasma, for all the greatness that it offers, does tend to blow up in your face every once in a while, necessitating that you delete all of your Plasma configuration files and start setting up things to your liking from scratch all over again.

(Yes, been there, done that, have the T-shirt and the bumper sticker. :face_with_diagonal_mouth:)

Well, there is a way you can protect yourself against this calamity, and as a bonus, it offers you the option of saving multiple different layouts, and of easily switching between them. :wink:

Assuming that your system is fully up to date — this is important, and it cannot be emphasized enough — the first thing you need to do is install a package called konsave from the AUR. :arrow_down:

pamac build konsave

… or… :arrow_down:

yay -S konsave

Now, you cannot just start using this tool right away, because although the developer states that it comes preconfigured for Plasma, this is only true for the Python-based installation of the package, which installs itself in your $HOME. It is not true for the version you install from the AUR, which installs the tool system-wide.

Therefore, after installing the package from the AUR, you must give it a first run — you simply start it from the command line, e.g. with the --help parameter. :arrow_down:

konsave --help

This will create a directory ~/.config/konsave in your $HOME, with in it, a file called conf.yaml.

What you must do next is open this file in an editor such as kate or kwrite — no root privileges required, because this is a file in your $HOME and it’s owned by you — and empty the file. Delete everything that’s in there.

Then, copy the entire code block here-below, paste it into the file, and save the file. :arrow_down:

---
# This is the configuration file for konsave.
# This file is pre-configured for KDE Plasma users.
# This will backup all the important files for your Plasma customizations.
# Please make sure it follows the correct format for proper working of Konsave.
# The format should be:
# ---
# save:
#     name:
#         location: "path/to/parent/directory"
#         entries: 
#         # these are files which will be backed up. 
#         # They should be present in the specified location.
#             - file1
#             - file2
# export:
#     # This includes files which will be exported with your profile.
#     # They will not be saved but only be exported and imported.
#     # These may include files like complete icon packs and themes..
#     name:
#         location: "path/to/parent/directory"
#         entries: 
#             - file1
#             - file2
# ...
# You can use these placeholders in the "location" of each item:
# $HOME: the home directory
# $CONFIG_DIR: refers to "$HOME/.config/"
# $SHARE_DIR: refers to "$HOME/.local/share"
# $BIN_DIR: refers to "$HOME/.local/bin"
# ${ENDS_WITH="text"}: for folders with different names on different computers whose names end with the same thing.
# The best example for this is the "*.default-release" folder of firefox.
# ${BEGINS_WITH="text"}: for folders with different names on different computers whose names start with the same thing.

save:
    configs:
        location: "$CONFIG_DIR"
        entries:
            - gtk-2.0
            - gtk-3.0
            - gtk-4.0
            - kate
            - Kvantum
            - latte
            - dolphinrc
            - katerc
            - konsolerc
            - kcminputrc
            - kdeglobals
            - kglobalshortcutsrc
            - klipperrc
            - krunnerrc
            - kscreenlockerrc
            - ksmserverrc
            - kwinrc
            - kwinrulesrc
            - plasma-org.kde.plasma.desktop-appletsrc
            - plasmarc
            - plasmashellrc
            - gtkrc
            - gtkrc-2.0
            - lattedockrc
            - breezerc
            - oxygenrc
            - lightlyrc
            - ksplashrc
            - khotkeysrc

    app_layouts:
        location: "$HOME/.local/share/kxmlgui5"
        entries:
            - dolphin
            - konsole

    # Here are a few examples of how you can add more stuff to back up.
    # Uncomment these lines if you want.
    # firefox:
    #     location: "$HOME/.mozilla/firefox/${ENDS_WITH='.default-release'}"
    #     entries:
    #         - chrome # for firefox customizations

    # code oss:
    #     location: "$CONFIG_DIR/Code - OSS/User/"
    #     entries:
    #         - settings.json


# The following files will only be used for exporting and importing.
export:
    share_folder:
        location: "$SHARE_DIR"
        entries:
            - plasma
            - kwin
            - konsole
            - fonts
            - color-schemes
            - aurorae
            - icons
            - wallpapers

    home_folder:
        location: "$HOME/"
        entries:
            - .fonts
            - .themes
            - .icons
    
        
    # You can add more files to export like this
    # name:
    #     location: "path/to/parent/directory"
    #     entries:
    #         - file1
    #         - file2
    #         - folder1
    #         - folder2
...

Now that you’ve modified and saved the file, you can start saving your (first) Plasma configuration, as follows… :arrow_down:

konsave -s my-1st-plasma-profile

… or alternatively… :arrow_down:

konsave --save my-1st-plasma-profile

You can give it any name you want, of course. But I’m calling it like this in the example above, because you may want to completely reconfigure your Plasma — wallpaper, theme, and so on — at some later point in time. Well, if that is the case, then you can save that one too, with… :arrow_down:

konsave -s my-2nd-plasma-profile

… or alternatively… :arrow_down:

konsave --save my-2nd-plasma-profile

And now imagine that after a while, you feel like going back to your initial configuration. Well, you can, and it’s as simple as… :arrow_down:

konsave -a my-1st-plasma-profile

… or alternatively… :arrow_down:

konsave --apply my-1st-plasma-profile

:tada: :stuck_out_tongue:

konsave also allows you to export your profile in a single file, so you can share it or maybe use it on another machine.

However — caveat emptor — an exported profile does not contain the actual wallpapers, theme packages, cursor packages, et al. The export file only contains the configuration, and if the target machine has those very same wallpapers, theme packages et al installed, then importing the profile by way of konsave there will of course successfully apply all of your settings on the target machine.

For more information — once you’ve installed the package and set it up as explained above — see… :arrow_down:

konsave --help

:wink:


(Special thanks to @Tomek for bringing this wonderful tool to my attention. :+1: )

5 Likes