def xkbcommontool(rmlvo):
- r = rmlvo.get('r', 'evdev')
- m = rmlvo.get('m', 'pc105')
- l = rmlvo.get('l', 'us')
- v = rmlvo.get('v', None)
- o = rmlvo.get('o', None)
- args = [
- 'rmlvo-to-keymap',
- '--rules', r,
- '--model', m,
- '--layout', l,
- ]
- if v is not None:
- args += ['--variant', v]
- if o is not None:
- args += ['--options', o]
-
- success = True
- out = io.StringIO()
- if verbose:
- print(':: {}'.format(' '.join(args)), file=out)
-
try:
- output = subprocess.check_output(args, stderr=subprocess.STDOUT)
+ r = rmlvo.get('r', 'evdev')
+ m = rmlvo.get('m', 'pc105')
+ l = rmlvo.get('l', 'us')
+ v = rmlvo.get('v', None)
+ o = rmlvo.get('o', None)
+ args = [
+ 'rmlvo-to-keymap',
+ '--rules', r,
+ '--model', m,
+ '--layout', l,
+ ]
+ if v is not None:
+ args += ['--variant', v]
+ if o is not None:
+ args += ['--options', o]
+
+ success = True
+ out = io.StringIO()
if verbose:
- print(output.decode('utf-8'), file=out)
- except subprocess.CalledProcessError as err:
- print('ERROR: Failed to compile: {}'.format(' '.join(args)), file=out)
- print(err.output.decode('utf-8'), file=out)
- success = False
+ print(':: {}'.format(' '.join(args)), file=out)
+
+ try:
+ output = subprocess.check_output(args, stderr=subprocess.STDOUT)
+ if verbose:
+ print(output.decode('utf-8'), file=out)
+ except subprocess.CalledProcessError as err:
+ print('ERROR: Failed to compile: {}'.format(' '.join(args)), file=out)
+ print(err.output.decode('utf-8'), file=out)
+ success = False
- return success, out.getvalue()
+ return success, out.getvalue()
+ except KeyboardInterrupt:
+ pass
def xkbcomp(rmlvo):
- r = rmlvo.get('r', 'evdev')
- m = rmlvo.get('m', 'pc105')
- l = rmlvo.get('l', 'us')
- v = rmlvo.get('v', None)
- o = rmlvo.get('o', None)
- args = ['setxkbmap', '-print']
- if r is not None:
- args.append('-rules')
- args.append('{}'.format(r))
- if m is not None:
- args.append('-model')
- args.append('{}'.format(m))
- if l is not None:
- args.append('-layout')
- args.append('{}'.format(l))
- if o is not None:
- args.append('-option')
- args.append('{}'.format(o))
-
- success = True
- out = io.StringIO()
- if verbose:
- print(':: {}'.format(' '.join(args)), file=out)
-
try:
- xkbcomp_args = ['xkbcomp', '-xkb', '-', '-']
-
- setxkbmap = subprocess.Popen(args, stdout=subprocess.PIPE)
- xkbcomp = subprocess.Popen(xkbcomp_args, stdin=setxkbmap.stdout,
- stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- setxkbmap.stdout.close()
- stdout, stderr = xkbcomp.communicate()
- if xkbcomp.returncode != 0:
+ r = rmlvo.get('r', 'evdev')
+ m = rmlvo.get('m', 'pc105')
+ l = rmlvo.get('l', 'us')
+ v = rmlvo.get('v', None)
+ o = rmlvo.get('o', None)
+ args = ['setxkbmap', '-print']
+ if r is not None:
+ args.append('-rules')
+ args.append('{}'.format(r))
+ if m is not None:
+ args.append('-model')
+ args.append('{}'.format(m))
+ if l is not None:
+ args.append('-layout')
+ args.append('{}'.format(l))
+ if o is not None:
+ args.append('-option')
+ args.append('{}'.format(o))
+
+ success = True
+ out = io.StringIO()
+ if verbose:
+ print(':: {}'.format(' '.join(args)), file=out)
+
+ try:
+ xkbcomp_args = ['xkbcomp', '-xkb', '-', '-']
+
+ setxkbmap = subprocess.Popen(args, stdout=subprocess.PIPE)
+ xkbcomp = subprocess.Popen(xkbcomp_args, stdin=setxkbmap.stdout,
+ stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ setxkbmap.stdout.close()
+ stdout, stderr = xkbcomp.communicate()
+ if xkbcomp.returncode != 0:
+ print('ERROR: Failed to compile: {}'.format(' '.join(args)), file=out)
+ success = False
+ if xkbcomp.returncode != 0 or verbose:
+ print(stdout.decode('utf-8'), file=out)
+ print(stderr.decode('utf-8'), file=out)
+
+ # This catches setxkbmap errors.
+ except subprocess.CalledProcessError as err:
print('ERROR: Failed to compile: {}'.format(' '.join(args)), file=out)
+ print(err.output.decode('utf-8'), file=out)
success = False
- if xkbcomp.returncode != 0 or verbose:
- print(stdout.decode('utf-8'), file=out)
- print(stderr.decode('utf-8'), file=out)
- # This catches setxkbmap errors.
- except subprocess.CalledProcessError as err:
- print('ERROR: Failed to compile: {}'.format(' '.join(args)), file=out)
- print(err.output.decode('utf-8'), file=out)
- success = False
-
- return success, out.getvalue()
+ return success, out.getvalue()
+ except KeyboardInterrupt:
+ pass
def parse(path):
if __name__ == '__main__':
- main(sys.argv)
+ try:
+ main(sys.argv)
+ except KeyboardInterrupt:
+ print('Exiting after Ctrl+C')