Warning, file /plasma/kwin/kconf_update/kwinrules-5.23-virtual-desktop-ids.py was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 #!/usr/bin/env python3 0002 0003 import fileinput 0004 import configparser 0005 import os.path 0006 import subprocess 0007 0008 # Get the config standard locations 0009 config_locations = subprocess.check_output(['qtpaths', '--paths', 'ConfigLocation']).decode('utf-8').strip().split(':') 0010 config_paths = [os.path.join(folder, 'kwinrc') for folder in config_locations] 0011 0012 # Get the desktops information from `kwinrc` config file 0013 kwinrc = configparser.ConfigParser(strict=False, allow_no_value=True) 0014 kwinrc.read(config_paths) 0015 0016 num_desktops = int(kwinrc.get('Desktops', 'Number', fallback='')) 0017 0018 # Generete the map from x11ids (ennumeration) to UUIDs 0019 desktopUUIDs = { -1: "" } # NET::OnAllDesktops -> Empty string 0020 for i in range(1, num_desktops + 1): 0021 uuid = kwinrc.get('Desktops', f'Id_{i}', fallback='') 0022 desktopUUIDs[i] = str(uuid) 0023 0024 # Apply the conversion to `kwinrulesrc` 0025 for line in fileinput.input(): 0026 # Rename key `desktoprule` to `desktopsrule` 0027 if line.startswith("desktoprule="): 0028 value = line[len("desktoprule="):].strip() 0029 print("desktopsrule=" + value) 0030 print("# DELETE desktoprule") 0031 continue 0032 0033 if not line.startswith("desktop="): 0034 print(line.strip()) 0035 continue 0036 0037 # Convert key `desktop` (x11id) to `desktops` (list of UUIDs) 0038 try: 0039 value = line[len("desktop="):].strip() 0040 x11id = int(value) 0041 uuid = desktopUUIDs[x11id] 0042 except: 0043 print(line.strip()) # If there is some error, print back the line 0044 continue 0045 0046 print("desktops=" + uuid) 0047 print("# DELETE desktop")