Skip to content

Commit d1a0637

Browse files
committedJun 25, 2021
dtv2change code rewrite - part 2
1 parent 07a9d76 commit d1a0637

File tree

2 files changed

+28
-14
lines changed

2 files changed

+28
-14
lines changed
 

‎README.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ Live change and eventually store.
3737

3838
``` bash
3939

40-
$ dtv2change -h
41-
usage: dtv2change [-h] [-V] [-r] [-n] [-chg] [-kbd KEYBOARD] [-cat CATEGORY [CATEGORY ...]] [-key KEY [KEY ...]]
40+
$ ./bin/dtv2change -h
41+
usage: dtv2change [-h] [-V] [-r] [-n] [-a] [-kbd KEYBOARD] [-cat CATEGORY [CATEGORY ...]] [-key KEY [KEY ...]]
4242

4343
Change Drevo tyrfing keys colors
4444

@@ -47,13 +47,14 @@ optional arguments:
4747
-V, --version display version (last modif. date)
4848
-r, --read read and apply saved config
4949
-n, --new replace or create config file
50-
-chg, --change change config with args and store changes
50+
-a, --append change config with args and store changes
5151
-kbd KEYBOARD, --keyboard KEYBOARD
52-
svg_color_name or hex color or [rgb|hsl]=(.25,1,.5)
52+
svg_color_name or hex coloror [rgb|hsl]=(.25,1,.5)
5353
-cat CATEGORY [CATEGORY ...], --category CATEGORY [CATEGORY ...]
54-
category_name svg_color_name or hex color or [rgb|hsl]=(.25,1,.5)
54+
category_name svg_color_name or hex coloror [rgb|hsl]=(.25,1,.5)
5555
-key KEY [KEY ...], --key KEY [KEY ...]
56-
key_name svg_color_name or hex color or [rgb|hsl]=(.25,1,.5)
56+
key_name svg_color_name or hex coloror [rgb|hsl]=(.25,1,.5)
57+
5758

5859

5960
```

‎bin/dtv2change

+21-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
__author__ = "david cobac"
33
__email__ = "david.cobac@gmail.com"
44
__year__ = 2020
5-
__last_modified__ = 20210624
5+
__last_modified__ = 20210625
66

77
import argparse
88
import dtv2
@@ -12,6 +12,7 @@ import os
1212
import re
1313
import ast
1414
import copy
15+
import time
1516

1617

1718
parseur_args = argparse.ArgumentParser(
@@ -73,19 +74,31 @@ class dtv2change:
7374

7475
def __init__(self):
7576
self.dico_change = {}
77+
self.dico_touches = {}
7678
self.clavier = dtv2.dtv2()
7779

7880
def apply_changes(self):
81+
self.only_keys()
82+
self.clavier.key_set(self.dico_touches)
83+
84+
def only_keys(self):
85+
self.dico_touches = {}
7986
if 'kbd' in self.dico_change:
80-
self.clavier.kbd(user_to_color_tuple(self.dico_change['kbd']))
81-
#
87+
for k in self.clavier._keys:
88+
self.dico_touches[k] = user_to_color_tuple(
89+
self.dico_change['kbd']
90+
)
8291
if 'cat' in self.dico_change:
83-
for k, v in self.dico_change['cat'].items():
84-
self.clavier.category(k, user_to_color_tuple(v))
85-
#
92+
for categ in self.dico_change['cat']:
93+
for k in self.clavier._category_keys[categ]:
94+
self.dico_touches[k] = user_to_color_tuple(
95+
self.dico_change['cat'][categ]
96+
)
8697
if 'key' in self.dico_change:
87-
for k, v in self.dico_change['key'].items():
88-
self.clavier.key(k, user_to_color_tuple(v))
98+
for k in self.dico_change['key']:
99+
self.dico_touches[k] = user_to_color_tuple(
100+
self.dico_change['key'][k]
101+
)
89102

90103
def read_file(self):
91104
with open(dtv2change.fichier_config) as fh:

0 commit comments

Comments
 (0)
Please sign in to comment.