├── .gitignore
├── LICENSE
├── README.md
├── contents
├── component
│ ├── activity.mjs
│ ├── config.mjs
│ ├── desktop.mjs
│ ├── layout.mjs
│ ├── list.mjs
│ ├── main.mjs
│ ├── manager.mjs
│ ├── output.mjs
│ ├── shared.mjs
│ └── shortcut.mjs
├── config
│ └── main.xml
└── ui
│ ├── config.ui
│ └── main.qml
└── metadata.json
/.gitignore:
--------------------------------------------------------------------------------
1 | preview/
2 |
--------------------------------------------------------------------------------
/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 | Grid-Tiling-KWin
635 | Copyright (C) 2017 lingtjien
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 | Grid-Tiling-KWin Copyright (C) 2017 lingtjien
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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Kwin Grid-Tiling Script
2 |
3 | [](https://youtu.be/N1Bg-H9Lpzs)
4 |
5 | ## Install
6 |
7 | ```
8 | mkdir -p ~/.local/share/kwin/scripts/grid-tiling
9 | cd ~/.local/share/kwin/scripts/grid-tiling
10 | ln -s /contents
11 | ln -s /metadata.json
12 | ```
13 |
14 | - `` is the path to this repository.
15 | - in order to uninstall, delete the linked or copied files that you created during installation
16 | - to install script system wide, do the process for `/usr/share` instead of `~/.local/share`
17 | - `kpackagetool6` is at this moment of writing broken and unable to install declarative kwin scripts without a `main.js`
18 |
19 | ## Functionality
20 |
21 | - automatically tile windows, up to any custom grid size per desktop and per screen
22 | - new windows are first attempted to be added to the desktop and screen that the application itself set
23 | - insufficient space will result in the script automatically trying other screens first before trying other desktops, ultimately resorting to not tiling the new window if none have any space.
24 | - grid size can be configured on a per screen basis using a comma separated list of integers in the configuration user interface
25 | - screen rows and columns defines the defaults per screen, example: `rows=2,2` and `colums=2,3` results `screen 1: 2x2`, `screen 2: 2x3`
26 | - rows and columns for screens that were not defined will default to the first element
27 | - desktop rows, columns and names define overrides based on matching the desktop name using regex
28 | - moving windows within a grid done by drag and drop and global shortcuts
29 | - restriction of minimum space a window can occupy on a desktop, as in the amount of windows this window can share a desktop with, matching based on regex
30 | - a size of `1` is the largest and fully takes up a desktop, size of `2` means that it takes up at least half of the virtual desktop and so forth...
31 | - settings for many variables: gap, border, tiling, etc... and global shortcuts for toggling them
32 | - supports native KWin signals
33 | - movement of windows between desktops, screens and activities
34 | - resizing of windows, provides additional global shortcuts
35 | - minimization of windows, provides additional global shortcut to toggle for all windows on a desktop
36 | - blacklist and whitelist windows from tiling by matching regex
37 |
38 | ## Recommended Setup
39 |
40 | | Action | Shortcut |
41 | | ------------------------------------ | --------------- |
42 | | Window to Next Desktop | Meta+End |
43 | | Window to Previous Desktop | Meta+Home |
44 | | Switch to Next Desktop | Meta+Right |
45 | | Switch to Previous Desktop | Meta+Left |
46 | | Toggle Overview | Meta+Space |
47 | | Move Window to Next Screen | Meta+PgUp |
48 | | Move Window to Previous Screen | Meta+PgDown |
49 | | Switch to Next Screen | Meta+Up |
50 | | Switch to Previous Screen | Meta+Down |
51 | | Grid Tiling: Move Left | Meta+Ctrl+Left |
52 | | Grid Tiling: Move Right | Meta+Ctrl+Right |
53 | | Grid Tiling: Move Up | Meta+Ctrl+Up |
54 | | Grid Tiling: Move Down | Meta+Ctrl+Down |
55 | | Switch to Window Left | Meta+Alt+Left |
56 | | Switch to Window Right | Meta+Alt+Right |
57 | | Switch to Window Above | Meta+Alt+Up |
58 | | Switch to Window Below | Meta+Alt+Down |
59 | | Grid Tiling: Increase Size | Meta+= |
60 | | Grid Tiling: Decrease Size | Meta+- |
61 | | Grid Tiling: Maximize Size | Meta++ |
62 | | Grid Tiling: Minimize Size | Meta+\_ |
63 | | Grid Tiling: Tile/Float | Meta+T |
64 | | Grid Tiling: Toggle Gap | Meta+G |
65 | | Grid Tiling: Toggle Border | Meta+B |
66 | | Minimize Window | Meta+N |
67 | | Grid Tiling: Toggle Minimize Desktop | Meta+M |
68 | | Window Operations Menu | Meta+` |
69 | | Grid Tiling: Refresh | Meta+R |
70 | | Grid Tiling: Reset | Meta+Ctrl+R |
71 | | Close Window | Meta+W |
72 | | Grid Tiling: Close Desktop | Meta+Q |
73 |
74 | ## Additional Info & Tips
75 |
76 | - screen edges can be configured to move windows between virtual desktops when dragged
77 | - focus policy can be configured to follow the cursor
78 | - this version of the script uses the latest KWin API methods. If you're using an older version of KWin, choose the appropriate branch
79 | - after installing a KWin script you can activate it in the system settings, here you'll also find the configuration button
80 | - when you adjust the settings in the menu, this script needs to be restarted before the settings are applied. You can do this by turning the script off, apply, turn it back on and apply again or a complete KWin restart (re-log/reboot)
81 | - after updates, some of the shortcuts may have been renamed, but KWin still keeps the old ones registered. To remove the no longer used shortcuts, first disable this script, then go to the shortcuts settings window and use the delete button on the `KWin` application that contains the shortcuts to this script. Restart KWin and then activate the script again and the old unused shortcuts should now all be gone
82 | - script assumes that the amount of desktops does not change. For the best result make sure you have more virtual desktops than you have windows normally. The script can handle more windows but once all desktops and screens are full, all new windows will start as floating instead of tiling until there is space again to tile new windows
83 | - name matching is performed using the javascript `RegExp` class which is build using the string that the user provides and then the `test` method is used on the window class (application) property (equivalent JS code `RegExp(config).test(window.resourceName)`). You can find the value for these properties on a window by opening the Windows Operations Menu (there is a global shortcut for this). For some examples check out the min space section of the configuration interface
84 | - if you never plan on using multiple screens you could also consider repurposing the KWin shortcuts for moving windows between screens to desktops instead. So you have more flexibility to move windows between the grid of desktops, while sacrificing the shortcuts that allow you to move them between screens
85 | - if you have trouble with other applications changing the geometry of windows you may try the `force` option
86 | - logging can be obtained from your system log, for example in wayland using `journalctl _COMM=kwin_wayland`
87 |
88 | ---
89 |
90 | [](https://www.paypal.com/donate/?hosted_button_id=BUNHJLSFY78PC)
--------------------------------------------------------------------------------
/contents/component/activity.mjs:
--------------------------------------------------------------------------------
1 | import { shared } from 'shared.mjs';
2 | import { Desktop } from 'desktop.mjs';
3 |
4 | export function Activity() {
5 | const desktops = {}; // key = KWin::VirtualDesktop::id
6 |
7 | function count() {
8 | return Object.values(desktops).reduce((n, d) => n + d.count(), 0);
9 | }
10 |
11 | function add(window) {
12 | const id = window.desktops[0].id;
13 | if (!desktops.hasOwnProperty(id)) desktops[id] = Desktop();
14 | if (desktops[id].add(window, id)) {
15 | window.desktopId = id;
16 | return window;
17 | } else {
18 | for (const d of shared.workspace.desktops) {
19 | const id = d.id;
20 | if (!desktops.hasOwnProperty(id)) desktops[id] = Desktop();
21 | if (desktops[id].add(window, id)) {
22 | window.desktopId = id;
23 | window.desktops = [d];
24 | return window;
25 | }
26 | }
27 | }
28 | // couldn't find any desktops with sufficient space to add window too
29 | }
30 |
31 | function remove(window) {
32 | const id = window.desktopId;
33 | if (desktops.hasOwnProperty(id)) {
34 | const desktop = desktops[id];
35 | if (desktop.remove(window)) {
36 | if (!desktop.count()) delete desktops[id];
37 | return window;
38 | }
39 | }
40 | }
41 |
42 | function moved(window) {
43 | let c, t;
44 | for (const [i, desktop] of shared.workspace.desktops.entries()) {
45 | const id = desktop.id;
46 | if (id === window.desktopId) c = i;
47 | if (id === window.desktops[0].id) t = i;
48 | }
49 | const direction = Math.sign(t - c);
50 | if (direction) {
51 | const max = shared.workspace.desktops.length;
52 | let i = t;
53 | while (i !== c) {
54 | const desktop = shared.workspace.desktops[i];
55 | const id = desktop.id;
56 | if (!desktops.hasOwnProperty(id)) desktops[id] = Desktop();
57 | const w = Object.assign({}, window);
58 | if (desktops[id].add(window)) {
59 | remove(w);
60 | window.desktopId = id;
61 | window.desktops = [desktop];
62 | return window;
63 | }
64 |
65 | i += direction;
66 | if (i < 0) i = max - 1;
67 | if (i >= max) i = 0;
68 | }
69 | }
70 | return window;
71 | }
72 |
73 | function render() {
74 | for (const [id, desktop] of Object.entries(desktops)) {
75 | desktop.render(shared.workspace.desktops.find((d) => d.id === id));
76 | }
77 | }
78 |
79 | return { desktops, count, add, remove, moved, render };
80 | }
81 |
--------------------------------------------------------------------------------
/contents/component/config.mjs:
--------------------------------------------------------------------------------
1 | import { shared } from 'shared.mjs';
2 |
3 | export const config = {};
4 |
5 | function regex(data) {
6 | // empty regex will always match, so only return a regex when there is an input, otherwise everything will be matched by an empty regex test
7 | if (data) return RegExp(data);
8 | }
9 |
10 | function splitTrim(data) {
11 | return data
12 | .split(',')
13 | .map((i) => Number(i.trim()))
14 | .filter((i) => i);
15 | }
16 |
17 | function parseScreenGrid(rows, columns) {
18 | const grid = {};
19 | for (let i = 0; i < shared.workspace.screens.length; ++i)
20 | grid[shared.workspace.screens[i].name] = [rows[i < rows.length ? i : 0], columns[i < columns.length ? i : 0]];
21 | return grid;
22 | }
23 |
24 | function parseDesktopGrid(read) {
25 | const grid = {};
26 | for (let i = 1; i <= 8; ++i) {
27 | const name = regex(read(`desktopName${i}`, ''));
28 | if (name) {
29 | for (const desktop of shared.workspace.desktops) {
30 | if (name.test(desktop.name)) {
31 | const g = parseScreenGrid(
32 | splitTrim(read(`desktopRows${i}`, '2')),
33 | splitTrim(read(`desktopColumns${i}`, '2'))
34 | );
35 | if (Object.keys(g).length) {
36 | grid[desktop.id] = g;
37 | break;
38 | }
39 | }
40 | }
41 | }
42 | }
43 | return grid;
44 | }
45 |
46 | function smallest(grid) {
47 | return Object.values(grid).reduce((s, [r, c]) => Math.min(s, 1 / (r * c)), 1);
48 | }
49 |
50 | function minSpace(read, defaults) {
51 | const data = [];
52 | for (let [i, d] of defaults) {
53 | const name = read(`minSpaceName${i}`, d);
54 | i = read(`minSpace${i}`, i);
55 | if (i && name) data.push([1 / i, regex(name)]);
56 | }
57 | return data;
58 | }
59 |
60 | export function setGap() {
61 | config.gap = config.gapShow ? config.gapValue : 0;
62 | }
63 |
64 | export function load(read) {
65 | config.grid = {
66 | screen: parseScreenGrid(splitTrim(read('screenRows', '2')), splitTrim(read('screenColumns', '2'))), // Record
67 | desktop: parseDesktopGrid(read), // Record>
68 | };
69 | config.smallestSpace = Object.values(config.grid.desktop).reduce(
70 | (s, d) => Math.min(s, smallest(d)),
71 | smallest(config.grid.screen)
72 | );
73 |
74 | config.gapShow = read('gapShow', true);
75 | config.gapValue = read('gapValue', 16);
76 | setGap();
77 |
78 | config.divider = {
79 | bound: read('dividerBound', 0.4),
80 | step: read('dividerStep', 0.05),
81 | };
82 |
83 | config.tile = read('tile', true);
84 |
85 | config.border = read('border', false);
86 | config.borderActive = read('borderActive', false);
87 | config.force = read('force', false);
88 |
89 | config.delay = read('delay', 10);
90 |
91 | config.margin = {
92 | t: read('marginT', 0),
93 | b: read('marginB', 0),
94 | l: read('marginL', 0),
95 | r: read('marginR', 0),
96 | };
97 |
98 | config.minSpace = minSpace(read, [
99 | [1, 'inkscape|krita|gimp|kdenlive|Godot|vlc'],
100 | [2, 'code|chrome'],
101 | [3, ''],
102 | [4, ''],
103 | [5, ''],
104 | [6, ''],
105 | [7, ''],
106 | [8, ''],
107 | [9, ''],
108 | [10, ''],
109 | ]);
110 |
111 | config.blacklist = regex(read('blacklist', 'plasmashell'));
112 | config.whitelist = regex(read('whitelist', ''));
113 | }
114 |
115 | export function grid(desktopId, outputName) {
116 | const d = config.grid.desktop[desktopId];
117 | return d ? d[outputName] : config.grid.screen[outputName];
118 | }
119 |
120 | export function clampDivider(value) {
121 | return Math.min(Math.max(-config.divider.bound, value), config.divider.bound);
122 | }
123 |
124 | export const calc = {
125 | x: (start) => start + config.margin.l + config.gap,
126 | y: (start) => start + config.margin.t + config.gap,
127 | width: (total, n) => (total - config.margin.l - config.margin.r - (n + 1) * config.gap) / n,
128 | height: (total, n) => (total - config.margin.t - config.margin.b - (n + 1) * config.gap) / n,
129 | };
130 |
--------------------------------------------------------------------------------
/contents/component/desktop.mjs:
--------------------------------------------------------------------------------
1 | import { shared, area } from 'shared.mjs';
2 | import { grid } from 'config.mjs';
3 | import { Output } from 'output.mjs';
4 |
5 | export function Desktop() {
6 | const outputs = {}; // key = KWin::Output::name
7 |
8 | function count() {
9 | return Object.values(outputs).reduce((n, o) => n + o.count(), 0);
10 | }
11 |
12 | function add(window, desktopId) {
13 | const name = window.output.name;
14 | if (!outputs.hasOwnProperty(name)) outputs[name] = Output();
15 | if (outputs[name].add(window, grid(desktopId, name))) {
16 | window.outputName = name;
17 | return window;
18 | } else {
19 | for (const o of shared.workspace.screens) {
20 | const n = o.name;
21 | if (!outputs.hasOwnProperty(n)) outputs[n] = Output();
22 | if (outputs[n].add(window, grid(desktopId, n))) {
23 | window.outputName = n;
24 | shared.workspace.sendClientToScreen(window, o); // output is read only in api
25 | return window;
26 | }
27 | }
28 | }
29 | // couldn't find any outputs with sufficient space to add window too
30 | }
31 |
32 | function remove(window) {
33 | const n = window.outputName;
34 | const output = outputs[n];
35 | if (output && output.remove(window)) {
36 | if (!output.count()) delete outputs[n];
37 | return window;
38 | }
39 | }
40 |
41 | function moved(window) {
42 | let c, t;
43 | for (const [i, output] of shared.workspace.screens.entries()) {
44 | const n = output.name;
45 | if (n === window.outputName) c = i;
46 | if (n === window.output.name) t = i;
47 | }
48 | const direction = Math.sign(t - c);
49 | if (direction) {
50 | const max = shared.workspace.screens.length;
51 | let i = t;
52 | while (i !== c) {
53 | const output = shared.workspace.screens[i];
54 | const n = output.name;
55 | if (!outputs.hasOwnProperty(n)) outputs[n] = Output();
56 | const w = Object.assign({}, window);
57 | if (outputs[n].add(window, grid(window.desktopId, n))) {
58 | remove(w);
59 | window.outputName = n;
60 | shared.workspace.sendClientToScreen(window, output); // output is read only in api
61 | return window;
62 | }
63 |
64 | i += direction;
65 | if (i < 0) i = max - 1;
66 | if (i >= max) i = 0;
67 | }
68 | }
69 | return window;
70 | }
71 |
72 | // provide at least desktopId in overwrite
73 | function render(desktop) {
74 | for (const [name, output] of Object.entries(outputs)) {
75 | output.render(
76 | area(
77 | desktop,
78 | shared.workspace.screens.find((s) => s.name === name)
79 | )
80 | );
81 | }
82 | }
83 |
84 | return { outputs, count, add, remove, moved, render };
85 | }
86 |
--------------------------------------------------------------------------------
/contents/component/layout.mjs:
--------------------------------------------------------------------------------
1 | import { Activity } from 'activity.mjs';
2 |
3 | export function Layout() {
4 | let activities = {}; // key = activity id
5 |
6 | function add(window) {
7 | const id = window.activities[0];
8 | if (!activities.hasOwnProperty(id)) activities[id] = Activity();
9 | if (activities[id].add(window)) {
10 | window.activityId = id;
11 | return window;
12 | }
13 | }
14 |
15 | function remove(window) {
16 | const id = window.activityId;
17 | if (activities[id].remove(window)) {
18 | if (!activities[id].count()) delete activities[id];
19 | return window;
20 | }
21 | }
22 |
23 | function moved(window) {
24 | const target = window.activities[0];
25 | if (!activities.hasOwnProperty(target)) activities[target] = Activity();
26 | const w = Object.assign({}, window);
27 | if (activities[target].add(window)) {
28 | remove(w);
29 | window.activityId = target;
30 | return window;
31 | }
32 | }
33 |
34 | function render() {
35 | for (const activity of Object.values(activities)) activity.render();
36 | }
37 |
38 | return { activities, add, remove, moved, render };
39 | }
40 |
--------------------------------------------------------------------------------
/contents/component/list.mjs:
--------------------------------------------------------------------------------
1 | import { calc, clampDivider, config } from 'config.mjs';
2 |
3 | export function List() {
4 | const windows = [];
5 | const dividers = [];
6 |
7 | function minimized() {
8 | return windows.reduce((s, w) => s + w.minimized, 0);
9 | }
10 |
11 | function minSpace() {
12 | return windows.reduce((s, w) => s + w.minSpace, 0);
13 | }
14 |
15 | function add(window) {
16 | window.windowIndex = windows.length;
17 | windows.push(window);
18 | if (windows.length > 0) dividers.push(0); // do not add a new divider when the first window is added to the column
19 | }
20 |
21 | function remove(window) {
22 | const i = window.windowIndex;
23 | if (i < windows.length) {
24 | for (let j = i + 1; j < windows.length; ++j) windows[j].windowIndex -= 1;
25 | windows.splice(i, 1);
26 | if (i === 0) {
27 | if (dividers.length > 0) dividers.shift();
28 | } else {
29 | dividers.splice(i - 1, 1);
30 | }
31 | return window;
32 | }
33 | }
34 |
35 | function swap(windowIndex, amount) {
36 | const t = windowIndex + amount;
37 | const target = windows[t];
38 | if (target) {
39 | const current = windows[windowIndex];
40 |
41 | target.windowIndex = windowIndex;
42 | windows[windowIndex] = target;
43 |
44 | current.windowIndex = t;
45 | windows[t] = current;
46 |
47 | return current;
48 | }
49 | }
50 |
51 | function dividerPost(windowIndex, amount) {
52 | if (windowIndex < windows.length - 1) dividers[windowIndex] = clampDivider(dividers[windowIndex] + amount);
53 | }
54 |
55 | function dividerPre(windowIndex, amount) {
56 | if (windowIndex > 0) dividers[windowIndex - 1] = clampDivider(dividers[windowIndex - 1] - amount);
57 | }
58 |
59 | function divider(windowIndex, amount) {
60 | dividerPost(windowIndex, amount);
61 | dividerPre(windowIndex, amount);
62 | }
63 |
64 | function overlap(window, area) {
65 | let remainder = window.frameGeometry.y + 0.5 * window.frameGeometry.height - config.margin.t - area.y; // center
66 | for (const w of windows) {
67 | if (!w.minimized) {
68 | remainder -= w.frameGeometry.height + config.gap;
69 | if (remainder < 0) return w;
70 | }
71 | }
72 | }
73 |
74 | function render(x, y, width, height) {
75 | height = calc.height(height, windows.length - minimized());
76 | y = calc.y(y);
77 |
78 | let current = 0;
79 | let previous = 0;
80 | for (let [i, window] of windows.entries()) {
81 | if (window.minimized) continue;
82 |
83 | let divider = dividers[i] || 0;
84 | if (divider) {
85 | const w = windows[i + 1];
86 | if (w && w.minimized) divider = 0;
87 | }
88 |
89 | current = height * divider;
90 | const h = height + current - previous;
91 | const geometry = Qt.rect(Math.floor(x), Math.floor(y), Math.floor(width), Math.floor(h));
92 |
93 | window.renderGeometry = geometry;
94 |
95 | // these properties are from kwin and will thus trigger additional signals, these properties must be set last to prevent the signals that are hooked into this script from triggering before the internal properties have been set
96 | window.noBorder = config.borderActive && window.active ? false : !config.border;
97 | window.frameGeometry = geometry;
98 |
99 | y += h + config.gap;
100 | previous = current;
101 | }
102 | }
103 |
104 | return { windows, minimized, minSpace, add, remove, swap, divider, dividerPre, dividerPost, overlap, render };
105 | }
106 |
--------------------------------------------------------------------------------
/contents/component/main.mjs:
--------------------------------------------------------------------------------
1 | import { shared } from 'shared.mjs';
2 | import { config, load } from 'config.mjs';
3 | import { activated, add, remove, start, stop } from 'manager.mjs';
4 |
5 | let signals = [];
6 |
7 | function connect(signal, callback) {
8 | signals.push({ signal, callback });
9 | shared.workspace[signal].connect(callback);
10 | }
11 |
12 | export function init(workspace, kwin, timer) {
13 | shared.workspace = workspace;
14 | shared.kwin = kwin;
15 | shared.timer = timer;
16 |
17 | load(kwin.readConfig);
18 |
19 | start();
20 |
21 | connect('windowRemoved', remove);
22 | connect('windowAdded', add);
23 | if (config.borderActive) connect('windowActivated', activated);
24 | }
25 |
26 | export function destroy() {
27 | for (const { signal, callback } of signals) shared.workspace[signal].disconnect(callback);
28 | signals = [];
29 | stop();
30 | }
31 |
--------------------------------------------------------------------------------
/contents/component/manager.mjs:
--------------------------------------------------------------------------------
1 | import { area, shared, setTimeout } from 'shared.mjs';
2 | import { config } from 'config.mjs';
3 | import { Layout } from 'layout.mjs';
4 |
5 | let floating = {};
6 | let tiled = {};
7 | let layout = Layout();
8 |
9 | function connect(window, signal, callback) {
10 | if (!window.hasOwnProperty('connected')) window.connected = [];
11 | window.connected.push({ signal, callback });
12 | window[signal].connect(callback);
13 | }
14 | function disconnect(window) {
15 | for (const { signal, callback } of window.connected) window[signal].disconnect(callback);
16 | delete window.connected;
17 | return window;
18 | }
19 |
20 | function ignored(window) {
21 | if (config.whitelist && config.whitelist.test(window.resourceName)) return false;
22 | return window.transient || window.specialWindow || (config.blacklist && config.blacklist.test(window.resourceName));
23 | }
24 |
25 | function addProps(window) {
26 | window.init = {
27 | noBorder: window.noBorder,
28 | frameGeometry: window.frameGeometry,
29 | };
30 |
31 | window.activities = [window.activities[0]];
32 | window.desktops = [window.desktops[0]];
33 |
34 | window.minSpace = config.smallestSpace;
35 | for (const [minSpace, name] of config.minSpace) {
36 | if (name && name.test(window.resourceName)) {
37 | window.minSpace = minSpace;
38 | break;
39 | }
40 | }
41 | return window;
42 | }
43 |
44 | function tile(window) {
45 | if (!tiled.hasOwnProperty(window.internalId) && layout.add(window)) {
46 | tiled[window.internalId] = addSignals(window);
47 | if (floating.hasOwnProperty(window.internalId)) delete floating[window.internalId];
48 | return window;
49 | }
50 | }
51 |
52 | function unTile(window) {
53 | if (tiled.hasOwnProperty(window.internalId)) {
54 | if (window.hasOwnProperty('init')) {
55 | for (const [prop, value] of Object.entries(window.init)) window[prop] = value;
56 | }
57 |
58 | window = tiled[window.internalId];
59 | if (layout.remove(window)) {
60 | layout.render();
61 | }
62 | delete tiled[disconnect(window).internalId];
63 | floating[window.internalId] = window;
64 | return window;
65 | }
66 | }
67 |
68 | function addSignals(window) {
69 | if (config.force) {
70 | connect(window, 'frameGeometryChanged', () => {
71 | if (!window.move && !window.resize && !window.fullScreen && window.frameGeometry !== window.renderGeometry)
72 | window.frameGeometry = window.renderGeometry;
73 | });
74 | }
75 |
76 | connect(window, 'moveResizedChanged', () => {
77 | const output = getOutput(window);
78 | const a = area(window.desktops[0], window.output);
79 | if (!output.resized(window, a)) output.moved(window, a);
80 | output.render(a);
81 | });
82 |
83 | connect(window, 'minimizedChanged', () => {
84 | const output = getOutput(window);
85 | if (output) output.render(area(window.desktops[0], window.output));
86 | });
87 |
88 | connect(window, 'activitiesChanged', () => {
89 | setTimeout(() => {
90 | if (!window.deleted) {
91 | if (window.activities.length !== 1 || !layout.moved(window)) unTile(window);
92 | layout.render();
93 | }
94 | }, config.delay);
95 | });
96 |
97 | connect(window, 'desktopsChanged', () => {
98 | setTimeout(() => {
99 | if (!window.deleted) {
100 | const activity = getActivity(window);
101 | if (activity) {
102 | if (window.desktops.length === 1) {
103 | activity.moved(window);
104 | shared.workspace.currentDesktop = window.desktops[0];
105 | } else {
106 | unTile(window);
107 | }
108 | activity.render();
109 | }
110 | }
111 | }, config.delay);
112 | });
113 |
114 | connect(window, 'outputChanged', () => {
115 | setTimeout(() => {
116 | if (!window.deleted) {
117 | const desktop = getDesktop(window);
118 | if (desktop) {
119 | desktop.moved(window);
120 | desktop.render(window.desktops[0]);
121 | }
122 | }
123 | }, config.delay);
124 | });
125 |
126 | return window;
127 | }
128 |
129 | export function add(window) {
130 | if (window) {
131 | setTimeout(() => {
132 | if (
133 | !window.deleted &&
134 | window.activities.length &&
135 | window.desktops.length &&
136 | !floating.hasOwnProperty(window.internalId) &&
137 | !tiled.hasOwnProperty(window.internalId) &&
138 | !ignored(window)
139 | ) {
140 | addProps(window);
141 | if (config.tile && tile(window)) {
142 | layout.render();
143 | shared.workspace.currentDesktop = window.desktops[0];
144 | }
145 | floating[window.internalId] = window;
146 | }
147 | }, config.delay);
148 | }
149 | }
150 |
151 | export function remove(window) {
152 | if (window) {
153 | if (tiled.hasOwnProperty(window.internalId)) {
154 | window = tiled[window.internalId];
155 | if (layout.remove(window)) {
156 | delete tiled[disconnect(window).internalId];
157 | layout.render();
158 | }
159 | } else if (floating.hasOwnProperty(window.internalId)) {
160 | delete floating[window.internalId];
161 | }
162 | }
163 | }
164 |
165 | export function activated(window) {
166 | const output = getOutput(window);
167 | if (output) output.render(area(window.desktops[0], window.output));
168 | }
169 |
170 | export function toggle() {
171 | const window = shared.workspace.activeWindow;
172 | if (window) {
173 | if (
174 | (floating.hasOwnProperty(window.internalId) && tile(window)) ||
175 | (tiled.hasOwnProperty(window.internalId) && unTile(window))
176 | ) {
177 | layout.render();
178 | return window;
179 | }
180 | return add(window);
181 | }
182 | }
183 |
184 | export function getActivity(window) {
185 | if (window && tiled.hasOwnProperty(window.internalId)) window = tiled[window.internalId];
186 | return layout.activities[window ? window.activityId : shared.workspace.currentActivity];
187 | }
188 |
189 | export function getDesktop(window) {
190 | const activity = getActivity(window);
191 | if (activity) return activity.desktops[window ? window.desktopId : shared.workspace.currentDesktop.id];
192 | }
193 |
194 | export function getOutput(window) {
195 | const desktop = getDesktop(window);
196 | if (desktop) return desktop.outputs[window ? window.outputName : shared.workspace.activeScreen.name];
197 | }
198 |
199 | export function render() {
200 | layout.render();
201 | }
202 |
203 | export function stop() {
204 | for (const window of Object.values(tiled)) disconnect(window);
205 | tiled = {};
206 | floating = {};
207 | layout = Layout();
208 | }
209 |
210 | export function start() {
211 | for (const window of shared.workspace.windows) add(window);
212 | layout.render();
213 | }
214 |
--------------------------------------------------------------------------------
/contents/component/output.mjs:
--------------------------------------------------------------------------------
1 | import { calc, clampDivider, config } from 'config.mjs';
2 | import { List } from 'list.mjs';
3 |
4 | export function Output() {
5 | const lists = [];
6 | const dividers = [];
7 |
8 | function count() {
9 | return lists.reduce((n, l) => n + l.windows.length, 0);
10 | }
11 |
12 | function minimized() {
13 | return lists.reduce((s, l) => s + (l.minimized() === l.windows.length), 0);
14 | }
15 |
16 | function addList(start = false) {
17 | // check if adding a new line won't decrease the size of the windows inside any of the existing lines below their minSpace
18 | if (!lists.some((l) => l.minSpace() > 1 / (lists.length + 1))) {
19 | if (start) {
20 | for (const l of lists) {
21 | for (const w of l.windows) w.listIndex += 1;
22 | }
23 | if (lists.unshift(List()) > 1) dividers.unshift(0);
24 | } else {
25 | if (lists.push(List()) > 1) dividers.push(0);
26 | }
27 | return start ? 0 : lists.length - 1;
28 | }
29 | }
30 |
31 | function removeLine(index) {
32 | for (let i = index + 1; i < lists.length; ++i) {
33 | for (const w of lists[i].windows) w.listIndex -= 1;
34 | }
35 | lists.splice(index, 1);
36 | if (index === 0) {
37 | if (dividers.length > 0) dividers.shift();
38 | } else {
39 | dividers.splice(index - 1, 1);
40 | }
41 | }
42 |
43 | function smallest() {
44 | if (lists.length) {
45 | let i = 0;
46 | let minSpace = lists[i].minSpace();
47 | for (let j = 1; j < lists.length; ++j) {
48 | const m = lists[j].minSpace();
49 | if (m < minSpace) {
50 | i = j;
51 | minSpace = m;
52 | }
53 | }
54 | return i;
55 | }
56 | }
57 |
58 | function add(window, grid) {
59 | const i = smallest();
60 | let list = lists[i];
61 | if (
62 | list &&
63 | list.minSpace() + window.minSpace <= 1 / lists.length &&
64 | list.windows.length < grid[0] &&
65 | (lists.length >= grid[1] || lists.length > list.windows.length)
66 | ) {
67 | list.add(window);
68 | window.listIndex = i;
69 | return window;
70 | } else if (window.minSpace <= 1 / (lists.length + 1) && lists.length < grid[1]) {
71 | const j = addList();
72 | list = lists[j];
73 | if (list) {
74 | list.add(window);
75 | window.listIndex = j;
76 | return window;
77 | }
78 | }
79 | }
80 |
81 | function remove(window) {
82 | const i = window.listIndex;
83 | if (i < lists.length) {
84 | const list = lists[i];
85 | if (list.remove(window)) {
86 | if (!list.windows.length) removeLine(i);
87 | return window;
88 | }
89 | }
90 | }
91 |
92 | function swap(listIndex, amount) {
93 | const t = listIndex + amount;
94 | const target = lists[t];
95 | if (target) {
96 | const current = lists[listIndex];
97 |
98 | for (const w of target.windows) w.listIndex = listIndex;
99 | lists[listIndex] = target;
100 |
101 | for (const w of current.windows) w.listIndex = t;
102 | lists[t] = current;
103 |
104 | return current;
105 | }
106 | }
107 |
108 | function move(window, amount, grid) {
109 | let t = window.listIndex + amount;
110 | let target = lists[t];
111 | if (!target && lists.length < grid[1] && lists[window.listIndex].windows.length > 1) {
112 | t = addList(amount < 0);
113 | target = lists[t];
114 | }
115 |
116 | if (target && target.minSpace() + window.minSpace <= 1 / lists.length && target.windows.length < grid[0]) {
117 | const c = window.listIndex;
118 | const current = lists[c];
119 | current.remove(window);
120 | if (!current.windows.length) {
121 | removeLine(c);
122 | if (t > c) --t;
123 | }
124 | target.add(window);
125 | window.listIndex = t;
126 | return window;
127 | }
128 | }
129 |
130 | function dividerPost(listIndex, amount) {
131 | if (listIndex < lists.length - 1) dividers[listIndex] = clampDivider(dividers[listIndex] + amount);
132 | }
133 |
134 | function dividerPre(listIndex, amount) {
135 | if (listIndex > 0) dividers[listIndex - 1] = clampDivider(dividers[listIndex - 1] - amount);
136 | }
137 |
138 | function divider(listIndex, amount) {
139 | dividerPost(listIndex, amount);
140 | dividerPre(listIndex, amount);
141 | }
142 |
143 | function resized(window, area) {
144 | let diff = {};
145 | for (const [key, value] of Object.entries(window.frameGeometry)) diff[key] = value - window.renderGeometry[key];
146 | if (diff.width === 0 && diff.height === 0) return;
147 |
148 | const width = calc.width(area.width, lists.length - minimized());
149 | if (diff.width !== 0) {
150 | if (diff.x === 0) dividerPost(window.listIndex, diff.width / width);
151 | else dividerPre(window.listIndex, diff.width / width);
152 | }
153 |
154 | const height = calc.height(
155 | area.height,
156 | lists[window.listIndex].windows.length - lists[window.listIndex].minimized()
157 | );
158 | if (diff.height !== 0) {
159 | if (diff.y === 0) lists[window.listIndex].dividerPost(window.windowIndex, diff.height / height);
160 | else lists[window.listIndex].dividerPre(window.windowIndex, diff.height / height);
161 | }
162 | return window;
163 | }
164 |
165 | function overlap(window, area) {
166 | let remainder = window.frameGeometry.x + 0.5 * window.frameGeometry.width - config.margin.l - area.x; // center
167 | for (const list of lists) {
168 | if (!list.minimized()) {
169 | remainder -= list.windows[0].frameGeometry.width + config.gap;
170 | if (remainder < 0) return list;
171 | }
172 | }
173 | }
174 |
175 | function moved(window, area) {
176 | const swapList = overlap(window, area);
177 | if (swapList) {
178 | const swapWindow = swapList.overlap(window, area);
179 | if (
180 | window !== swapWindow &&
181 | swapWindow &&
182 | lists[window.listIndex].minSpace() - window.minSpace + swapWindow.minSpace <= 1 / lists.length &&
183 | swapList.minSpace() - swapWindow.minSpace + window.minSpace <= 1 / lists.length
184 | ) {
185 | const swapWindowIndex = swapWindow.windowIndex;
186 | const swapListIndex = swapWindow.listIndex;
187 |
188 | swapWindow.windowIndex = window.windowIndex;
189 | swapWindow.listIndex = window.listIndex;
190 | lists[window.listIndex].windows[window.windowIndex] = swapWindow;
191 |
192 | window.windowIndex = swapWindowIndex;
193 | window.listIndex = swapListIndex;
194 | swapList.windows[swapWindowIndex] = window;
195 | }
196 | }
197 | }
198 |
199 | function render(area) {
200 | const width = calc.width(area.width, lists.length - minimized());
201 | let x = calc.x(area.x);
202 | let current = 0;
203 | let previous = 0;
204 | for (let [i, list] of lists.entries()) {
205 | if (list.minimized() === list.windows.length) continue;
206 |
207 | let divider = dividers[i] || 0;
208 | if (divider) {
209 | const l = lists[i + 1];
210 | if (l && l.minimized() === l.windows.length) divider = 0;
211 | }
212 |
213 | current = width * divider;
214 | const w = width + current - previous;
215 |
216 | list.render(x, area.y, w, area.height);
217 |
218 | x += w + config.gap;
219 | previous = current;
220 | }
221 | }
222 |
223 | return { lists, count, minimized, add, remove, swap, move, divider, resized, moved, render };
224 | }
225 |
--------------------------------------------------------------------------------
/contents/component/shared.mjs:
--------------------------------------------------------------------------------
1 | export const shared = { workspace: null, kwin: null, timer: null };
2 |
3 | // KWin desktop and output object types, not our custom internal ones
4 | export function area(desktop, output) {
5 | return shared.workspace.clientArea(0, output, desktop);
6 | }
7 |
8 | export function setTimeout(callback, interval) {
9 | return shared.timer.createObject(null, { callback, interval });
10 | }
11 |
12 | export function clearTimeout(t) {
13 | t.stop();
14 | t.destroy();
15 | }
16 |
--------------------------------------------------------------------------------
/contents/component/shortcut.mjs:
--------------------------------------------------------------------------------
1 | import { area, shared } from 'shared.mjs';
2 | import { init, destroy } from 'main.mjs';
3 | import { config, grid, setGap } from 'config.mjs';
4 | import { getOutput, render, start, toggle as tileFloat } from 'manager.mjs';
5 |
6 | export { tileFloat };
7 | export const refresh = start;
8 |
9 | export const toggle = {
10 | tile: () => {
11 | config.tile = !config.tile;
12 | },
13 | gap: () => {
14 | config.gapShow = !config.gapShow;
15 | setGap();
16 | render();
17 | },
18 | border: () => {
19 | config.border = !config.border;
20 | render();
21 | },
22 | minimizeDesktop: () => {
23 | const output = getOutput();
24 | if (output) {
25 | const minimize = output.lists.reduce((s, l) => s + l.minimized(), 0) === 0;
26 | for (const list of output.lists) {
27 | for (const window of list.windows) window.minimized = minimize;
28 | }
29 | }
30 | },
31 | };
32 |
33 | export const resize = {};
34 | for (const [key, direction, size] of [
35 | ['increase', 1, 'step'],
36 | ['decrease', -1, 'step'],
37 | ['maximize', 1, 'bound'],
38 | ['minimize', -1, 'bound'],
39 | ]) {
40 | resize[key] = () => {
41 | const window = shared.workspace.activeWindow;
42 | const output = getOutput(window);
43 | if (output) {
44 | const amount = direction * config.divider[size];
45 | output.lists[window.listIndex].divider(window.windowIndex, amount);
46 | output.divider(window.listIndex, amount);
47 | output.render(area(window.desktops[0], window.output));
48 | }
49 | };
50 | }
51 |
52 | export const move = {};
53 | for (const [key, amount] of [
54 | ['up', -1],
55 | ['down', 1],
56 | ]) {
57 | move[key] = () => {
58 | const window = shared.workspace.activeWindow;
59 | const output = getOutput(window);
60 | if (output && output.lists[window.listIndex].swap(window.windowIndex, amount))
61 | output.render(area(window.desktops[0], window.output));
62 | };
63 | }
64 | for (const [key, amount] of [
65 | ['left', -1],
66 | ['right', 1],
67 | ]) {
68 | move[key] = () => {
69 | const window = shared.workspace.activeWindow;
70 | const output = getOutput(window);
71 | if (
72 | output &&
73 | (output.move(window, amount, grid(window.desktopId, window.outputName)) ||
74 | output.swap(window.listIndex, amount))
75 | )
76 | output.render(area(window.desktops[0], window.output));
77 | };
78 | }
79 |
80 | export function closeDesktop() {
81 | for (const window of shared.workspace.windows) {
82 | if (
83 | window &&
84 | window.output === shared.workspace.activeScreen &&
85 | window.desktops.includes(shared.workspace.currentDesktop) &&
86 | window.activities.includes(shared.workspace.currentActivity)
87 | )
88 | window.closeWindow();
89 | }
90 | }
91 |
92 | export function reset() {
93 | destroy();
94 | init(shared.workspace, shared.kwin, shared.timer);
95 | }
96 |
--------------------------------------------------------------------------------
/contents/config/main.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 | true
10 |
11 |
12 |
13 | true
14 |
15 |
16 |
17 | false
18 |
19 |
20 |
21 | false
22 |
23 |
24 |
25 | false
26 |
27 |
28 |
29 | 16
30 |
31 |
32 |
33 | 0.4
34 |
35 |
36 |
37 | 0.05
38 |
39 |
40 |
41 | 10
42 |
43 |
44 |
45 | 0
46 |
47 |
48 |
49 | 0
50 |
51 |
52 |
53 | 0
54 |
55 |
56 |
57 | 0
58 |
59 |
60 |
61 | plasmashell
62 |
63 |
64 |
65 |
66 |
67 |
68 | 2
69 |
70 |
71 | 2
72 |
73 |
74 | 2
75 |
76 |
77 | 2
78 |
79 |
80 |
81 |
82 |
83 | 2
84 |
85 |
86 | 2
87 |
88 |
89 |
90 |
91 |
92 | 2
93 |
94 |
95 | 2
96 |
97 |
98 |
99 |
100 |
101 | 2
102 |
103 |
104 | 2
105 |
106 |
107 |
108 |
109 |
110 | 2
111 |
112 |
113 | 2
114 |
115 |
116 |
117 |
118 |
119 | 2
120 |
121 |
122 | 2
123 |
124 |
125 |
126 |
127 |
128 | 2
129 |
130 |
131 | 2
132 |
133 |
134 |
135 |
136 |
137 | 2
138 |
139 |
140 | 2
141 |
142 |
143 |
144 |
145 |
146 | 1
147 |
148 |
149 | inkscape|krita|gimp|kdenlive|Godot|vlc
150 |
151 |
152 | 2
153 |
154 |
155 | code|chrome
156 |
157 |
158 | 3
159 |
160 |
161 |
162 |
163 |
164 | 4
165 |
166 |
167 |
168 |
169 |
170 | 5
171 |
172 |
173 |
174 |
175 |
176 | 6
177 |
178 |
179 |
180 |
181 |
182 | 7
183 |
184 |
185 |
186 |
187 |
188 | 8
189 |
190 |
191 |
192 |
193 |
194 |
--------------------------------------------------------------------------------
/contents/ui/config.ui:
--------------------------------------------------------------------------------
1 |
2 |
3 | KWin::GridTilingConfigForm
4 |
5 |
6 |
7 | 480
8 | 320
9 |
10 |
11 |
12 | Grid Tiling
13 |
14 |
15 |
16 |
17 | 0
18 | 0
19 | 480
20 | 320
21 |
22 |
23 |
24 |
25 | Main
26 |
27 |
28 |
29 |
30 |
31 | 6
32 |
33 |
34 |
35 |
36 | Tile
37 |
38 |
39 |
40 |
41 |
42 |
43 | Gap
44 |
45 |
46 |
47 |
48 |
49 |
50 | Border
51 |
52 |
53 |
54 |
55 |
56 |
57 | Active Border
58 |
59 |
60 |
61 |
62 |
63 |
64 | Force
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | Qt::Horizontal
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 | Gap
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 | Bound
93 |
94 |
95 |
96 |
97 |
98 |
99 | 0.500000000000000
100 |
101 |
102 | 0.050000000000000
103 |
104 |
105 |
106 |
107 |
108 |
109 | Step Size
110 |
111 |
112 |
113 |
114 |
115 |
116 | 0.500000000000000
117 |
118 |
119 | 0.010000000000000
120 |
121 |
122 |
123 |
124 |
125 |
126 | Delay
127 |
128 |
129 |
130 |
131 |
132 |
133 | 9999
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 | Qt::Horizontal
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 | Qt::Horizontal
152 |
153 |
154 |
155 |
156 |
157 |
158 | Qt::LeftToRight
159 |
160 |
161 | Margin
162 |
163 |
164 |
165 |
166 |
167 |
168 | Qt::Horizontal
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 | Left
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 | Bottom
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 | Top
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 | Right
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 | Qt::Horizontal
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 | Blacklist
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 | Apps not tiled if regex matches with name
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 | Whitelist
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 | Apps always tiled if regex matches with name
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 | Qt::Vertical
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 | Grid
279 |
280 |
281 |
282 |
283 |
284 | QFrame::Plain
285 |
286 |
287 | true
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 | Qt::Horizontal
297 |
298 |
299 |
300 |
301 |
302 |
303 | Qt::LeftToRight
304 |
305 |
306 | Screens
307 |
308 |
309 |
310 |
311 |
312 |
313 | Qt::Horizontal
314 |
315 |
316 |
317 |
318 |
319 |
320 |
321 |
322 |
323 |
324 | Rows
325 |
326 |
327 |
328 |
329 |
330 |
331 | Number of rows per screen (separated by comma)
332 |
333 |
334 |
335 |
336 |
337 |
338 | Columns
339 |
340 |
341 |
342 |
343 |
344 |
345 | Number of columns per screen (separated by comma)
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 | Qt::Horizontal
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 | Qt::Horizontal
364 |
365 |
366 |
367 |
368 |
369 |
370 | Qt::LeftToRight
371 |
372 |
373 | Desktops
374 |
375 |
376 |
377 |
378 |
379 |
380 | Qt::Horizontal
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 | Rows
392 |
393 |
394 |
395 |
396 |
397 |
398 | Columns
399 |
400 |
401 |
402 |
403 |
404 |
405 | Name
406 |
407 |
408 |
409 |
410 |
411 |
412 | Number of rows per screen (separated by comma)
413 |
414 |
415 |
416 |
417 |
418 |
419 | Number of columns per screen (separated by comma)
420 |
421 |
422 |
423 |
424 |
425 |
426 | Match given regex with desktop name
427 |
428 |
429 |
430 |
431 |
432 |
433 | Number of rows per screen (separated by comma)
434 |
435 |
436 |
437 |
438 |
439 |
440 | Number of columns per screen (separated by comma)
441 |
442 |
443 |
444 |
445 |
446 |
447 | Match given regex with desktop name
448 |
449 |
450 |
451 |
452 |
453 |
454 | Number of rows per screen (separated by comma)
455 |
456 |
457 |
458 |
459 |
460 |
461 | Number of columns per screen (separated by comma)
462 |
463 |
464 |
465 |
466 |
467 |
468 | Match given regex with desktop name
469 |
470 |
471 |
472 |
473 |
474 |
475 | Number of rows per screen (separated by comma)
476 |
477 |
478 |
479 |
480 |
481 |
482 | Number of columns per screen (separated by comma)
483 |
484 |
485 |
486 |
487 |
488 |
489 | Match given regex with desktop name
490 |
491 |
492 |
493 |
494 |
495 |
496 | Number of rows per screen (separated by comma)
497 |
498 |
499 |
500 |
501 |
502 |
503 | Number of columns per screen (separated by comma)
504 |
505 |
506 |
507 |
508 |
509 |
510 | Match given regex with desktop name
511 |
512 |
513 |
514 |
515 |
516 |
517 | Number of rows per screen (separated by comma)
518 |
519 |
520 |
521 |
522 |
523 |
524 | Number of columns per screen (separated by comma)
525 |
526 |
527 |
528 |
529 |
530 |
531 | Match given regex with desktop name
532 |
533 |
534 |
535 |
536 |
537 |
538 | Number of rows per screen (separated by comma)
539 |
540 |
541 |
542 |
543 |
544 |
545 | Number of columns per screen (separated by comma)
546 |
547 |
548 |
549 |
550 |
551 |
552 | Match given regex with desktop name
553 |
554 |
555 |
556 |
557 |
558 |
559 | Number of rows per screen (separated by comma)
560 |
561 |
562 |
563 |
564 |
565 |
566 | Number of columns per screen (separated by comma)
567 |
568 |
569 |
570 |
571 |
572 |
573 | Match given regex with desktop name
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 | Min Space
588 |
589 |
590 |
591 |
592 |
593 | QFrame::Plain
594 |
595 |
596 | true
597 |
598 |
599 |
600 |
601 |
602 |
603 | Value
604 |
605 |
606 |
607 |
608 |
609 |
610 | Name
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 | Match given regex with app name
621 |
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 | Match given regex with app name
631 |
632 |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 | Match given regex with app name
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 | Match given regex with app name
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 | Match given regex with app name
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 | Match given regex with app name
671 |
672 |
673 |
674 |
675 |
676 |
677 |
678 |
679 |
680 | Match given regex with app name
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 | Match given regex with app name
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
--------------------------------------------------------------------------------
/contents/ui/main.qml:
--------------------------------------------------------------------------------
1 | import QtQuick;
2 | import org.kde.kwin;
3 |
4 | import '../component/main.mjs' as Main;
5 | import '../component/shortcut.mjs' as Shortcut;
6 |
7 | Item {
8 | Component {
9 | id: timer
10 | Timer {
11 | property var callback
12 | running: true
13 | repeat: false
14 | onTriggered: {
15 | callback();
16 | destroy();
17 | }
18 | }
19 | }
20 |
21 | Component.onCompleted: {
22 | Main.init(Workspace, KWin, timer);
23 | }
24 |
25 | Component.onDestruction: {
26 | Main.destroy();
27 | }
28 |
29 | readonly property string prefix: 'Grid Tiling: '
30 |
31 | ShortcutHandler {
32 | name: prefix + 'Tile/Float'
33 | text: prefix + 'Tile/Float'
34 | sequence: 'Meta+T'
35 | onActivated: Shortcut.tileFloat()
36 | }
37 |
38 | ShortcutHandler {
39 | name: prefix + 'Toggle Tile'
40 | text: prefix + 'Toggle Tile'
41 | sequence: 'Meta+Shift+T'
42 | onActivated: Shortcut.toggle.tile()
43 | }
44 |
45 | ShortcutHandler {
46 | name: prefix + 'Toggle Gap'
47 | text: prefix + 'Toggle Gap'
48 | sequence: 'Meta+G'
49 | onActivated: Shortcut.toggle.gap()
50 | }
51 |
52 | ShortcutHandler {
53 | name: prefix + 'Toggle Border'
54 | text: prefix + 'Toggle Border'
55 | sequence: 'Meta+B'
56 | onActivated: Shortcut.toggle.border()
57 | }
58 |
59 | ShortcutHandler {
60 | name: prefix + 'Toggle Minimize Desktop'
61 | text: prefix + 'Toggle Minimize Desktop'
62 | sequence: 'Meta+M'
63 | onActivated: Shortcut.toggle.minimizeDesktop()
64 | }
65 |
66 | ShortcutHandler {
67 | name: prefix + 'Increase Size'
68 | text: prefix + 'Increase Size'
69 | sequence: 'Meta+='
70 | onActivated: Shortcut.resize.increase()
71 | }
72 |
73 | ShortcutHandler {
74 | name: prefix + 'Decrease Size'
75 | text: prefix + 'Decrease Size'
76 | sequence: 'Meta+-'
77 | onActivated: Shortcut.resize.decrease()
78 | }
79 |
80 | ShortcutHandler {
81 | name: prefix + 'Maximize Size'
82 | text: prefix + 'Maximize Size'
83 | sequence: 'Meta++'
84 | onActivated: Shortcut.resize.maximize()
85 | }
86 |
87 | ShortcutHandler {
88 | name: prefix + 'Minimize Size'
89 | text: prefix + 'Minimize Size'
90 | sequence: 'Meta+_'
91 | onActivated: Shortcut.resize.minimize()
92 | }
93 |
94 | ShortcutHandler {
95 | name: prefix + 'Move Up'
96 | text: prefix + 'Move Up'
97 | sequence: 'Meta+Ctrl+Up'
98 | onActivated: Shortcut.move.up()
99 | }
100 |
101 | ShortcutHandler {
102 | name: prefix + 'Move Down'
103 | text: prefix + 'Move Down'
104 | sequence: 'Meta+Ctrl+Down'
105 | onActivated: Shortcut.move.down()
106 | }
107 |
108 | ShortcutHandler {
109 | name: prefix + 'Move Left'
110 | text: prefix + 'Move Left'
111 | sequence: 'Meta+Ctrl+Left'
112 | onActivated: Shortcut.move.left()
113 | }
114 |
115 | ShortcutHandler {
116 | name: prefix + 'Move Right'
117 | text: prefix + 'Move Right'
118 | sequence: 'Meta+Ctrl+Right'
119 | onActivated: Shortcut.move.right()
120 | }
121 |
122 | ShortcutHandler {
123 | name: prefix + 'Close Desktop'
124 | text: prefix + 'Close Desktop'
125 | sequence: 'Meta+Q'
126 | onActivated: Shortcut.closeDesktop()
127 | }
128 |
129 | ShortcutHandler {
130 | name: prefix + 'Refresh'
131 | text: prefix + 'Refresh'
132 | sequence: 'Meta+R'
133 | onActivated: Shortcut.refresh()
134 | }
135 |
136 | ShortcutHandler {
137 | name: prefix + 'Reset'
138 | text: prefix + 'Reset'
139 | sequence: 'Meta+Ctrl+R'
140 | onActivated: Shortcut.reset()
141 | }
142 | }
143 |
--------------------------------------------------------------------------------
/metadata.json:
--------------------------------------------------------------------------------
1 | {
2 | "KPackageStructure": "KWin/Script",
3 | "KPlugin": {
4 | "Name": "Grid Tiling",
5 | "Description": "Automatically tile new windows with gaps in any grid size",
6 | "Icon": "preferences-system-windows-script-test",
7 | "Id": "grid-tiling",
8 | "License": "GPL",
9 | "Authors": [
10 | {
11 | "Name": "Ling"
12 | }
13 | ]
14 | },
15 | "X-KDE-ConfigModule": "kwin/effects/configs/kcm_kwin4_genericscripted",
16 | "X-Plasma-API": "declarativescript",
17 | "X-Plasma-API-Minimum-Version": "6.0"
18 | }
19 |
--------------------------------------------------------------------------------