Revisions
-
jrd revised this gist
Jun 17, 2020 . 1 changed file with 9 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ #!/usr/bin/env python3 from os import getuid from subprocess import run from sys import exit, stderr @@ -15,7 +15,7 @@ if getuid() != 0: ) exit(0) # création sauvegarde si inexistante ou fichier plus récent (après mise à jour) run(['cp', '-u', MAIN_PATH, BACKUP_PATH], check=True) with open(MAIN_PATH, 'r+') as f: content = f.read() # liste des modifications ('original': 'modification') @@ -30,4 +30,10 @@ with open(MAIN_PATH, 'r+') as f: for original, modification in modifications.items(): content = content.replace(original.strip(), modification.strip()) f.write(content) xkbinfo = dict([ map(lambda x: x.strip(), line.split(':', 1)) for line in run(['setxkbmap', '-query'], check=True, capture_output=True, text=True).stdout.strip().split('\n') # noqa: E501 ]) run(['setxkbmap', xkbinfo['layout'], xkbinfo['variant']], check=True) print("Modifications effectuées, veuillez redémarrer X dès que possible") -
jrd created this gist
Apr 16, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ #!/usr/bin/env python3 from os import getuid from subprocess import check_call from sys import exit, stderr MAIN_PATH = '/usr/share/X11/xkb/symbols/fr' BACKUP_PATH = MAIN_PATH + '.bck' if getuid() != 0: print( "Vous devez lancer ce script avec les droits d’administration.", file=stderr, ) exit(0) # création sauvegarde si inexistante ou fichier plus récent (après mise à jour) check_call(['cp', '-u', MAIN_PATH, BACKUP_PATH]) with open(MAIN_PATH, 'r+') as f: content = f.read() # liste des modifications ('original': 'modification') modifications = { """key <AC05> { type[group1] = "FOUR_LEVEL", [ comma, semicolon, apostrophe, dead_belowcomma ] }; // , ; ' ,""": # noqa: E501 """key <AC05> { type[group1] = "FOUR_LEVEL", [ comma, semicolon, rightsinglequotemark, dead_belowcomma ] }; // , ; ’ ,""", # noqa: E501 """key <AB06> { type[group1] = "FOUR_LEVEL", [ rightsinglequotemark, question, questiondown, dead_hook ] }; // ’ ? ¿ ̉ """: # noqa: E501 """key <AB06> { type[group1] = "FOUR_LEVEL", [ apostrophe, question, questiondown, dead_hook ] }; // ' ? ¿ ̉ """, # noqa: E501 } if all([orig.strip() in content for orig in modifications]): f.seek(0) for original, modification in modifications.items(): content = content.replace(original.strip(), modification.strip()) f.write(content) print("Modifications effectuées, veuillez redémarrer X")