LinuxCommandLibrary

kreadconfig5

Read configuration settings from KDE configuration files

TLDR

Read a key from the global configuration

$ kreadconfig5 --group [group_name] --key [key_name]
copy

Read a key from a specific configuration file
$ kwriteconfig5 --file [path/to/file] --group [group_name] --key [key_name]
copy

Check if systemd is used to start the Plasma session
$ kreadconfig5 --file [startkderc] --group [General] --key [systemdBoot]
copy

SYNOPSIS

kreadconfig5 [OPTIONS] [--file file] [--group group] [--key key] [--type type] [--default value]

PARAMETERS

--file
    Specifies the configuration file to read from. If omitted, reads from the default KDE configuration file.

--group
    Specifies the group name within the configuration file to read from.

--key
    Specifies the key name within the group to read from.

--type
    Specifies the data type of the value to read. Possible values are string, int, bool, double.
If omitted, the type is auto-detected.

--default
    Specifies the default value to return if the key is not found. If omitted, an empty string is returned.

--exactKey
    Require the key to exist. If key does not exist, nothing is printed.

--global
    Read the global configuration file.

--remove
    Remove the value.

--version
    Displays version information.

--help
    Displays help information.

DESCRIPTION

kreadconfig5 is a command-line tool provided by the KDE Frameworks 5 to read configuration settings. It enables users and scripts to retrieve specific values from KDE's configuration files without needing to run a full KDE application. This is particularly useful for scripting, automation, and accessing KDE settings from outside of the KDE environment. The tool accesses the configuration files based on the provided group and key parameters. It can retrieve settings of various data types like strings, numbers, and booleans. If the configuration file cannot be found or the specified group or key doesn't exist, kreadconfig5 can be configured to return a default value or exit with a non-zero status. Using kreadconfig5 provides a streamlined approach to retrieving KDE settings compared to manually parsing configuration files.

DATA TYPES

The --type option allows you to specify the data type you expect. Correctly specifying the type ensures that the returned value is in the correct format. If you don't specify it, kreadconfig5 will try to guess, which might not always be accurate.

EXIT CODES

The command exits with 0 on success and a non-zero value on failure (e.g., if the specified key isn't found and no default is given).

HISTORY

kreadconfig5 is part of the KDE Frameworks 5, a collection of libraries that extend Qt to provide common functionality for KDE applications. It evolved from earlier configuration tools in KDE 4 like kreadconfig. The '5' indicates that it's specifically designed for KDE Frameworks 5. Its purpose is to provide a reliable command-line interface to KDE's configuration system, ensuring that settings can be accessed and manipulated consistently across the KDE ecosystem.

SEE ALSO

kwriteconfig5(1), kdeoptions(7)

Copied to clipboard