fix layout raw strings
This commit is contained in:
parent
6f262652ff
commit
187e8e679a
2 changed files with 19 additions and 6 deletions
21
fleepit.py
21
fleepit.py
|
@ -21,13 +21,14 @@ import typing
|
||||||
|
|
||||||
LANGSETS = {
|
LANGSETS = {
|
||||||
'qwerty-en-ru': (
|
'qwerty-en-ru': (
|
||||||
"""`1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,./~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>?""",
|
r"""`1234567890-=qwertyuiop[]\asdfghjkl;'zxcvbnm,.~!@#$%^&*()_+QWERTYUIOP{}|ASDFGHJKL:"ZXCVBNM<>""",
|
||||||
"""ё1234567890-=йцукенгшщзхъ\фывапролджэячсмитьбю.Ё!"№;%:?*()_+ЙЦУКЕНГШЩЗХЪ/ФЫВАПРОЛДЖЭЯЧСМИТЬБЮ,""",
|
r"""ё1234567890-=йцукенгшщзхъ\фывапролджэячсмитьбюЁ!"№;%:?*()_+ЙЦУКЕНГШЩЗХЪ/ФЫВАПРОЛДЖЭЯЧСМИТЬБЮ""",
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def make_langset_dict(ls: typing.Tuple[str, str]) -> typing.Dict[str, str]:
|
def make_langset_dict(langset: str) -> typing.Dict[str, str]:
|
||||||
|
ls = LANGSETS[langset]
|
||||||
flipper = {}
|
flipper = {}
|
||||||
for (a, b) in zip(*ls):
|
for (a, b) in zip(*ls):
|
||||||
flipper[a] = b
|
flipper[a] = b
|
||||||
|
@ -45,16 +46,24 @@ def do_x11(args: argparse.Namespace):
|
||||||
result.check_returncode()
|
result.check_returncode()
|
||||||
clip = result.stdout
|
clip = result.stdout
|
||||||
if clip.strip() == '':
|
if clip.strip() == '':
|
||||||
|
if args.verbose:
|
||||||
|
print(f'clipboard is empty')
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if args.verbose:
|
||||||
|
print(f'clipboard: "{ clip }"')
|
||||||
|
|
||||||
# Clear selection
|
# Clear selection
|
||||||
result = subprocess.run([ 'xclip', '-i', '-selection', 'primary' ], text=True, input='')
|
result = subprocess.run([ 'xclip', '-i', '-selection', 'primary' ], text=True, input='')
|
||||||
result.check_returncode()
|
result.check_returncode()
|
||||||
|
|
||||||
# Do convert
|
# Do convert
|
||||||
conv = make_langset_dict(LANGSETS[args.langset])
|
conv = make_langset_dict(args.langset)
|
||||||
converted = flip_langset(clip, conv)
|
converted = flip_langset(clip, conv)
|
||||||
|
|
||||||
|
if args.verbose:
|
||||||
|
print(f'converted: "{ converted }"')
|
||||||
|
|
||||||
# Write selection
|
# Write selection
|
||||||
result = subprocess.run([ 'xclip', '-i', '-selection', 'clipboard' ], text=True, input=converted)
|
result = subprocess.run([ 'xclip', '-i', '-selection', 'clipboard' ], text=True, input=converted)
|
||||||
result.check_returncode()
|
result.check_returncode()
|
||||||
|
@ -75,6 +84,10 @@ def main():
|
||||||
],
|
],
|
||||||
required=True,
|
required=True,
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'-v', '--verbose',
|
||||||
|
action='store_true',
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-l', '--langset',
|
'-l', '--langset',
|
||||||
type=str,
|
type=str,
|
||||||
|
|
4
setup.py
4
setup.py
|
@ -11,12 +11,12 @@ except:
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='fleepit',
|
name='fleepit',
|
||||||
version='3',
|
version='4',
|
||||||
py_modules=['fleepit'],
|
py_modules=['fleepit'],
|
||||||
description='Text seleciton keyboard layout switcher based on xclip / etc for X11 & wayland',
|
description='Text seleciton keyboard layout switcher based on xclip / etc for X11 & wayland',
|
||||||
url='https://git.pegasko.art/bitrate16/fleepit',
|
url='https://git.pegasko.art/bitrate16/fleepit',
|
||||||
author_email='pegasko@pegasko.art',
|
author_email='pegasko@pegasko.art',
|
||||||
license='AGPL 3.0',
|
license='Apache 2.0',
|
||||||
keywords='keyboard layout shortcut layout-switcher',
|
keywords='keyboard layout shortcut layout-switcher',
|
||||||
entry_points='''
|
entry_points='''
|
||||||
[console_scripts]
|
[console_scripts]
|
||||||
|
|
Loading…
Reference in a new issue