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
$ kreadconfig5 --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 [--file <file>] [--group <group>] [--key <key>] [--default <value>] [--type <type>]
kreadconfig5 [--file <file>] [--list-groups | --list-keys [--group <group>] | --list-all]
kreadconfig5 [--help | --version]

PARAMETERS

--file <file>
    Specifies the full path to the configuration file to read. If not provided, it defaults to the main application configuration file (e.g., 'kdeglobals' for common settings) or the specific application's .rc file.

--group <group>
    Specifies the configuration group (section) within the file from which to read the key. This option is required when using '--key' or '--list-keys'.

--key <key>
    Specifies the configuration key whose value is to be read. This option is required for reading a specific value.

--default <value>
    Provides a default value to output if the specified key or group is not found. If omitted and the key is not found, the command will exit with an error (non-zero exit code).

--type <type>
    Specifies the expected data type of the value. Supported types include: string, bool, int, double, path, url, color, font. This helps in correct parsing and conversion of the configuration value.

--list-groups
    Lists all configuration groups (sections) found in the specified configuration file. If no file is specified, it lists groups in 'kdeglobals'.

--list-keys
    Lists all keys within a specified configuration group. This option requires the '--group' option to be also provided.

--list-all
    Lists all groups and their respective keys found in the specified configuration file. If no file is specified, it lists all in 'kdeglobals'.

--version
    Displays the version information for the kreadconfig5 command and the KDE Frameworks version it belongs to.

--help
    Displays a help message with usage information and available options for the command.

DESCRIPTION

kreadconfig5 is a fundamental command-line utility provided by the KDE Frameworks 5 KConfig module. Its primary purpose is to read specific values from KDE's standardized .ini-style configuration files. These files serve as the central repository for storing settings across KDE applications and the entire desktop environment, commonly located in the user's ~/.config/ directory.

The command is an indispensable tool for system administrators and script developers, enabling them to programmatically query and retrieve KDE settings. This facilitates automation, allowing scripts to adapt their behavior dynamically based on the current desktop configuration, such as theme, language, or specific application preferences. Users can precisely specify the configuration file, the desired group (section), and the key within that group to retrieve its corresponding value. kreadconfig5 also offers options for providing default values in case a setting is not found, or for listing all available groups and keys within a given configuration file, making it versatile for both direct querying and configuration exploration.

CAVEATS

kreadconfig5 requires KDE Frameworks 5 libraries to be installed and will not function on systems without these dependencies. It is designed to read .ini-style configuration files, which is KDE's primary format, but cannot parse other configuration formats like XML or JSON. The command returns an exit status of 0 on success, and a non-zero value if the specified file, group, or key cannot be found (unless a default value is explicitly provided with '--default').

COMMON CONFIGURATION LOCATIONS

KDE configuration files are typically found in the user's home directory under ~/.config/. For instance, global desktop settings are stored in ~/.config/kdeglobals, while application-specific configurations are often located in files named ~/.config/<appname>rc (e.g., ~/.config/konsole-rc for Konsole).

USAGE IN SCRIPTS

This command is widely utilized in shell scripts to dynamically query and retrieve current desktop settings, such as the active theme, icon set, or language preferences. Its ability to provide default values for non-existent entries significantly enhances the robustness and flexibility of scripts, allowing them to adapt gracefully to various user configurations or missing settings.

HISTORY

kreadconfig5 is an integral part of KDE Frameworks 5, which represents a significant architectural evolution from earlier KDE desktop environments (KDE 3, KDE 4). It emerged as the successor to older command-line utilities (such as those prefixed with 'kde-config' in earlier versions) designed for interacting with the KConfig system. Its development aimed to provide a robust, consistent, and modular command-line interface for reading KDE configuration values, aligning with the broader design principles of KDE Frameworks.

SEE ALSO

kwriteconfig5(1), kded5(8)

Copied to clipboard