├── .gitignore
├── LICENSE
├── MANIFEST.in
├── README.md
├── docs
├── development.md
├── overview.md
└── usage.md
├── setup.cfg
├── setup.py
└── xinput_gui
├── __init__.py
├── __main__.py
├── gui
├── __init__.py
├── device_list.py
├── dialog_about.py
├── dialog_create_master.py
├── dialog_device_info.py
├── dialog_edit.py
├── dialog_reattach.py
├── log.py
├── prop_list.py
├── win_main.py
└── win_settings.py
├── res
├── config.json
└── xinput-gui.ui
├── settings.py
├── view_controller.py
├── view_model.py
└── xinput
├── __init__.py
├── devices.py
└── xinput.py
/.gitignore:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 |
6 | # C extensions
7 | *.so
8 |
9 | # Distribution / packaging
10 | .Python
11 | build/
12 | develop-eggs/
13 | dist/
14 | downloads/
15 | eggs/
16 | .eggs/
17 | lib/
18 | lib64/
19 | parts/
20 | sdist/
21 | var/
22 | wheels/
23 | *.egg-info/
24 | .installed.cfg
25 | *.egg
26 | MANIFEST
27 |
28 | # PyInstaller
29 | # Usually these files are written by a python script from a template
30 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
31 | *.manifest
32 | *.spec
33 |
34 | # Installer logs
35 | pip-log.txt
36 | pip-delete-this-directory.txt
37 |
38 | # Unit test / coverage reports
39 | htmlcov/
40 | .tox/
41 | .coverage
42 | .coverage.*
43 | .cache
44 | nosetests.xml
45 | coverage.xml
46 | *.cover
47 | .hypothesis/
48 | .pytest_cache/
49 |
50 | # Translations
51 | *.mo
52 | *.pot
53 |
54 | # Django stuff:
55 | *.log
56 | local_settings.py
57 | db.sqlite3
58 |
59 | # Flask stuff:
60 | instance/
61 | .webassets-cache
62 |
63 | # Scrapy stuff:
64 | .scrapy
65 |
66 | # Sphinx documentation
67 | docs/_build/
68 |
69 | # PyBuilder
70 | target/
71 |
72 | # Jupyter Notebook
73 | .ipynb_checkpoints
74 |
75 | # pyenv
76 | .python-version
77 |
78 | # celery beat schedule file
79 | celerybeat-schedule
80 |
81 | # SageMath parsed files
82 | *.sage.py
83 |
84 | # Environments
85 | .env
86 | .venv
87 | env/
88 | venv/
89 | ENV/
90 | env.bak/
91 | venv.bak/
92 |
93 | # Spyder project settings
94 | .spyderproject
95 | .spyproject
96 |
97 | # Rope project settings
98 | .ropeproject
99 |
100 | # mkdocs documentation
101 | /site
102 |
103 | # mypy
104 | .mypy_cache/
105 |
106 | *~
107 |
108 | \#*#
109 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | include LICENSE
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # xinput-gui
2 | A simple GUI for Xorg's Xinput tool.
3 |
4 | |  |  |
5 | | --- | --- |
6 |
7 | xinput allows you to edit properties of devices like keyboards, mice, and touchpads. This GUI wraps around the xinput command to make editing them faster and more user-friendly.
8 |
9 | ## Installation
10 |
11 | xinput-gui depends on Python 3.5+, GTK+ 3.20+, PyGObject, and xinput.
12 |
13 | ### Arch Linux
14 |
15 | Available as a package on the AUR: [xinput-gui](https://aur.archlinux.org/packages/xinput-gui)
16 |
17 | Install it with `makepkg` or your preferred AUR helper.
18 |
19 | ### Gentoo
20 |
21 | Available as a Gentoo package thanks to [@filalex77](https://github.com/filalex77): [app-misc/xinput-gui](https://github.com/filalex77/bright/tree/master/app-misc/xinput-gui)
22 |
23 | To install it, run the following commands:
24 |
25 | ```
26 | eselect-repository enable bright
27 | emerge --sync
28 | emerge xinput-gui
29 | ```
30 |
31 | ### pip
32 |
33 | Available on PyPI: [xinput-gui](https://pypi.org/project/xinput-gui/)
34 |
35 | Install it with pip: `pip install --user xinput-gui`.
36 |
37 | ### Manual install
38 |
39 | Download the [latest release](https://github.com/IvanFon/xinput-gui/releases/latest) or clone this repo and run `./setup.py install --user`.
40 |
41 | ## Usage
42 |
43 | Just run `xinput-gui`. Selecting a device will list all of it's properties. When editing them, changes will be applied immediately.
44 |
45 | For detailed usage instructions, information on development and contributing, and more, see the [documentation](docs/overview.md).
46 |
--------------------------------------------------------------------------------
/docs/development.md:
--------------------------------------------------------------------------------
1 | # Development Info
2 |
3 | - [Overview](#overview)
4 | - [Contributing](#contributing)
5 | - [Issues](#issues)
6 | - [Pull requests](#pull-requests)
7 | - [Upcoming features](#upcoming-features)
8 |
9 | ## Overview
10 |
11 | xinput-gui is written in Python 3. The GUI uses GTK+ 3 and was made using the Glade interface designer.
12 |
13 | Internally, xinput-gui wraps around the `xinput` command by calling it and parsing it's output.
14 |
15 | ## Contributing
16 |
17 | ### Issues
18 |
19 | Please feel free to open issues with bugs, feature requests, or any other discussion you find necessary.
20 |
21 | If you're reporting a bug, remember to include your version of xinput-gui (can be found in `Help -> About`), your operating system version, detailed steps to reproduce the bug, and, if it helps, a screenshot.
22 |
23 | ### Pull requests
24 |
25 | Pull requests are always welcome, but before you start working on a feature/bugfix, *open an issue*. Pull requests that haven't been discussed beforehand may take a while to merge, or not be merged at all. Before you start putting work into a feature, open an issue for discussion to make sure that it's something that's wanted by the project.
26 |
27 | ## Upcoming features
28 |
29 | This is a rough roadmap of planned features:
30 |
31 | - Log all commands and their output
32 | - This allows for better error handling
33 | - Save and display a list of all changes, and allow them to be easily copied and pasted into an Xorg config file to make them persistent
34 | - Allow testing devices
35 | - Button mapping
36 | - Move away from parsing `xinput` command
37 | - Move directly to X11 APIs
38 | - Use libinput
39 | - Both of these approaches could add more complexity than desired
40 |
--------------------------------------------------------------------------------
/docs/overview.md:
--------------------------------------------------------------------------------
1 | # Overview
2 |
3 | Xinput GUI, or xinput-gui, is a simple GUI for Xorg's Xinput tool.
4 |
5 | xinput is a command-line utility for managing, testing, and configuring X11 display server input devices. This includes mice, keyboards, and touchpads.
6 |
7 | xinput-gui is a wrapper around the xinput command. It aims to simplify the configuration of X input devices for users who aren't as familiar with the terminal, while being more flexible than other tools provided by various desktop environments.
8 |
9 | For installation instructions, see the [project README](../README.md).
10 |
11 | To learn how to use xinput-gui, see [xinput-gui Usage](usage.md).
12 |
13 | For development info, see [Development Info](development.md).
14 |
--------------------------------------------------------------------------------
/docs/usage.md:
--------------------------------------------------------------------------------
1 | # xinput-gui Usage
2 |
3 | - [Listing devices and properties](#listing-devices-and-properties)
4 | - [Editing properties](#editing-properties)
5 | - [Floating and reattaching slave devices](#floating-and-reattaching-slave-devices)
6 | - [Device info](#device-info)
7 | - [Refreshing](#refreshing)
8 | - [Settings](#settings)
9 | - [Config file](#config-file)
10 |
11 | ## Listing devices and properties
12 |
13 | xinput-gui's interface is split into two parts: a device list, and a properties list.
14 |
15 | When you open xinput-gui, the properties list will be blank, because no device is selected. To list the properties of a device, click on it in the device list.
16 |
17 | The device list is displayed in a hierarchy of master and slave devices. A master device is what you see in X, such as a mouse cursor. A slave device is a physical device which controls a master device.
18 |
19 | Every device is either a pointer or keyboard. Master devices are always pairs of a pointer and keyboard. On an average Linux system, you'll probably have one master device (one pointer and one keyboard), with all your physical devices (mice, keyboards, touchpads) attached to that master.
20 |
21 | When you select a device in the device list, it's properties will be listed in the property list. Each property has an ID (hidden by default), a name and a value.
22 |
23 | ## Editing properties
24 |
25 | To edit a device property, select the device and press the `Edit property` button on the device properties toolbar. A dialog will appear showing you the property's current value and allowing you to enter a new one.
26 |
27 | If inline property editing is enabled in the settings, double-click on the property value and you can change it's value directly in the property list. Press enter to apply the change.
28 |
29 | ## Creating and removing master devices
30 |
31 | To create a master device, click on the `Add master device` button on the device list toolbar. A dialog will appear asking you for a name for the new master device. Once you type in a valid name, press enter/create to create the master device. You will see the new pointer and keyboard in the device list.
32 |
33 | To remove a master device, select it in the device list. The `Remove master device` button on the device list toolbar will become active. Click on it and the selected master device will be removed.
34 |
35 | ## Floating and reattaching slave devices
36 |
37 | Slave devices can be floating, which means not attached to any master device, or they can be reattached to a different master device.
38 |
39 | To float or reattach a slave device, select it in the device list. The `Reattach slave device` button on the device list toolbar will be come active. Click on it, and a dialog will appear, allowing you to choose whether you want to float the device, or reattach it to a different master. When reattaching a device, you can select the master device you wish to reattach it to from the dropdown.
40 |
41 | Floating slave devices will be displayed at the top level of the device list with type `floating`.
42 |
43 | ## Device info
44 |
45 | To get more info about a selected device, click on the `Show device info` button on the device list toolbar. A dialog will appear containing the output of `xinput list [device]`. This contains the device's InputClasses.
46 |
47 | ## Refreshing
48 |
49 | If the list of devices or properties has been changed while xinput-gui is running, you can use the `Refresh devices` and `Refresh properties` buttons on the device and property list toolbars to refresh their info.
50 |
51 | The `Refresh properties` button will only become active when a device is selected.
52 |
53 | ## Settings
54 |
55 | You can change xinput-gui's settings by clicking on `Edit -> Settings` on the menubar. The following settings are available:
56 |
57 | - Vertical layout
58 | - Default value: false
59 | - When enabled, the window will be taller rather than wider, and the properties list will be below the device list, as opposed to beside it. This is useful for vertical monitor or split screen setups, as the vertical layout will allow more room for device and property names.
60 | - Edit property values inline
61 | - Default value: true
62 | - When enabled, property values can be quickly edited by double-clicking on their value in the property list, without having to open the edit dialog.
63 | - Hide device IDs
64 | - Default value: true
65 | - When enabled, device IDs will be hidden in the device list.
66 | - Hide property IDs
67 | - Default value: true
68 | - When enabled, property IDs will be hidden in the property list.
69 |
70 | Click `Save` to save and apply your changes, or `Cancel` to discard them.
71 |
72 | ### Config file
73 |
74 | xinput-gui will save your settings to `$HOME/.xinput-gui.json`. To reset your settings, delete that file, and next time you launch xinput-gui, it will load the default settings and recreate the file.
75 |
--------------------------------------------------------------------------------
/setup.cfg:
--------------------------------------------------------------------------------
1 | [pep8]
2 | ignore = E402
3 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | from setuptools import setup
3 |
4 | with open('README.md') as f:
5 | long_description = f.read()
6 |
7 | setup(
8 | name='xinput-gui',
9 | version='0.3.1',
10 | description='A simple GUI for Xorg\'s Xinput tool.',
11 | long_description=long_description,
12 | long_description_content_type='text/markdown',
13 | author='Ivan Fonseca',
14 | author_email='ivanfon@riseup.net',
15 | url='https://github.com/IvanFon/xinput-gui',
16 | license='GPLv3+',
17 | classifiers=[
18 | 'Development Status :: 4 - Beta',
19 | 'Environment :: X11 Applications :: GTK',
20 | 'Intended Audience :: End Users/Desktop',
21 | 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
22 | 'Natural Language :: English',
23 | 'Operating System :: POSIX',
24 | 'Programming Language :: Python :: 3 :: Only',
25 | 'Programming Language :: Python :: 3.5',
26 | 'Programming Language :: Python :: 3.6',
27 | 'Programming Language :: Python :: 3.7',
28 | 'Programming Language :: Python :: 3.8',
29 | 'Topic :: Desktop Environment',
30 | 'Topic :: Utilities'
31 | ],
32 | keywords='xinput keyboard mouse touchpad',
33 | packages=[
34 | 'xinput_gui',
35 | 'xinput_gui/gui',
36 | 'xinput_gui/xinput'
37 | ],
38 | install_requires=['PyGObject'],
39 | package_data={'xinput_gui': ['res/*']},
40 | entry_points={'gui_scripts': ['xinput-gui = xinput_gui.__main__:main']}
41 | )
42 |
--------------------------------------------------------------------------------
/xinput_gui/__init__.py:
--------------------------------------------------------------------------------
1 | '''A simple GUI for Xorg's Xinput tool.'''
2 |
--------------------------------------------------------------------------------
/xinput_gui/__main__.py:
--------------------------------------------------------------------------------
1 | # __main__.py - app entry point
2 | # Copyright (C) 2019 Ivan Fonseca
3 | #
4 | # This file is part of xinput-gui.
5 | #
6 | # xinput-gui is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the # License,
9 | # or (at your option) any later version.
10 | #
11 | # xinput-gui is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with xinput-gui. If not, see .
18 |
19 | '''App entry point.'''
20 |
21 | from .view_controller import ViewController
22 |
23 |
24 | def main():
25 | '''Start xinput-gui.'''
26 |
27 | view_controller = ViewController()
28 | view_controller.start()
29 |
--------------------------------------------------------------------------------
/xinput_gui/gui/__init__.py:
--------------------------------------------------------------------------------
1 | '''Gtk GUI.'''
2 |
--------------------------------------------------------------------------------
/xinput_gui/gui/device_list.py:
--------------------------------------------------------------------------------
1 | # device_list.py - device list
2 | # Copyright (C) 2019 Ivan Fonseca
3 | #
4 | # This file is part of xinput-gui.
5 | #
6 | # xinput-gui is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the # License,
9 | # or (at your option) any later version.
10 | #
11 | # xinput-gui is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with xinput-gui. If not, see .
18 |
19 | '''Device list.'''
20 |
21 | from typing import TYPE_CHECKING, List
22 |
23 | import gi
24 | gi.require_version('Gtk', '3.0')
25 | from gi.repository import Gtk
26 | from pkg_resources import resource_filename
27 |
28 | from ..settings import Settings
29 | from ..xinput.devices import Device, DeviceType
30 |
31 | if TYPE_CHECKING:
32 | from ..view_controller import ViewController
33 | from .win_main import MainWindow
34 |
35 |
36 | class DeviceList:
37 | '''Device list.'''
38 |
39 | def __init__(self, controller: 'ViewController', main_window: 'MainWindow', settings: Settings) -> None:
40 | '''Init DeviceList.'''
41 |
42 | self.controller = controller
43 | self.main_window = main_window
44 | self.settings = settings
45 | self.refreshing = False
46 |
47 | builder = self.get_builder()
48 |
49 | builder.connect_signals(DeviceList.SignalHandler(controller))
50 |
51 | self.grid_device_list = builder.get_object('grid_device_list')
52 | self.store_devices = builder.get_object('store_devices')
53 | self.tree_devices = builder.get_object('tree_devices')
54 | self.tree_devices_selection = builder.get_object(
55 | 'tree_devices_selection')
56 | self.tree_column_devices_id = builder.get_object(
57 | 'tree_column_devices_id')
58 | self.tool_remove_master = builder.get_object('tool_remove_master')
59 | self.tool_reattach_slave = builder.get_object('tool_reattach_slave')
60 |
61 | def get_builder(self) -> Gtk.Builder:
62 | '''Get device list Gtk Builder.'''
63 |
64 | builder = Gtk.Builder()
65 | builder.add_objects_from_file(
66 | resource_filename('xinput_gui', 'res/xinput-gui.ui'),
67 | ['grid_device_list', 'store_devices'])
68 | return builder
69 |
70 | def apply_settings(self) -> None:
71 | '''Apply current settings.'''
72 |
73 | # Hide device IDs
74 | self.tree_column_devices_id.set_visible(not self.settings.hide_device_ids)
75 |
76 | def refresh_devices(self, devices: List[Device]) -> None:
77 | '''Refresh the device list.
78 |
79 | Args:
80 | devices: List of Devices.
81 | '''
82 |
83 | self.store_devices.clear()
84 | self.tree_devices_selection.unselect_all()
85 | self.tool_remove_master.set_sensitive(False)
86 |
87 | master_iter = None
88 | floating_devices = []
89 | for device in devices:
90 | device_row = [
91 | int(device.id),
92 | device.name,
93 | device.type.value,
94 | ]
95 |
96 | if device.type == DeviceType.FLOATING:
97 | floating_devices.append(device_row)
98 | continue
99 |
100 | cur_iter = self.store_devices.append(master_iter, device_row)
101 |
102 | if device.master:
103 | self.store_devices.remove(cur_iter)
104 | master_iter = self.store_devices.append(None, device_row)
105 |
106 | for device in floating_devices:
107 | self.store_devices.append(None, device)
108 |
109 | self.tree_devices.expand_all()
110 |
111 | def show_device(self, device: Device) -> None:
112 | '''Display properties of selected device.
113 |
114 | Args:
115 | device: Device to show.
116 | '''
117 |
118 | if device is None:
119 | return
120 |
121 | # Check if device is master
122 | if device.master:
123 | self.tool_remove_master.set_sensitive(True)
124 | self.tool_reattach_slave.set_sensitive(False)
125 | else:
126 | self.tool_remove_master.set_sensitive(False)
127 | self.tool_reattach_slave.set_sensitive(True)
128 |
129 | # Check if device is floating
130 | if device.type == DeviceType.FLOATING:
131 | self.tool_reattach_slave.set_icon_name('gtk-connect')
132 | else:
133 | self.tool_reattach_slave.set_icon_name('gtk-disconnect')
134 |
135 | class SignalHandler:
136 | '''Handle device list signals.'''
137 |
138 | def __init__(self, controller: 'ViewController') -> None:
139 | '''Init SignalHandler.'''
140 |
141 | self.controller = controller
142 |
143 | def on_tree_devices_selection_changed(
144 | self,
145 | selection: Gtk.TreeSelection) -> None:
146 | '''tree_devices_selection "changed" signal.'''
147 |
148 | model, treeiter = selection.get_selected()
149 |
150 | if not treeiter:
151 | return
152 |
153 | self.controller.device_selected(model[treeiter][0])
154 |
155 | def on_tool_create_master_clicked(self, *args) -> None:
156 | '''tool_create_master "clicked" signal.'''
157 |
158 | self.controller.show_create_master_dialog()
159 |
160 | def on_tool_remove_master_clicked(self, *args) -> None:
161 | '''tool_remove_master "clicked" signal.'''
162 |
163 | self.controller.remove_selected_master_device()
164 |
165 | def on_tool_reattach_slave_clicked(self, *args) -> None:
166 | '''tool_reattach_slave "clicked" signal.'''
167 |
168 | self.controller.show_reattach_dialog()
169 |
170 | def on_tool_device_info_clicked(self, *args) -> None:
171 | '''tool_device_info "clicked" signal.'''
172 |
173 | self.controller.show_device_info()
174 |
175 | def on_tool_refresh_devices_clicked(self, *args) -> None:
176 | '''tool_refresh_devices "clicked" signal.'''
177 |
178 | self.controller.refresh_devices()
179 |
--------------------------------------------------------------------------------
/xinput_gui/gui/dialog_about.py:
--------------------------------------------------------------------------------
1 | # dialog_about.py - about dialog
2 | # Copyright (C) 2019 Ivan Fonseca
3 | #
4 | # This file is part of xinput-gui.
5 | #
6 | # xinput-gui is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the # License,
9 | # or (at your option) any later version.
10 | #
11 | # xinput-gui is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with xinput-gui. If not, see .
18 |
19 | '''About dialog.'''
20 |
21 | import gi
22 | gi.require_version('Gtk', '3.0')
23 | from gi.repository import Gtk
24 | from pkg_resources import require, resource_filename
25 |
26 |
27 | __version__ = require('xinput_gui')[0].version
28 |
29 |
30 | class AboutDialog:
31 | '''About dialog.'''
32 |
33 | def __init__(self, main_window) -> None:
34 | '''Init AboutDialog.'''
35 |
36 | builder = self.get_builder()
37 |
38 | builder.connect_signals(AboutDialog.SignalHandler(self))
39 |
40 | self.dialog_about = builder.get_object('dialog_about')
41 |
42 | self.dialog_about.set_version(__version__)
43 | self.dialog_about.set_transient_for(main_window.win_main)
44 |
45 | def get_builder(self) -> Gtk.Builder:
46 | '''Get about dialog Gtk Builder.'''
47 |
48 | builder = Gtk.Builder()
49 | builder.add_objects_from_file(
50 | resource_filename('xinput_gui', 'res/xinput-gui.ui'),
51 | ['dialog_about'])
52 | return builder
53 |
54 | def show(self) -> None:
55 | '''Show the about dialog.'''
56 |
57 | self.dialog_about.run()
58 |
59 | class SignalHandler:
60 | '''Handle about dialog signals.'''
61 |
62 | def __init__(self, gui) -> None:
63 | '''Init SignalHandler.'''
64 |
65 | self.gui = gui
66 |
67 | def on_dialog_about_response(self, *args) -> None:
68 | '''dialog_about "response" signal.'''
69 |
70 | self.gui.dialog_about.hide()
71 |
--------------------------------------------------------------------------------
/xinput_gui/gui/dialog_create_master.py:
--------------------------------------------------------------------------------
1 | # dialog_create_master.py - create master device dialog
2 | # Copyright (C) 2019 Ivan Fonseca
3 | #
4 | # This file is part of xinput-gui.
5 | #
6 | # xinput-gui is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the # License,
9 | # or (at your option) any later version.
10 | #
11 | # xinput-gui is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with xinput-gui. If not, see .
18 |
19 | '''Create master device dialog.'''
20 |
21 | from typing import TYPE_CHECKING
22 |
23 | import gi
24 | gi.require_version('Gtk', '3.0')
25 | from gi.repository import Gtk
26 | from pkg_resources import resource_filename
27 |
28 | if TYPE_CHECKING:
29 | from ..view_controller import ViewController
30 | from .win_main import MainWindow
31 |
32 |
33 | class CreateMasterDialog:
34 | '''Create master device dialog.'''
35 |
36 | def __init__(self, controller: 'ViewController', main_window: 'MainWindow') -> None:
37 | '''Init CreateMasterDialog.'''
38 |
39 | self.controller = controller
40 |
41 | builder = self.get_builder()
42 |
43 | builder.connect_signals(CreateMasterDialog.SignalHandler(self))
44 |
45 | self.dialog_create_master = builder.get_object('dialog_create_master')
46 | self.entry_new_master_name = builder.get_object('entry_new_master_name')
47 | self.btn_create = builder.get_object('btn_create_master_create')
48 |
49 | self.dialog_create_master.set_transient_for(main_window.win_main)
50 |
51 | def get_builder(self) -> Gtk.Builder:
52 | '''Get create master device dialog Gtk Builder.'''
53 |
54 | builder = Gtk.Builder()
55 | builder.add_objects_from_file(
56 | resource_filename('xinput_gui', 'res/xinput-gui.ui'),
57 | ['dialog_create_master'])
58 | return builder
59 |
60 | def show(self) -> Gtk.ResponseType:
61 | '''Show the create master device dialog.'''
62 |
63 | # Setup dialog
64 |
65 | self.entry_new_master_name.set_text('')
66 | self.entry_new_master_name.grab_focus()
67 | # Default error message
68 | self.check_errors()
69 |
70 | # Show dialog
71 |
72 | res = self.dialog_create_master.run()
73 | if res == Gtk.ResponseType.APPLY:
74 | new_master_name = self.entry_new_master_name.get_text()
75 |
76 | self.controller.create_master_device(new_master_name)
77 |
78 | self.dialog_create_master.hide()
79 | return res
80 |
81 | def change_error_message(self, message: str) -> None:
82 | '''Change the error message label.'''
83 |
84 | self.dialog_create_master.get_message_area().get_children()[1].set_label(message)
85 |
86 | def check_errors(self) -> None:
87 | '''Check for errors in the new device name.'''
88 |
89 | name = self.entry_new_master_name.get_text()
90 |
91 | self.btn_create.set_sensitive(False)
92 |
93 | if name == '':
94 | self.change_error_message('Error: device name cannot be blank.')
95 | return
96 |
97 | self.change_error_message('Device name valid.')
98 | self.btn_create.set_sensitive(True)
99 |
100 | class SignalHandler:
101 | '''Handle create master device dialog signals.'''
102 |
103 | def __init__(self, gui) -> None:
104 | '''Init SignalHandler.'''
105 |
106 | self.gui = gui
107 |
108 | def on_entry_new_master_name_activate(self, *args) -> None:
109 | '''entry_new_master_name "activate" signal.'''
110 |
111 | self.gui.btn_create.clicked()
112 |
113 | def on_entry_new_master_name_changed(self, *args) -> None:
114 | '''entry_new_master_name "changed" signal.'''
115 |
116 | self.gui.check_errors()
117 |
--------------------------------------------------------------------------------
/xinput_gui/gui/dialog_device_info.py:
--------------------------------------------------------------------------------
1 | # dialog_device_info.py - device info dialog
2 | # Copyright (C) 2019 Ivan Fonseca
3 | #
4 | # This file is part of xinput-gui.
5 | #
6 | # xinput-gui is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the # License,
9 | # or (at your option) any later version.
10 | #
11 | # xinput-gui is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with xinput-gui. If not, see .
18 |
19 | '''Device info dialog.'''
20 |
21 | from typing import TYPE_CHECKING
22 |
23 | import gi
24 | gi.require_version('Gtk', '3.0')
25 | from gi.repository import Gtk
26 | from pkg_resources import resource_filename
27 |
28 | from ..xinput.devices import Device
29 |
30 | if TYPE_CHECKING:
31 | from ..view_controller import ViewController
32 | from .win_main import MainWindow
33 |
34 |
35 | class DeviceInfoDialog:
36 | '''Device info dialog.'''
37 |
38 | def __init__(self, controller: 'ViewController', main_window: 'MainWindow') -> None:
39 | '''Init DeviceInfoDialog.'''
40 |
41 | self.controller = controller
42 |
43 | builder = self.get_builder()
44 |
45 | self.dialog_device_info = builder.get_object('dialog_device_info')
46 | self.buffer_device_info = builder.get_object('buffer_device_info')
47 |
48 | self.dialog_device_info.set_transient_for(main_window.win_main)
49 |
50 | def get_builder(self) -> Gtk.Builder:
51 | '''Get device info dialog Gtk Builder.'''
52 |
53 | builder = Gtk.Builder()
54 | builder.add_objects_from_file(
55 | resource_filename('xinput_gui', 'res/xinput-gui.ui'),
56 | ['dialog_device_info', 'buffer_device_info'])
57 | return builder
58 |
59 | def show(self, device: Device) -> None:
60 | '''Show the device info dialog.
61 |
62 | Args:
63 | device: Device whose info is being shown.
64 | '''
65 |
66 | # Setup dialog
67 |
68 | labels = self.dialog_device_info.get_message_area().get_children()
69 | labels[1].set_label(device.name)
70 | self.buffer_device_info.set_text(device.get_info())
71 |
72 | # Show dialog
73 |
74 | self.dialog_device_info.run()
75 | self.dialog_device_info.hide()
76 |
--------------------------------------------------------------------------------
/xinput_gui/gui/dialog_edit.py:
--------------------------------------------------------------------------------
1 | # dialog_edit.py - edit dialog
2 | # Copyright (C) 2019 Ivan Fonseca
3 | #
4 | # This file is part of xinput-gui.
5 | #
6 | # xinput-gui is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the # License,
9 | # or (at your option) any later version.
10 | #
11 | # xinput-gui is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with xinput-gui. If not, see .
18 |
19 | '''Edit dialog.'''
20 |
21 | from typing import TYPE_CHECKING
22 |
23 | import gi
24 | gi.require_version('Gtk', '3.0')
25 | from gi.repository import Gtk
26 | from pkg_resources import resource_filename
27 |
28 | from ..xinput.devices import Device, Prop
29 |
30 | if TYPE_CHECKING:
31 | from ..view_controller import ViewController
32 | from .win_main import MainWindow
33 |
34 |
35 | class EditDialog:
36 | '''Edit dialog.'''
37 |
38 | def __init__(self, controller: 'ViewController', main_window: 'MainWindow') -> None:
39 | '''Init EditDialog.'''
40 |
41 | self.controller = controller
42 |
43 | builder = self.get_builder()
44 |
45 | builder.connect_signals(EditDialog.SignalHandler(self))
46 |
47 | self.dialog_edit = builder.get_object('dialog_edit')
48 | self.entry_old_val = builder.get_object('entry_old_val')
49 | self.entry_new_val = builder.get_object('entry_new_val')
50 | self.btn_edit_cancel = builder.get_object('btn_edit_cancel')
51 | self.btn_edit_apply = builder.get_object('btn_edit_apply')
52 |
53 | self.dialog_edit.set_transient_for(main_window.win_main)
54 |
55 | def get_builder(self) -> Gtk.Builder:
56 | '''Get edit dialog Gtk Builder.'''
57 |
58 | builder = Gtk.Builder()
59 | builder.add_objects_from_file(
60 | resource_filename('xinput_gui', 'res/xinput-gui.ui'),
61 | ['dialog_edit'])
62 | return builder
63 |
64 | def show(self,
65 | device: Device,
66 | prop: Prop) -> Gtk.ResponseType:
67 | '''Show the edit dialog.
68 |
69 | Args:
70 | device: Device being edited.
71 | prop: Device property being edited.
72 | '''
73 |
74 | # Setup dialog
75 |
76 | labels = self.dialog_edit.get_message_area().get_children()
77 | labels[0].set_label(device.name)
78 | labels[1].set_label(prop.name)
79 | self.entry_old_val.set_text(prop.val)
80 | self.entry_new_val.set_text(prop.val)
81 | self.entry_new_val.grab_focus()
82 |
83 | # Show dialog
84 |
85 | res = self.dialog_edit.run()
86 | if res == Gtk.ResponseType.APPLY:
87 | new_prop_val = self.entry_new_val.get_text()
88 |
89 | self.controller.set_prop(new_prop_val)
90 |
91 | self.dialog_edit.hide()
92 | return res
93 |
94 | class SignalHandler:
95 | '''Handle edit dialog signals.'''
96 |
97 | def __init__(self, gui) -> None:
98 | '''Init SignalHandler.'''
99 |
100 | self.gui = gui
101 |
102 | def on_entry_new_val_activate(self, *args) -> None:
103 | '''entry_new_val "activate" signal.'''
104 |
105 | self.gui.btn_edit_apply.clicked()
106 |
--------------------------------------------------------------------------------
/xinput_gui/gui/dialog_reattach.py:
--------------------------------------------------------------------------------
1 | # dialog_reattach.py - reattach dialog
2 | # Copyright (C) 2019 Ivan Fonseca
3 | #
4 | # This file is part of xinput-gui.
5 | #
6 | # xinput-gui is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the # License,
9 | # or (at your option) any later version.
10 | #
11 | # xinput-gui is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with xinput-gui. If not, see .
18 |
19 | '''Reattach dialog.'''
20 |
21 | from typing import TYPE_CHECKING, List
22 |
23 | import gi
24 | gi.require_version('Gtk', '3.0')
25 | from gi.repository import Gtk
26 | from pkg_resources import resource_filename
27 |
28 | from ..xinput.devices import Device, DeviceType
29 |
30 | if TYPE_CHECKING:
31 | from ..view_controller import ViewController
32 | from .win_main import MainWindow
33 |
34 |
35 | class ReattachDialog:
36 | '''Reattach dialog.'''
37 |
38 | def __init__(self, controller: 'ViewController', main_window: 'MainWindow') -> None:
39 | '''Init ReattachDialog.'''
40 |
41 | self.controller = controller
42 |
43 | builder = self.get_builder()
44 |
45 | self.dialog_reattach = builder.get_object('dialog_reattach')
46 | self.rad_float_device = builder.get_object('rad_float_device')
47 | self.rad_reattach_device = builder.get_object('rad_reattach_device')
48 | self.cmb_reattach_device = builder.get_object('cmb_reattach_device')
49 | self.store_reattach = builder.get_object('store_reattach')
50 |
51 | self.dialog_reattach.set_transient_for(main_window.win_main)
52 |
53 | def get_builder(self) -> Gtk.Builder:
54 | '''Get reattach dialog Gtk Builder.'''
55 |
56 | builder = Gtk.Builder()
57 | builder.add_objects_from_file(
58 | resource_filename('xinput_gui', 'res/xinput-gui.ui'),
59 | ['dialog_reattach', 'store_reattach'])
60 | return builder
61 |
62 | def show(self, selected_device: Device, devices: List[Device]) -> Gtk.ResponseType:
63 | '''Show the reattach dialog.
64 |
65 | Args:
66 | selected_device: Device being shown.
67 | devices: List of devices.
68 | '''
69 |
70 | # Setup dialog
71 |
72 | labels = self.dialog_reattach.get_message_area().get_children()
73 | labels[1].set_label(selected_device.name)
74 | self.rad_float_device.set_sensitive(not selected_device.type == DeviceType.FLOATING)
75 | self.rad_float_device.set_active(not selected_device.type == DeviceType.FLOATING)
76 | self.rad_reattach_device.set_sensitive(False)
77 | self.rad_reattach_device.set_active(selected_device.type == DeviceType.FLOATING)
78 |
79 | self.store_reattach.clear()
80 | for d in devices:
81 | self.rad_reattach_device.set_sensitive(True)
82 | self.cmb_reattach_device.set_sensitive(True)
83 | self.cmb_reattach_device.set_active(0)
84 | if d.master:
85 | self.store_reattach.append([int(d.id), d.name])
86 |
87 | # Show dialog
88 |
89 | res = self.dialog_reattach.run()
90 | if res == Gtk.ResponseType.APPLY:
91 | # Float
92 | if self.rad_float_device.get_active():
93 | self.controller.float_selected_device()
94 | # Reattach
95 | else:
96 | master_id = self.store_reattach[self.cmb_reattach_device.get_active()][0]
97 |
98 | self.controller.reattach_selected_device(master_id)
99 |
100 | self.dialog_reattach.hide()
101 | return res
102 |
--------------------------------------------------------------------------------
/xinput_gui/gui/log.py:
--------------------------------------------------------------------------------
1 | # log.py - log
2 | # Copyright (C) 2019 Ivan Fonseca
3 | #
4 | # This file is part of xinput-gui.
5 | #
6 | # xinput-gui is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the # License,
9 | # or (at your option) any later version.
10 | #
11 | # xinput-gui is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with xinput-gui. If not, see .
18 |
19 | '''Log.'''
20 |
21 | from typing import TYPE_CHECKING
22 |
23 | import gi
24 | gi.require_version('Gtk', '3.0')
25 | from gi.repository import Gtk
26 | from pkg_resources import resource_filename
27 |
28 | if TYPE_CHECKING:
29 | from .win_main import MainWindow
30 |
31 |
32 | class Log:
33 | '''Log.'''
34 |
35 | def __init__(self, main_window: 'MainWindow'):
36 | '''Init Log.'''
37 |
38 | self.main_window = main_window
39 |
40 | builder = self.get_builder()
41 |
42 | builder.connect_signals(Log.SignalHandler(self))
43 |
44 | self.grid_log = builder.get_object('grid_log')
45 | self.buffer_log = builder.get_object('buffer_log')
46 | self.text_log = builder.get_object('text_log')
47 | self.btn_clear_log = builder.get_object('btn_clear_log')
48 |
49 | def get_builder(self) -> Gtk.Builder:
50 | '''Get device list Gtk Builder.'''
51 |
52 | builder = Gtk.Builder()
53 | builder.add_objects_from_file(
54 | resource_filename('xinput_gui', 'res/xinput-gui.ui'),
55 | ['grid_log', 'buffer_log'])
56 | return builder
57 |
58 | def clear_log(self) -> None:
59 | '''Clear the log.'''
60 |
61 | self.buffer_log.set_text('')
62 |
63 | # Unfocus clear button
64 | self.main_window.win_main.set_focus(None)
65 |
66 | def update(self, log_text: str) -> None:
67 | '''Update log.
68 |
69 | Args:
70 | log_text: Updated log text.
71 | '''
72 |
73 | self.buffer_log.set_text(log_text)
74 |
75 | class SignalHandler:
76 | '''Handle log signals.'''
77 |
78 | def __init__(self, gui) -> None:
79 | '''Init SignalHandler.'''
80 |
81 | self.gui = gui
82 |
83 | def on_btn_clear_log_clicked(self, *args) -> None:
84 | '''btn_clear_log "clicked" signal.'''
85 |
86 | self.gui.clear_log()
87 |
--------------------------------------------------------------------------------
/xinput_gui/gui/prop_list.py:
--------------------------------------------------------------------------------
1 | # prop_list.py - prop list
2 | # Copyright (C) 2019 Ivan Fonseca
3 | #
4 | # This file is part of xinput-gui.
5 | #
6 | # xinput-gui is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the # License,
9 | # or (at your option) any later version.
10 | #
11 | # xinput-gui is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with xinput-gui. If not, see .
18 |
19 | '''Device properties list.'''
20 |
21 | from typing import TYPE_CHECKING
22 |
23 | import gi
24 | gi.require_version('Gtk', '3.0')
25 | from gi.repository import Gtk
26 | from pkg_resources import resource_filename
27 |
28 | from ..settings import Settings
29 | from ..xinput.devices import Device
30 |
31 | if TYPE_CHECKING:
32 | from ..view_controller import ViewController
33 | from .win_main import MainWindow
34 |
35 |
36 | class PropList:
37 | '''Device properties list.'''
38 |
39 | def __init__(self, controller: 'ViewController', main_window: 'MainWindow', settings: Settings) -> None:
40 | '''Init PropList.'''
41 |
42 | self.controller = controller
43 | self.main_window = main_window
44 | self.settings = settings
45 |
46 | builder = self.get_builder()
47 |
48 | builder.connect_signals(PropList.SignalHandler(controller))
49 |
50 | self.grid_prop_list = builder.get_object('grid_prop_list')
51 | self.store_props = builder.get_object('store_props')
52 | self.tree_props = builder.get_object('tree_props')
53 | self.tree_props_selection = builder.get_object(
54 | 'tree_props_selection')
55 | self.tree_column_props_id = builder.get_object(
56 | 'tree_column_props_id')
57 | self.cell_prop_val = builder.get_object('cell_prop_val')
58 | self.tool_edit_prop = builder.get_object('tool_edit_prop')
59 | self.tool_refresh_props = builder.get_object('tool_refresh_props')
60 |
61 | def get_builder(self) -> Gtk.Builder:
62 | '''Get prop list Gtk Builder.'''
63 |
64 | builder = Gtk.Builder()
65 | builder.add_objects_from_file(
66 | resource_filename('xinput_gui', 'res/xinput-gui.ui'),
67 | ['grid_prop_list', 'store_props'])
68 | return builder
69 |
70 | def apply_settings(self) -> None:
71 | '''Apply current settings.'''
72 |
73 | # Hide prop IDs
74 | self.tree_column_props_id.set_visible(not self.settings.hide_prop_ids)
75 | # Inline prop editing
76 | self.cell_prop_val.set_property('editable', self.settings.inline_prop_edit)
77 |
78 | def show_device_props(self, device: Device) -> None:
79 | '''Show device properties.
80 |
81 | Args:
82 | device: Device to display props of.
83 | '''
84 |
85 | self.store_props.clear()
86 | self.tree_props_selection.unselect_all()
87 | self.tool_edit_prop.set_sensitive(False)
88 | self.tool_refresh_props.set_sensitive(True)
89 |
90 | for prop in device.props:
91 | self.store_props.append(None, [
92 | int(prop.id),
93 | prop.name,
94 | prop.val,
95 | ])
96 |
97 | self.tree_props.scroll_to_point(0, 0)
98 |
99 | def enable_edit_tool(self) -> None:
100 | '''Enable edit prop tool.'''
101 |
102 | self.tool_edit_prop.set_sensitive(True)
103 |
104 | class SignalHandler:
105 | '''Handle prop list signals.'''
106 |
107 | def __init__(self, controller) -> None:
108 | '''Init SignalHandler.'''
109 |
110 | self.controller = controller
111 |
112 | def on_tree_props_selection_changed(
113 | self,
114 | selection: Gtk.TreeSelection) -> None:
115 | '''tree_props_selection "changed" signal.'''
116 |
117 | model, treeiter = selection.get_selected()
118 |
119 | if not treeiter:
120 | return
121 |
122 | self.controller.prop_selected(
123 | model[treeiter][0],
124 | model[treeiter][1],
125 | model[treeiter][2],
126 | )
127 |
128 | def on_tree_props_row_activated(self, *args) -> None:
129 | '''tree_props "row-activated" signal.'''
130 |
131 | self.controller.show_edit_dialog()
132 |
133 | def on_cell_prop_val_edited(self,
134 | renderer: Gtk.CellRendererText,
135 | path: str,
136 | new_text) -> None:
137 | '''cell_prop_val "edited" signal.'''
138 |
139 | self.controller.set_prop(new_text)
140 |
141 | def on_tool_edit_prop_clicked(self, *args) -> None:
142 | '''tool_edit_prop "clicked" signal.'''
143 |
144 | self.controller.show_edit_dialog()
145 |
146 | def on_tool_refresh_props_clicked(self, *args) -> None:
147 | '''tool_refresh_props "clicked" signal.'''
148 |
149 | self.controller.refresh_props()
150 |
--------------------------------------------------------------------------------
/xinput_gui/gui/win_main.py:
--------------------------------------------------------------------------------
1 | # win_main.py - main app window
2 | # Copyright (C) 2019 Ivan Fonseca
3 | #
4 | # This file is part of xinput-gui.
5 | #
6 | # xinput-gui is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the # License,
9 | # or (at your option) any later version.
10 | #
11 | # xinput-gui is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with xinput-gui. If not, see .
18 |
19 | '''Main app window.'''
20 |
21 | from typing import TYPE_CHECKING
22 |
23 | import gi
24 | gi.require_version('Gtk', '3.0')
25 | from gi.repository import Gtk
26 | from pkg_resources import require, resource_filename
27 |
28 | from ..settings import Settings
29 | from .device_list import DeviceList
30 | from .dialog_about import AboutDialog
31 | from .log import Log
32 | from .prop_list import PropList
33 | from .win_settings import SettingsWindow
34 |
35 | if TYPE_CHECKING:
36 | from ..view_controller import ViewController
37 |
38 |
39 | __version__ = require('xinput_gui')[0].version
40 |
41 |
42 | class MainWindow:
43 | '''Main app window.'''
44 |
45 | def __init__(self, controller: 'ViewController', settings: Settings) -> None:
46 | '''Init MainWindow.'''
47 |
48 | self.controller = controller
49 | self.settings = settings
50 | self.refreshing = False
51 |
52 | builder = self.get_builder()
53 |
54 | builder.connect_signals(MainWindow.SignalHandler(self))
55 |
56 | self.win_main = builder.get_object('win_main')
57 | self.box_editor = builder.get_object('box_stack_editor')
58 | self.box_log = builder.get_object('box_stack_log')
59 |
60 | self.win_main.set_title('Xinput GUI {}'.format(__version__))
61 | self.win_main.show_all()
62 |
63 | self.about_dialog = AboutDialog(self)
64 | self.device_list = DeviceList(controller, self, settings)
65 | self.log = Log(self)
66 | self.prop_list = PropList(controller, self, settings)
67 | self.settings_window = SettingsWindow(self, settings)
68 |
69 | self.box_editor.pack_start(self.device_list.grid_device_list,
70 | True, True, 0)
71 | self.box_editor.pack_start(self.prop_list.grid_prop_list,
72 | True, True, 0)
73 |
74 | self.box_log.pack_start(self.log.grid_log, True, True, 0)
75 |
76 | self.apply_settings()
77 |
78 | def get_builder(self) -> Gtk.Builder:
79 | '''Get main window Gtk Builder.'''
80 |
81 | builder = Gtk.Builder()
82 | builder.add_objects_from_file(
83 | resource_filename('xinput_gui', 'res/xinput-gui.ui'),
84 | ['win_main'])
85 | return builder
86 |
87 | def apply_settings(self) -> None:
88 | '''Apply current settings.'''
89 |
90 | self.device_list.apply_settings()
91 | self.prop_list.apply_settings()
92 |
93 | # Vertical layout
94 | if self.settings.vertical_layout:
95 | self.box_editor.set_orientation(Gtk.Orientation.VERTICAL)
96 | self.win_main.resize(600, 800)
97 | else:
98 | self.box_editor.set_orientation(Gtk.Orientation.HORIZONTAL)
99 | self.win_main.resize(900, 450)
100 |
101 | def show_settings_window(self) -> None:
102 | '''Shows the settings window.'''
103 |
104 | self.settings_window.show()
105 |
106 | def show_about_dialog(self) -> None:
107 | '''Shows the about dialog.'''
108 |
109 | self.about_dialog.show()
110 |
111 | class SignalHandler:
112 | '''Handle main window signals.'''
113 |
114 | def __init__(self, gui) -> None:
115 | '''Init SignalHandler.'''
116 |
117 | self.gui = gui
118 |
119 | def on_win_main_destroy(self, *args) -> None:
120 | '''win_main "destroy" signal.'''
121 |
122 | Gtk.main_quit()
123 |
124 | def on_menu_settings_activate(self, *args) -> None:
125 | '''menu_settings "activate" signal.'''
126 |
127 | self.gui.show_settings_window()
128 |
129 | def on_menu_about_activate(self, *args) -> None:
130 | '''menu_about "activate" signal.'''
131 |
132 | self.gui.show_about_dialog()
133 |
--------------------------------------------------------------------------------
/xinput_gui/gui/win_settings.py:
--------------------------------------------------------------------------------
1 | # win_settings.py - settings window
2 | # Copyright (C) 2019 Ivan Fonseca
3 | #
4 | # This file is part of xinput-gui.
5 | #
6 | # xinput-gui is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the # License,
9 | # or (at your option) any later version.
10 | #
11 | # xinput-gui is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with xinput-gui. If not, see .
18 |
19 | '''Settings window.'''
20 |
21 | import gi
22 | gi.require_version('Gtk', '3.0')
23 | from gi.repository import Gtk
24 | from pkg_resources import resource_filename
25 |
26 | from ..settings import Settings
27 |
28 |
29 | class SettingsWindow:
30 | '''Settings window.'''
31 |
32 | def __init__(self, main_window, settings: Settings) -> None:
33 | '''Init SettingsWindow.'''
34 |
35 | self.main_window = main_window
36 | self.settings = settings
37 |
38 | builder = self.get_builder()
39 |
40 | builder.connect_signals(SettingsWindow.SignalHandler(self))
41 |
42 | self.win_settings = builder.get_object('win_settings')
43 | self.btn_settings_save = builder.get_object('btn_settings_save')
44 | self.chk_vertical_layout = builder.get_object('chk_vertical_layout')
45 | self.chk_inline_prop_edit = builder.get_object('chk_inline_prop_edit')
46 | self.chk_hide_device_ids = builder.get_object('chk_hide_device_ids')
47 | self.chk_hide_prop_ids = builder.get_object('chk_hide_prop_ids')
48 |
49 | self.win_settings.set_transient_for(main_window.win_main)
50 |
51 | def get_builder(self) -> Gtk.Builder:
52 | '''Get settings window Gtk Builder.'''
53 |
54 | builder = Gtk.Builder()
55 | builder.add_objects_from_file(
56 | resource_filename('xinput_gui', 'res/xinput-gui.ui'),
57 | ['win_settings'])
58 | return builder
59 |
60 | def show(self) -> None:
61 | '''Show the settings window.'''
62 |
63 | # Get settings and update controls
64 | self.chk_vertical_layout.set_active(self.settings.vertical_layout)
65 | self.chk_inline_prop_edit.set_active(self.settings.inline_prop_edit)
66 | self.chk_hide_device_ids.set_active(self.settings.hide_device_ids)
67 | self.chk_hide_prop_ids.set_active(self.settings.hide_prop_ids)
68 |
69 | self.btn_settings_save.set_sensitive(False)
70 | self.win_settings.show_all()
71 |
72 | def hide(self) -> None:
73 | '''Hide the settings window.'''
74 |
75 | self.win_settings.hide()
76 |
77 | def save_settings(self) -> None:
78 | '''Save settings.'''
79 |
80 | # Get settings
81 | self.settings.vertical_layout = self.chk_vertical_layout.get_active()
82 | self.settings.inline_prop_edit = self.chk_inline_prop_edit.get_active()
83 | self.settings.hide_device_ids = self.chk_hide_device_ids.get_active()
84 | self.settings.hide_prop_ids = self.chk_hide_prop_ids.get_active()
85 |
86 | # Save
87 | self.settings.save_config()
88 |
89 | # Apply
90 | self.main_window.apply_settings()
91 |
92 | class SignalHandler:
93 | '''Handle settings window signals.'''
94 |
95 | def __init__(self, gui) -> None:
96 | '''Init SignalHandler.'''
97 |
98 | self.gui = gui
99 |
100 | def on_btn_settings_save_clicked(self, *args) -> None:
101 | '''btn_settings_save "clicked" signal.'''
102 |
103 | self.gui.save_settings()
104 | self.gui.hide()
105 |
106 | def on_btn_settings_cancel_clicked(self, *args) -> None:
107 | '''btn_edit_cancel "clicked" signal.'''
108 |
109 | self.gui.hide()
110 |
111 | def on_setting_changed(self, *args):
112 | '''Fired when any setting widget has been changed.'''
113 |
114 | self.gui.btn_settings_save.set_sensitive(True)
115 |
--------------------------------------------------------------------------------
/xinput_gui/res/config.json:
--------------------------------------------------------------------------------
1 | {
2 | "vertical_layout": false,
3 | "inline_prop_edit": true,
4 | "hide_device_ids": true,
5 | "hide_prop_ids": true
6 | }
7 |
--------------------------------------------------------------------------------
/xinput_gui/res/xinput-gui.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
76 |
77 |
78 | True
79 | False
80 | 6
81 |
82 |
83 | True
84 | False
85 | This log shows xinput commands ran by xinput-gui along with their output. It may be useful when determining why a change failed to be applied, or for debugging xinput-gui.
86 | True
87 |
88 |
89 | 0
90 | 0
91 |
92 |
93 |
94 |
95 | Clear Log
96 | True
97 | True
98 | True
99 |
100 |
101 |
102 | 1
103 | 0
104 |
105 |
106 |
107 |
108 | True
109 | True
110 | True
111 | in
112 |
113 |
114 | True
115 | True
116 | False
117 | buffer_log
118 |
119 |
120 |
121 |
122 | 0
123 | 1
124 | 2
125 |
126 |
127 |
128 |
129 | False
130 | True
131 | center-on-parent
132 | dialog
133 | xinput-gui
134 | 💜
135 | https://github.com/IvanFon/xinput-gui
136 | Github
137 | Ivan Fonseca
138 | McSinyx
139 | Romain F. T.
140 | image-missing
141 | gpl-3-0
142 |
143 |
144 |
145 |
146 |
147 |
148 | False
149 | vertical
150 | 2
151 |
152 |
153 | False
154 | end
155 |
156 |
157 | False
158 | False
159 | 0
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 | False
170 | True
171 | center-on-parent
172 | dialog
173 | Create Master Device
174 | Error:
175 |
176 |
177 |
178 |
179 |
180 | False
181 | vertical
182 | 2
183 |
184 |
185 | False
186 |
187 |
188 | Cancel
189 | True
190 | True
191 | True
192 |
193 |
194 | True
195 | True
196 | 0
197 |
198 |
199 |
200 |
201 | Create
202 | True
203 | False
204 | True
205 | True
206 |
207 |
208 | True
209 | True
210 | 1
211 |
212 |
213 |
214 |
215 | False
216 | False
217 | 0
218 |
219 |
220 |
221 |
222 | True
223 | False
224 | 10
225 | 10
226 | 10
227 | 5
228 | 10
229 |
230 |
231 | True
232 | False
233 | New device name:
234 |
235 |
236 | 0
237 | 0
238 |
239 |
240 |
241 |
242 | True
243 | True
244 |
245 |
246 |
247 |
248 | 1
249 | 0
250 |
251 |
252 |
253 |
254 | True
255 | True
256 | 2
257 |
258 |
259 |
260 |
261 |
262 | btn_create_master_cancel
263 | btn_create_master_create
264 |
265 |
266 |
267 | False
268 | True
269 | center-on-parent
270 | dialog
271 | Device Name
272 | Property Name
273 |
274 |
275 |
276 |
277 |
278 | False
279 | vertical
280 | 2
281 |
282 |
283 | False
284 | True
285 |
286 |
287 | Cancel
288 | True
289 | True
290 | True
291 |
292 |
293 | True
294 | True
295 | 0
296 |
297 |
298 |
299 |
300 | Apply
301 | True
302 | True
303 | True
304 |
305 |
306 | True
307 | True
308 | 1
309 |
310 |
311 |
312 |
313 | False
314 | False
315 | 0
316 |
317 |
318 |
319 |
320 | True
321 | False
322 | 10
323 | 10
324 | 10
325 | 10
326 | 5
327 | 10
328 |
329 |
330 | True
331 | False
332 | Current:
333 |
334 |
335 | 0
336 | 0
337 |
338 |
339 |
340 |
341 | True
342 | False
343 | New:
344 |
345 |
346 | 0
347 | 1
348 |
349 |
350 |
351 |
352 | True
353 | False
354 | True
355 |
356 |
357 | 1
358 | 0
359 |
360 |
361 |
362 |
363 | True
364 | True
365 | True
366 |
367 |
368 |
369 | 1
370 | 1
371 |
372 |
373 |
374 |
375 | True
376 | True
377 | 2
378 |
379 |
380 |
381 |
382 |
383 | btn_edit_cancel
384 | btn_edit_apply
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 | True
399 | False
400 |
401 |
402 | True
403 | False
404 | 6
405 | Devices
406 | 0
407 |
408 |
409 |
410 |
411 |
412 | 0
413 | 0
414 |
415 |
416 |
417 |
418 | True
419 | True
420 | True
421 | True
422 | in
423 |
424 |
425 | True
426 | True
427 | store_devices
428 | 1
429 | True
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 | ID
438 |
439 |
440 |
441 | 0
442 |
443 |
444 |
445 |
446 |
447 |
448 | True
449 | 225
450 | 500
451 | Name
452 |
453 |
454 |
455 | 1
456 |
457 |
458 |
459 |
460 |
461 |
462 | Type
463 |
464 |
465 |
466 | 2
467 |
468 |
469 |
470 |
471 |
472 |
473 |
474 |
475 | 0
476 | 1
477 |
478 |
479 |
480 |
481 | True
482 | False
483 | 2
484 |
485 |
486 | True
487 | False
488 | Add master device
489 | Add master
490 | True
491 | gtk-add
492 |
493 |
494 |
495 | False
496 | True
497 |
498 |
499 |
500 |
501 | True
502 | False
503 | False
504 | Remove master device
505 | Remove Master
506 | True
507 | gtk-remove
508 |
509 |
510 |
511 | False
512 | True
513 |
514 |
515 |
516 |
517 | True
518 | False
519 | Reattach slave device
520 | Reattach
521 | True
522 | gtk-connect
523 |
524 |
525 |
526 | False
527 | True
528 |
529 |
530 |
531 |
532 | True
533 | False
534 | Show device info
535 | Show device info
536 | True
537 | gtk-info
538 |
539 |
540 |
541 | False
542 | True
543 |
544 |
545 |
546 |
547 | True
548 | False
549 | Refresh devices
550 | Refresh devices
551 | True
552 | gtk-refresh
553 |
554 |
555 |
556 | False
557 | True
558 |
559 |
560 |
563 |
564 |
565 | 0
566 | 2
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 | True
582 | False
583 |
584 |
585 | True
586 | False
587 | 5
588 | Properties
589 | 0
590 |
591 |
592 |
593 |
594 |
595 | 0
596 | 0
597 |
598 |
599 |
600 |
601 | True
602 | True
603 | True
604 | True
605 | in
606 |
607 |
608 | True
609 | True
610 | store_props
611 | 1
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 | False
621 | ID
622 |
623 |
624 |
625 | 0
626 |
627 |
628 |
629 |
630 |
631 |
632 | True
633 | 300
634 | 650
635 | Name
636 |
637 |
638 |
639 | 1
640 |
641 |
642 |
643 |
644 |
645 |
646 | Value
647 |
648 |
649 | True
650 |
651 |
652 |
653 | 2
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 | 0
663 | 1
664 |
665 |
666 |
667 |
668 | True
669 | False
670 | 2
671 |
672 |
673 | True
674 | False
675 | False
676 | Edit property
677 | Edit property
678 | True
679 | gtk-edit
680 |
681 |
682 |
683 | False
684 | True
685 |
686 |
687 |
688 |
689 | True
690 | False
691 | False
692 | Refresh properties
693 | Refresh properties
694 | True
695 | gtk-refresh
696 |
697 |
698 |
699 | False
700 | True
701 |
702 |
703 |
706 |
707 |
708 | 0
709 | 2
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 | False
723 | True
724 | center-on-parent
725 | dialog
726 | Float/Reattach Device
727 | Device Name
728 |
729 |
730 |
731 |
732 |
733 | False
734 | vertical
735 | 2
736 |
737 |
738 | False
739 |
740 |
741 | Cancel
742 | True
743 | True
744 | True
745 |
746 |
747 | True
748 | True
749 | 0
750 |
751 |
752 |
753 |
754 | Apply
755 | True
756 | True
757 | True
758 |
759 |
760 | True
761 | True
762 | 1
763 |
764 |
765 |
766 |
767 | False
768 | False
769 | 0
770 |
771 |
772 |
773 |
774 | True
775 | False
776 | 10
777 | 10
778 | 10
779 |
780 |
781 | Float device
782 | True
783 | True
784 | False
785 | 5
786 | True
787 | True
788 | rad_reattach_device
789 |
790 |
791 | 0
792 | 0
793 | 2
794 |
795 |
796 |
797 |
798 | True
799 | False
800 | store_reattach
801 |
802 |
803 |
804 | 0
805 |
806 |
807 |
808 |
809 | 1
810 | 1
811 |
812 |
813 |
814 |
815 | Reattach device to:
816 | True
817 | True
818 | False
819 | 5
820 | True
821 | rad_float_device
822 |
823 |
824 | 0
825 | 1
826 |
827 |
828 |
829 |
830 | False
831 | True
832 | 2
833 |
834 |
835 |
836 |
837 |
838 | btn_reattach_cancel
839 | btn_reattach_apply
840 |
841 |
842 |
843 | False
844 | Xinput GUI
845 | 900
846 | 450
847 |
848 |
849 |
850 |
851 |
852 |
853 | True
854 | False
855 | vertical
856 |
857 |
858 | True
859 | False
860 |
861 |
862 | True
863 | False
864 | Edit
865 | True
866 |
867 |
868 | True
869 | False
870 |
871 |
872 | True
873 | False
874 | Settings
875 | True
876 |
877 |
878 |
879 |
880 |
881 |
882 |
883 |
884 |
885 | True
886 | False
887 | Help
888 | True
889 |
890 |
891 | True
892 | False
893 |
894 |
895 | True
896 | False
897 | About
898 | True
899 |
900 |
901 |
902 |
903 |
904 |
905 |
906 |
907 |
908 | False
909 | True
910 | 0
911 |
912 |
913 |
914 |
915 | True
916 | False
917 | center
918 | 6
919 | stack_main
920 |
921 |
922 | False
923 | True
924 | 1
925 |
926 |
927 |
928 |
929 | True
930 | False
931 | 12
932 | 12
933 | 6
934 | 12
935 | 100
936 | crossfade
937 |
938 |
939 | True
940 | False
941 | 16
942 | True
943 |
944 |
945 |
946 |
947 |
948 |
949 |
950 |
951 | page_editor
952 | Editor
953 |
954 |
955 |
956 |
957 | True
958 | False
959 | vertical
960 |
961 |
962 |
963 |
964 |
965 | page_log
966 | Log
967 | 1
968 |
969 |
970 |
971 |
972 | True
973 | True
974 | 2
975 |
976 |
977 |
978 |
979 |
980 |
981 | False
982 | Settings
983 | False
984 | True
985 | center-on-parent
986 |
987 |
988 |
989 |
990 |
991 | True
992 | False
993 | 10
994 | 10
995 | 10
996 | 10
997 | vertical
998 | 10
999 |
1000 |
1001 | True
1002 | False
1003 |
1004 |
1005 | 100
1006 | True
1007 | True
1008 | False
1009 | False
1010 |
1011 |
1012 | Vertical layout
1013 | True
1014 | True
1015 | False
1016 | False
1017 | True
1018 |
1019 |
1020 |
1021 |
1022 |
1023 |
1024 |
1025 | 100
1026 | True
1027 | True
1028 | False
1029 | False
1030 |
1031 |
1032 | Edit property values inline
1033 | True
1034 | True
1035 | False
1036 | False
1037 | True
1038 | True
1039 |
1040 |
1041 |
1042 |
1043 |
1044 |
1045 |
1046 | 100
1047 | True
1048 | True
1049 | False
1050 | False
1051 |
1052 |
1053 | Hide device IDs
1054 | True
1055 | True
1056 | False
1057 | False
1058 | True
1059 | True
1060 |
1061 |
1062 |
1063 |
1064 |
1065 |
1066 |
1067 | 100
1068 | True
1069 | True
1070 | False
1071 | False
1072 |
1073 |
1074 | Hide property IDs
1075 | True
1076 | True
1077 | False
1078 | False
1079 | True
1080 | True
1081 |
1082 |
1083 |
1084 |
1085 |
1086 |
1087 |
1088 | False
1089 | True
1090 | 0
1091 |
1092 |
1093 |
1094 |
1095 | True
1096 | False
1097 | True
1098 | start
1099 |
1100 |
1101 | Cancel
1102 | True
1103 | True
1104 | True
1105 |
1106 |
1107 |
1108 | True
1109 | True
1110 | 1
1111 |
1112 |
1113 |
1114 |
1115 | Save
1116 | True
1117 | True
1118 | True
1119 |
1120 |
1121 |
1122 | True
1123 | True
1124 | 2
1125 |
1126 |
1127 |
1128 |
1129 | False
1130 | True
1131 | 1
1132 |
1133 |
1134 |
1135 |
1136 |
1137 |
1138 |
--------------------------------------------------------------------------------
/xinput_gui/settings.py:
--------------------------------------------------------------------------------
1 | # settings.py - application settings
2 | # Copyright (C) 2019 Ivan Fonseca
3 | #
4 | # This file is part of xinput-gui.
5 | #
6 | # xinput-gui is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the # License,
9 | # or (at your option) any later version.
10 | #
11 | # xinput-gui is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with xinput-gui. If not, see .
18 |
19 | '''Application settings.'''
20 |
21 | from pathlib import Path
22 | from shutil import copyfile
23 | import json
24 | import os
25 |
26 | from pkg_resources import resource_filename
27 |
28 |
29 | CONFIG_PATH = Path(os.environ['HOME']).joinpath('.xinput-gui.json')
30 |
31 |
32 | class Settings:
33 | '''Loads and stores application settings.'''
34 |
35 | def __init__(self):
36 | '''Init Settings.'''
37 |
38 | self.config = {}
39 |
40 | self.vertical_layout = False
41 | self.inline_prop_edit = True
42 | self.hide_device_ids = True
43 | self.hide_prop_ids = True
44 |
45 | self.load_config()
46 |
47 | def load_config(self):
48 | '''Load config file.'''
49 |
50 | # Create config if needed
51 | if not CONFIG_PATH.is_file():
52 | copyfile(resource_filename('xinput_gui', 'res/config.json'), CONFIG_PATH)
53 |
54 | with open(CONFIG_PATH) as config_file:
55 | self.config = json.load(config_file)
56 |
57 | self.vertical_layout = self.config.get('vertical_layout', self.vertical_layout)
58 | self.inline_prop_edit = self.config.get('inline_prop_edit', self.inline_prop_edit)
59 | self.hide_device_ids = self.config.get('hide_device_ids', self.hide_device_ids)
60 | self.hide_prop_ids = self.config.get('hide_prop_ids', self.hide_prop_ids)
61 |
62 | def save_config(self):
63 | '''Save config file.'''
64 |
65 | self.config['vertical_layout'] = self.vertical_layout
66 | self.config['inline_prop_edit'] = self.inline_prop_edit
67 | self.config['hide_device_ids'] = self.hide_device_ids
68 | self.config['hide_prop_ids'] = self.hide_prop_ids
69 |
70 | with open(CONFIG_PATH, 'w', encoding='utf-8') as config_file:
71 | json.dump(self.config, config_file, indent=2)
72 |
--------------------------------------------------------------------------------
/xinput_gui/view_controller.py:
--------------------------------------------------------------------------------
1 | # view_controller.py - app view controller
2 | # Copyright (C) 2019 Ivan Fonseca
3 | #
4 | # This file is part of xinput-gui.
5 | #
6 | # xinput-gui is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the # License,
9 | # or (at your option) any later version.
10 | #
11 | # xinput-gui is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with xinput-gui. If not, see .
18 |
19 | '''App view controller.'''
20 |
21 | import gi
22 | gi.require_version('Gtk', '3.0')
23 | from gi.repository import Gtk
24 |
25 | from .gui.dialog_create_master import CreateMasterDialog
26 | from .gui.dialog_device_info import DeviceInfoDialog
27 | from .gui.dialog_edit import EditDialog
28 | from .gui.dialog_reattach import ReattachDialog
29 | from .gui.win_main import MainWindow
30 | from .settings import Settings
31 | from .view_model import ViewModel
32 |
33 |
34 | class ViewController:
35 | '''App view controller.'''
36 |
37 | def __init__(self) -> None:
38 | '''Init ViewController.'''
39 |
40 | self.model = ViewModel(self)
41 | self.settings = Settings()
42 | self.main_window = MainWindow(self, self.settings)
43 | self.device_list = self.main_window.device_list
44 | self.prop_list = self.main_window.prop_list
45 | self.log = self.main_window.log
46 |
47 | self.model.xinput.set_controller(self)
48 |
49 | self.dialog_create_master = CreateMasterDialog(self, self.main_window)
50 | self.dialog_device_info = DeviceInfoDialog(self, self.main_window)
51 | self.dialog_edit = EditDialog(self, self.main_window)
52 | self.dialog_reattach = ReattachDialog(self, self.main_window)
53 |
54 | def start(self) -> None:
55 | '''Start app.'''
56 |
57 | self.refresh_devices()
58 |
59 | Gtk.main()
60 |
61 | def log_updated(self, log_text: str) -> None:
62 | '''Xinput log updated.
63 |
64 | Args:
65 | log_text: Updated log text.
66 | '''
67 |
68 | self.log.update(log_text)
69 |
70 | def refresh_devices(self) -> None:
71 | '''Refresh devices.'''
72 |
73 | self.model.refreshing = True
74 |
75 | devices = self.model.refresh_devices()
76 | self.device_list.refresh_devices(devices)
77 |
78 | self.model.refreshing = False
79 |
80 | def device_selected(self, id_: int) -> None:
81 | '''Device was selected.
82 |
83 | Args:
84 | id_: Selected device ID.
85 | '''
86 |
87 | if self.model.refreshing:
88 | return
89 |
90 | self.model.set_selected_device(id_)
91 |
92 | self.device_list.show_device(self.model.selected_device)
93 | self.prop_list.show_device_props(self.model.selected_device)
94 |
95 | def show_create_master_dialog(self) -> None:
96 | '''Show create master dialog.'''
97 |
98 | res = self.dialog_create_master.show()
99 | if res == Gtk.ResponseType.APPLY:
100 | self.refresh_devices()
101 |
102 | def create_master_device(self, new_master_name: str) -> None:
103 | '''Create a master device.
104 |
105 | Args:
106 | new_master_name: Name of new master device.
107 | '''
108 |
109 | self.model.create_master_device(new_master_name)
110 |
111 | def remove_selected_master_device(self) -> None:
112 | '''Remove selected master device.'''
113 |
114 | self.model.remove_selected_master_device()
115 | self.refresh_devices()
116 |
117 | def show_reattach_dialog(self) -> None:
118 | '''Show float/reattach dialog.'''
119 |
120 | res = self.dialog_reattach.show(self.model.selected_device,
121 | self.model.xinput.devices)
122 | if res == Gtk.ResponseType.APPLY:
123 | self.refresh_devices()
124 |
125 | def float_selected_device(self) -> None:
126 | '''Float selected device.'''
127 |
128 | self.model.float_selected_device()
129 |
130 | def reattach_selected_device(self, master_id: int) -> None:
131 | '''Reattach selected device to given master device.
132 |
133 | Args:
134 | master_id: ID of master device to reattach selected device to.
135 | '''
136 |
137 | self.model.reattach_selected_device(master_id)
138 |
139 | def show_device_info(self) -> None:
140 | '''Show selected device info.'''
141 |
142 | self.dialog_device_info.show(self.model.selected_device)
143 |
144 | def refresh_props(self) -> None:
145 | '''Refresh selected device properties.'''
146 |
147 | self.model.selected_device.get_props()
148 | self.prop_list.show_device_props(self.model.selected_device)
149 |
150 | def prop_selected(self, id_: int, name: str, val: str) -> None:
151 | '''Set selected device property.
152 |
153 | Args:
154 | id_: Property ID.
155 | name: Property name.
156 | val: Property value.
157 | '''
158 |
159 | self.model.set_selected_prop(id_, name, val)
160 | self.prop_list.enable_edit_tool()
161 |
162 | def show_edit_dialog(self) -> None:
163 | '''Show property edit dialog.
164 |
165 | Args:
166 | prop: Property being edited.
167 | '''
168 |
169 | res = self.dialog_edit.show(self.model.selected_device,
170 | self.model.selected_prop)
171 | if res == Gtk.ResponseType.APPLY:
172 | self.refresh_props()
173 |
174 | def set_prop(self, new_val: str) -> None:
175 | '''Set the value of the currently selected device property.
176 |
177 | Args:
178 | new_val: New value for the property.
179 | '''
180 |
181 | self.model.set_selected_device_prop(new_val)
182 | self.refresh_props()
183 |
--------------------------------------------------------------------------------
/xinput_gui/view_model.py:
--------------------------------------------------------------------------------
1 | # view_model.py - app view model
2 | # Copyright (C) 2019 Ivan Fonseca
3 | #
4 | # This file is part of xinput-gui.
5 | #
6 | # xinput-gui is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the # License,
9 | # or (at your option) any later version.
10 | #
11 | # xinput-gui is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with xinput-gui. If not, see .
18 |
19 | '''App view model.'''
20 |
21 | from typing import TYPE_CHECKING, List
22 |
23 | from .xinput.devices import Device, Prop
24 | from .xinput.xinput import Xinput
25 |
26 | if TYPE_CHECKING:
27 | from .view_controller import ViewController
28 |
29 |
30 | class ViewModel:
31 | '''App view model.'''
32 |
33 | def __init__(self, controller: 'ViewController') -> None:
34 | '''Init ViewModel.'''
35 |
36 | self.xinput = Xinput()
37 |
38 | # Currently selected device
39 | self.selected_device = None
40 | # Currently selected device property
41 | self.selected_prop = None
42 | # If currently refreshing devices
43 | self.refreshing = False
44 |
45 | def refresh_devices(self) -> List[Device]:
46 | '''Refresh devices.
47 |
48 | Returns: List of Devices.
49 | '''
50 |
51 | self.xinput.get_devices()
52 | return self.xinput.devices
53 |
54 | def set_selected_device(self, id_: int) -> None:
55 | '''Set selected device by ID.'''
56 |
57 | self.selected_device = self.xinput.get_device_by_id(id_)
58 |
59 | def set_selected_prop(self, id_: int, name: str, val: str) -> None:
60 | '''Set selected device property.
61 |
62 | Args:
63 | id_: Property ID.
64 | name: Property name.
65 | val: Property value.
66 | '''
67 |
68 | self.selected_prop = Prop(id_, name, val)
69 |
70 | def create_master_device(self, new_master_name: str) -> None:
71 | '''Create a master device.
72 |
73 | Args:
74 | new_master_name: Name of new master device.
75 | '''
76 |
77 | self.xinput.create_master_device(new_master_name)
78 |
79 | def remove_selected_master_device(self) -> None:
80 | '''Remove selected master device.'''
81 |
82 | self.xinput.remove_master_device(self.selected_device)
83 |
84 | def float_selected_device(self) -> None:
85 | '''Float selected device.'''
86 |
87 | self.selected_device.float()
88 |
89 | def reattach_selected_device(self, master_id: int) -> None:
90 | '''Reattach selected device to given master device.
91 |
92 | Args:
93 | master_id: ID of master device to reattach selected device to.
94 | '''
95 |
96 | self.selected_device.reattach(master_id)
97 |
98 | def set_selected_device_prop(self, new_val: str) -> None:
99 | '''Set selected device property.
100 |
101 | Args:
102 | new_val: New value for the property.
103 | '''
104 |
105 | self.selected_device.set_prop(self.selected_prop.id, new_val)
106 |
--------------------------------------------------------------------------------
/xinput_gui/xinput/__init__.py:
--------------------------------------------------------------------------------
1 | '''xinput wrapper.'''
2 |
--------------------------------------------------------------------------------
/xinput_gui/xinput/devices.py:
--------------------------------------------------------------------------------
1 | # devices.py - xinput device classes
2 | # Copyright (C) 2019 Ivan Fonseca
3 | #
4 | # This file is part of xinput-gui.
5 | #
6 | # xinput-gui is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the # License,
9 | # or (at your option) any later version.
10 | #
11 | # xinput-gui is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with xinput-gui. If not, see .
18 |
19 | '''xinput device classes.'''
20 |
21 | from enum import Enum
22 | from typing import TYPE_CHECKING
23 | import re
24 |
25 | if TYPE_CHECKING:
26 | from .xinput import Xinput
27 |
28 |
29 | class DeviceType(Enum):
30 | '''Device types.'''
31 |
32 | FLOATING = 'floating'
33 | POINTER = 'pointer'
34 | KEYBOARD = 'keyboard'
35 |
36 |
37 | class Prop:
38 | '''An xinput device property.'''
39 |
40 | def __init__(self, id_: int, name: str, val: str) -> None:
41 | '''Init Prop.
42 |
43 | Args:
44 | id_: property ID.
45 | name: property name.
46 | val: property value.
47 | '''
48 |
49 | self.id = id_
50 | self.name = name
51 | self.val = val
52 |
53 |
54 | class Device:
55 | '''An xinput device.'''
56 |
57 | def __init__(self,
58 | xinput: 'Xinput',
59 | id_: int,
60 | name: str,
61 | type_: DeviceType,
62 | master: bool) -> None:
63 | '''Init Device.
64 |
65 | Args:
66 | id_: xinput device ID.
67 | name: xinput device name.
68 | type_: xinput device type.
69 | master: if device is master.
70 | '''
71 |
72 | self.xinput = xinput
73 | self.id = id_
74 | self.name = name
75 | self.type = type_
76 | self.master = master
77 |
78 | self.props = []
79 |
80 | self.get_props()
81 |
82 | def get_props(self) -> None:
83 | '''Get device properties.'''
84 |
85 | self.props.clear()
86 |
87 | props_cmd = 'xinput list-props {}'.format(self.id)
88 | props_out = self.xinput.run_command(props_cmd)
89 | props_out = props_out.splitlines()
90 | props_out.pop(0)
91 | props_out = list(map(lambda x: x.replace('\t', ''), props_out))
92 |
93 | for prop in props_out:
94 | matches = re.search(r'^(.+) \((\d+)\):(.+)$', prop)
95 | self.props.append(Prop(
96 | matches.group(2).strip(),
97 | matches.group(1).strip(),
98 | matches.group(3).strip(),
99 | ))
100 |
101 | def set_prop(self, prop_id: int, prop_val: str) -> None:
102 | '''Set a device property.
103 |
104 | Args:
105 | prop_id: ID of property to change.
106 | prop_val: new property value.
107 | '''
108 |
109 | cmd = 'xinput set-prop {} {} {}'.format(self.id, prop_id, prop_val)
110 | self.xinput.run_command(cmd)
111 |
112 | def float(self) -> None:
113 | '''Float slave device.'''
114 |
115 | if self.master:
116 | return
117 |
118 | cmd = 'xinput float {}'.format(self.id)
119 | self.xinput.run_command(cmd)
120 |
121 | def reattach(self, master_id: int) -> None:
122 | '''Reattach device to master.
123 |
124 | Args:
125 | master_id: ID of xinput master device to reattach slave device to.
126 | '''
127 |
128 | if self.master:
129 | return
130 |
131 | cmd = 'xinput reattach {} {}'.format(self.id, master_id)
132 | self.xinput.run_command(cmd)
133 |
134 | def get_info(self) -> str:
135 | '''Get device info.
136 |
137 | Returns:
138 | Device info.
139 | '''
140 |
141 | cmd = 'xinput list {}'.format(self.id)
142 | cmd_out = self.xinput.run_command(cmd)
143 |
144 | return cmd_out
145 |
--------------------------------------------------------------------------------
/xinput_gui/xinput/xinput.py:
--------------------------------------------------------------------------------
1 | # xinput.py - xinput wrapper
2 | # Copyright (C) 2019 Ivan Fonseca
3 | #
4 | # This file is part of xinput-gui.
5 | #
6 | # xinput-gui is free software: you can redistribute it and/or modify
7 | # it under the terms of the GNU General Public License as published by
8 | # the Free Software Foundation, either version 3 of the # License,
9 | # or (at your option) any later version.
10 | #
11 | # xinput-gui is distributed in the hope that it will be useful,
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | # GNU General Public License for more details.
15 | #
16 | # You should have received a copy of the GNU General Public License
17 | # along with xinput-gui. If not, see .
18 |
19 | '''xinput wrapper.'''
20 |
21 | from typing import TYPE_CHECKING
22 | import re
23 | import subprocess
24 |
25 | from .devices import Device, DeviceType
26 |
27 | if TYPE_CHECKING:
28 | from ..view_controller import ViewController
29 |
30 |
31 | class Xinput():
32 | '''xinput wrapper.'''
33 |
34 | def __init__(self) -> None:
35 | '''Init Xinput.'''
36 |
37 | self.devices = []
38 | self.log = ''
39 |
40 | def set_controller(self, controller: 'ViewController') -> None:
41 | self.controller = controller
42 |
43 | def run_command(self, cmd) -> str:
44 | '''Run a command.
45 |
46 | Returns:
47 | Command output.
48 | '''
49 |
50 | cmd_out = subprocess.run(cmd.split(' '),
51 | stdout=subprocess.PIPE,
52 | stderr=subprocess.PIPE)
53 | cmd_out = cmd_out.stdout.decode('utf-8')
54 |
55 | # Update log
56 | self.log += 'COMMAND:\n'
57 | self.log += cmd
58 | self.log += '\nOUTPUT:\n'
59 | self.log += cmd_out
60 | self.log += '\n\n========== SEPARATOR ==========\n\n'
61 |
62 | self.controller.log_updated(self.log)
63 |
64 | return cmd_out
65 |
66 | def get_devices(self) -> None:
67 | '''Get xinput devices.'''
68 |
69 | self.devices.clear()
70 |
71 | device_id_cmd = 'xinput list --id-only'
72 | device_ids = self.run_command(device_id_cmd).splitlines()
73 | device_ids = map(lambda x: re.search(r'\D*(\d+)\D*', x).group(1), device_ids)
74 |
75 | for device_id in device_ids:
76 | device_name_cmd = 'xinput list --name-only {}'.format(device_id)
77 | device_name_out = self.run_command(device_name_cmd)
78 | device_name = device_name_out.rstrip('\n')
79 |
80 | device_type_cmd = 'xinput list --short {}'.format(device_id)
81 | device_type_out = self.run_command(device_type_cmd)
82 | if 'floating' in device_type_out:
83 | device_type = DeviceType.FLOATING
84 | elif 'pointer' in device_type_out:
85 | device_type = DeviceType.POINTER
86 | else:
87 | device_type = DeviceType.KEYBOARD
88 |
89 | device_master = 'master' in device_type_out
90 |
91 | self.devices.append(Device(self,
92 | device_id,
93 | device_name,
94 | device_type,
95 | device_master))
96 |
97 | def get_device_by_id(self, id_: int) -> Device:
98 | '''Get a device by it's ID.
99 |
100 | Args:
101 | id_: xinput device ID.
102 | '''
103 |
104 | for device in self.devices:
105 | if int(device.id) == id_:
106 | return device
107 |
108 | return None
109 |
110 | def create_master_device(self, name: str) -> None:
111 | '''Create a new xinput master device.
112 |
113 | Args:
114 | name: new device name.
115 | '''
116 |
117 | cmd = 'xinput create-master "{}"'.format(name)
118 | self.run_command(cmd)
119 |
120 | self.get_devices()
121 |
122 | def remove_master_device(self, device: Device) -> None:
123 | '''Remove a master xinput device.
124 |
125 | Args:
126 | device: Master Device to remove.
127 | '''
128 |
129 | if not device.master:
130 | return
131 |
132 | cmd = 'xinput remove-master {}'.format(device.id)
133 | self.run_command(cmd)
134 |
135 | self.get_devices()
136 |
--------------------------------------------------------------------------------