Widget Properties

A rundown of the QML Properties in a widget

Plasmoid property group

As discussed in the main.qml setup widget section, when you import org.kde.plasma.plasmoid 2.0, the main Item in your widget will have the Plasmoid (with a capital) property group similar to when you import QtQuick.Layouts 1.0. This Plasmoid property group has properties from AppletInterface which inherits a few properties from PlasmaQuick::AppletQuickItem.

plasmoid context property

You can reference a property from the Plasmoid.___ property group by the root Item { id: widget } of the widget with widget.Plasmoid.___. An easier method is to use the global context property plasmoid (lowercase) which is dynamically defined at runtime when the property group is imported.

contents/ui/main.qml
import QtQuick 2.0
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.plasmoid 2.0
Item {
    id: widget
    Plasmoid.icon: 'starred-symbolic'
    Plasmoid.fullRepresentation: PlasmaComponents3.Label {
        text: plasmoid.icon
        // OR
        // text: widget.Plasmoid.icon
    }
}

Plasmoid properties

PropertyTypeNotes
Plasmoid.activationTogglesExpandedboolKeyboard shortcut will toggle Plasmoid.expanded. Since KDE Frameworks 5.76, this is true by default.
Plasmoid.apiVersionintDue not use. Always returns 0. Source code.
Plasmoid.associatedApplicationstring
Plasmoid.associatedApplicationUrlsQList<QUrl>
Plasmoid.availableScreenRectrect
Plasmoid.availableScreenRegionQVariantList
Plasmoid.backgroundHintsPlasma::Types::BackgroundHintsDocumentation. Turn off the desktop widget bg.
Plasmoid.busyboolDraw the BusyIndicator overtop the widget.
Plasmoid.compactRepresentationComponentDocumentation. The smaller "icon" view view of the widget shown in the panel.
Plasmoid.compactRepresentationItemItemThe instance of the compactRepresentation Component. May be null on load if not visible.
Plasmoid.configurationKDeclarative::ConfigPropertyMapDocumentation. Provides access to all user configurable values as sub-properties.
Plasmoid.configurationRequiredboolWither to show a Configure button on top of the compact/full representation. It may look better to create your own button that calls plasmoid.action("configure").trigger().
Plasmoid.configurationRequiredReasonstringNot currently implemented to do anything.
Plasmoid.constraintHintsPlasma::Types::ConstraintHints
Plasmoid.containmentDisplayHintsPlasma::Types::ContainmentDisplayHints
Plasmoid.contextualActionsQList<QObject*>
Plasmoid.currentActivitystring
Plasmoid.editModeboolOnly available to Containments like the "panel" widget. Used to toggle the global widget editing mode.
Plasmoid.effectiveBackgroundHintsPlasma::Types::BackgroundHintsDocumentation. The actual background hints the applet has based on backgroundHints and userBackgroundHints.
Plasmoid.expandedbool
Plasmoid.formFactorPlasma::Types::FormFactor
Plasmoid.fullRepresentationComponentDocumentation. The full "popup" view of the widget.
Plasmoid.fullRepresentationItemItemThe instance of the fullRepresentation Component. Since widget popup's a lazy loaded, it is null until the popup is opened.
Plasmoid.globalShortcutQKeySequence
Plasmoid.hideOnWindowDeactivateboolSet to false to "pin" the widget's full representation dialog open when out of focus.
Plasmoid.iconstringExample
Plasmoid.iduintThis is an integer representing the widget instance. See Plasmoid.metaData.pluginId for the widget namespace.
Plasmoid.immutabilityPlasma::Types::ImmutabilityTypeDetect if Kiosk mode has locked the widgets, or the user Lock Widget mode from Plasma 5.18 and below.
Plasmoid.immutablebooltrue if either UserImmutable or SystemImmutable.
Plasmoid.loadingboolAlways false when widget is running.
Plasmoid.locationPlasma::Types::LocationLocation of widget on the screen.
Plasmoid.metaDataKPluginMetaDataReads metadata.json (or metadata.desktop). See the AboutPlugin.qml source code for examples.
Plasmoid.metaData.authorsQVariantList
Plasmoid.metaData.categorystring
Plasmoid.metaData.copyrightTextstring
Plasmoid.metaData.dependenciesQStringList
Plasmoid.metaData.descriptionstring
Plasmoid.metaData.extraInformationstring
Plasmoid.metaData.fileNamestring
Plasmoid.metaData.formFactorsQStringList
Plasmoid.metaData.iconNamestring
Plasmoid.metaData.initialPreferenceint
Plasmoid.metaData.isEnabledByDefaultbool
Plasmoid.metaData.isHiddenbool
Plasmoid.metaData.isValidbool
Plasmoid.metaData.licensestring
Plasmoid.metaData.licenseTextstring
Plasmoid.metaData.metaDataFileNamestring
Plasmoid.metaData.mimeTypesQStringList
Plasmoid.metaData.namestringThe translated widget Name. Also see Plasmoid.title
Plasmoid.metaData.otherContributorsQVariantList
Plasmoid.metaData.pluginIdstringDocumentation. The widget namespace. Id in metadata.json, or X-KDE-PluginInfo-Name in metadata.desktop.
Plasmoid.metaData.rawDataQJsonObject
Plasmoid.metaData.serviceTypesQStringList
Plasmoid.metaData.translatorsQVariantList
Plasmoid.metaData.versionstringReads Version in metadata.json or X-KDE-PluginInfo-Version in metadata.desktop.
Plasmoid.metaData.websitestring
Plasmoid.nativeInterfaceQObjectDocumentation. Provides access to C++ properties by extending Plasma::Applet like the SystemTray.
Plasmoid.pluginNamestringDocumentation. The widget namespace. Alias of Plasmoid.metaData.pluginId
Plasmoid.preferredRepresentationComponentForce a representation and ignore Plasmoid.switchHeight. Example
Plasmoid.rootItemQObjectReference the widget's root item. Cannot be used in the config dialog.
Plasmoid.screenint
Plasmoid.screenGeometryrect
Plasmoid.selfAppletInterface
Plasmoid.statusPlasma::Types::ItemStatus
Plasmoid.switchHeightintThe minimum height required to switch to fullRepresentation.
Plasmoid.switchWidthintThe minimum width required to switch to fullRepresentation.
Plasmoid.titlestringThe translated widget name.
Plasmoid.toolTipItemItem
Plasmoid.toolTipMainTextstringThe mainText in the default tooltip layout.
Plasmoid.toolTipSubTextstringThe subText in the default tooltip layout.
Plasmoid.toolTipTextFormatintThe TextFormat of the subText. Defaults to PlainText.
Plasmoid.userBackgroundHintsPlasma::Types::BackgroundHintsDocumentation. The user specified background hint.
Plasmoid.userConfiguringbool

Plasmoid.compactRepresentation

The compact representation uses DefaultCompactRepresentation.qml by default. To summarize, it:

  • Draws the plasmoid.icon using a Kirigami.Icon
  • Defines a MouseArea to toggle the expanded property which displays the full representation.

https://invent.kde.org/plasma/plasma-desktop/-/blob/master/desktoppackage/contents/applet/CompactApplet.qml

Plasmoid.fullRepresentation

If there's enough room (more than Plasmoid.switchHeight) then the widget's full representation can be drawn directly in the panel or on the desktop. If you want to force this behaviour you can set Plasmoid.preferredRepresentation.

Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation

If there isn't enough room, then the widget will display Plasmoid.compactRepresentation instead, and the full representation will be visible when plasmoid.expanded is true.

In a plasma widget, the full representation will be shown in a PlasmaCore.Dialog which you cannot access directly. You can manipulate the dialog with:

  • Set Layout.preferredWidth and Layout.preferredHeight in your full representation Item to change to dialog size.
  • Set Plasmoid.hideOnWindowDeactivate to prevent the dialog from closing. You can use this to have a configurable "pin" like the digital clock widget does.

The dialog's source code can be found in CompactApplet.qml to see the exact behavior.

contents/ui/main.qml
import QtQuick 2.0
import QtQuick.Layouts 1.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.plasmoid 2.0

Item {
    // Always display the compact view.
    // Never show the full popup view even if there is space for it.
    Plasmoid.preferredRepresentation: Plasmoid.compactRepresentation

    Plasmoid.fullRepresentation: Item {
        Layout.minimumWidth: label.implicitWidth
        Layout.minimumHeight: label.implicitHeight
        Layout.preferredWidth: 640 * PlasmaCore.Units.devicePixelRatio
        Layout.preferredHeight: 480 * PlasmaCore.Units.devicePixelRatio
        
        PlasmaComponents.Label {
            id: label
            anchors.fill: parent
            text: "Hello World!"
            horizontalAlignment: Text.AlignHCenter
        }
    }
}

Plasmoid.icon

As mentioned in the setup widget metadata.json section, by default the plasmoid icon is populated with the Icon value in metadata.json.

To set a dynamic or user configurable icon, you will need to assign an icon name to Plasmoid.icon.

You can search for icon names in the /usr/share/icon folder. You can also look for an icon name by right clicking your app launcher widget then editing the icon in its settings. It uses a searchable interface and lists them by category. Plasma's SDK also has the Cuttlefish app (screenshot) which you can install with sudo apt install plasma-sdk.

Also checkout the configurable panel icon example

contents/ui/main.qml
import QtQuick 2.0
import org.kde.plasma.plasmoid 2.0

Item {
    id: widget
    property bool hasUnread: true
    Plasmoid.icon: hasUnread ? "mail-unread" : "mail-message"

    Timer {
        interval: 1000
        repeat: true
        running: true
        onTriggered: widget.hasUnread = !widget.hasUnread
    }
}

Plasmoid.configuration

This property provides access to the values user configurable values. You can easily access config values with plasmoid.configuration.varName. By default it populates with the keys and values in config/main.xml. You can easily write to plasmoid.configuration.varName = "value" to change the value for the user.

Read more about configuration and the config dialog in it's section of the tutorial.

The user's configuration is serialized to ~/.config/plasma-org.kde.plasma.desktop-appletsrc when the plasmashell process terminates and is only loaded at startup.

Since: KDE Frameworks 5.78, you can reference the default value of plasmoid.configuration.varName with plasmoid.configuration.varNameDefault.

Since: KDE Frameworks 5.89, the KDeclarative::ConfigPropertyMap datatype was deprecated and will eventually change to KConfig's KConfigPropertyMap .

contents/ui/main.qml
import QtQuick 2.0
import org.kde.plasma.components 3.0 as PlasmaComponents3
import org.kde.plasma.plasmoid 2.0

RowLayout {
    id: widget
    PlasmaComponents.Label {
        text: i18np("%1 Click", "%1 Clicks", plasmoid.configuration.numClicked)
    }
    PlasmaComponents3.Button {
        icon.name: "value-increase-symbolic"
        text: i18n("Add")
        onClicked: plasmoid.configuration.numClicked += 1
    }
}

Plasmoid.backgroundHints

  • PlasmaCore.Types.DefaultBackground (default) is equal to StandardBackground.
  • PlasmaCore.Types.StandardBackground The standard background from the theme is drawn.
  • PlasmaCore.Types.TranslucentBackground An alternate version of the background is drawn, usually more translucent.
  • PlasmaCore.Types.ShadowBackground The applet won't have a svg background but a drop shadow of its content done via a shader. The text color will also invert.
  • PlasmaCore.Types.NoBackground This property is used to hide a desktop widget background. An example would be the Analog Clock widget.
  • PlasmaCore.Types.ConfigurableBackground Allows the user to toggle between StandardBackground and ShadowBackground. Note that this is a bit flag to be used with another enum value.

To use ConfigurableBackground, combine the flag with another value with the bitwise OR operator |.

PlasmaCore.Types.NoBackground | PlasmaCore.Types.ConfigurableBackground

Note: For ShadowBackground, make sure you use PlasmaCore.ColorScope.colorGroup in your IconItem to have the symbolic icons follow the text color.

PlasmaCore.IconItem {
    colorGroup: PlasmaCore.ColorScope.colorGroup
}
contents/ui/main.qml
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.plasmoid 2.0

Item {
    id: widget
    Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground
}

contents/ui/main.qml
import QtQuick 2.0
import QtQuick.Layouts 1.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents3
import org.kde.plasma.plasmoid 2.0

Item {
    id: widget
    Plasmoid.icon: 'starred-symbolic'
    Plasmoid.backgroundHints: PlasmaCore.Types.StandardBackground | PlasmaCore.Types.ConfigurableBackground
    // Plasmoid.backgroundHints: PlasmaCore.Types.ShadowBackground | PlasmaCore.Types.ConfigurableBackground
    // Plasmoid.backgroundHints: PlasmaCore.Types.NoBackground | PlasmaCore.Types.ConfigurableBackground

    Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation
    Plasmoid.fullRepresentation: RowLayout {
        PlasmaCore.IconItem {
            source: plasmoid.icon
            colorGroup: PlasmaCore.ColorScope.colorGroup
            Layout.fillHeight: true
            Layout.preferredWidth: height
        }
        PlasmaComponents3.Label {
            text: "Text"
            font.pointSize: 30
        }
    }
}

metadata.json

The common metadata.json properties are covered in the setup widget section.

metadata.desktop is the older format while metadata.json is the newer replacement format. The .desktop file is simpler to script using kreadconfig5 which is the reason why this tutorial prefers it in certain places like translations.

You can read the generated C++ API Documentation for metadata.json for the json schema. The full list of properties for the older metadata.desktop properties for widgets is defined in the Plasma/Applet service type.

Name, Description

These two are based on the standard XDG desktop file properties. You can also translate these properties with Name[fr]. The translated Name is used in the "Add Widgets" list. The Description (previously known as Comment in the metadata.desktop) is only used for the default tooltip subtext when the widget is added to a panel.
metadata.json
{
    "KPlugin": {
        "Description": "Month display with your appointments and events",
        "Description[fr]": "Vue mensuelle avec vos rendez-vous et évènements",
        "Name": "Calendar",
        "Name[fr]": "Calendrier"
    }
}
metadata.desktop
[Desktop Entry]
Name=Calendar
Name[fr]=Calendrier
Comment=Month display with your appointments and events
Comment[fr]=Vue mensuelle avec vos rendez-vous et évènements

Icon

Icon is the icon name associated with the widget. You can search for icon names in the /usr/share/icon folder. You can also look for an icon name by right clicking your app launcher widget then editing the icon in its settings. It uses a searchable interface and lists them by category. Plasma's SDK also has the Cuttlefish app which you can install with sudo apt install plasma-sdk.
metadata.json
{
    "KPlugin": {
        "Icon": "office-calendar",
    }
}
metadata.desktop
[Desktop Entry]
Icon=office-calendar

Id

The Id (or X-KDE-PluginInfo-Name in metadata.desktop) needs to be a unique name, since it's used for the folder name it's installed into. You could use com.github.zren.helloworld if you're on github, or use org.kde.plasma.helloworld if you are planning on contributing the widget to KDE. You should consider this the widget's namespace.

To view the currently installed namespaces use:

❯ kpackagetool5 --type Plasma/Applet --list
Listing service types: Plasma/Applet in ~/.local/share/plasma/plasmoids/
com.github.zren.helloworld

❯ kpackagetool5 --type Plasma/Applet --list --global
Listing service types: Plasma/Applet in /usr/share/plasma/plasmoids/
org.kde.desktopcontainment
org.kde.kdeconnect
org.kde.kscreen
org.kde.milou
org.kde.panel
org.kde.plasma.activitybar
org.kde.plasma.activitypager
org.kde.plasma.addons.katesessions
...
~/.local/share/plasma/plasmoids/com.github.zren.helloworld/
/usr/share/plasma/plasmoids/com.github.zren.helloworld/
metadata.json
{
    "KPlugin": {
        "Id": "com.github.zren.helloworld",
    }
}
metadata.desktop
[Desktop Entry]
X-KDE-PluginInfo-Name=com.github.zren.helloworld

Category

The Category (or X-KDE-PluginInfo-Category in metadata.desktop) is used to filter widgets in the widget list.

metadata.json
{
    "KPlugin": {
        "Category": "Date and Time",
    }
}
metadata.desktop
[Desktop Entry]
X-KDE-PluginInfo-Category=Date and Time
  • Accessibility: tools that help those with special needs or disabilities use their computer
  • Application Launchers: application starters and file openers.
  • Astronomy: anything to do with the night sky or other celestial bodies.
  • Date and Time: clocks, calendars, scheduling, etc
  • Development Tools: tools and utilities to aid software developers
  • Education: teaching and educational aides
  • Environment and Weather: add-ons that display information regarding the weather or other environmentally related data
  • Examples: samples that are not meant for production systems
  • File System: anything that operates on files or the file system as its primary purpose, such as file watchers or directory listings. Simply using a file as storage does not qualify the add-on for this category.
  • Fun and Games: for games and amusements
  • Graphics: for add-ons where displaying images, photos or graphical eye candy is the primary purpose
  • Language: add-ons whose primary purpose is language related, such as dictionaries and translators.
  • Mapping: geography and geographic data add-ons
  • Multimedia: music and video.
  • Online Services: add-ons that provide an interface to online services such as social networking or blogging sites. If there is another more appropriate category for the add-on given the topic (e.g. mapping if the applet's purpose is to show maps), even if the data is retrieved from the Internet prefer that other category over this one.
  • System Information: display and interaction with information about the computer such as network activity, hardware health, memory usage, etc
  • Utilities: Useful tools like calculators
  • Windows and Tasks: managers for application windows and/or tasks, such as taskbars

This list was taken from: https://techbase.kde.org/Projects/Plasma/PIG

KPackageStructure

KPackageStructure is a string to identify the associated KPackage::PackageStructure . For a plasma widget, it should be Plasma/Applet.

metadata.json
{
    "KPackageStructure": "Plasma/Applet"
}
metadata.desktop
[Desktop Entry]
X-KDE-ServiceTypes=Plasma/Applet

X-Plasma-API, X-Plasma-MainScript

X-Plasma-API tells plasma what script engine to use. declarativeappletscript is the standard QML loader.

X-Plasma-MainScript is the entry point of your qml code. The default value is ui/main.qml.

metadata.json
{
    "X-Plasma-API": "declarativeappletscript",
    "X-Plasma-MainScript": "ui/main.qml"
}
metadata.desktop
[Desktop Entry]
X-Plasma-API=declarativeappletscript
X-Plasma-MainScript=ui/main.qml

X-Plasma-Provides (Alternatives)

A Plasmoid can specify the type of functionality it offers, for example whether it's a clock, an application launcher, etc. This mechanism is used to list alternative plasmoids for a certain function. When you open the context menu of the Application Launcher (aka kickoff) in the Plasma desktop panel, you'll see that a number of different Plasmoids are offered here as alternatives, like the Application Menu (aka kicker) and Application Dashboard (aka kickerdash). All three of these widgets define:

metadata.json
{
    "X-Plasma-Provides": [
        "org.kde.plasma.launchermenu"
    ]
}
metadata.desktop
[Desktop Entry]
X-Plasma-Provides=org.kde.plasma.launchermenu

These "Provides" are in fact arbitrary, so you can choose your own here. The field accepts multiple values separated by a comma. Here are some possible values that are used throughout Plasma:

  • org.kde.plasma.launchermenu: App Launcher Menus
  • org.kde.plasma.multimediacontrols: Multimedia controls
  • org.kde.plasma.time: Clocks
  • org.kde.plasma.date: Calendars
  • org.kde.plasma.time,org.kde.plasma.date: Clocks with calendars (Eg: Digital Clock)
  • org.kde.plasma.powermanagement: Power management (Eg: Battery and Brightness)
  • org.kde.plasma.notifications: Notifications
  • org.kde.plasma.removabledevices: Removable devices, auto mounter, etc.
  • org.kde.plasma.multitasking: Task switchers
  • org.kde.plasma.virtualdesktops: Virtual desktop switcher
  • org.kde.plasma.activities: Switchers for Plasma activities
  • org.kde.plasma.trash: Trash / file deletion

You can search plasma's code for more examples:

X-Plasma-NotificationArea (System Tray)

The Media Controller widget serves as a good example since it uses most of the systemtray metadata features. Its metadata contains the following:

metadata.json
{
    "KPlugin": {
        "EnabledByDefault": true
    },
    "X-Plasma-DBusActivationService": "org.mpris.MediaPlayer2.*",
    "X-Plasma-NotificationArea": "true",
    "X-Plasma-NotificationAreaCategory": "ApplicationStatus"
}
metadata.desktop
[Desktop Entry]
X-KDE-PluginInfo-EnabledByDefault=true
X-Plasma-NotificationArea=true
X-Plasma-NotificationAreaCategory=ApplicationStatus
X-Plasma-DBusActivationService=org.mpris.MediaPlayer2.*

By specifying X-Plasma-NotificationArea, this widget will be found by the systemtray widget.

EnabledByDefault will make sure it's enabled in the systemtray by default.

It's prudent for the widget to also set the X-Plasma-NotificationAreaCategory so that the icons are grouped together. Its allowed values are:

  • ApplicationStatus: indicates that this item represents an active application
  • Hardware: indicates that this item allows managing hardware (could be a battery monitor or the wifi applet)
  • SystemServices: indicates that this item shows information about system services, for example the status of file indexing, software updates, etc.

You can search plasma's code for more examples:

X-Plasma-DBusActivationService

X-Plasma-DBusActivationService will load and unload widgets in the systemtray automatically when a DBus service becomes available or is stopped. This is very convenient to load widgets automatically, so the user doesn't have to explicitly go to the notification area settings and enable or remove a widget.

An example of this is the Media Controller widget, which is auto-loaded as soon as an application starts offering the org.mpris.MediaPlayer2 DBus service in the session. As you can see in its metadata.json file, X-Plasma-DBusActivationService accepts wildcards which makes it a bit easier to match DBus names. This key can also be very useful to avoid having a widget loaded when it's unnecessary, so it can help to avoid visual clutter and wasted memory.

metadata.json
{
    "X-Plasma-DBusActivationService": "org.mpris.MediaPlayer2.*"
}
metadata.desktop
[Desktop Entry]
X-Plasma-DBusActivationService=org.mpris.MediaPlayer2.*

Search plasma-workspace for X-Plasma-DBusActivationService for more examples.