├── .gitignore
├── LICENSE
├── README.md
├── format.sh
├── icon.png
├── madwidgets
├── autotimer
│ ├── README.md
│ └── autotimer.lua
├── doubletap
│ ├── README.md
│ └── doubletap.lua
├── hotcorner
│ └── hotcorner.lua
├── lockdelay
│ ├── README.md
│ └── lockdelay.lua
├── menupanel
│ ├── README.md
│ └── menupanel.lua
├── multibutton
│ ├── README.md
│ └── multibutton.lua
├── overlay
│ ├── README.md
│ └── overlay.lua
├── sysmonitor
│ ├── README.md
│ └── sysmonitor.lua
├── tagbar
│ └── tagbar.lua
├── tagview
│ └── tagview.lua
├── topbar
│ ├── README.md
│ └── topbar.lua
├── utils.lua
└── volumecontrol
│ ├── README.md
│ └── volumecontrol.lua
├── modules
├── autostart.lua
├── bindings.lua
├── clients.lua
├── dropdowns.lua
├── frames.lua
├── globals.lua
├── menupanels.lua
├── notifications.lua
├── rules.lua
├── screens.lua
├── theme.lua
└── utils.lua
├── quick_actions.txt
├── rc.lua
├── scripts
├── counter.rb
├── data
│ └── commands.data
├── desktop
│ ├── readme.txt
│ └── w_timer.desktop
├── readme.txt
├── restart.rb
└── timer.rb
└── wallpaper.jpg
/.gitignore:
--------------------------------------------------------------------------------
1 | *
2 |
3 | !.gitignore
4 | !rc.lua
5 | !LICENSE
6 | !README.md
7 | !/madwidgets/
8 | !/madwidgets/**
9 | !/modules/
10 | !/modules/**
11 | !/themes/
12 | !/themes/**
13 | !/icons/
14 | !/icons/**
15 | !/scripts/
16 | !/scripts/**
17 | !wallpaper.jpg
18 | !icon.png
19 | !quick_actions.txt
20 | !format.sh
21 | timer.data
--------------------------------------------------------------------------------
/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 | .
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | Here is my awesomewm setup.
4 |
5 | It's built around floating windows.
6 |
7 | Tiling features are intentionally stripped away.
8 |
9 | Tiling is done manually through rules.
10 |
11 | There's also no titlebars at all.
12 |
13 | Instead there's right clicking the taskbar.
14 |
15 | I make heavy use of the widgets and libraries that I wrote in "madwidgets".
16 |
17 | You should be able to use madwidgets in other setups too, if you copy the whole thing.
18 |
19 | I make heavy use of Rofi in my workflow.
20 | Since it's easy to show list results of text or get input for commands. It's easy to create .desktop files in ~/.local/share/applications to make scripts visible.
21 |
22 | To use, clone this in ~/.config
23 |
24 | Rename the dir to "awesome".
25 |
26 | Restart awesome.
27 |
28 | # Modules
29 |
30 | ## autostart.lua
31 | Programs to start/call when awesome starts
32 |
33 | ## bindings.lua
34 | Keyboard and mouse bindings
35 |
36 | ## menupanels.lua
37 | My menupanel (madwidget) setup
38 |
39 | ## notifications.lua
40 | Naughty notifications setup
41 |
42 | ## rules.lua
43 | Window rules, how and where programs get displayed
44 |
45 | ## screens.lua
46 | Where the screen and panel get built
47 |
48 | ## theme.lua
49 | Some custom theming rules
50 |
51 | ## utils.lua
52 | Utilities and functions
53 |
54 | ## clients.lua
55 | Client signals
56 |
57 | ## globals.lua
58 | Holds some global variables
59 |
60 | # Other programs used
61 |
62 | >dash
63 |
64 | >numlockx
65 |
66 | >xset
67 |
68 | >setxkbmap
69 |
70 | >systemctl
71 |
72 | >pavucontrol
73 |
74 | >spectacle
75 |
76 | >playerctl
77 |
78 | >rofi
79 |
80 | >i3lock
81 |
82 | >firefox-developer-edition
83 |
84 | >some scripts
85 |
86 | >geany
87 |
88 | >osmo
89 |
90 | >alacritty
91 |
92 | >clipton
93 |
94 | >tilix
95 |
96 | >killall
97 |
98 | >echo
99 |
100 | >cat
101 |
102 | >sponge
103 |
104 | >onboard
105 |
106 | >btop
107 |
108 | >nethogs
109 |
110 | >ip
111 |
112 | >sed
113 |
114 | >speedcrunch
115 |
116 | ## Used by widgets
117 |
118 | >awk
119 |
120 | >sensors
121 |
122 | >free
123 |
124 | >cat
125 |
126 | >mpstat
127 |
128 | >sleep
129 |
130 | >sed
131 |
132 | >grep
133 |
134 | >pamixer
135 |
136 | >pkill
137 |
138 | >espeak
139 |
140 | # Some shortcuts
141 |
142 | Win + Backspace
143 |
144 | >Toggle maximize
145 |
146 | ---
147 |
148 | Win + Shift + Backspace
149 |
150 | >Toggle fullscreen
151 |
152 | ---
153 |
154 | Win + Numpad number
155 |
156 | >Snap to the region represented by the numpad
157 |
158 | ---
159 |
160 | Win + \
161 |
162 | >Move to other monitor
163 |
164 | ---
165 |
166 | Win + Mouse wheel
167 |
168 | >Resize at center
169 |
170 | ---
171 |
172 | ScrLk
173 |
174 | >Toggle Util Screen terminal
175 |
176 | (Same is achieved by ctrl + Delete when the pointer is at the top of the screen)
177 |
178 | ---
179 |
180 | Middle click on bottom left icon
181 |
182 | >Lock screen
183 |
184 | ---
185 |
186 | Win + Spacebar
187 |
188 | >Open Rofi
189 |
190 | ---
191 |
192 | Win + `
193 |
194 | >Open the main menupanel
195 |
196 | ---
197 |
198 | Ctrl + `
199 |
200 | >Open the clipboard manager
201 |
202 | ---
203 |
204 | Right click on tag
205 |
206 | >Move client to that tag
207 |
208 | ---
209 |
210 | Alt + Tab
211 |
212 | >Show Rofi in altab mode
213 |
214 | ---
215 |
216 | Right click tasklist item
217 |
218 | >Show a menupanel with actions on that client
219 |
220 | ---
221 |
222 | Click on sysmonitors
223 |
224 | >Open btop
225 |
226 | >Open sensors
227 |
228 | >Open nethogs
229 |
230 | ---
231 |
232 | Click on volume control
233 |
234 | >Open pavucontrol
235 |
236 | ---
237 |
238 | Click on date
239 |
240 | >Open the osmo calendar
241 |
242 | ---
243 |
244 | Alt + F4
245 |
246 | >Close client
247 |
248 | ---
249 |
250 | Double tap the mouse DPI button
251 |
252 | >Close client under cursor
253 |
254 | To do this, bind Win + Delete to the DPI button
255 |
256 | That's what I do at least, and it's very efficient
257 |
258 | ---
259 |
260 | PrtSc
261 |
262 | >Open Spectacle to take a region screenshot
263 |
264 | Using Escape to cancel this shows more screenshot options
265 |
266 | # Log
267 |
268 | There's a simple log system that saves information to ~/.awm_log
269 |
270 | It automatically saves "critical" notifications to it.
271 |
272 | Other information can be added manually with the `add_to_log` function.
273 |
274 | # Notes
275 |
276 | If your mouse has topside buttons, you can use them for virtual desktop changing.
--------------------------------------------------------------------------------
/format.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | stylua .
4 | stylua --glob modules/*
5 | stylua --glob madwidgets/*
--------------------------------------------------------------------------------
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madprops/awesome-setup/f0e8856028168d11f63ecc58135c597af096a527/icon.png
--------------------------------------------------------------------------------
/madwidgets/autotimer/README.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | 
4 |
5 | 
6 |
7 | ```lua
8 | function auto_suspend(minutes)
9 | autotimer.start_timer("Suspend", minutes, function() suspend() end)
10 | end
11 | ```
12 |
13 | Use this to perform an action after some minutes.
14 |
15 | Or count upwards:
16 |
17 | ```lua
18 | function counter()
19 | autotimer.start_counter("My Counter")
20 | end
21 | ```
22 |
23 | A widget has to be created to show how many minutes are left.
24 |
25 | First initialize autotimer:
26 |
27 | ```lua
28 | autotimer = require("madwidgets/autotimer/autotimer")
29 | autotimer.create({left = " ", right = " "})
30 | ```
31 |
32 | Then place autotimer where you want the container widget:
33 |
34 | ```
35 | [widget],
36 | autotimer,
37 | [widget],
38 | ```
39 |
40 | Middle clicking the widgets stop the actions.
41 |
42 | Example:
43 |
44 | ```lua
45 | autotimer.create({
46 | fontcolor = "blue",
47 | left = " ", right = " * ",
48 | right_color = "grey",
49 | separator = "|", separator_color = "red"
50 | })
51 | ```
52 |
53 | Supports multibutton args plus:
54 |
55 | ```lua
56 | args = args or {}
57 | args.separator = args.separator or "|"
58 | args.separator_color = args.separator_color or beautiful.fg_normal
59 | ```
--------------------------------------------------------------------------------
/madwidgets/autotimer/autotimer.lua:
--------------------------------------------------------------------------------
1 | local gears = require("gears")
2 | local wibox = require("wibox")
3 | local beautiful = require("beautiful")
4 | local utils = require("madwidgets/utils")
5 | local multibutton = require("madwidgets/multibutton/multibutton")
6 |
7 | local autotimer = {}
8 | autotimer.max_minutes = 60000
9 | autotimer.actions = {}
10 |
11 | function autotimer.count_active()
12 | local count = 0
13 |
14 | for i, action in pairs(autotimer.actions) do
15 | if action then
16 | count = count + 1
17 | end
18 | end
19 |
20 | return count
21 | end
22 |
23 | function autotimer.do_stop(name)
24 | if not autotimer.active(name) then
25 | return
26 | end
27 |
28 | if autotimer.actions[name].mode == "timer" then
29 | autotimer.actions[name].timer:stop()
30 | end
31 |
32 | autotimer.container:remove_widgets(autotimer.actions[name].widget)
33 | autotimer.actions[name] = nil
34 |
35 | if autotimer.count_active() == 0 then
36 | autotimer.widget.visible = false
37 | end
38 | end
39 |
40 | function autotimer.active(name)
41 | return autotimer.actions[name] ~= nil
42 | end
43 |
44 | function init_timer(name, minutes)
45 | local m = math.min(autotimer.max_minutes, minutes)
46 |
47 | autotimer.actions[name].timer = gears.timer.start_new(m * 60, function()
48 | local action = autotimer.actions[name].action
49 | autotimer.do_stop(name)
50 | action()
51 | end)
52 | end
53 |
54 | function autotimer.start_timer(name, minutes, action)
55 | if minutes == 0 then
56 | return
57 | end
58 |
59 | autotimer.start(name)
60 | autotimer.actions[name].mode = "timer"
61 |
62 | local a = action or function() end
63 | autotimer.actions[name].action = a
64 |
65 | init_timer(name, minutes)
66 | autotimer.update()
67 | end
68 |
69 | function autotimer.start_counter(name)
70 | autotimer.start(name)
71 | autotimer.actions[name].mode = "counter"
72 | autotimer.update()
73 | end
74 |
75 | function autotimer.start(name)
76 | autotimer.do_stop(name)
77 | autotimer.actions[name] = {}
78 | autotimer.actions[name].name = name
79 |
80 | autotimer.actions[name].text_widget = wibox.widget({
81 | text = "",
82 | align = "center",
83 | valign = "center",
84 | widget = wibox.widget.textbox,
85 | })
86 |
87 | local args = {}
88 | args.widget = autotimer.actions[name].text_widget
89 |
90 | args.on_click = function()
91 | if autotimer.actions[name].mode == "timer" then
92 | utils.msg("Middle click to stop. Shift + Wheel to increase or decrease")
93 | elseif autotimer.actions[name].mode == "counter" then
94 | utils.msg("Middle click to stop")
95 | end
96 | end
97 |
98 | args.on_wheel_up = function(instance, mods)
99 | if utils.shift_pressed(mods) then
100 | autotimer.add_minutes(name, 5)
101 | else
102 | utils.switch_tag("prev")
103 | end
104 | end
105 |
106 | args.on_wheel_down = function(instance, mods)
107 | if utils.shift_pressed(mods) then
108 | autotimer.add_minutes(name, -5)
109 | else
110 | utils.switch_tag("next")
111 | end
112 | end
113 |
114 | args.on_middle_click = function()
115 | autotimer.stop(name)
116 | end
117 |
118 | args.fontcolor = autotimer.args.fontcolor
119 | args.bgcolor = autotimer.args.bgcolor
120 |
121 | autotimer.actions[name].widget = multibutton.create(args).widget
122 | autotimer.container:add(autotimer.actions[name].widget)
123 | autotimer.actions[name].date_started = os.time()
124 | autotimer.widget.visible = true
125 | utils.msg("Started " .. name)
126 | end
127 |
128 | function autotimer.add_minutes(name, minutes)
129 | local action = autotimer.actions[name]
130 |
131 | if action.mode == "timer" then
132 | action.timer:stop()
133 | local d = os.time() - action.date_started
134 | local s = action.timer.timeout - d
135 | local sm = utils.round(s / 60)
136 | local m = utils.round_mult(s / 60, 5)
137 | local new_m
138 |
139 | if minutes > 0 then
140 | if m > sm then
141 | new_m = m
142 | else
143 | new_m = m + minutes
144 | end
145 | else
146 | if m < sm then
147 | new_m = m
148 | else
149 | new_m = m + minutes
150 | end
151 | end
152 |
153 | new_m = math.max(new_m, 1)
154 | action.date_started = os.time()
155 | init_timer(name, new_m)
156 | autotimer.update()
157 | elseif action.mode == "counter" then
158 | local d = os.time() - action.date_started
159 | local s = d + minutes
160 | local m = utils.round_mult(s, 5)
161 |
162 | if m <= 0 then
163 | m = 1
164 | end
165 |
166 | action.date_started = os.time() - m
167 | autotimer.update()
168 | end
169 | end
170 |
171 | function autotimer.stop(name)
172 | if not autotimer.active(name) then
173 | utils.msg(name .. " is not active")
174 | return
175 | end
176 |
177 | autotimer.do_stop(name)
178 | utils.msg(name .. " stopped")
179 | end
180 |
181 | function autotimer.update()
182 | for i, action in pairs(autotimer.actions) do
183 | if not autotimer.active(action.name) then
184 | return
185 | end
186 |
187 | local r
188 | local d = os.time() - action.date_started
189 |
190 | if action.mode == "timer" then
191 | if action.timer == nil then
192 | return
193 | end
194 |
195 | r = action.timer.timeout - d
196 | elseif action.mode == "counter" then
197 | if d / 60 >= autotimer.max_minutes then
198 | autotimer.do_stop(action.name)
199 | return
200 | end
201 |
202 | r = d
203 | end
204 |
205 | local t = r / 60
206 | local u
207 | local s
208 |
209 | if t >= 60 then
210 | u = utils.round_decimal(r / 60 / 60, 1)
211 | s = "hrs"
212 | elseif t >= 1 then
213 | u = utils.numpad(utils.round(r / 60))
214 | s = "mins"
215 | else
216 | u = utils.numpad(utils.round(r))
217 | s = "secs"
218 | end
219 |
220 | action.text_widget.text = action.name .. ": " .. u .. " " .. s
221 | end
222 | end
223 |
224 | function autotimer.create(args)
225 | args = args or {}
226 | args.separator = args.separator or "|"
227 | args.separator_color = args.separator_color or beautiful.fg_normal
228 |
229 | autotimer.container = wibox.widget({
230 | spacing = 25,
231 | spacing_widget = {
232 | markup = ""
235 | .. gears.string.xml_escape(args.separator)
236 | .. "",
237 | align = "center",
238 | valign = "center",
239 | widget = wibox.widget.textbox,
240 | },
241 | widget = wibox.layout.fixed.horizontal,
242 | })
243 |
244 | args.widget = autotimer.container
245 | autotimer.widget = multibutton.create(args).widget
246 | autotimer.widget.visible = false
247 | autotimer.args = args
248 | end
249 |
250 | autotimer.update_timer = gears.timer({
251 | timeout = 1,
252 | call_now = false,
253 | autostart = true,
254 | single_shot = false,
255 | callback = function()
256 | autotimer.update()
257 | end,
258 | })
259 |
260 | return autotimer
261 |
--------------------------------------------------------------------------------
/madwidgets/doubletap/README.md:
--------------------------------------------------------------------------------
1 | # doubletap
2 |
3 | This simulates a double-click trigger.
4 |
5 | To create:
6 |
7 | Put this near the top:
8 | >local doubletap = require("madwidgets/doubletap/doubletap")
9 |
10 | ```lua
11 | local mytap = doubletap.create({
12 | delay = 300,
13 | action = function()
14 | something()
15 | end
16 | })
17 | ```
18 |
19 | To trigger just bind instance.trigger() to some keybind:
20 |
21 | ```lua
22 | awful.key({modkey}, "Delete", function()
23 | mytap.trigger()
24 | end)
25 | ```
26 |
27 | So for instance if modkey+delete is triggered twice before 300ms, it will trigger the action.
28 |
29 | ## Example Usage
30 |
31 | Map a key combo to the dpi button or some other convenient button of your mouse.
32 |
33 | Bind a doubletap to that key combo.
34 |
35 | Double click the button to trigger an action to close the client below the cursor.
36 |
37 | This is a quick way to close windows.
38 |
39 | ```lua
40 | local closetap = doubletap.create({
41 | delay = 300,
42 | lockdelay = 1000,
43 | action = function()
44 | mouse.object_under_pointer():kill()
45 | end
46 | })
47 | ```
48 |
49 | >delay (ms)
50 |
51 | Two taps need to happen <= this range to trigger. So for instance 200 needs quick taps while 2000 can be slow taps.
52 |
53 | >lockdelay (ms)
54 |
55 | After the last trigger, the taps will be locked until this time has passed. This is to avoid accidental double taps in some cases.
--------------------------------------------------------------------------------
/madwidgets/doubletap/doubletap.lua:
--------------------------------------------------------------------------------
1 | local gears = require("gears")
2 | local lockdelay = require("madwidgets/lockdelay/lockdelay")
3 |
4 | local doubletap = {}
5 |
6 | function doubletap.create(args)
7 | args = args or {}
8 | local tap = {}
9 | args.delay = args.delay or 300
10 | args.lockdelay = args.lockdelay or 0
11 | args.action = args.action or function() end
12 |
13 | local taptimer = gears.timer({
14 | timeout = args.delay / 1000,
15 | })
16 |
17 | taptimer:connect_signal("timeout", function()
18 | taptimer:stop()
19 | end)
20 |
21 | tap.lockdelay = lockdelay.create({ action = args.action, delay = args.lockdelay })
22 |
23 | function tap.trigger()
24 | if taptimer.started then
25 | tap.lockdelay.trigger()
26 | else
27 | taptimer:start()
28 | end
29 | end
30 |
31 | return tap
32 | end
33 |
34 | return doubletap
35 |
--------------------------------------------------------------------------------
/madwidgets/hotcorner/hotcorner.lua:
--------------------------------------------------------------------------------
1 | local awful = require("awful")
2 | local wibox = require("wibox")
3 | local multibutton = require("madwidgets/multibutton/multibutton")
4 | local hotcorner = {}
5 |
6 | function hotcorner.create(args)
7 | local instance = {}
8 |
9 | args.text = "."
10 | args.opacity = 0
11 | local dot = multibutton.create(args).widget
12 |
13 | local x, y
14 | local size = 2
15 |
16 | if args.placement == "top_left" then
17 | x = args.screen.geometry.x
18 | y = args.screen.geometry.y
19 | elseif args.placement == "top_right" then
20 | x = args.screen.geometry.x + (args.screen.geometry.width - size)
21 | y = args.screen.geometry.y
22 | end
23 |
24 | instance.widget = wibox({
25 | x = x,
26 | y = y,
27 | visible = true,
28 | screen = args.screen,
29 | ontop = true,
30 | height = size,
31 | width = size,
32 | type = "utility",
33 | widget = dot,
34 | })
35 |
36 | return instance
37 | end
38 |
39 | return hotcorner
40 |
--------------------------------------------------------------------------------
/madwidgets/lockdelay/README.md:
--------------------------------------------------------------------------------
1 | # lockdelay
2 |
3 | Temporarily lock a function from executing
4 |
5 | To create:
6 |
7 | Put this near the top:
8 | >local lockdelay = require("madwidgets/lockdelay/lockdelay")
9 |
10 | ```
11 | lock = lockdelay.create({action=some_function, delay=time_in_milliseconds})
12 | lock.trigger(...)
13 | ```
--------------------------------------------------------------------------------
/madwidgets/lockdelay/lockdelay.lua:
--------------------------------------------------------------------------------
1 | local gears = require("gears")
2 | local lockdelay = {}
3 |
4 | function lockdelay.create(args)
5 | args = args or {}
6 | local lock = {}
7 | local locked = false
8 | args.delay = args.delay or 0
9 | args.action = args.action or function() end
10 | local d = args.delay / 1000
11 |
12 | function lock.trigger(arg)
13 | if locked then
14 | return
15 | else
16 | locked = true
17 | gears.timer.start_new(d, function()
18 | locked = false
19 | return false
20 | end)
21 | args.action(arg)
22 | end
23 | end
24 |
25 | return lock
26 | end
27 |
28 | return lockdelay
29 |
--------------------------------------------------------------------------------
/madwidgets/menupanel/README.md:
--------------------------------------------------------------------------------
1 | # menupanel
2 |
3 | This creates a panel that can be toggled temporarily to present buttons.
4 |
5 | It's meant to replace the main panel until closed.
6 |
7 | 
8 |
9 | ## To use it
10 |
11 | Put this near the top:
12 | >local menupanel = require("madwidgets/menupanel/menupanel")
13 |
14 | Add the following after theme definitions like font size are set:
15 |
16 | ```lua
17 | local mp_main = menupanel.create({
18 | placement = "bottom",
19 | height = 25,
20 | speak = false,
21 | hide_button = true,
22 | hide_button_placement = "left",
23 | items = {
24 | {
25 | name = "Launch an Application",
26 | action = function() launcher() end
27 | },
28 | {
29 | name = "Open Video On Clipboard",
30 | action = function() video_from_clipboard() end,
31 | needs_confirm = true
32 | },
33 | {
34 | name = "Open Symbols Picker",
35 | action = function() symbolmenu() end
36 | },
37 | }
38 | })
39 | ```
40 |
41 | All arguments are shown in the example above. It's not necessary to define all of them.
42 |
43 | To start a menu panel use .start()
44 |
45 | Mode are `keyboard` or `mouse`
46 |
47 | >instance.start("keyboard")
48 |
49 | >instance.start("mouse")
50 |
51 | To show a new panel on top of the previous one:
52 |
53 | Try something like this:
54 |
55 | ```
56 | {
57 | name = "Launch",
58 | action = function(trigger) somepanel.show(trigger) end,
59 | },
60 | ```
61 |
62 | Action returns a trigger which is either `action_mouse` or `action_keyboard`.
63 |
64 | To hide:
65 |
66 | >instance.hide()
67 |
68 | It is able to speak out items if "speak" property is set to true. It uses espeak for this.
69 |
70 | ## Actions
71 |
72 | Click (or Enter) triggers an action and hides the panel.
73 |
74 | Middle click (or Shift+Enter) triggers an action but doesn't hide the panel.
75 |
76 | There is a 'parent' property that can reference another menupanel instance.
77 | Doing this enables showing the parent menupanel when Esc is pressed on the current menupanel.
78 | This is a way to form menus with submenus using multiple menupanels.
79 |
80 | Escape or clicking the x button hides the menupanel or goes to parent.
81 |
82 | Shift+Escape hides the menupanel completely (doesn't go to parent)
83 |
84 | ## Theming
85 |
86 | You can use these arguments to customize the look of a menupanel:
87 |
88 | >bgcolor
89 |
90 | >bgcolor2
91 |
92 | >fontcolor
93 |
94 | >bordercolor
95 |
96 | >bordercolor2
97 |
98 | Whether to use the primary screen when opening with keyboard. Defaults to true
99 |
100 | >primary_mode
101 |
102 | Define the primary screen. Defaults to 1
103 |
104 | >primary_screen
105 |
106 | There's an instance method to update an item programatically:
107 |
108 | >instance.update_item(index, name, action)
--------------------------------------------------------------------------------
/madwidgets/menupanel/menupanel.lua:
--------------------------------------------------------------------------------
1 | local awful = require("awful")
2 | local wibox = require("wibox")
3 | local gears = require("gears")
4 |
5 | local menupanel = {}
6 | local instances = {}
7 | local modkey = "Shift"
8 |
9 | function menupanel.get_button_under_cursor(instance)
10 | local w = mouse.current_widget
11 | if w ~= nil and w.x_index ~= nil then
12 | return w.x_index
13 | end
14 | end
15 |
16 | function menupanel.set_screen(instance, mode)
17 | if instance.args.primary_mode and string.find(mode, "keyboard") then
18 | instance.widget.screen = instance.args.primary_screen
19 | else
20 | instance.widget.screen = awful.screen.focused()
21 | end
22 | end
23 |
24 | function menupanel.speak(txt)
25 | awful.spawn.with_shell('pkill espeak; espeak "' .. txt .. '"', false)
26 | end
27 |
28 | function menupanel.focus_button(instance, btn)
29 | btn.bg = instance.args.bgcolor2
30 | btn.fg = instance.args.fontcolor
31 | btn.border_color = instance.args.bordercolor2
32 | if instance.args.speak then
33 | menupanel.speak(btn.textbox.text)
34 | end
35 | instance.focused = btn.x_index
36 | menupanel.reset_confirm_charges(instance)
37 | menupanel.unfocus_button(instance, instance.hide_button)
38 | end
39 |
40 | function menupanel.unfocus_button(instance, btn)
41 | btn.bg = instance.args.bgcolor
42 | btn.fg = instance.args.fontcolor
43 | btn.border_color = instance.args.bordercolor
44 | end
45 |
46 | function menupanel.unfocus_except(instance, index)
47 | for i, btn in ipairs(instance.buttons) do
48 | if i == index then
49 | menupanel.focus_button(instance, btn)
50 | else
51 | menupanel.unfocus_button(instance, btn)
52 | end
53 | end
54 | end
55 |
56 | function menupanel.unfocus_all(instance)
57 | for i, btn in ipairs(instance.buttons) do
58 | menupanel.unfocus_button(instance, btn)
59 | end
60 | instance.focused = 0
61 | end
62 |
63 | function menupanel.hide_all(instance)
64 | for i, insta in ipairs(instances) do
65 | if insta.widget.visible then
66 | insta.hide()
67 | end
68 | end
69 | end
70 |
71 | function menupanel.show_parent(instance)
72 | if instance.args.parent ~= nil then
73 | instance.args.parent.show("parent_" .. instance.trigger)
74 | end
75 | end
76 |
77 | function menupanel.hide2(instance)
78 | instance.hide()
79 | menupanel.show_parent(instance)
80 | end
81 |
82 | function menupanel.action(instance, item, mode)
83 | if mode == 1 or mode == 2 then
84 | if item.action ~= nil then
85 | if item.needs_confirm then
86 | if item.confirm_charge < 1 then
87 | menupanel.reset_confirm_charges_except(instance, item.x_index)
88 | item.confirm_charge = item.confirm_charge + 1
89 | local btn = instance.buttons[item.x_index]
90 | menupanel.confirm_charge_border(btn)
91 | if instance.args.speak then
92 | menupanel.speak("Confirm " .. btn.textbox.xoriginaltext)
93 | end
94 | else
95 | menupanel.reset_confirm_charges(instance)
96 | if mode == 1 then
97 | instance.hide()
98 | end
99 | item.action("action_" .. instance.trigger)
100 | end
101 | else
102 | if mode == 1 then
103 | instance.hide()
104 | end
105 | item.action("action_" .. instance.trigger)
106 | end
107 | end
108 | end
109 | end
110 |
111 | function menupanel.reset_confirm_charges(instance)
112 | for i, item in ipairs(instance.args.items) do
113 | item.confirm_charge = 0
114 | local btn = instance.buttons[i]
115 | btn.textbox.text = btn.textbox.xoriginaltext
116 | end
117 | end
118 |
119 | function menupanel.reset_confirm_charges_except(instance, index)
120 | for i, item in ipairs(instance.args.items) do
121 | if i ~= index then
122 | item.confirm_charge = 0
123 | local btn = instance.buttons[i]
124 | btn.textbox.text = btn.textbox.xoriginaltext
125 | end
126 | end
127 | end
128 |
129 | function menupanel.confirm_charge_border(btn)
130 | btn.textbox.text = "*" .. btn.textbox.xoriginaltext .. "*"
131 | end
132 |
133 | function menupanel.basic_button(instance, textbox)
134 | return wibox.widget({
135 | textbox,
136 | widget = wibox.container.background,
137 | border_width = 1,
138 | border_color = instance.args.bordercolor,
139 | })
140 | end
141 |
142 | function menupanel.create_textbox(text)
143 | return wibox.widget({
144 | text = text,
145 | align = "center",
146 | widget = wibox.widget.textbox,
147 | })
148 | end
149 |
150 | function menupanel.prepare_button(instance, textbox, index)
151 | local button = menupanel.basic_button(instance, textbox)
152 |
153 | button.x_index = index
154 | button.textbox = textbox
155 | button.textbox.xoriginaltext = textbox.text
156 |
157 | button:connect_signal("mouse::enter", function(btn)
158 | menupanel.unfocus_except(instance, index)
159 | end)
160 |
161 | return button
162 | end
163 |
164 | function menupanel.prepare_hide_button(instance, textbox)
165 | local button = menupanel.basic_button(instance, textbox)
166 |
167 | button:connect_signal("mouse::enter", function(btn)
168 | menupanel.focus_hide_button(instance)
169 | end)
170 |
171 | return button
172 | end
173 |
174 | function menupanel.focus_hide_button(instance)
175 | instance.hide_button.bg = instance.args.bgcolor2
176 | instance.hide_button.fg = instance.args.fontcolor
177 | instance.hide_button.border_color = instance.args.bordercolor2
178 | menupanel.unfocus_all(instance)
179 | end
180 |
181 | function menupanel.create(args)
182 | args = args or {}
183 |
184 | if args.speak == nil then
185 | args.speak = false
186 | end
187 |
188 | if args.hide_button == nil then
189 | args.hide_button = true
190 | end
191 |
192 | args.height = args.height or 30
193 | args.hide_button_placement = args.hide_button_placement or "left"
194 | args.placement = args.placement or "bottom"
195 | args.bgcolor = args.bgcolor or "#21252B"
196 | args.bgcolor2 = args.bgcolor2 or "#2F333D"
197 | args.fontcolor = args.fontcolor or "#B8bABC"
198 | args.bordercolor = args.bordercolor or "#485767"
199 | args.bordercolor2 = args.bordercolor2 or "#11A8CD"
200 | args.primary_screen = args.primary_screen or 1
201 | args.primary_mode = args.primary_mode or true
202 |
203 | local instance = {}
204 | instance.args = args
205 |
206 | instance.widget = awful.popup({
207 | placement = args.placement,
208 | ontop = true,
209 | visible = true,
210 | border_width = 0,
211 | minimum_height = args.height,
212 | minimum_width = awful.screen.focused().geometry.width,
213 | widget = wibox.container.background,
214 | bg = args.bgcolor,
215 | fg = args.fontcolor,
216 | })
217 |
218 | instance.focused = 1
219 |
220 | instance.keygrabber = awful.keygrabber({
221 | keybindings = {
222 | {
223 | {},
224 | "Left",
225 | function()
226 | if instance.focused > 1 then
227 | instance.focused = instance.focused - 1
228 | menupanel.unfocus_except(instance, instance.focused)
229 | else
230 | if args.hide_button_placement == "left" then
231 | menupanel.focus_hide_button(instance)
232 | end
233 | end
234 | end,
235 | },
236 | {
237 | {},
238 | "Right",
239 | function()
240 | if instance.focused < #instance.args.items then
241 | instance.focused = instance.focused + 1
242 | menupanel.unfocus_except(instance, instance.focused)
243 | else
244 | if args.hide_button_placement == "right" then
245 | menupanel.focus_hide_button(instance)
246 | end
247 | end
248 | end,
249 | },
250 | {
251 | {},
252 | "Return",
253 | function()
254 | instance.trigger = "keyboard"
255 | if instance.focused > 0 then
256 | menupanel.action(instance, instance.args.items[instance.focused], 1)
257 | else
258 | menupanel.hide2(instance)
259 | end
260 | end,
261 | },
262 | {
263 | { modkey },
264 | "Return",
265 | function()
266 | instance.trigger = "keyboard"
267 | if instance.focused > 0 then
268 | menupanel.action(instance, instance.args.items[instance.focused], 2)
269 | else
270 | menupanel.hide2(instance)
271 | end
272 | end,
273 | },
274 | {
275 | {},
276 | "Escape",
277 | function()
278 | instance.trigger = "keyboard"
279 | menupanel.hide2(instance)
280 | end,
281 | },
282 | {
283 | { modkey },
284 | "Escape",
285 | function()
286 | instance.trigger = "keyboard"
287 | menupanel.hide_all(instance)
288 | end,
289 | },
290 | },
291 | })
292 |
293 | -- Methods
294 |
295 | function instance.show(mode)
296 | menupanel.hide_all(instance)
297 | menupanel.set_screen(instance, mode)
298 | menupanel.reset_confirm_charges(instance)
299 | instance.widget.visible = true
300 |
301 | local index = 1
302 |
303 | if mode == "parent_keyboard" then
304 | index = instance.focused
305 | elseif mode == "keyboard" then
306 | index = 1
307 | elseif string.find(mode, "mouse") then
308 | index = menupanel.get_button_under_cursor(instance)
309 | end
310 |
311 | instance.focused = index
312 |
313 | if instance.focused == 0 then
314 | menupanel.focus_hide_button(instance)
315 | else
316 | menupanel.unfocus_except(instance, instance.focused)
317 | end
318 |
319 | instance.keygrabber:start()
320 | end
321 |
322 | function instance.start(mode)
323 | gears.timer.start_new(0.025, function()
324 | instance.show(mode)
325 | end)
326 | end
327 |
328 | function instance.hide()
329 | instance.widget.visible = false
330 | instance.keygrabber:stop()
331 | end
332 |
333 | function instance.update_item(index, name, action)
334 | if name then
335 | instance.args.items[index].name = name
336 | instance.buttons[index].textbox.text = name
337 | instance.buttons[index].textbox.xoriginaltext = name
338 | end
339 |
340 | if action then
341 | instance.args.items[index].action = action
342 | end
343 | end
344 |
345 | function instance.get_item(index)
346 | return instance.args.items[index]
347 | end
348 |
349 | -- Items
350 |
351 | instance.buttons = {}
352 |
353 | for i, item in ipairs(args.items) do
354 | if item.needs_confirm == nil then
355 | item.needs_confirm = false
356 | end
357 |
358 | item.x_index = i
359 | item.confirm_charge = 0
360 |
361 | local textbox = menupanel.create_textbox(item.name)
362 |
363 | textbox:connect_signal("button::press", function(_, _, _, mode)
364 | instance.trigger = "mouse"
365 | menupanel.action(instance, item, mode)
366 | end)
367 |
368 | textbox.x_index = i
369 | table.insert(instance.buttons, menupanel.prepare_button(instance, textbox, i))
370 | end
371 |
372 | -- Setup
373 |
374 | local left = {
375 | layout = wibox.layout.fixed.horizontal,
376 | }
377 |
378 | local middle = wibox.widget({
379 | layout = wibox.layout.ratio.horizontal,
380 | table.unpack(instance.buttons),
381 | })
382 |
383 | local right = {
384 | layout = wibox.layout.fixed.horizontal,
385 | }
386 |
387 | if args.hide_button then
388 | local textbox = menupanel.create_textbox(" x ")
389 |
390 | textbox:connect_signal("button::press", function(_, _, _, mode)
391 | instance.trigger = "mouse"
392 | menupanel.hide2(instance)
393 | end)
394 |
395 | textbox.x_index = 0
396 | instance.hide_button = menupanel.prepare_hide_button(instance, textbox)
397 |
398 | if args.hide_button_placement == "left" then
399 | table.insert(left, instance.hide_button)
400 | elseif args.hide_button_placement == "right" then
401 | table.insert(right, instance.hide_button)
402 | end
403 | end
404 |
405 | instance.widget:setup({
406 | layout = wibox.layout.align.horizontal,
407 | left,
408 | middle,
409 | right,
410 | })
411 |
412 | -- Hide instances when clicking outside
413 |
414 | function menupanel.on_unfocus()
415 | menupanel.hide_all(instance)
416 | end
417 |
418 | button.connect_signal("press", menupanel.on_unfocus)
419 |
420 | instance.widget:connect_signal("mouse::leave", function()
421 | button.connect_signal("press", menupanel.on_unfocus)
422 | end)
423 |
424 | instance.widget:connect_signal("mouse::enter", function()
425 | button.disconnect_signal("press", menupanel.on_unfocus)
426 | end)
427 |
428 | instance.widget:connect_signal("property::visible", function(self)
429 | if not self.visible then
430 | button.disconnect_signal("press", menupanel.on_unfocus)
431 | end
432 | end)
433 |
434 | -- Timer to give time for widget to get drawn
435 |
436 | gears.timer.start_new(0.5, function()
437 | instance.widget.visible = false
438 | end)
439 |
440 | table.insert(instances, instance)
441 | return instance
442 | end
443 |
444 | return menupanel
445 |
--------------------------------------------------------------------------------
/madwidgets/multibutton/README.md:
--------------------------------------------------------------------------------
1 | # multibutton
2 |
3 | Generic programmable button that is easy to bind click events to.
4 |
5 | Put this near the top:
6 | >local multibutton = require("madwidgets/multibutton/multibutton")
7 |
8 | Then include the button or buttons somewhere like:
9 |
10 | ```lua
11 | left = {
12 | layout = wibox.layout.fixed.horizontal,
13 | multibutton.create({
14 | text = "❇",
15 | on_click = function(btn)
16 | menupanels.main.toggle()
17 | end,
18 | on_middle_click = function(btn)
19 | lockscreen()
20 | end,
21 | on_right_click = function(btn)
22 | dropdown()
23 | end,
24 | on_wheel_up = function(btn)
25 | prev_tag()
26 | end,
27 | on_wheel_down = function(btn)
28 | next_tag()
29 | end,
30 | on_mouse_enter = function(btn)
31 | something()
32 | end,
33 | on_mouse_leave = function(btn)
34 | something()
35 | end,
36 | bgcolor = "#000000",
37 | fontcolor = "#ffffff"
38 | }),
39 | s.mytaglist,
40 | wibox.widget.textbox(" "),
41 | }
42 | ```
43 |
44 | If a 'widget' argument is provided it will use that instead of creating a textbox with the text.
45 |
46 | Not all arguments need to be provided.
--------------------------------------------------------------------------------
/madwidgets/multibutton/multibutton.lua:
--------------------------------------------------------------------------------
1 | local wibox = require("wibox")
2 | local gears = require("gears")
3 | local beautiful = require("beautiful")
4 | local utils = require("madwidgets/utils")
5 |
6 | local multibutton = {}
7 |
8 | function multibutton.create(args)
9 | args = args or {}
10 | args.on_click = args.on_click or function() end
11 | args.on_click_2 = args.on_click_2 or function() end
12 | args.on_middle_click = args.on_middle_click or function() end
13 | args.on_right_click = args.on_right_click or function() end
14 | args.on_wheel_up = args.on_wheel_up or function() end
15 | args.on_wheel_down = args.on_wheel_down or function() end
16 | args.on_mouse_enter = args.on_mouse_enter or function() end
17 | args.on_mouse_leave = args.on_mouse_leave or function() end
18 | args.on_left_text_click = args.on_left_text_click or function() end
19 | args.on_right_text_click = args.on_right_text_click or function() end
20 | args.bgcolor = args.bgcolor or beautiful.bg_normal
21 | args.fontcolor = args.fontcolor or beautiful.fg_normal
22 | args.left = args.left or ""
23 | args.right = args.right or ""
24 | args.left_color = args.left_color or beautiful.fg_normal
25 | args.right_color = args.right_color or beautiful.fg_normal
26 | args.side_actions = args.side_actions or true
27 | args.opacity = args.opacity or 1
28 |
29 | local instance = {}
30 | instance.args = args
31 |
32 | instance.left_text = wibox.widget({
33 | align = "center",
34 | valign = "center",
35 | markup = "" .. gears.string.xml_escape(args.left) .. "",
36 | widget = wibox.widget.textbox,
37 | })
38 |
39 | local left = {
40 | layout = wibox.layout.fixed.horizontal,
41 | instance.left_text,
42 | }
43 |
44 | instance.right_text = wibox.widget({
45 | align = "center",
46 | valign = "center",
47 | markup = "" .. gears.string.xml_escape(args.right) .. "",
48 | widget = wibox.widget.textbox,
49 | })
50 |
51 | local right = {
52 | layout = wibox.layout.fixed.horizontal,
53 | instance.right_text,
54 | }
55 |
56 | if args.widget then
57 | instance.subwidget = args.widget
58 | elseif args.text then
59 | instance.subwidget = wibox.widget({
60 | align = "center",
61 | valign = "center",
62 | text = args.text,
63 | widget = wibox.widget.textbox,
64 | })
65 | else
66 | return {}
67 | end
68 |
69 | local center = {
70 | layout = wibox.layout.align.horizontal,
71 | {
72 | widget = wibox.widget.textbox,
73 | },
74 | instance.subwidget,
75 | {
76 | widget = wibox.widget.textbox,
77 | },
78 | }
79 |
80 | instance.widget = wibox.widget({
81 | widget = wibox.container.background,
82 | bg = args.bgcolor,
83 | fg = args.fontcolor,
84 | opacity = args.opacity,
85 | })
86 |
87 | instance.widget:setup({
88 | layout = wibox.layout.align.horizontal,
89 | left,
90 | center,
91 | right,
92 | })
93 |
94 | function instance.action(button, mods)
95 | if button == 1 then
96 | args.on_click(instance, mods)
97 | elseif button == 2 then
98 | args.on_middle_click(instance, mods)
99 | elseif button == 3 then
100 | args.on_right_click(instance, mods)
101 | elseif button == 4 then
102 | args.on_wheel_up(instance, mods)
103 | elseif button == 5 then
104 | args.on_wheel_down(instance, mods)
105 | end
106 | end
107 |
108 | function instance.underline(button)
109 | instance.subwidget:set_markup("" .. instance.subwidget.text .. "")
110 | end
111 |
112 | function instance.normal(button)
113 | instance.subwidget:set_markup(instance.subwidget.text)
114 | end
115 |
116 | instance.subwidget:connect_signal("button::press", function(a, b, c, button, mods)
117 | instance.action(button, mods)
118 | end)
119 |
120 | if args.side_actions then
121 | instance.left_text:connect_signal("button::press", function(a, b, c, button, mods)
122 | instance.action(button, mods)
123 | end)
124 |
125 | instance.right_text:connect_signal("button::press", function(a, b, c, button, mods)
126 | instance.action(button, mods)
127 | end)
128 | end
129 |
130 | instance.subwidget:connect_signal("button::release", function(a, b, c, button, mods)
131 | if button == 1 then
132 | args.on_click_2(instance)
133 | end
134 | end)
135 |
136 | instance.left_text:connect_signal("button::press", function(a, b, c, button, mods)
137 | if button == 1 then
138 | args.on_left_text_click(instance)
139 | end
140 | end)
141 |
142 | instance.right_text:connect_signal("button::press", function(a, b, c, button, mods)
143 | if button == 1 then
144 | args.on_right_text_click(instance)
145 | end
146 | end)
147 |
148 | instance.widget:connect_signal("mouse::enter", function()
149 | args.on_mouse_enter(instance)
150 | end)
151 |
152 | instance.widget:connect_signal("mouse::leave", function()
153 | args.on_mouse_leave(instance)
154 | end)
155 |
156 | return instance
157 | end
158 |
159 | return multibutton
160 |
--------------------------------------------------------------------------------
/madwidgets/overlay/README.md:
--------------------------------------------------------------------------------
1 | Show an overlay in the middle of the screen.
2 |
3 | For instance to show desktop number on tag change.
4 |
5 | ```lua
6 | args.delay = args.delay or 2
7 | args.bgcolor = args.bgcolor or "#000000"
8 | args.fontcolor = args.fontcolor or "#ffffff"
9 | args.bordercolor = args.bordercolor or "#d8dee9"
10 | args.font = args.font or "monospace 18"
11 | args.height = args.height or 55
12 | args.borderwidth = args.borderwidth or 1
13 | ```
14 |
15 | ```lua
16 | local overlay = require("madwidgets/overlay/overlay")
17 |
18 | Overlay = overlay.create({
19 | delay = 2,
20 | bgcolor = "#000000",
21 | fontcolor = "#ffffff"
22 | })
23 |
24 | Overlay.show("some text")
25 | ```
--------------------------------------------------------------------------------
/madwidgets/overlay/overlay.lua:
--------------------------------------------------------------------------------
1 | local awful = require("awful")
2 | local wibox = require("wibox")
3 | local gears = require("gears")
4 |
5 | local overlay = {}
6 |
7 | function overlay.create(args)
8 | local instance = {}
9 | args.delay = args.delay or 1.5
10 | args.bgcolor = args.bgcolor or "#445666"
11 | args.fontcolor = args.fontcolor or "#d5dAf0"
12 | args.textbox_bgcolor = args.textbox_bgcolor or "#445666"
13 | args.textbox_fontcolor = args.textbox_fontcolor or "#d5dAf0"
14 | args.bordercolor = args.bordercolor or "#d5dAf0"
15 | args.font = args.font or "monospace 16"
16 | args.height = args.height or 55
17 | args.borderwidth = args.borderwidth or 1
18 | args.widget = args.widget or wibox.widget({})
19 | args.screen = args.screen or 1
20 |
21 | instance.widget = awful.popup({
22 | placement = "centered",
23 | ontop = true,
24 | visible = false,
25 | border_width = 1,
26 | widget = wibox.container.background,
27 | bg = args.bgcolor,
28 | fg = args.fontcolor,
29 | border_color = args.bordercolor,
30 | border_width = args.borderwidth,
31 | })
32 |
33 | instance.textbox = wibox.widget({
34 | markup = "---:---%",
35 | align = "center",
36 | valign = "center",
37 | widget = wibox.widget.textbox,
38 | font = args.font,
39 | forced_height = args.height,
40 | })
41 |
42 | local textbox = wibox.widget({
43 | instance.textbox,
44 | widget = wibox.container.background,
45 | bg = args.textbox_bgcolor,
46 | fg = args.textbox_fontcolor,
47 | })
48 |
49 | instance.widget:setup({
50 | layout = wibox.layout.align.vertical,
51 | textbox,
52 | args.widget,
53 | })
54 |
55 | instance.widget:connect_signal("mouse::enter", function()
56 | instance.hide()
57 | end)
58 |
59 | instance.timer = gears.timer({
60 | timeout = args.delay,
61 | autostart = false,
62 | })
63 |
64 | instance.timer:connect_signal("timeout", function()
65 | instance.hide()
66 | end)
67 |
68 | function instance.hide()
69 | instance.widget.visible = false
70 | end
71 |
72 | function instance.show(text)
73 | instance.textbox.text = " " .. text .. " "
74 | instance.widget.screen = args.screen
75 | instance.widget.visible = true
76 |
77 | if instance.timer.started then
78 | instance.timer:stop()
79 | end
80 |
81 | instance.timer:start()
82 | end
83 |
84 | return instance
85 | end
86 |
87 | return overlay
88 |
--------------------------------------------------------------------------------
/madwidgets/sysmonitor/README.md:
--------------------------------------------------------------------------------
1 | # sysmonitor
2 |
3 | Show CPU, RAM, Temperature, or Net Download/Upload
4 |
5 | 
6 |
7 | ## To use it
8 |
9 | Put this near the top:
10 | >local sysmonitor = require("madwidgets/sysmonitor/sysmonitor")
11 |
12 | Then place it somewhere in the panel:
13 |
14 | ```
15 | sysmonitor.create({
16 | mode = "cpu"
17 | })
18 | ```
19 |
20 | Available modes:
21 |
22 | - cpu
23 | - ram
24 | - tmp
25 | - net_download
26 | - net_upload
27 |
28 | Use multibutton to wrap the widget with mouse events:
29 |
30 | ```
31 | local cpu_widget = sysmonitor.create({
32 | mode = "cpu", bgcolor = beautiful.bg_normal,
33 | fontcolor = nicegreen, alertcolor = nicered,
34 | left = " ", right = " "
35 | }).widget
36 |
37 | multibutton.create({
38 | widget = cpu_widget,
39 | on_click = function()
40 | system_monitor()
41 | end,
42 | on_wheel_down = function()
43 | decrease_volume()
44 | end,
45 | on_wheel_up = function()
46 | increase_volume()
47 | end
48 | })
49 | ```
50 |
51 | Every type has an `alert_max` value. If not defined as an argument it uses a default.
52 |
53 | When this limit is reached, the font color turns to alertcolor, else it uses fontcolor.
54 |
55 | (alert_max of net monitors are calculated in megabits)
56 |
57 | A specific command to be used can be passed with the "command" argument.
58 |
59 | A specific timer timeout to be used can be passed with the "timeout" argument.
--------------------------------------------------------------------------------
/madwidgets/sysmonitor/sysmonitor.lua:
--------------------------------------------------------------------------------
1 | local awful = require("awful")
2 | local wibox = require("wibox")
3 | local gears = require("gears")
4 | local utils = require("madwidgets/utils")
5 | local multibutton = require("madwidgets/multibutton/multibutton")
6 |
7 | local sysmonitor = {}
8 |
9 | function sysmonitor.update_string(instance, s, u)
10 | local t = ""
11 | local mode = instance.args.mode
12 |
13 | if mode == "cpu" then
14 | t = "CPU"
15 | u = "%"
16 | elseif mode == "ram" then
17 | t = "RAM"
18 | u = "%"
19 | elseif mode == "tmp" then
20 | t = "TMP"
21 | u = "°"
22 | elseif mode == "gpu" then
23 | t = "GPU"
24 | u = "%"
25 | elseif mode == "gpu_ram" then
26 | t = "GPU RAM"
27 | u = "%"
28 | elseif mode == "net_download" then
29 | t = "DW"
30 | elseif mode == "net_upload" then
31 | t = "UP"
32 | else
33 | return
34 | end
35 |
36 | u = u or "?"
37 |
38 | local new_text = t .. ":" .. s .. u
39 |
40 | if instance.current_text ~= new_text then
41 | instance.text_widget.text = new_text
42 | instance.current_text = new_text
43 | end
44 | end
45 |
46 | function sysmonitor.check_alert(instance, n)
47 | if n >= instance.args.alert_max then
48 | if instance.current_color ~= instance.args.alertcolor then
49 | instance.widget.fg = instance.args.alertcolor
50 | instance.current_color = instance.args.alertcolor
51 | end
52 | else
53 | if instance.current_color ~= instance.args.fontcolor then
54 | instance.widget.fg = instance.args.fontcolor
55 | instance.current_color = instance.args.fontcolor
56 | end
57 | end
58 | end
59 |
60 | function sysmonitor.default_string(instance)
61 | sysmonitor.update_string(instance, "---")
62 | end
63 |
64 | function sysmonitor.on_null(instance)
65 | sysmonitor.default_string(instance)
66 | sysmonitor.check_alert(instance, 0)
67 | instance.timer:again()
68 | end
69 |
70 | function sysmonitor.calc_net(instance)
71 | local cmd = "ip route show default | awk '/default/ {print $5; exit}'"
72 |
73 | awful.spawn.easy_async_with_shell(cmd, function(dev)
74 | dev = utils.trim(dev)
75 |
76 | if not dev or dev == "" then
77 | sysmonitor.on_null(instance)
78 | return
79 | end
80 |
81 | local cmd2 = string.format(instance.args.command, dev)
82 |
83 | awful.spawn.easy_async_with_shell(cmd2 .. "; sleep 1", function(o)
84 | if not utils.isnumber(o) then
85 | sysmonitor.on_null(instance)
86 | return
87 | end
88 |
89 | awful.spawn.easy_async_with_shell(cmd2, function(o2)
90 | if not utils.isnumber(o2) then
91 | sysmonitor.on_null(instance)
92 | return
93 | end
94 |
95 | local diff = tonumber(o2) - tonumber(o)
96 | local mb = diff / 125000
97 | local v = mb
98 | local u = "M"
99 |
100 | if mb < 1 then
101 | v = diff / 125
102 | u = "K"
103 | end
104 |
105 | sysmonitor.check_alert(instance, mb)
106 | sysmonitor.update_string(instance, utils.numpad(v, 3), u)
107 | instance.timer:again()
108 | end)
109 | end)
110 | end)
111 | end
112 |
113 | function sysmonitor.calc_gpu(instance)
114 | local cmd = "/opt/rocm/bin/rocm-smi --showtemp --showuse --showmemuse --json | jq '.card0' |"
115 | local gpu = " jq '.\"GPU use (%)\"'"
116 | local ram = " jq '.\"GPU Memory Allocated (VRAM%)\"'"
117 |
118 | if instance.args.mode == "gpu_ram" then
119 | cmd = cmd .. ram
120 | else
121 | cmd = cmd .. gpu
122 | end
123 |
124 | awful.spawn.easy_async_with_shell(cmd, function(o)
125 | o = utils.trim(o)
126 | o = utils.remove_quotes(o)
127 |
128 | if not utils.isnumber(o) then
129 | sysmonitor.on_null(instance)
130 | return
131 | end
132 |
133 | sysmonitor.check_alert(instance, tonumber(o))
134 | sysmonitor.update_string(instance, utils.numpad(o, 3), "%")
135 | instance.timer:again()
136 | end)
137 | end
138 |
139 | function sysmonitor.update(instance)
140 | if instance.args.mode == "cpu" or instance.args.mode == "ram" or instance.args.mode == "tmp" then
141 | awful.spawn.easy_async_with_shell(instance.args.command, function(o)
142 | if not utils.isnumber(o) then
143 | sysmonitor.on_null(instance)
144 | return
145 | end
146 |
147 | sysmonitor.check_alert(instance, tonumber(o))
148 | sysmonitor.update_string(instance, utils.numpad(o, 3))
149 | instance.timer:again()
150 | end)
151 | elseif instance.args.mode == "net_download" or instance.args.mode == "net_upload" then
152 | sysmonitor.calc_net(instance)
153 | elseif instance.args.mode == "gpu" or instance.args.mode == "gpu_ram" then
154 | sysmonitor.calc_gpu(instance)
155 | end
156 | end
157 |
158 | function sysmonitor.create(args)
159 | args = args or {}
160 | args.alertcolor = args.alertcolor or "#E2242C"
161 | args.timeout = args.timeout or 3
162 |
163 | if args.mode == "cpu" then
164 | args.alert_max = args.alert_max or 70
165 | args.command = args.command or "mpstat 1 2 | awk 'END{print 100-$NF}'"
166 |
167 | elseif args.mode == "ram" then
168 | args.alert_max = args.alert_max or 70
169 | args.command = args.command or "free | grep Mem | awk '{print $3/$2 * 100.0}'"
170 |
171 | elseif args.mode == "gpu" then
172 | args.alert_max = args.alert_max or 70
173 | args.command = args.command or ""
174 |
175 | elseif args.mode == "gpu_ram" then
176 | args.alert_max = args.alert_max or 70
177 | args.command = args.command or ""
178 |
179 | elseif args.mode == "tmp" then
180 | args.alert_max = args.alert_max or 70
181 | args.command = args.command or "sensors | grep Tctl: | awk '{print $2}' | sed 's/[^0-9.]*//g'"
182 |
183 | elseif args.mode == "net_download" then
184 | args.alert_max = args.alert_max or 10
185 | args.command = args.command or "cat /sys/class/net/%s/statistics/rx_bytes"
186 |
187 | elseif args.mode == "net_upload" then
188 | args.alert_max = args.alert_max or 10
189 | args.command = args.command or "cat /sys/class/net/%s/statistics/tx_bytes"
190 | end
191 |
192 | local instance = {}
193 | instance.args = args
194 | instance.current_color = ""
195 | instance.current_text = ""
196 |
197 | instance.text_widget = wibox.widget({
198 | markup = "---:---%",
199 | align = "center",
200 | valign = "center",
201 | widget = wibox.widget.textbox,
202 | })
203 |
204 | args.widget = instance.text_widget
205 | instance.widget = multibutton.create(args).widget
206 |
207 | instance.timer = gears.timer({
208 | timeout = args.timeout,
209 | call_now = false,
210 | autostart = true,
211 | single_shot = true,
212 | callback = function()
213 | sysmonitor.update(instance)
214 | end,
215 | })
216 |
217 | return instance
218 | end
219 |
220 | return sysmonitor
221 |
--------------------------------------------------------------------------------
/madwidgets/tagbar/tagbar.lua:
--------------------------------------------------------------------------------
1 | local awful = require("awful")
2 | local wibox = require("wibox")
3 | local utils = require("madwidgets/utils")
4 | local topbar = require("madwidgets/topbar/topbar")
5 |
6 | local tagbar = {}
7 | local instances = {}
8 |
9 | tagbar.colors = {
10 | "#2E3440",
11 | "#4169E1",
12 | "#008080",
13 | "#800080",
14 | "#4B0082",
15 | }
16 |
17 | function tagbar.setup()
18 | tag.connect_signal("property::selected", function(t)
19 | if not t.selected then
20 | return
21 | end
22 |
23 | for _, instance in ipairs(instances) do
24 | if instance.args.screen == t.screen then
25 | instance.update()
26 | end
27 | end
28 | end)
29 | end
30 |
31 | function tagbar.create(args)
32 | local instance = {}
33 | instance.args = args
34 |
35 | function instance.update()
36 | local tag = utils.my_tag()
37 | local index = 1
38 |
39 | if tag then
40 | index = utils.my_tag().index
41 | end
42 |
43 | instance.widget.update("Desktop: " .. index)
44 | local color = tagbar.colors[1]
45 |
46 | if args.change_colors then
47 | color = tagbar.colors[index]
48 | end
49 |
50 | instance.widget.color(color)
51 | end
52 |
53 | local left = ""
54 | local right = ""
55 |
56 | if args.show_arrows then
57 | left = " < "
58 | right = " > "
59 | end
60 |
61 | instance.widget = topbar.create({
62 | screen = args.screen,
63 | bgcolor = args.topbar_color,
64 | on_click = args.on_click,
65 | on_right_click = args.on_right_click,
66 | on_middle_click = args.on_middle_click,
67 | on_wheel_down = args.on_wheel_down,
68 | on_wheel_up = args.on_wheel_up,
69 | show_arrows = args.show_arrows,
70 | left = left,
71 | right = right,
72 | left_color = "#FFFFFF",
73 | right_color = "#FFFFFF",
74 | on_left_text_click = function()
75 | utils.switch_tag("prev")
76 | end,
77 | on_right_text_click = function()
78 | utils.switch_tag("next")
79 | end,
80 | })
81 |
82 | table.insert(instances, instance)
83 | instance.update()
84 | return instance
85 | end
86 |
87 | return tagbar
88 |
--------------------------------------------------------------------------------
/madwidgets/tagview/tagview.lua:
--------------------------------------------------------------------------------
1 | local awful = require("awful")
2 | local wibox = require("wibox")
3 | local utils = require("madwidgets/utils")
4 | local overlay = require("madwidgets/overlay/overlay")
5 |
6 | local tagview = {}
7 | local instances = {}
8 |
9 | function tagview.setup()
10 | tag.connect_signal("property::selected", function(t)
11 | if not t.selected then
12 | return
13 | end
14 |
15 | for _, instance in ipairs(instances) do
16 | if instance.args.screen == t.screen then
17 | local index = utils.my_tag().index
18 | instance.widget.show("Desktop: " .. index)
19 | end
20 | end
21 | end)
22 | end
23 |
24 | function tagview.create(args)
25 | local instance = {}
26 | args.overlay_color = args.overlay_color or "#2B303B"
27 | args.textbox_bgcolor = args.textbox_bgcolor or "#394753"
28 | instance.args = args
29 |
30 | local tsk = awful.widget.tasklist({
31 | screen = args.screen,
32 | filter = awful.widget.tasklist.filter.currenttags,
33 | widget_template = {
34 | {
35 | {
36 | {
37 | {
38 | id = "icon_role",
39 | widget = wibox.widget.imagebox,
40 | },
41 | right = 10,
42 | top = 2,
43 | bottom = 2,
44 | widget = wibox.container.margin,
45 | },
46 | {
47 | id = "text_role",
48 | widget = wibox.widget.textbox,
49 | },
50 | layout = wibox.layout.fixed.horizontal,
51 | },
52 | left = 10,
53 | right = 10,
54 | widget = wibox.container.margin,
55 | },
56 | id = "background_role",
57 | widget = wibox.container.background,
58 | },
59 | style = {
60 | bg_normal = args.overlay_color,
61 | bg_focus = args.overlay_color,
62 | bg_minimize = args.overlay_color,
63 | shape_border_color = args.overlay_color,
64 | shape_border_color_focus = args.overlay_color,
65 | font = "monospace 14",
66 | },
67 | })
68 |
69 | local cont = wibox.widget({
70 | tsk,
71 | widget = wibox.container.margin,
72 | forced_height = 60,
73 | forced_width = 600,
74 | left = 5,
75 | right = 5,
76 | top = 14,
77 | bottom = 14,
78 | })
79 |
80 | instance.widget = overlay.create({
81 | screen = args.screen,
82 | widget = cont,
83 | bgcolor = args.overlay_color,
84 | textbox_bgcolor = args.textbox_bgcolor,
85 | height = 50,
86 | })
87 |
88 | table.insert(instances, instance)
89 | return instance
90 | end
91 |
92 | return tagview
93 |
--------------------------------------------------------------------------------
/madwidgets/topbar/README.md:
--------------------------------------------------------------------------------
1 | Show an overlay in the middle of the screen.
2 |
3 | For instance to show desktop number on tag change.
4 |
5 | ```lua
6 | args.delay = args.delay or 2
7 | args.bgcolor = args.bgcolor or "#000000"
8 | args.fontcolor = args.fontcolor or "#ffffff"
9 | args.bordercolor = args.bordercolor or "#d8dee9"
10 | args.font = args.font or "monospace 18"
11 | args.height = args.height or 55
12 | args.borderwidth = args.borderwidth or 1
13 | ```
14 |
15 | ```lua
16 | local overlay = require("madwidgets/overlay/overlay")
17 |
18 | Overlay = overlay.create({
19 | delay = 2,
20 | bgcolor = "#000000",
21 | fontcolor = "#ffffff"
22 | })
23 |
24 | Overlay.show("some text")
25 | ```
--------------------------------------------------------------------------------
/madwidgets/topbar/topbar.lua:
--------------------------------------------------------------------------------
1 | local awful = require("awful")
2 | local wibox = require("wibox")
3 |
4 | local multibutton = require("madwidgets/multibutton/multibutton")
5 |
6 | local topbar = {}
7 |
8 | function topbar.create(args)
9 | local instance = {}
10 | args.delay = args.delay or 1.5
11 | args.bgcolor = args.bgcolor or "#445666"
12 | args.fontcolor = args.fontcolor or "#d5dAf0"
13 | args.bordercolor = args.bordercolor or "#d5dAf0"
14 | args.font = args.font or "monospace 11"
15 | args.height = args.height or 22
16 | args.borderwidth = args.borderwidth or 1
17 | args.screen = args.screen or 1
18 |
19 | instance.widget = awful.wibar({
20 | position = "top",
21 | screen = args.screen,
22 | height = args.height,
23 | })
24 |
25 | args.text = "Topbar"
26 | args.bgcolor = "#2E3440"
27 | instance.multibutton = multibutton.create(args)
28 |
29 | function instance.update(text)
30 | instance.multibutton.subwidget.markup = "" .. text .. ""
31 | end
32 |
33 | function instance.color(color)
34 | instance.multibutton.widget.bg = color
35 | end
36 |
37 | instance.widget:setup({
38 | layout = wibox.layout.align.horizontal,
39 | {
40 | widget = wibox.widget.textbox,
41 | },
42 | instance.multibutton.widget,
43 | {
44 | widget = wibox.widget.textbox,
45 | },
46 | })
47 |
48 | return instance
49 | end
50 |
51 | return topbar
52 |
--------------------------------------------------------------------------------
/madwidgets/utils.lua:
--------------------------------------------------------------------------------
1 | local awful = require("awful")
2 | local naughty = require("naughty")
3 | local utils = {}
4 |
5 | function utils.numpad(s, n)
6 | s = utils.round(tonumber(s))
7 | local ss = s
8 |
9 | if n == 3 then
10 | if s < 100 then
11 | ss = "0" .. s
12 | end
13 | end
14 |
15 | if s < 10 then
16 | ss = "0" .. ss
17 | end
18 |
19 | return ss
20 | end
21 |
22 | function utils.round(n)
23 | return math.floor(n + 0.5)
24 | end
25 |
26 | function utils.round_decimal(n, p)
27 | return tonumber(string.format("%." .. p .. "f", n))
28 | end
29 |
30 | function utils.round_mult(num, mult)
31 | return math.floor(num / mult + 0.5) * mult
32 | end
33 |
34 | function utils.indexof(value, array)
35 | for i, instance in ipairs(array) do
36 | if array[i] == value then
37 | return i
38 | end
39 | end
40 | return -1
41 | end
42 |
43 | function utils.isnumber(num)
44 | if not tonumber(num) then
45 | return false
46 | else
47 | return true
48 | end
49 | end
50 |
51 | function utils.msg(txt)
52 | naughty.notify({ title = " " .. tostring(txt) .. " " })
53 | end
54 |
55 | function utils.trim(text)
56 | return string.gsub(text, "^%s*(.-)%s*$", "%1")
57 | end
58 |
59 | function utils.my_screen()
60 | return awful.screen.focused()
61 | end
62 |
63 | function utils.my_tag()
64 | return utils.my_screen().selected_tag
65 | end
66 |
67 | function utils.switch_tag(direction, sticky)
68 | local index = utils.my_tag().index
69 | local num_tags = #utils.my_screen().tags
70 | local ok = (direction == "next" and index < num_tags) or (direction == "prev" and index > 1)
71 | local new_index
72 |
73 | if ok then
74 | if direction == "next" then
75 | new_index = index + 1
76 | elseif direction == "prev" then
77 | new_index = index - 1
78 | end
79 |
80 | s_index = new_index
81 |
82 | local new_tag = utils.my_screen().tags[new_index]
83 |
84 | if sticky then
85 | if client.focus and client.focus.screen == utils.my_screen() then
86 | client.focus:move_to_tag(new_tag)
87 | end
88 | end
89 |
90 | new_tag:view_only()
91 | end
92 | end
93 |
94 | function utils.shift_pressed(mods)
95 | for _, mod in ipairs(mods) do
96 | if mod == "Shift" then
97 | return true
98 | end
99 | end
100 |
101 | return false
102 | end
103 |
104 | function utils.print_table(t, indent)
105 | indent = indent or ""
106 |
107 | for key, value in pairs(t) do
108 | if type(value) == "table" then
109 | utils.msg(indent .. key .. " : ")
110 | utils.print_table(value, indent .. " ")
111 | else
112 | utils.msg(indent .. key .. " : " .. tostring(value))
113 | end
114 | end
115 | end
116 |
117 | function utils.remove_quotes(s)
118 | return string.gsub(s, "\"", "")
119 | end
120 |
121 | return utils
122 |
--------------------------------------------------------------------------------
/madwidgets/volumecontrol/README.md:
--------------------------------------------------------------------------------
1 | # volumecontrol
2 |
3 | This creates a text based volume widget and provides volume control functions.
4 |
5 | The widget includes mouse events on click, middle click, and mousewheel.
6 |
7 | 
8 |
9 | ## To use it
10 |
11 | Put this near the top:
12 | >local volumecontrol = require("madwidgets/volumecontrol/volumecontrol")
13 |
14 | Then add the widget to the panel, similar to:
15 |
16 | ```lua
17 | right = {
18 | layout = right_layout,
19 | wibox.widget.systray(),
20 |
21 | volumecontrol.create({
22 | bgcolor = beautiful.bg_normal,
23 | left = " ", right = " ",
24 | on_click = function() do_something() end
25 | }),
26 |
27 | mytextclock
28 | }
29 | ```
30 |
31 | You can add keyboard shortcuts like:
32 |
33 | ```lua
34 | awful.key({}, "XF86AudioRaiseVolume", function()
35 | volumecontrol.increase()
36 | end),
37 |
38 | awful.key({}, "XF86AudioLowerVolume", function()
39 | volumecontrol.decrease()
40 | end),
41 | ```
42 |
43 | ## Functions
44 |
45 | volumecontrol.set(number)
46 | >Set the volume to a specific %
47 |
48 | ---
49 |
50 | volumecontrol.increase()
51 | >Increase volume by a % step
52 |
53 | ---
54 |
55 | volumecontrol.decrease()
56 | >Decrease volume by a % step
57 |
58 | ---
59 |
60 | volumecontrol.mute()
61 | >Toggle between 0% volume and last used volume
62 |
63 | ---
64 |
65 | volumecontrol.refresh()
66 | >Updates the widgets volume text.
67 |
68 | ## Variables
69 |
70 | volumecontrol.max_volume
71 | >Default: 100 (%)
72 |
73 | ---
74 |
75 | volumecontrol.steps
76 | >Default 5 (% - used in increase and decrease)
--------------------------------------------------------------------------------
/madwidgets/volumecontrol/volumecontrol.lua:
--------------------------------------------------------------------------------
1 | local awful = require("awful")
2 | local wibox = require("wibox")
3 | local gears = require("gears")
4 | local beautiful = require("beautiful")
5 | local utils = require("madwidgets/utils")
6 | local multibutton = require("madwidgets/multibutton/multibutton")
7 |
8 | local volumecontrol = {}
9 | volumecontrol.max_volume = 100
10 | volumecontrol.steps = 2
11 |
12 | local instances = {}
13 | local last_volume = 100
14 |
15 | function volumecontrol.update_volume(vol)
16 | for i, instance in ipairs(instances) do
17 | if instance.shown_volume ~= vol then
18 | local s = volumecontrol.volstring(utils.numpad(vol, 3))
19 | instance.text_widget.text = s
20 | instance.shown_volume = vol
21 |
22 | if vol == 0 then
23 | instance.widget.fg = instance.args.mutecolor
24 | elseif vol >= volumecontrol.max_volume then
25 | instance.widget.fg = instance.args.maxcolor
26 | else
27 | instance.widget.fg = instance.args.fontcolor
28 | end
29 | end
30 | end
31 | end
32 |
33 | function volumecontrol.get_volume(f)
34 | awful.spawn.easy_async_with_shell("pamixer --get-volume", function(o)
35 | if not utils.isnumber(o) then
36 | return
37 | end
38 | f(tonumber(o))
39 | end)
40 | end
41 |
42 | function volumecontrol.change_volume(vol)
43 | awful.spawn.with_shell("pamixer --set-volume " .. vol, false)
44 | volumecontrol.update_volume(vol)
45 | end
46 |
47 | function volumecontrol.set(vol)
48 | vol = tonumber(vol)
49 |
50 | if (vol > volumecontrol.max_volume) or (vol < 0) then
51 | return
52 | end
53 |
54 | volumecontrol.change_volume(vol)
55 | end
56 |
57 | function volumecontrol.set_round(vol)
58 | vol = utils.round_mult(tonumber(vol), volumecontrol.steps)
59 |
60 | if vol > volumecontrol.max_volume or vol < 0 then
61 | return
62 | end
63 |
64 | volumecontrol.change_volume(vol)
65 | end
66 |
67 | function volumecontrol.osd(vol)
68 | utils.msg("Volume:" .. vol .. "%")
69 | end
70 |
71 | function volumecontrol.increase(osd)
72 | volumecontrol.get_volume(function(vol)
73 | vol = vol + volumecontrol.steps
74 |
75 | if vol > volumecontrol.max_volume then
76 | vol = volumecontrol.max_volume
77 | end
78 |
79 | volumecontrol.change_volume(vol)
80 |
81 | if osd then
82 | volumecontrol.osd(vol)
83 | end
84 | end)
85 | end
86 |
87 | function volumecontrol.decrease(osd)
88 | volumecontrol.get_volume(function(vol)
89 | vol = vol - volumecontrol.steps
90 |
91 | if vol < 0 then
92 | vol = 0
93 | end
94 |
95 | volumecontrol.change_volume(vol)
96 |
97 | if osd then
98 | volumecontrol.osd(vol)
99 | end
100 | end)
101 | end
102 |
103 | function volumecontrol.mute()
104 | volumecontrol.get_volume(function(vol)
105 | if vol == 0 then
106 | volumecontrol.set(last_volume)
107 | else
108 | last_volume = vol
109 | volumecontrol.set(0)
110 | end
111 | end)
112 | end
113 |
114 | function volumecontrol.set_max_volume()
115 | volumecontrol.set(volumecontrol.max_volume)
116 | end
117 |
118 | function volumecontrol.refresh()
119 | volumecontrol.get_volume(function(vol)
120 | volumecontrol.update_volume(vol)
121 | end)
122 | end
123 |
124 | function volumecontrol.volstring(s)
125 | return "Vol:" .. s .. "%"
126 | end
127 |
128 | function volumecontrol.create(args)
129 | args = args or {}
130 |
131 | local instance = {}
132 | instance.args = args
133 | args.on_click = args.on_click or function() end
134 | args.fontcolor = args.fontcolor or beautiful.fg_normal
135 | args.mutecolor = args.mutecolor or beautiful.fg_normal
136 | args.maxcolor = args.maxcolor or beautiful.fg_normal
137 |
138 | instance.text_widget = wibox.widget({
139 | markup = volumecontrol.volstring("---"),
140 | align = "center",
141 | valign = "center",
142 | widget = wibox.widget.textbox,
143 | })
144 |
145 | args.widget = instance.text_widget
146 |
147 | args.on_middle_click = function()
148 | volumecontrol.mute()
149 | end
150 |
151 | args.on_right_click = function()
152 | volumecontrol.set_max_volume()
153 | end
154 |
155 | args.on_wheel_down = function()
156 | volumecontrol.decrease()
157 | end
158 |
159 | args.on_wheel_up = function()
160 | volumecontrol.increase()
161 | end
162 |
163 | instance.widget = multibutton.create(args).widget
164 | instance.shown_volume = -1
165 | table.insert(instances, instance)
166 |
167 | if #instances == 1 then
168 | volumecontrol.timer = gears.timer({
169 | timeout = 3,
170 | call_now = false,
171 | autostart = true,
172 | single_shot = true,
173 | callback = function()
174 | volumecontrol.refresh()
175 | end,
176 | })
177 | end
178 |
179 | return instance
180 | end
181 |
182 | return volumecontrol
183 |
--------------------------------------------------------------------------------
/modules/autostart.lua:
--------------------------------------------------------------------------------
1 | local awful = require("awful")
2 | local beautiful = require("beautiful")
3 |
4 | -- X Settings
5 | Utils.spawn("numlockx")
6 | Utils.spawn("xset m 0 0")
7 | Utils.spawn("xset r rate 220 40")
8 | Utils.spawn("xset s off")
9 | Utils.spawn("xset -dpms")
10 | Utils.spawn("xset s noblank")
11 | Utils.spawn("setxkbmap -option caps:none")
12 |
13 | -- Clipboard Manager
14 | Utils.spawn("systemctl --user start clipton")
15 |
16 | -- Wallpaper
17 | Utils.spawn("feh --bg-fill " .. beautiful.wallpaper)
18 |
--------------------------------------------------------------------------------
/modules/bindings.lua:
--------------------------------------------------------------------------------
1 | Bindings = {}
2 |
3 | local gears = require("gears")
4 | local awful = require("awful")
5 | local doubletap = require("madwidgets/doubletap/doubletap")
6 | local altkey = "Mod1"
7 | local modkey = "Mod4"
8 |
9 | local closetap = doubletap.create({
10 | delay = 300,
11 | lockdelay = 500,
12 | action = function()
13 | Utils.smart_close_cursor()
14 | end,
15 | })
16 |
17 | Bindings.globalkeys = gears.table.join(
18 | awful.key({ modkey, "Control" }, "BackSpace", awesome.restart),
19 | awful.key({ modkey, "Shift" }, "q", awesome.quit),
20 |
21 | awful.key({
22 | modifiers = { modkey },
23 | keygroup = "numrow",
24 | group = "tag",
25 | on_press = function(index)
26 | local screen = awful.screen.focused()
27 | local tag = screen.tags[index]
28 |
29 | if tag then
30 | tag:view_only()
31 | end
32 | end,
33 | }),
34 |
35 | awful.key({
36 | modifiers = { modkey, "Shift" },
37 | keygroup = "numrow",
38 | group = "tag",
39 | on_press = function(index)
40 | if client.focus then
41 | local tag = client.focus.screen.tags[index]
42 |
43 | if tag then
44 | client.focus:move_to_tag(tag)
45 | end
46 | end
47 | end,
48 | }),
49 |
50 | awful.key({ modkey }, "`", function()
51 | Utils.show_menupanel("keyboard")
52 | end),
53 |
54 | awful.key({ "Control" }, "`", function()
55 | Utils.show_clipboard()
56 | end),
57 |
58 | awful.key({ modkey }, "Return", function()
59 | Utils.prev_client()
60 | end),
61 |
62 | awful.key({ modkey }, "space", function()
63 | Utils.launcher()
64 | end),
65 |
66 | awful.key({ "Shift" }, "Scroll_Lock", function()
67 | Dropdowns.start_utils()
68 | end),
69 |
70 | awful.key({}, "Scroll_Lock", function()
71 | Dropdowns.toggle("utils")
72 | end),
73 |
74 | awful.key({ modkey }, "l", function()
75 | Utils.lockscreen()
76 | end),
77 |
78 | awful.key({ modkey, "Shift" }, "l", function()
79 | Utils.alt_lockscreen()
80 | end),
81 |
82 | awful.key({ "Shift" }, "Pause", function()
83 | Utils.randstring()
84 | end),
85 |
86 | awful.key({}, "Pause", function()
87 | Utils.randword()
88 | end),
89 |
90 | awful.key({}, "Print", function()
91 | Utils.screenshot()
92 | end),
93 |
94 | awful.key({ "Control" }, "Print", function()
95 | Utils.screenshot_window()
96 | end),
97 |
98 | awful.key({ "Control", "Shift" }, "Print", function()
99 | Utils.screenshot_screen()
100 | end),
101 |
102 | awful.key({}, "XF86AudioRaiseVolume", function()
103 | Utils.increase_volume(false)
104 | end),
105 |
106 | awful.key({}, "XF86AudioLowerVolume", function()
107 | Utils.decrease_volume(false)
108 | end),
109 |
110 | awful.key({ "Control", "Shift" }, "Escape", function()
111 | if mouse.coords().y <= 20 then
112 | Dropdowns.toggle("utils")
113 | return
114 | end
115 | end),
116 |
117 | awful.key({ "Control", "Shift" }, "Escape", function()
118 | Utils.smart_close_cursor()
119 | end),
120 |
121 | awful.key({ modkey, "Control" }, "space", function()
122 | Utils.smart_button()
123 | end),
124 |
125 | awful.key({ modkey, "Shift", "Control" }, "space", function()
126 | Utils.show_audio_controls()
127 | end),
128 |
129 | awful.key({ altkey }, "Tab", function()
130 | Utils.altab()
131 | end),
132 |
133 | awful.key({ modkey }, "Left", function()
134 | Utils.prev_tag()
135 | end),
136 |
137 | awful.key({ modkey }, "Right", function()
138 | Utils.next_tag()
139 | end),
140 |
141 | awful.key({ modkey, "Shift" }, "Left", function()
142 | Utils.prev_tag_all()
143 | end),
144 |
145 | awful.key({ modkey, "Shift" }, "Right", function()
146 | Utils.next_tag_all()
147 | end),
148 |
149 | awful.key({ modkey, "Shift" }, "bracketleft", function()
150 | Utils.cursor_on_prev_screen()
151 | end),
152 |
153 | awful.key({ modkey, "Shift" }, "bracketright", function()
154 | Utils.cursor_on_next_screen()
155 | end),
156 |
157 | awful.key({ modkey, "Shift" }, "F5", function()
158 | Utils.refresh_on_cursor()
159 | end),
160 |
161 | awful.key({ modkey, "Shift" }, "Home", function()
162 | Utils.home_on_cursor()
163 | end),
164 |
165 | awful.key({ modkey, "Shift" }, "End", function()
166 | Utils.end_on_cursor()
167 | end)
168 | )
169 |
170 | Bindings.clientkeys = gears.table.join(
171 | awful.key({ altkey }, "F4", function(c)
172 | if not c.x_keys then
173 | return
174 | end
175 |
176 | Utils.close(c)
177 | end),
178 |
179 | awful.key({ modkey }, "\\", function(c)
180 | if not c.x_keys then
181 | return
182 | end
183 |
184 | c:move_to_screen()
185 | end),
186 |
187 | awful.key({ modkey }, "BackSpace", function(c)
188 | if not c.x_keys then
189 | return
190 | end
191 |
192 | Utils.maximize(c)
193 | end),
194 |
195 | awful.key({ modkey, "Shift"}, "m", function(c)
196 | if not c.x_keys then
197 | return
198 | end
199 |
200 | Utils.maximize_on_cursor(c)
201 | end),
202 |
203 | awful.key({ modkey, "Shift" }, "BackSpace", function(c)
204 | if not c.x_keys then
205 | return
206 | end
207 |
208 | Utils.fullscreen(c)
209 | end),
210 |
211 | awful.key({ "Shift" }, "BackSpace", function(c)
212 | if not c.x_keys then
213 | return
214 | end
215 |
216 | Rules.reset(c)
217 | end),
218 |
219 | awful.key({ modkey }, "KP_Add", function(c)
220 | if not c.x_keys then
221 | return
222 | end
223 |
224 | Utils.grow_in_place(c)
225 | end),
226 |
227 | awful.key({ modkey }, "KP_Subtract", function(c)
228 | if not c.x_keys then
229 | return
230 | end
231 |
232 | Utils.shrink_in_place(c)
233 | end),
234 |
235 | awful.key({ modkey }, "#79", function(c)
236 | if not c.x_keys then
237 | return
238 | end
239 |
240 | Utils.snap(c, "corner", awful.placement.top_left)
241 | end),
242 |
243 | awful.key({ modkey }, "#80", function(c)
244 | if not c.x_keys then
245 | return
246 | end
247 |
248 | Utils.snap(c, "horizontally", awful.placement.top)
249 | end),
250 |
251 | awful.key({ modkey }, "#81", function(c)
252 | if not c.x_keys then
253 | return
254 | end
255 |
256 | Utils.snap(c, "corner", awful.placement.top_right)
257 | end),
258 |
259 | awful.key({ modkey }, "#83", function(c)
260 | if not c.x_keys then
261 | return
262 | end
263 |
264 | Utils.snap(c, "vertically", awful.placement.left)
265 | end),
266 |
267 | awful.key({ modkey }, "#84", function(c)
268 | if not c.x_keys then
269 | return
270 | end
271 |
272 | Utils.maximize(c)
273 | end),
274 |
275 | awful.key({ modkey }, "#85", function(c)
276 | if not c.x_keys then
277 | return
278 | end
279 |
280 | Utils.snap(c, "vertically", awful.placement.right)
281 | end),
282 |
283 | awful.key({ modkey }, "#87", function(c)
284 | if not c.x_keys then
285 | return
286 | end
287 |
288 | Utils.snap(c, "corner", awful.placement.bottom_left)
289 | end),
290 |
291 | awful.key({ modkey }, "#88", function(c)
292 | if not c.x_keys then
293 | return
294 | end
295 |
296 | Utils.snap(c, "horizontally", awful.placement.bottom)
297 | end),
298 |
299 | awful.key({ modkey }, "#89", function(c)
300 | if not c.x_keys then
301 | return
302 | end
303 |
304 | Utils.snap(c, "corner", awful.placement.bottom_right)
305 | end),
306 |
307 | awful.key({ modkey, "Control" }, "Left", function()
308 | Utils.prev_tag(true)
309 | end),
310 |
311 | awful.key({ modkey, "Control" }, "Right", function()
312 | Utils.next_tag(true)
313 | end)
314 | )
315 |
316 | Bindings.clientbuttons = gears.table.join(
317 | awful.button({}, 1, function(c)
318 | Utils.focus(c)
319 | end),
320 |
321 | awful.button({}, 2, function(c)
322 | Utils.middle_click(c)
323 | end),
324 |
325 | awful.button({}, 3, function(c)
326 | Utils.focus(c)
327 | end),
328 |
329 | awful.button({ modkey }, 1, function(c)
330 | if not c.x_keys then
331 | return
332 | end
333 |
334 | Utils.focus(c)
335 | c.maximized = false
336 | awful.mouse.client.move(c)
337 | end),
338 |
339 | awful.button({ modkey }, 3, function(c)
340 | if not c.x_keys then
341 | return
342 | end
343 |
344 | Utils.focus(c)
345 | c.maximized = false
346 | awful.mouse.client.resize(c)
347 | end),
348 |
349 | awful.button({ modkey }, 4, function(c)
350 | if not c.x_keys then
351 | return
352 | end
353 |
354 | mousegrabber.run(function(_mouse)
355 | if c.x_frame == "none" then
356 | Utils.grow_in_place(c)
357 | else
358 | Frames.cycle(c, true, true)
359 | end
360 |
361 | return false
362 | end, "mouse")
363 | end),
364 |
365 | awful.button({ modkey }, 5, function(c)
366 | if not c.x_keys then
367 | return
368 | end
369 |
370 | mousegrabber.run(function(_mouse)
371 | if c.x_frame == "none" then
372 | Utils.shrink_in_place(c)
373 | else
374 | Frames.cycle(c, false, true)
375 | end
376 |
377 | return false
378 | end, "mouse")
379 | end)
380 | )
381 |
382 | Bindings.tasklist_buttons = gears.table.join(
383 | awful.button({}, 1, function(c)
384 | Utils.minimize(c)
385 | Dropdowns.check_hide(c)
386 | end),
387 |
388 | awful.button({}, 2, function(c)
389 | Utils.show_client_title(c)
390 | end),
391 |
392 | awful.button({}, 3, function(c)
393 | Utils.show_task_context(c)
394 | end),
395 |
396 | awful.button({}, 4, function(c)
397 | if Frames.cycle(c, true, true) then
398 | Dropdowns.check_hide(c)
399 | end
400 | end),
401 |
402 | awful.button({ modkey }, 4, function(c)
403 | awful.client.swap.byidx(-1, c)
404 | end),
405 |
406 | awful.button({}, 5, function(c)
407 | if Frames.cycle(c, false, true) then
408 | Dropdowns.check_hide(c)
409 | end
410 | end),
411 |
412 | awful.button({ modkey }, 5, function(c)
413 | awful.client.swap.byidx(1, c)
414 | end)
415 | )
416 |
417 | root.keys(Bindings.globalkeys)
418 |
--------------------------------------------------------------------------------
/modules/clients.lua:
--------------------------------------------------------------------------------
1 | client.connect_signal("manage", function(c)
2 | Rules.check_title(c)
3 | Frames.apply_rules(c, 1)
4 | c.x_focus_date = Utils.nano()
5 | Frames.refresh(c.x_frame)
6 | end)
7 |
8 | client.connect_signal("unmanage", function(c)
9 | Frames.refresh(c.x_frame)
10 | end)
11 |
12 | client.connect_signal("property::name", function(c)
13 | Rules.check_title(c)
14 | Frames.apply_rules(c, 1)
15 | end)
16 |
17 | client.connect_signal("property::fullscreen", function(c)
18 | Utils.check_fullscreen(c)
19 | end)
20 |
21 | client.connect_signal("focus", function(c)
22 | c.x_focus_date = Utils.nano()
23 | end)
24 |
--------------------------------------------------------------------------------
/modules/dropdowns.lua:
--------------------------------------------------------------------------------
1 | -- Dropdowns are one or more clients that can be spawned on any tag
2 | -- They get shown and dismissed on demand
3 | -- They don't take space in the tasklist
4 |
5 | Dropdowns = {}
6 | Dropdowns.dd_utils_on = false
7 | Dropdowns.dropdowns = { "utils", "melt" }
8 | Dropdowns.buttons = {}
9 |
10 | function Dropdowns.setup()
11 | -- When changing tag, hide the active dropdown, on the specific screen
12 | tag.connect_signal("property::selected", function(t)
13 | Dropdowns.hide_screen(t.screen)
14 | end)
15 | end
16 |
17 | function Dropdowns.start_utils()
18 | Utils.spawn("dolphin")
19 | Utils.spawn("speedcrunch")
20 | Utils.spawn("terminator")
21 | Dropdowns.underline_text("utils")
22 | end
23 |
24 | function Dropdowns.start_melt()
25 | Utils.spawn("meltdown --profile dropdown")
26 | Dropdowns.underline_text("melt")
27 | end
28 |
29 | Dropdowns.underline_text = function(what)
30 | active_screen = Dropdowns.get_screen(what)
31 |
32 | for _, item in ipairs(Dropdowns.buttons[what]) do
33 | if item.screen == active_screen then
34 | item.button.underline()
35 | else
36 | item.button.normal()
37 | end
38 | end
39 | end
40 |
41 | Dropdowns.normal_text = function(what)
42 | for _, item in ipairs(Dropdowns.buttons[what]) do
43 | item.button.normal()
44 | end
45 | end
46 |
47 | -- When raising a client from the tasklist
48 | function Dropdowns.check_hide(c)
49 | if not Dropdowns.included(c) then
50 | Dropdowns.hide_screen(c.screen)
51 | end
52 | end
53 |
54 | function Dropdowns.included(c)
55 | for index, dropdown in ipairs(Dropdowns.dropdowns) do
56 | if c[Dropdowns.get_x(dropdown)] then
57 | return true
58 | end
59 | end
60 |
61 | return false
62 | end
63 |
64 | function Dropdowns.get_x(what)
65 | return "x_dropdown_" .. what
66 | end
67 |
68 | function Dropdowns.get_on(what)
69 | return Dropdowns["dd_" .. what .. "_on"]
70 | end
71 |
72 | function Dropdowns.set_on(what, value)
73 | Dropdowns["dd_" .. what .. "_on"] = value
74 | end
75 |
76 | function Dropdowns.get_tag(what)
77 | return Dropdowns["dd_" .. what .. "_tag"]
78 | end
79 |
80 | function Dropdowns.set_tag(what, value)
81 | Dropdowns["dd_" .. what .. "_tag"] = value
82 | end
83 |
84 | function Dropdowns.get_screen(what)
85 | return Dropdowns["dd_" .. what .. "_screen"]
86 | end
87 |
88 | function Dropdowns.set_screen(what, value)
89 | Dropdowns["dd_" .. what .. "_screen"] = value
90 | end
91 |
92 | function Dropdowns.toggle(what)
93 | if Dropdowns.get_on(what) then
94 | local tag = Dropdowns.get_tag(what)
95 | local same_tag = tag == Utils.my_tag()
96 |
97 | if not same_tag or not tag.selected then
98 | Dropdowns.show(what)
99 | else
100 | Dropdowns.hide(what)
101 | end
102 | else
103 | Dropdowns.show(what)
104 | end
105 | end
106 |
107 | function Dropdowns.show(what)
108 | Dropdowns.hide_screen(Utils.my_screen())
109 | local t = Utils.my_tag()
110 | local max
111 |
112 | for _, c in ipairs(client.get()) do
113 | if c[Dropdowns.get_x(what)] then
114 | c:move_to_tag(t)
115 | c.hidden = false
116 | c:raise()
117 |
118 | if not Dropdowns.get_on(what) then
119 | Rules.reset(c)
120 | else
121 | if c.maximized then
122 | max = c
123 | end
124 | end
125 | end
126 | end
127 |
128 | if max ~= nil then
129 | Utils.focus(max)
130 | end
131 | Dropdowns.set_on(what, true)
132 | Dropdowns.set_screen(what, Utils.my_screen())
133 | Dropdowns.set_tag(what, Utils.my_tag())
134 | Dropdowns.underline_text(what)
135 | end
136 |
137 | function Dropdowns.hide(what)
138 | for _, c in ipairs(client.get()) do
139 | if c[Dropdowns.get_x(what)] then
140 | c.hidden = true
141 | end
142 | end
143 |
144 | Dropdowns.set_on(what, false)
145 | Dropdowns.normal_text(what)
146 | end
147 |
148 | function Dropdowns.hide_others(what)
149 | for index, dropdown in ipairs(Dropdowns.dropdowns) do
150 | if dropdown ~= what then
151 | if Dropdowns.get_on(dropdown) then
152 | Dropdowns.hide(dropdown)
153 | end
154 | end
155 | end
156 | end
157 |
158 | function Dropdowns.hide_all()
159 | for index, dropdown in ipairs(Dropdowns.dropdowns) do
160 | Dropdowns.hide(dropdown)
161 | end
162 | end
163 |
164 | function Dropdowns.hide_screen(screen)
165 | local hid_some = false
166 |
167 | for index, dropdown in ipairs(Dropdowns.dropdowns) do
168 | if Dropdowns.get_on(dropdown) then
169 | if Dropdowns.get_screen(dropdown) == screen then
170 | Dropdowns.hide(dropdown)
171 | hid_some = true
172 | end
173 | end
174 | end
175 |
176 | return hid_some
177 | end
178 |
179 | function Dropdowns.check()
180 | for index, dropdown in ipairs(Dropdowns.dropdowns) do
181 | if Dropdowns.get_on(dropdown) then
182 | if Dropdowns.get_screen(dropdown) == Utils.my_screen() then
183 | Dropdowns.hide(dropdown)
184 | end
185 | end
186 | end
187 | end
188 |
189 | function Dropdowns.register_button(what, button, screen)
190 | if Dropdowns.buttons[what] == nil then
191 | Dropdowns.buttons[what] = {}
192 | end
193 |
194 | item = {}
195 | item.button = button
196 | item.screen = screen
197 |
198 | table.insert(Dropdowns.buttons[what], item)
199 | end
200 |
201 | Dropdowns.setup()
202 |
--------------------------------------------------------------------------------
/modules/frames.lua:
--------------------------------------------------------------------------------
1 | -- Frames are groups of clients that can be cycled through
2 | -- They are placed in the same place on the screen
3 | -- For instance you can have 3 clients in the top right
4 | -- Only one tasklist item is shown at a time
5 | -- Clicking the tasklist button cycles between them
6 | -- You can also use the mousewheel
7 |
8 | local awful = require("awful")
9 |
10 | Frames = {}
11 | Frames.frames = {}
12 | local hide_tasklist = false
13 | local height_top = 0.64
14 | local height_bottom = 0.36
15 | local half_width = 0.5
16 | local one_third = 0.34
17 | local two_thirds = 0.66
18 |
19 | Frames.frames.top_left = {
20 | screen = 2,
21 | width = two_thirds,
22 | height = height_top,
23 | x_index = 10,
24 | placement = "top_left",
25 | }
26 |
27 | Frames.frames.bottom_left = {
28 | screen = 2,
29 | width = two_thirds,
30 | height = height_bottom,
31 | x_index = 20,
32 | placement = "bottom_left",
33 | }
34 |
35 | Frames.frames.top_right = {
36 | screen = 2,
37 | width = one_third,
38 | height = height_top,
39 | x_index = 30,
40 | placement = "top_right",
41 | }
42 |
43 | Frames.frames.bottom_right = {
44 | screen = 2,
45 | width = one_third,
46 | height = height_bottom,
47 | x_index = 40,
48 | placement = "bottom_right",
49 | }
50 |
51 | function Frames.apply_rules(c, i)
52 | if c.x_frame_ready then
53 | return
54 | end
55 |
56 | local rules = Frames.frames[c.x_frame]
57 |
58 | if rules == nil then
59 | return
60 | end
61 |
62 | c.x_frame_ready = true
63 | c.maximized = false
64 | c.screen = rules.screen
65 | c.width = Utils.width_factor(rules.width)
66 | c.height = Utils.height_factor(rules.height)
67 | c.x_index = rules.x_index + i
68 | Utils.placement(c, rules.placement)
69 | end
70 |
71 | function Frames.start()
72 | for frame, _ in pairs(Frames.frames) do
73 | Frames.refresh(frame)
74 | end
75 | end
76 |
77 | function Frames.refresh(frame)
78 | if frame == "none" then
79 | return
80 | end
81 |
82 | local frames = {}
83 |
84 | for _, c in ipairs(client.get()) do
85 | if c.x_frame == frame then
86 | table.insert(frames, c)
87 | end
88 | end
89 |
90 | if #frames == 0 then
91 | return
92 | end
93 |
94 | if hide_tasklist then
95 | for _, c in ipairs(frames) do
96 | c.skip_taskbar = true
97 | end
98 | end
99 |
100 | table.sort(frames, function(a, b)
101 | return a.x_focus_date > b.x_focus_date
102 | end)
103 |
104 | if hide_tasklist then
105 | frames[1].skip_taskbar = false
106 | end
107 | end
108 |
109 | function Frames.cycle(c1, reverse, alt)
110 | if c1.x_frame == "none" then
111 | return false
112 | end
113 |
114 | if reverse == nil then
115 | reverse = false
116 | end
117 |
118 | if alt == nil then
119 | alt = false
120 | end
121 |
122 | local frames = {}
123 | local match = false
124 | local focused
125 |
126 | for _, c2 in ipairs(Utils.clients()) do
127 | if c2.x_frame == c1.x_frame then
128 | table.insert(frames, c2)
129 | end
130 | end
131 |
132 | if alt then
133 | table.sort(frames, function(a, b)
134 | return a.x_focus_date > b.x_focus_date
135 | end)
136 | focused = frames[1]
137 | else
138 | focused = c1
139 | end
140 |
141 | if #frames == 0 then
142 | return false
143 | end
144 |
145 | if reverse then
146 | table.sort(frames, function(a, b)
147 | return a.x_index > b.x_index
148 | end)
149 | else
150 | table.sort(frames, function(a, b)
151 | return a.x_index < b.x_index
152 | end)
153 | end
154 |
155 | local selected
156 |
157 | for i, c2 in ipairs(frames) do
158 | if hide_tasklist then
159 | c2.skip_taskbar = true
160 | end
161 |
162 | Frames.apply_rules(c2, i)
163 |
164 | if focused == c2 then
165 | match = true
166 | elseif match then
167 | selected = c2
168 | end
169 | end
170 |
171 | if frames[1] == focused then
172 | selected = frames[#frames]
173 | else
174 | selected = frames[1]
175 | end
176 |
177 | Utils.focus(selected)
178 |
179 | if hide_tasklist then
180 | selected.skip_taskbar = false
181 | end
182 |
183 | return true
184 | end
185 |
--------------------------------------------------------------------------------
/modules/globals.lua:
--------------------------------------------------------------------------------
1 | local gears = require("gears")
2 |
3 | Globals = {}
4 |
5 | Globals.nicegreen = "#6FE2C8"
6 | Globals.niceblue = "#25AEF3"
7 | Globals.nicered = "#E9006A"
8 | Globals.nicedark = "#445666"
9 | Globals.flower = "❇"
10 | Globals.star = "⍟"
11 | Globals.utils = "🖥️"
12 | Globals.melt = "🫠"
13 | Globals.primary_screen = 1
14 | Globals.volumecontrol = require("madwidgets/volumecontrol/volumecontrol")
15 | Globals.volumecontrol.max_volume = 100
16 | Globals.conf_dir = gears.filesystem.get_configuration_dir()
17 |
--------------------------------------------------------------------------------
/modules/menupanels.lua:
--------------------------------------------------------------------------------
1 | Menupanels = {}
2 |
3 | local menupanel = require("madwidgets/menupanel/menupanel")
4 |
5 | local height = 30
6 |
7 | Menupanels.utils = {}
8 |
9 | function Menupanels.utils.showinfo(text)
10 | Menupanels.info.update_item(1, text)
11 | Menupanels.info.start("mouse")
12 | end
13 |
14 | Menupanels.main = menupanel.create({
15 | placement = "top",
16 | height = height,
17 | items = {
18 | {
19 | name = "Launch",
20 | action = function(trigger)
21 | Menupanels.applications.show(trigger)
22 | end,
23 | },
24 | {
25 | name = "Terminals",
26 | action = function(trigger)
27 | Menupanels.terminals.show(trigger)
28 | end,
29 | },
30 | {
31 | name = "Log",
32 | action = function(trigger)
33 | Menupanels.log.show(trigger)
34 | end,
35 | },
36 | {
37 | name = "Notifications",
38 | action = function()
39 | Utils.show_notifications()
40 | end,
41 | },
42 | {
43 | name = "Bluetooth",
44 | action = function(trigger)
45 | Menupanels.bluetooth.show(trigger)
46 | end,
47 | },
48 | {
49 | name = "Layouts",
50 | action = function(trigger)
51 | Menupanels.layouts.show(trigger)
52 | end,
53 | },
54 | {
55 | name = "Leave",
56 | action = function(trigger)
57 | Menupanels.leave.show(trigger)
58 | end,
59 | },
60 | },
61 | })
62 |
63 | Menupanels.applications = menupanel.create({
64 | placement = "top",
65 | height = height,
66 | parent = Menupanels.main,
67 | items = {
68 | {
69 | name = "Chan",
70 | action = function()
71 | Utils.spawn("firefox-developer-edition -P 4chanposter")
72 | end,
73 | },
74 | {
75 | name = "Cytube",
76 | action = function()
77 | Utils.spawn("firefox-developer-edition -P cytube")
78 | end,
79 | },
80 | {
81 | name = "Tile 1",
82 | action = function()
83 | Utils.spawn("firefox-developer-edition -P tile1")
84 | end,
85 | },
86 | {
87 | name = "Tile 2",
88 | action = function()
89 | Utils.spawn("firefox-developer-edition -P tile2")
90 | end,
91 | },
92 | {
93 | name = "Tile 3",
94 | action = function()
95 | Utils.spawn("firefox-developer-edition -P tile3")
96 | end,
97 | },
98 | {
99 | name = "Dev 1",
100 | action = function()
101 | Utils.spawn("firefox-developer-edition -P dev1")
102 | end,
103 | },
104 | {
105 | name = "Dev 2",
106 | action = function()
107 | Utils.spawn("firefox-developer-edition -P dev2")
108 | end,
109 | },
110 | {
111 | name = "Dev 3",
112 | action = function()
113 | Utils.spawn("firefox-developer-edition -P dev3")
114 | end,
115 | },
116 | {
117 | name = "KB",
118 | action = function()
119 | Utils.spawn("onboard")
120 | end,
121 | },
122 | },
123 | })
124 |
125 | Menupanels.terminals = menupanel.create({
126 | placement = "top",
127 | height = height,
128 | parent = Menupanels.main,
129 | items = {
130 | {
131 | name = "Default",
132 | action = function()
133 | Utils.spawn("terminator")
134 | end,
135 | },
136 | {
137 | name = "Meltdown",
138 | action = function()
139 | Utils.spawn("terminator -p meltdown")
140 | end,
141 | },
142 | {
143 | name = "Grasshopper",
144 | action = function()
145 | Utils.spawn("terminator -p grasshopper")
146 | end,
147 | },
148 | },
149 | })
150 |
151 | Menupanels.log = menupanel.create({
152 | placement = "top",
153 | height = height,
154 | parent = Menupanels.main,
155 | items = {
156 | {
157 | name = "Show Log",
158 | action = function()
159 | Utils.show_log()
160 | end,
161 | },
162 | {
163 | name = "Wake",
164 | action = function()
165 | Utils.add_to_log("Wake", true)
166 | end,
167 | needs_confirm = true,
168 | },
169 | {
170 | name = "Meds 1",
171 | action = function()
172 | Utils.add_to_log("Meds 1", true)
173 | end,
174 | needs_confirm = true,
175 | },
176 | {
177 | name = "Meds 2",
178 | action = function()
179 | Utils.add_to_log("Meds 2", true)
180 | end,
181 | needs_confirm = true,
182 | },
183 | },
184 | })
185 |
186 | Menupanels.leave = menupanel.create({
187 | placement = "top",
188 | height = height,
189 | parent = Menupanels.main,
190 | items = {
191 | {
192 | name = "Restart",
193 | action = function()
194 | awesome.restart()
195 | end,
196 | needs_confirm = true,
197 | },
198 | {
199 | name = "Logout",
200 | action = function()
201 | awesome.quit()
202 | end,
203 | needs_confirm = true,
204 | },
205 | {
206 | name = "Suspend",
207 | action = function(trigger)
208 | Menupanels.suspend.show(trigger)
209 | end,
210 | },
211 | {
212 | name = "Reboot",
213 | action = function()
214 | Utils.shellspawn("reboot")
215 | end,
216 | needs_confirm = true,
217 | },
218 | {
219 | name = "Shutdown",
220 | action = function()
221 | Utils.shellspawn("shutdown now")
222 | end,
223 | needs_confirm = true,
224 | },
225 | },
226 | })
227 |
228 | Menupanels.layouts = menupanel.create({
229 | placement = "top",
230 | height = height,
231 | parent = Menupanels.main,
232 | items = {
233 | {
234 | name = "Maximized",
235 | action = function()
236 | Utils.max_layout()
237 | end,
238 | },
239 | {
240 | name = "Horizontal",
241 | action = function()
242 | Utils.horizontal_layout()
243 | end,
244 | },
245 | {
246 | name = "Vertical",
247 | action = function()
248 | Utils.vertical_layout()
249 | end,
250 | },
251 | {
252 | name = "Paper Horizontal",
253 | action = function()
254 | Utils.paper_horizontal_layout()
255 | end,
256 | },
257 | {
258 | name = "Paper Vertical",
259 | action = function()
260 | Utils.paper_vertical_layout()
261 | end,
262 | },
263 | },
264 | })
265 |
266 | Menupanels.suspend = menupanel.create({
267 | placement = "top",
268 | height = height,
269 | items = {
270 | {
271 | name = "Now",
272 | action = function()
273 | Utils.suspend()
274 | end,
275 | needs_confirm = true,
276 | },
277 | {
278 | name = "5 minutes",
279 | action = function()
280 | Utils.auto_suspend(5)
281 | end,
282 | needs_confirm = true,
283 | },
284 | {
285 | name = "30 minutes",
286 | action = function()
287 | Utils.auto_suspend(30)
288 | end,
289 | needs_confirm = true,
290 | },
291 | {
292 | name = "60 minutes",
293 | action = function()
294 | Utils.auto_suspend(60)
295 | end,
296 | needs_confirm = true,
297 | },
298 | {
299 | name = "90 minutes",
300 | action = function()
301 | Utils.auto_suspend(90)
302 | end,
303 | needs_confirm = true,
304 | },
305 | },
306 | })
307 |
308 | Menupanels.bluetooth = menupanel.create({
309 | placement = "top",
310 | height = height,
311 | parent = Menupanels.main,
312 | items = {
313 | {
314 | name = "Connect",
315 | action = function()
316 | Utils.bluetooth(true)
317 | end,
318 | needs_confirm = true,
319 | },
320 | {
321 | name = "Disconnect",
322 | action = function()
323 | Utils.bluetooth(false)
324 | end,
325 | needs_confirm = true,
326 | },
327 | },
328 | })
329 |
330 | Menupanels.context = menupanel.create({
331 | placement = "bottom",
332 | height = height,
333 | items = {
334 | {
335 | name = "Maximize",
336 | action = function()
337 | Utils.maximize(Utils.get_context_client())
338 | end,
339 | },
340 | {
341 | name = "Fullscreen",
342 | action = function()
343 | Utils.fullscreen(Utils.get_context_client())
344 | end,
345 | },
346 | {
347 | name = "On Top",
348 | action = function()
349 | Utils.on_top(Utils.get_context_client())
350 | end,
351 | },
352 | {
353 | name = "Center",
354 | action = function()
355 | Utils.center(Utils.get_context_client())
356 | end,
357 | },
358 | {
359 | name = "Expand",
360 | action = function()
361 | Utils.expand(Utils.get_context_client())
362 | end,
363 | },
364 | {
365 | name = "Decorate",
366 | action = function()
367 | Utils.decorate(Utils.get_context_client())
368 | end,
369 | },
370 | {
371 | name = "Reset",
372 | action = function()
373 | Rules.reset(Utils.get_context_client())
374 | end,
375 | },
376 | {
377 | name = "Close",
378 | action = function()
379 | Utils.close(Utils.get_context_client())
380 | end,
381 | needs_confirm = true,
382 | },
383 | },
384 | })
385 |
386 | Menupanels.info = menupanel.create({
387 | placement = "bottom",
388 | height = height,
389 | items = {
390 | {
391 | name = "- Empty -",
392 | action = function()
393 | Utils.to_clipboard(Menupanels.info.get_item(1).name)
394 | end,
395 | },
396 | },
397 | })
398 |
--------------------------------------------------------------------------------
/modules/notifications.lua:
--------------------------------------------------------------------------------
1 | local ruled = require("ruled")
2 | local naughty = require("naughty")
3 | local gears = require("gears")
4 |
5 | naughty.connect_signal("request::display_error", function(message, startup)
6 | naughty.notification({
7 | urgency = "critical",
8 | title = "Oops, an error happened" .. (startup and " during startup!" or "!"),
9 | message = message,
10 | })
11 | end)
12 |
13 | ruled.notification.connect_signal("request::rules", function()
14 | ruled.notification.append_rule({
15 | rule = {},
16 | properties = {
17 | position = "bottom_right",
18 | implicit_timeout = 5,
19 | never_timeout = false,
20 | screen = Globals.primary_screen,
21 | },
22 | })
23 | end)
24 |
25 | local icon = gears.filesystem.get_configuration_dir() .. "icon.png"
26 |
27 | naughty.connect_signal("request::display", function(n)
28 | local text = Utils.trim(n.title)
29 | local msg = Utils.trim(n.message)
30 |
31 | if not Utils.isempty(msg) then
32 | text = text .. " > " .. msg
33 | end
34 |
35 | Utils.add_to_notifications(text)
36 | n.title = string.format("%s", n.title)
37 | n.icon = icon
38 |
39 | naughty.layout.box({
40 | notification = n,
41 | })
42 | end)
43 |
--------------------------------------------------------------------------------
/modules/rules.lua:
--------------------------------------------------------------------------------
1 | local awful = require("awful")
2 | local screen_left = 1
3 | local screen_right = 2
4 |
5 | Rules = {}
6 |
7 | awful.rules.rules = {
8 | {
9 | rule = {},
10 | properties = {
11 | border_width = 0,
12 | focus = awful.client.focus.filter,
13 | raise = true,
14 | keys = Bindings.clientkeys,
15 | buttons = Bindings.clientbuttons,
16 | screen = awful.screen.preferred,
17 | placement = awful.placement.centered,
18 | skip_taskbar = false,
19 | titlebars_enabled = false,
20 | x_keys = true,
21 | x_rules_applied = false,
22 | x_client = true,
23 | x_terminal = false,
24 | x_dropdown_utils = false,
25 | x_dropdown_melt = false,
26 | x_index = 0,
27 | x_focus_date = 0,
28 | x_frame = "none",
29 | x_frame_ready = false,
30 | x_alt_q = false,
31 | x_ctrl_d = false,
32 | border_color = "#00dbd7"
33 | },
34 | callback = function(c)
35 | if c.fullscreen then
36 | c.fullscreen = false
37 | c.fullscreen = true
38 | end
39 | end,
40 | },
41 | {
42 | rule = { class = "firefox-developer-edition" },
43 | properties = {
44 | x_hotcorner = "1_top_left",
45 | x_index = 1,
46 | },
47 | },
48 | {
49 | rule = { instance = "code" },
50 | properties = {
51 | screen = screen_left,
52 | x_terminal = true,
53 | x_index = 1,
54 | tag = "2",
55 | fullscreen = false,
56 | maximized = true,
57 | },
58 | },
59 | {
60 | rule = { instance = "fl64.exe" },
61 | properties = {
62 | maximized = true,
63 | },
64 | },
65 | {
66 | rule = { instance = "VirtualBox Machine" },
67 | properties = {
68 | maximized = false,
69 | x_keys = false,
70 | },
71 | },
72 | -- Screen Right
73 | {
74 | rule = { instance = "hexchat" },
75 | properties = {
76 | x_frame = "bottom_left",
77 | },
78 | },
79 | {
80 | rule = { instance = "audacious" },
81 | properties = {
82 | x_frame = "bottom_right",
83 | x_alt_q = true,
84 | },
85 | },
86 | {
87 | rule = { instance = "com.github.taiko2k.tauonmb" },
88 | properties = {
89 | x_frame = "bottom_right",
90 | },
91 | },
92 | {
93 | rule = { instance = "tauonmb" },
94 | properties = {
95 | x_frame = "bottom_right",
96 | },
97 | },
98 | {
99 | rule = { instance = "konsole" },
100 | properties = {
101 | border_width = 3,
102 | border_color = "#72dcff",
103 | },
104 | },
105 | {
106 | rule = { instance = "strawberry" },
107 | properties = {
108 | x_frame = "bottom_right",
109 | x_ctrl_d = true,
110 | },
111 | },
112 | {
113 | rule = { instance = "Devtools" },
114 | properties = {
115 | maximized = true,
116 | screen = screen_right,
117 | x_index = 1,
118 | },
119 | },
120 | {
121 | rule = { instance = "Nicotine" },
122 | properties = {
123 | x_frame = "top_left",
124 | },
125 | },
126 | {
127 | rule = { class = "cromulant" },
128 | properties = {
129 | x_frame = "bottom_right",
130 | },
131 | },
132 | {
133 | rule = { class = "Milton" },
134 | properties = {
135 | x_frame = "top_right",
136 | },
137 | },
138 | {
139 | rule = { class = "cool-retro-term" },
140 | properties = {
141 | x_index = 1,
142 | width = Utils.width_factor(0.6),
143 | height = Utils.height_factor(1),
144 | placement = function(c)
145 | Utils.placement(c, "left")
146 | end,
147 | tag = "9",
148 | screen = screen_left,
149 | },
150 | },
151 | {
152 | rule = { class = "crom_stream" },
153 | properties = {
154 | x_index = 2,
155 | width = Utils.width_factor(0.4),
156 | height = Utils.height_factor(1),
157 | placement = function(c)
158 | Utils.placement(c, "right")
159 | end,
160 | tag = "9",
161 | screen = screen_left,
162 | },
163 | },
164 | {
165 | rule = { class = "crom_vid" },
166 | properties = {
167 | x_index = 2,
168 | height = Utils.height_factor(1),
169 | tag = "9",
170 | screen = screen_left,
171 | },
172 | },
173 | {
174 | rule = { class = "haruna" },
175 | properties = {
176 | x_frame = "top_right",
177 | },
178 | },
179 | -- Util Screen
180 | {
181 | rule = { instance = "dolphin" },
182 | properties = {
183 | maximized = false,
184 | placement = function(c)
185 | Utils.placement(c, "top_left")
186 | end,
187 | width = Utils.width_factor(0.75),
188 | height = Utils.height_factor(0.5),
189 | skip_taskbar = true,
190 | x_dropdown_utils = true,
191 | },
192 | },
193 | {
194 | rule = { instance = "pcmanfm" },
195 | properties = {
196 | maximized = false,
197 | placement = function(c)
198 | Utils.placement(c, "top_left")
199 | end,
200 | width = Utils.width_factor(0.75),
201 | height = Utils.height_factor(0.5),
202 | skip_taskbar = true,
203 | x_dropdown_utils = true,
204 | },
205 | },
206 | {
207 | rule = { instance = "speedcrunch" },
208 | properties = {
209 | maximized = false,
210 | placement = function(c)
211 | Utils.placement(c, "top_right")
212 | end,
213 | width = Utils.width_factor(0.25),
214 | height = Utils.height_factor(0.5),
215 | skip_taskbar = true,
216 | x_dropdown_utils = true,
217 | },
218 | },
219 | {
220 | rule = { instance = "terminator" },
221 | properties = {
222 | maximized = false,
223 | placement = function(c)
224 | Utils.placement(c, "bottom")
225 | end,
226 | width = Utils.width_factor(1),
227 | height = Utils.height_factor(0.5),
228 | skip_taskbar = true,
229 | x_dropdown_utils = true,
230 | x_terminal = true,
231 | },
232 | },
233 | {
234 | rule = { instance = "tilix" },
235 | properties = {
236 | maximized = false,
237 | placement = function(c)
238 | Utils.placement(c, "bottom")
239 | end,
240 | width = Utils.width_factor(1),
241 | height = Utils.height_factor(0.5),
242 | skip_taskbar = true,
243 | x_dropdown_utils = true,
244 | x_terminal = true,
245 | },
246 | },
247 | -- Other Rules
248 | {
249 | rule = { instance = "Alacritty" },
250 | properties = {
251 | maximized = false,
252 | placement = function(c)
253 | Utils.placement(c, "centered")
254 | end,
255 | width = Utils.width_factor(0.7),
256 | height = Utils.height_factor(0.7),
257 | x_terminal = true,
258 | },
259 | },
260 | }
261 |
262 | function Rules.check_title(c, force)
263 | if force == nil then
264 | force = false
265 | end
266 |
267 | -- c.maximized should be before awful.placement calls
268 |
269 | if Utils.startswith(c.name, "[ff_tile1]") then
270 | if not c.x_rules_applied or force then
271 | c.x_rules_applied = true
272 | c.x_frame = "top_left"
273 | end
274 | elseif Utils.startswith(c.name, "[ff_tile2]") then
275 | if not c.x_rules_applied or force then
276 | c.x_rules_applied = true
277 | c.x_frame = "top_right"
278 | end
279 | elseif Utils.startswith(c.name, "[ff_tile3]") then
280 | if not c.x_rules_applied or force then
281 | c.x_rules_applied = true
282 | c.x_frame = "bottom_right"
283 | end
284 | elseif Utils.startswith(c.name, "[cytube]") then
285 | if not c.x_rules_applied or force then
286 | c.x_rules_applied = true
287 | c.width = Utils.width_factor(1)
288 | c.height = Utils.height_factor(0.64)
289 | c.screen = 2
290 | end
291 | elseif Utils.startswith(c.name, "Meltdown (dropdown)") then
292 | if not c.x_rules_applied or force then
293 | c.x_rules_applied = true
294 | c.width = Utils.width_factor(0.44)
295 | c.height = Utils.height_factor(0.8)
296 | c.skip_taskbar = true
297 | c.x_dropdown_melt = true
298 | c.border_width = 4
299 | c.border_color = "#ffa472"
300 | end
301 | elseif Utils.startswith(c.name, "Meltdown (dev") then
302 | if not c.x_rules_applied or force then
303 | c.skip_taskbar = true
304 | c.x_dropdown_melt = true
305 | c.border_width = 4
306 | c.border_color = "#72dcff"
307 | end
308 | elseif Utils.startswith(c.name, "Meltdown (info)") then
309 | if not c.x_rules_applied or force then
310 | c.screen = screen_left
311 | c.x_index = 3
312 | c.height = Utils.height_factor(0.333)
313 | Utils.placement(c, "bottom_right")
314 | end
315 | end
316 | end
317 |
318 | function Rules.reset(c)
319 | awful.rules.apply(c)
320 | Rules.check_title(c, true)
321 | Frames.apply_rules(c, 1)
322 | c.x_focus_date = Utils.nano()
323 | end
324 |
325 | function Rules.apply(c)
326 | awful.rules.apply(c)
327 | end
328 |
--------------------------------------------------------------------------------
/modules/screens.lua:
--------------------------------------------------------------------------------
1 | local awful = require("awful")
2 | local wibox = require("wibox")
3 | local gears = require("gears")
4 | local multibutton = require("madwidgets/multibutton/multibutton")
5 | local sysmonitor = require("madwidgets/sysmonitor/sysmonitor")
6 | local autotimer = require("madwidgets/autotimer/autotimer")
7 |
8 | autotimer.create({
9 | left = "",
10 | fontcolor = Globals.niceblue,
11 | separator = "|",
12 | separator_color = Globals.nicedark,
13 | })
14 |
15 | local function sysmonitor_widget(mode)
16 | local args = {}
17 | args.mode = mode
18 |
19 | if mode == "cpu" or mode == "ram" or
20 | mode == "tmp" or mode == "gpu"
21 | or mode == "gpu_ram" then
22 |
23 | args.on_wheel_up = function()
24 | Utils.switch_tag("prev")
25 | end
26 | args.on_wheel_down = function()
27 | Utils.switch_tag("next")
28 | end
29 | else
30 | args.on_wheel_down = function()
31 | Utils.decrease_volume()
32 | end
33 |
34 | args.on_wheel_up = function()
35 | Utils.increase_volume()
36 | end
37 | end
38 |
39 | args.left_color = Globals.nicedark
40 |
41 | if mode == "cpu" then
42 | args.left = ""
43 | args.right = " | "
44 | args.right_color = Globals.nicedark
45 | args.on_click = function()
46 | Utils.system_monitor()
47 | end
48 | elseif mode == "ram" then
49 | args.right = " | "
50 | args.right_color = Globals.nicedark
51 | args.on_click = function()
52 | Utils.system_monitor()
53 | end
54 | elseif mode == "tmp" then
55 | args.right = " |"
56 | args.right_color = Globals.nicedark
57 | args.on_click = function()
58 | Utils.system_monitor_temp()
59 | end
60 | elseif mode == "gpu" then
61 | args.right = " | "
62 | args.on_click = function()
63 | Utils.system_monitor()
64 | end
65 | elseif mode == "gpu_ram" then
66 | args.on_click = function()
67 | Utils.system_monitor()
68 | end
69 | elseif mode == "net_download" then
70 | args.left = " " .. Globals.star .. " "
71 | args.left_color = Globals.niceblue
72 | args.right = " | "
73 | args.right_color = Globals.nicedark
74 | args.on_click = function()
75 | Utils.network_monitor()
76 | end
77 | elseif mode == "net_upload" then
78 | args.on_click = function()
79 | Utils.network_monitor()
80 | end
81 | end
82 |
83 | return sysmonitor.create(args)
84 | end
85 |
86 | local tags = {}
87 |
88 | for i = 1, 9 do
89 | table.insert(tags, tostring(i))
90 | end
91 |
92 | awful.screen.connect_for_each_screen(function(s)
93 | awful.tag(tags, s, awful.layout.suit.floating)
94 |
95 | -- Top Panel
96 |
97 | s.mytaglist = awful.widget.taglist({
98 | screen = s,
99 | filter = awful.widget.taglist.filter.all,
100 | buttons = {
101 | awful.button({}, 1, function(t)
102 | t:view_only()
103 | end),
104 | awful.button({}, 3, function(t)
105 | Utils.move_to_tag(t)
106 | end),
107 | awful.button({}, 4, function(t)
108 | Utils.switch_tag("prev")
109 | end),
110 | awful.button({}, 5, function(t)
111 | Utils.switch_tag("next")
112 | end),
113 | },
114 | })
115 |
116 | s.mywibar1 = awful.wibar({
117 | ontop = true,
118 | position = "top",
119 | screen = s,
120 | })
121 |
122 | local left = {
123 | layout = wibox.layout.fixed.horizontal,
124 | multibutton.create({
125 | text = " " .. Globals.flower .. " ",
126 | on_click = function()
127 | Utils.main_menu_click()
128 | end,
129 | on_right_click = function()
130 | Utils.main_menu_right_click()
131 | end,
132 | on_middle_click = function()
133 | Utils.main_menu_middle_click()
134 | end,
135 | on_wheel_up = function()
136 | Utils.main_menu_wheel_up()
137 | end,
138 | on_wheel_down = function()
139 | Utils.main_menu_wheel_down()
140 | end,
141 | }),
142 | s.mytaglist,
143 | }
144 |
145 | local center = {
146 | layout = wibox.layout.align.horizontal,
147 | nil,
148 | multibutton.create({
149 | text = "",
150 | right_color = Globals.nicedark,
151 | on_wheel_up = function()
152 | Utils.switch_tag("prev")
153 | end,
154 | on_wheel_down = function()
155 | Utils.switch_tag("next")
156 | end,
157 | }),
158 | nil,
159 | }
160 |
161 | local systray = wibox.widget.systray()
162 | systray:set_screen(screen[Globals.primary_screen])
163 | local systray_container = wibox.layout.margin(systray, 0, 0, 3, 3)
164 |
165 | -- Utils
166 | local utils_button = multibutton.create({
167 | text = "Utils",
168 | left = " " .. Globals.utils .. " ",
169 | right = " | ",
170 | right_color = Globals.nicedark,
171 | on_click = function()
172 | Dropdowns.toggle("utils")
173 | end,
174 | on_middle_click = function()
175 | Dropdowns.start_utils()
176 | end,
177 | on_wheel_up = function()
178 | Utils.switch_tag("prev")
179 | end,
180 | on_wheel_down = function()
181 | Utils.switch_tag("next")
182 | end,
183 | })
184 |
185 | Dropdowns.register_button("utils", utils_button, s)
186 |
187 | -- Melt
188 | local melt_button = multibutton.create({
189 | text = "Melt",
190 | left = Globals.melt .. " ",
191 | right = " | ",
192 | right_color = Globals.nicedark,
193 | on_click = function()
194 | Dropdowns.toggle("melt")
195 | end,
196 | on_middle_click = function()
197 | Dropdowns.start_melt()
198 | end,
199 | on_wheel_up = function()
200 | Utils.switch_tag("prev")
201 | end,
202 | on_wheel_down = function()
203 | Utils.switch_tag("next")
204 | end,
205 | })
206 |
207 | Dropdowns.register_button("melt", melt_button, s)
208 |
209 | local right = {
210 | layout = wibox.layout.fixed.horizontal(),
211 | autotimer.widget,
212 | Utils.space(),
213 | systray_container,
214 | utils_button,
215 | melt_button,
216 | sysmonitor_widget("cpu"),
217 | sysmonitor_widget("ram"),
218 | sysmonitor_widget("tmp"),
219 | -- sysmonitor_widget("gpu"),
220 | -- sysmonitor_widget("gpu_ram"),
221 | sysmonitor_widget("net_download"),
222 | sysmonitor_widget("net_upload"),
223 | Globals.volumecontrol.create({
224 | left = " " .. Globals.star .. " ",
225 | right = " " .. Globals.star .. " ",
226 | left_color = Globals.niceblue,
227 | right_color = Globals.niceblue,
228 | mutecolor = Globals.nicedark,
229 | maxcolor = Globals.nicegreen,
230 | on_click = function()
231 | Utils.show_audio_controls()
232 | end,
233 | }),
234 | -- multibutton.create({
235 | -- widget = wibox.widget.textclock("%a-%d-%b %I:%M:%S %P", 1),
236 | -- on_click = function()
237 | -- Utils.calendar()
238 | -- end,
239 | -- on_wheel_up = function()
240 | -- Utils.increase_volume()
241 | -- end,
242 | -- on_wheel_down = function()
243 | -- Utils.decrease_volume()
244 | -- end,
245 | -- right = " ",
246 | -- }),
247 | }
248 |
249 | s.mywibar1:setup({
250 | layout = wibox.layout.align.horizontal,
251 | left,
252 | center,
253 | right,
254 | })
255 |
256 | -- Bottom Panel
257 |
258 | s.mytasklist = awful.widget.tasklist({
259 | screen = s,
260 | buttons = Bindings.tasklist_buttons,
261 | filter = function()
262 | return true
263 | end,
264 | source = function()
265 | return Utils.sort_index(s)
266 | end,
267 | widget_template = {
268 | {
269 | {
270 | {
271 | {
272 | id = "icon_role",
273 | widget = wibox.widget.imagebox,
274 | },
275 | right = 10,
276 | top = 3,
277 | bottom = 3,
278 | widget = wibox.container.margin,
279 | },
280 | {
281 | id = "text_role",
282 | widget = wibox.widget.textbox,
283 | },
284 | layout = wibox.layout.fixed.horizontal,
285 | },
286 | left = 10,
287 | right = 10,
288 | widget = wibox.container.margin,
289 | },
290 | id = "background_role",
291 | widget = wibox.container.background,
292 | },
293 | })
294 |
295 | s.mywibar2 = awful.wibar({
296 | ontop = true,
297 | position = "bottom",
298 | screen = s,
299 | })
300 |
301 | s.mywibar2:setup({
302 | layout = wibox.layout.align.horizontal,
303 | nil,
304 | s.mytasklist,
305 | nil,
306 | })
307 | end)
308 |
309 | -- Double click titlebar
310 | function double_click_event_handler(double_click_event)
311 | if double_click_timer then
312 | double_click_timer:stop()
313 | double_click_timer = nil
314 | return true
315 | end
316 |
317 | double_click_timer = gears.timer.start_new(0.20, function()
318 | double_click_timer = nil
319 | return false
320 | end)
321 | end
322 |
323 | client.connect_signal("request::titlebars", function(c)
324 | -- buttons for the titlebar
325 | local buttons = {
326 | awful.button({}, 1, function()
327 | -- WILL EXECUTE THIS ON DOUBLE CLICK
328 | if double_click_event_handler() then
329 | c.maximized = not c.maximized
330 | c:raise()
331 | else
332 | c:activate({ context = "titlebar", action = "mouse_move" })
333 | end
334 | end),
335 | awful.button({}, 3, function()
336 | c:activate({ context = "titlebar", action = "mouse_resize" })
337 | end),
338 | }
339 |
340 | awful.titlebar(c).widget = {
341 | { -- Left
342 | awful.titlebar.widget.iconwidget(c),
343 | buttons = buttons,
344 | layout = wibox.layout.fixed.horizontal,
345 | },
346 | { -- Middle
347 | { -- Title
348 | halign = "center",
349 | widget = awful.titlebar.widget.titlewidget(c),
350 | },
351 | buttons = buttons,
352 | layout = wibox.layout.flex.horizontal,
353 | },
354 | { -- Right
355 | awful.titlebar.widget.maximizedbutton(c),
356 | awful.titlebar.widget.ontopbutton(c),
357 | awful.titlebar.widget.closebutton(c),
358 | layout = wibox.layout.fixed.horizontal(),
359 | },
360 | layout = wibox.layout.align.horizontal,
361 | }
362 | end)
363 |
--------------------------------------------------------------------------------
/modules/theme.lua:
--------------------------------------------------------------------------------
1 | local awful = require("awful")
2 | local gears = require("gears")
3 | local beautiful = require("beautiful")
4 |
5 | beautiful.init(gears.filesystem.get_themes_dir() .. "default/theme.lua")
6 |
7 | beautiful.font = "monospace 13"
8 | beautiful.wibar_height = 30
9 | beautiful.tasklist_shape_border_width = 1
10 | beautiful.notification_font = "monospace 18px"
11 | beautiful.notification_icon_size = 30
12 | beautiful.systray_icon_spacing = 5
13 | awful.mouse.snap.default_distance = 25
14 |
15 | -- Colors
16 | local grey = "#b8babc"
17 | local bg0 = "#222020"
18 | local bg1 = "#2B303B"
19 | local border = "#445666"
20 | local green = "#18911D"
21 | local white = "#ffffff"
22 |
23 | beautiful.fg_normal = grey
24 | beautiful.bg_normal = bg0
25 | beautiful.bg_systray = bg0
26 | beautiful.bg_urgent = green
27 | beautiful.fg_urgent = white
28 | beautiful.tasklist_shape_border_color = bg1
29 | beautiful.tasklist_shape_border_color_focus = border
30 | beautiful.tasklist_fg_normal = grey
31 | beautiful.tasklist_bg_normal = bg0
32 | beautiful.tasklist_fg_focus = white
33 | beautiful.tasklist_bg_focus = bg1
34 | beautiful.tasklist_fg_minimize = grey
35 | beautiful.tasklist_bg_minimize = bg0
36 | beautiful.tasklist_plain_task_name = true
37 | beautiful.taglist_fg_focus = white
38 | beautiful.taglist_bg_focus = bg1
39 |
40 | -- Wallpaper
41 | beautiful.wallpaper = Globals.conf_dir .. "wallpaper.jpg"
42 |
--------------------------------------------------------------------------------
/modules/utils.lua:
--------------------------------------------------------------------------------
1 | Utils = {}
2 |
3 | local awful = require("awful")
4 | local naughty = require("naughty")
5 | local wibox = require("wibox")
6 | local gears = require("gears")
7 | local socket = require("socket")
8 | local lockdelay = require("madwidgets/lockdelay/lockdelay")
9 | local autotimer = require("madwidgets/autotimer/autotimer")
10 | local debounce_timers = {}
11 | local keys_used = {}
12 | local context_client
13 |
14 | local media_lock = lockdelay.create({
15 | action = function(cmd)
16 | Utils.spawn(cmd)
17 | end,
18 | delay = 250,
19 | })
20 |
21 | local tag_next_lock = lockdelay.create({
22 | action = function(sticky)
23 | Utils.switch_tag("next", sticky)
24 | end,
25 | delay = 100,
26 | })
27 |
28 | local tag_prev_lock = lockdelay.create({
29 | action = function(sticky)
30 | Utils.switch_tag("prev", sticky)
31 | end,
32 | delay = 100,
33 | })
34 |
35 | function Utils.msg(txt, info)
36 | local run = function() end
37 |
38 | if info and Utils.startswith(info, "https://") then
39 | run = function()
40 | Utils.open_tab(info)
41 | end
42 | end
43 |
44 | local n = naughty.notify({ title = " " .. tostring(txt) .. " " })
45 |
46 | n:connect_signal("destroyed", function(n, reason)
47 | if reason == naughty.notification_closed_reason.dismissed_by_user then
48 | run()
49 | end
50 | end)
51 | end
52 |
53 | function Utils.prev_client()
54 | awful.client.focus.history.previous()
55 | if client.focus then
56 | client.focus:raise()
57 | end
58 | end
59 |
60 | function Utils.center(c)
61 | awful.placement.centered(c, { honor_workarea = true })
62 | end
63 |
64 | function Utils.maximize(c)
65 | c.maximized = not c.maximized
66 | Utils.focus(c)
67 | end
68 |
69 | function Utils.maximize_on_cursor(c)
70 | local c = mouse.object_under_pointer()
71 |
72 | if c then
73 | Utils.maximize(c)
74 | end
75 | end
76 |
77 | function Utils.fullscreen(c)
78 | c.fullscreen = not c.fullscreen
79 | Utils.focus(c)
80 | end
81 |
82 | function Utils.on_top(c)
83 | c.ontop = not c.ontop
84 | end
85 |
86 | function Utils.check_fullscreen(c)
87 | Utils.my_screen().mywibar1.ontop = not c.fullscreen
88 | Utils.my_screen().mywibar2.ontop = not c.fullscreen
89 | end
90 |
91 | function Utils.focus(c)
92 | c:emit_signal("request::activate", "tasklist", { raise = true })
93 | end
94 |
95 | function Utils.close_current()
96 | local c = client.focus
97 |
98 | if c then
99 | c:kill()
100 | end
101 | end
102 |
103 | function Utils.close(c)
104 | c:kill()
105 | end
106 |
107 | function Utils.snap(c, axis, position)
108 | local f
109 |
110 | c.maximized = false
111 |
112 | if axis == "corner" then
113 | f = awful.placement.scale + position
114 | else
115 | f = awful.placement.scale + position + (axis and awful.placement["maximize_" .. axis] or nil)
116 | end
117 |
118 | f(c, {
119 | honor_workarea = true,
120 | to_percent = 0.5,
121 | })
122 | end
123 |
124 | function Utils.placement(c, what)
125 | awful.placement[what](c, { honor_workarea = true })
126 | end
127 |
128 | function Utils.launcher()
129 | Utils.spawn("rofi -modi drun -show drun -show-icons -no-click-to-exit")
130 | end
131 |
132 | function Utils.altab()
133 | Utils.spawn("rofi -show window -show-icons -no-click-to-exit")
134 | end
135 |
136 | function Utils.screenshot()
137 | Utils.spawn("flameshot gui")
138 | end
139 |
140 | function Utils.screenshot_window()
141 | Utils.spawn("spectacle -a")
142 | end
143 |
144 | function Utils.screenshot_screen()
145 | Utils.spawn("spectacle -m")
146 | end
147 |
148 | function Utils.randstring()
149 | Utils.run_script_2("randword.sh")
150 | end
151 |
152 | function Utils.randword()
153 | Utils.run_script_2("randword.sh word")
154 | end
155 |
156 | function Utils.to_clipboard(text)
157 | Utils.shellspawn('echo -n "' .. Utils.trim(Utils.escape_quotes(text)) .. '" | xclip -selection clipboard')
158 | end
159 |
160 | function Utils.escape_quotes(text)
161 | return string.gsub(text, '"', '\\"')
162 | end
163 |
164 | function Utils.trim(text)
165 | return string.gsub(text, "^%s*(.-)%s*$", "%1")
166 | end
167 |
168 | function Utils.startswith(s1, s2)
169 | return string.sub(s1, 1, string.len(s2)) == s2
170 | end
171 |
172 | function Utils.show_menupanel(mode)
173 | Menupanels.main.start(mode)
174 | end
175 |
176 | function Utils.get_context_client()
177 | return context_client
178 | end
179 |
180 | function Utils.show_task_context(c)
181 | context_client = c
182 | Menupanels.context.start("mouse")
183 | end
184 |
185 | function Utils.show_client_title(c)
186 | Menupanels.utils.showinfo(c.name)
187 | end
188 |
189 | function Utils.stop_all_players()
190 | Utils.spawn("playerctl --all-players pause")
191 | end
192 |
193 | function Utils.lockscreen(suspend)
194 | local s = ""
195 |
196 | if suspend then
197 | s = "systemctl suspend; "
198 | end
199 |
200 | Utils.shellspawn(s .. "i3lock --color=000000 -n")
201 | end
202 |
203 | function Utils.suspend()
204 | Utils.lockscreen(true)
205 | end
206 |
207 | function Utils.unlockscreen()
208 | Utils.shellspawn("killall i3lock")
209 | end
210 |
211 | function Utils.alt_lockscreen()
212 | Utils.stop_all_players()
213 | Utils.lockscreen()
214 | end
215 |
216 | function Utils.open_tab(url)
217 | Utils.shellspawn("firefox-developer-edition --new-tab --url '" .. url .. "'")
218 | end
219 |
220 | function Utils.add_to_file(path, text, num)
221 | Utils.shellspawn(
222 | "echo '" .. text .. "' | cat - " .. path .. " | sponge " .. path .. " && sed -i '" .. num .. ",$ d' " .. path
223 | )
224 | end
225 |
226 | local log_path = os.getenv("HOME") .. "/.awm_log"
227 |
228 | function Utils.add_to_log(text, announce)
229 | local txt = os.date("%c") .. " " .. Utils.trim(text)
230 | Utils.add_to_file(log_path, txt, 1000)
231 |
232 | if announce then
233 | Utils.msg("Added to log: " .. text)
234 | end
235 | end
236 |
237 | function Utils.show_log(name)
238 | Utils.shellspawn("geany " .. log_path)
239 | end
240 |
241 | local notifications_path = os.getenv("HOME") .. "/.awm_notifications"
242 |
243 | function Utils.add_to_notifications(text)
244 | local clean = Utils.trim(text)
245 |
246 | if Utils.startswith(clean, "Volume:") then
247 | return
248 | end
249 |
250 | local txt = os.date("%c") .. " " .. clean
251 | Utils.add_to_file(notifications_path, txt, 1000)
252 | end
253 |
254 | function Utils.show_notifications(name)
255 | Utils.shellspawn("geany " .. notifications_path)
256 | end
257 |
258 | function Utils.calendar()
259 | Utils.spawn("osmo")
260 | end
261 |
262 | function Utils.increase_volume(osd)
263 | Globals.volumecontrol.increase(osd)
264 | end
265 |
266 | function Utils.decrease_volume(osd)
267 | Globals.volumecontrol.decrease(osd)
268 | end
269 |
270 | function Utils.set_volume(v)
271 | Globals.volumecontrol.set_round(v)
272 | end
273 |
274 | function Utils.max_volume()
275 | local v = Globals.volumecontrol.max_volume
276 | Globals.volumecontrol.set_round(v)
277 | end
278 |
279 | function Utils.min_volume()
280 | Globals.volumecontrol.set_round(30)
281 | end
282 |
283 | function Utils.refresh_volume()
284 | Globals.volumecontrol.refresh()
285 | end
286 |
287 | function Utils.spawn(cmd)
288 | awful.spawn(cmd, false)
289 | end
290 |
291 | function Utils.spawn_2(cmd)
292 | awful.spawn(cmd)
293 | end
294 |
295 | function Utils.shellspawn(cmd)
296 | awful.spawn.with_shell(cmd, false)
297 | end
298 |
299 | function Utils.singlespawn(cmd)
300 | awful.spawn.single_instance(cmd)
301 | end
302 |
303 | function Utils.run_script(cmd)
304 | Utils.spawn(Globals.conf_dir .. "/scripts/" .. cmd)
305 | end
306 |
307 | function Utils.run_script_2(cmd)
308 | Utils.spawn(os.getenv("HOME") .. "/scripts/" .. cmd)
309 | end
310 |
311 | function Utils.width_factor(n, c)
312 | local width = Utils.my_screen().workarea.width * n
313 |
314 | if c then
315 | local border = c.border_width or 0
316 | width = width - (border * 2)
317 | end
318 |
319 | return width
320 | end
321 |
322 | function Utils.height_factor(n, c)
323 | local height = Utils.my_screen().workarea.height * n
324 |
325 | if c then
326 | local border = c.border_width or 0
327 | height = height - (border * 2)
328 | end
329 |
330 | return height
331 | end
332 |
333 | function Utils.ratio(c)
334 | return c.width / c.height
335 | end
336 |
337 | function Utils.shrink_or_grow(c, what)
338 | Utils.focus(c)
339 | c.maximized = false
340 | local w = 20 * Utils.ratio(c)
341 | local h = 20
342 |
343 | if what == "grow" then
344 | c.height = c.height + h
345 | c.width = c.width + w
346 | elseif what == "shrink" then
347 | c.height = c.height - h
348 | c.width = c.width - w
349 | end
350 |
351 | Utils.center(c)
352 | end
353 |
354 | function Utils.grow_in_place(c)
355 | Utils.shrink_or_grow(c, "grow")
356 | end
357 |
358 | function Utils.shrink_in_place(c)
359 | Utils.shrink_or_grow(c, "shrink")
360 | end
361 |
362 | function Utils.my_screen()
363 | return awful.screen.focused()
364 | end
365 |
366 | function Utils.my_tag()
367 | return Utils.my_screen().selected_tag
368 | end
369 |
370 | function Utils.clients()
371 | local filtered = {}
372 | local clients = Utils.my_tag():clients()
373 |
374 | for i = 1, #clients do
375 | local c = clients[i]
376 |
377 | if not Dropdowns.included(c) then
378 | table.insert(filtered, c)
379 | end
380 | end
381 |
382 | return filtered
383 | end
384 |
385 | function Utils.open_terminal(cmd)
386 | Utils.spawn("konsole -e " .. cmd)
387 | end
388 |
389 | function Utils.system_monitor()
390 | Utils.open_terminal("htop")
391 | end
392 |
393 | function Utils.system_monitor_temp()
394 | Utils.open_terminal("watch -n 2 sensors")
395 | end
396 |
397 | -- To run nethogs without sudo you need to do this once:
398 | -- sudo setcap "cap_net_admin,cap_net_raw=ep" /usr/bin/nethogs
399 | function Utils.network_monitor()
400 | Utils.open_terminal("nethogs")
401 | end
402 |
403 | function Utils.space()
404 | return wibox.widget.textbox(" ")
405 | end
406 |
407 | function Utils.show_clipboard()
408 | Utils.spawn("clipton")
409 | end
410 |
411 | function Utils.switch_tag(direction, sticky)
412 | Dropdowns.check()
413 | local index = Utils.my_tag().index
414 | local num_tags = #Utils.my_screen().tags
415 | local ok = (direction == "next" and index < num_tags) or (direction == "prev" and index > 1)
416 | local new_index
417 |
418 | if ok then
419 | if direction == "next" then
420 | new_index = index + 1
421 | elseif direction == "prev" then
422 | new_index = index - 1
423 | end
424 |
425 | s_index = new_index
426 |
427 | local new_tag = Utils.my_screen().tags[new_index]
428 |
429 | if sticky then
430 | if client.focus and client.focus.screen == Utils.my_screen() then
431 | client.focus:move_to_tag(new_tag)
432 | end
433 | end
434 |
435 | new_tag:view_only()
436 | new_c = Utils.highest_in_tag(new_tag)
437 |
438 | if new_c then
439 | Utils.focus(new_c)
440 | end
441 | end
442 | end
443 |
444 | function Utils.next_tag(sticky)
445 | tag_next_lock.trigger(sticky)
446 | end
447 |
448 | function Utils.prev_tag(sticky)
449 | tag_prev_lock.trigger(sticky)
450 | end
451 |
452 | function Utils.next_tag_all()
453 | i = Utils.my_tag().index + 1
454 |
455 | if i > #Utils.my_screen().tags then
456 | i = #Utils.my_screen().tags
457 | end
458 |
459 | for s in screen do
460 | Utils.goto_tag(s, i)
461 | end
462 | end
463 |
464 | function Utils.prev_tag_all()
465 | i = Utils.my_tag().index - 1
466 |
467 | if i < 1 then
468 | i = 1
469 | end
470 |
471 | for s in screen do
472 | Utils.goto_tag(s, i)
473 | end
474 | end
475 |
476 | function Utils.goto_tag(s, i)
477 | local tag = s.tags[i]
478 |
479 | if tag then
480 | tag:view_only()
481 | end
482 | end
483 |
484 | function Utils.sleep(n)
485 | os.execute("sleep " .. tonumber(n))
486 | end
487 |
488 | function Utils.show_audio_controls()
489 | Utils.shellspawn("python ~/code/empris/empris.py")
490 | end
491 |
492 | function Utils.move_to_tag(t)
493 | if client.focus then
494 | client.focus:move_to_tag(t)
495 | t:view_only()
496 | end
497 | end
498 |
499 | function Utils.to_screen_tag(c, screen_index, tag_index)
500 | if c then
501 | tag = screen[screen_index].tags[tag_index]
502 | c:move_to_tag(tag)
503 | tag:view_only()
504 | end
505 | end
506 |
507 | function Utils.auto_suspend(minutes)
508 | autotimer.start_timer("Suspend", minutes, function()
509 | Utils.suspend()
510 | end)
511 | end
512 |
513 | function Utils.timer(title, minutes)
514 | autotimer.start_timer(title, minutes, function()
515 | Utils.msg(title .. " ended")
516 | end)
517 | end
518 |
519 | function Utils.counter(title)
520 | autotimer.start_counter(title)
521 | end
522 |
523 | function Utils.isempty(s)
524 | return s == nil or s == ""
525 | end
526 |
527 | function Utils.highest_in_tag(tag)
528 | for _, c in ipairs(client.get(tag.screen, true)) do
529 | if Utils.table_contains(c:tags(), tag) then
530 | if not Dropdowns.included(c) then
531 | return c
532 | end
533 | end
534 | end
535 | end
536 |
537 | function Utils.table_contains(tab, val)
538 | for index, value in ipairs(tab) do
539 | if value == val then
540 | return true
541 | end
542 | end
543 |
544 | return false
545 | end
546 |
547 | function Utils.key_press(key)
548 | root.fake_input("key_press", key)
549 | end
550 |
551 | function Utils.key_release(key)
552 | root.fake_input("key_release", key)
553 | end
554 |
555 | function Utils.keyboard(
556 | ctrl,
557 | shift,
558 | alt,
559 | key
560 | )
561 | local timer = gears.timer({
562 | timeout = 0.11,
563 | single_shot = true,
564 | })
565 |
566 | timer:connect_signal("timeout", function()
567 | Utils.release_keys()
568 | Utils.key_release(key)
569 |
570 | if ctrl then
571 | Utils.key_press("Control_L")
572 | end
573 |
574 | if shift then
575 | Utils.key_press("Shift_L")
576 | end
577 |
578 | if alt then
579 | Utils.key_press("Alt_L")
580 | end
581 |
582 | Utils.key_press(key)
583 | Utils.key_release(key)
584 | keys_used[key] = true
585 | Utils.debounce_keys()
586 | end)
587 |
588 | timer:start()
589 | end
590 |
591 | function Utils.minimize(c)
592 | if client.focus == c then
593 | if Frames.cycle(c) then
594 | return
595 | end
596 | end
597 |
598 | c:activate({ context = "tasklist", action = "toggle_minimization" })
599 | end
600 |
601 | function Utils.smart_close_current()
602 | local c = client.focus
603 |
604 | if c then
605 | Utils.smart_close(c)
606 | end
607 | end
608 |
609 | function Utils.smart_close_cursor(c)
610 | local c = mouse.object_under_pointer()
611 |
612 | if c then
613 | Utils.smart_close(c)
614 | end
615 | end
616 |
617 | function Utils.smart_close(c)
618 | if not c then
619 | return
620 | end
621 |
622 | if not c.x_keys then
623 | return
624 | end
625 |
626 | if c.x_no_close then
627 | return
628 | end
629 |
630 | if Dropdowns.included(c) then
631 | Dropdowns.hide_all()
632 | return
633 | end
634 |
635 | if c.kill then
636 | if (c.instance == "Navigator") or (c.instance == "code") then
637 | Utils.focus(c)
638 | Utils.keyboard(true, false, false, "w")
639 | else
640 | c:kill()
641 | end
642 | end
643 | end
644 |
645 | function Utils.smart_button(c)
646 | local c = mouse.object_under_pointer()
647 | if not c then
648 | return
649 | end
650 | if not c.x_client then
651 | return
652 | end
653 |
654 | if c.x_terminal then
655 | Utils.focus(c)
656 | Utils.run_script("restart.rb " .. c.instance)
657 | elseif c.x_frame ~= "none" then
658 | Rules.reset(c)
659 | elseif not Dropdowns.included(c) then
660 | if #Utils.clients() > 1 then
661 | Utils.minimize(c)
662 | end
663 | end
664 | end
665 |
666 | function Utils.bluetooth(on)
667 | local cmd
668 | local mac = "1C:6E:4C:8B:90:53"
669 |
670 | if on then
671 | cmd = "bluetoothctl connect " .. mac
672 | else
673 | cmd = "bluetoothctl disconnect " .. mac
674 | end
675 |
676 | Utils.spawn(cmd)
677 | end
678 |
679 | function Utils.corner_click()
680 | Dropdowns.toggle("utils")
681 | end
682 |
683 | function Utils.corner_middle_click() end
684 |
685 | function Utils.corner_wheel_up() end
686 |
687 | function Utils.corner_wheel_down() end
688 |
689 | function Utils.middle_click(c)
690 | if c.x_alt_q then
691 | Utils.keyboard(false, false, true, "q")
692 | elseif c.x_ctrl_d then
693 | Utils.keyboard(true, false, false, "d")
694 | else
695 | Utils.focus(c)
696 | end
697 | end
698 |
699 | function Utils.first_tag()
700 | Utils.my_screen().tags[1]:view_only()
701 | end
702 |
703 | function Utils.seconds()
704 | return os.time()
705 | end
706 |
707 | function Utils.nano()
708 | return socket.gettime()
709 | end
710 |
711 | function Utils.decorate(c)
712 | c.titlebars_enabled = not c.titlebars_enabled
713 |
714 | if c.titlebars_enabled then
715 | awful.titlebar.show(c)
716 | else
717 | awful.titlebar.hide(c)
718 | end
719 | end
720 |
721 | function Utils.launch_dev()
722 | Utils.spawn("code")
723 | Utils.spawn("tilix --session ~/sessions/meltdown.json")
724 | end
725 |
726 | function Utils.tagbar_click()
727 | Dropdowns.toggle("utils")
728 | end
729 |
730 | function Utils.tagbar_right_click()
731 | Utils.altab()
732 | end
733 |
734 | function Utils.tagbar_middle_click()
735 | Utils.smart_close_current()
736 | end
737 |
738 | function Utils.tagbar_wheel_up()
739 | Utils.switch_tag("prev")
740 | end
741 |
742 | function Utils.tagbar_wheel_down()
743 | Utils.switch_tag("next")
744 | end
745 |
746 | function Utils.main_menu_click()
747 | Utils.show_menupanel("mouse")
748 | end
749 |
750 | function Utils.main_menu_right_click()
751 | Dropdowns.toggle("utils")
752 | end
753 |
754 | function Utils.main_menu_middle_click()
755 | Utils.stop_all_players()
756 | Utils.lockscreen()
757 | end
758 |
759 | function Utils.main_menu_wheel_up()
760 | Utils.switch_tag("prev")
761 | end
762 |
763 | function Utils.main_menu_wheel_down()
764 | Utils.switch_tag("next")
765 | end
766 |
767 | function Utils.clean_clients(clients)
768 | local filtered = {}
769 |
770 | for i = 1, #clients do
771 | local c = clients[i]
772 |
773 | if not Dropdowns.included(c) then
774 | table.insert(filtered, c)
775 | end
776 | end
777 |
778 | return filtered
779 | end
780 |
781 | function Utils.two_clients()
782 | local tag = Utils.my_tag()
783 | local clients = Utils.sort_index(tag.screen)
784 | clients = Utils.clean_clients(clients)
785 |
786 | if #clients < 2 then
787 | return
788 | end
789 |
790 | table.sort(clients, function(a, b)
791 | return a.first_tag.index > b.first_tag.index
792 | end)
793 |
794 | c1 = clients[1]
795 | c2 = clients[2]
796 |
797 | c1.maximized = false
798 | c2.maximized = false
799 |
800 | c1.border_width = 2
801 | c2.border_width = 2
802 |
803 | return c1, c2
804 | end
805 |
806 | function Utils.max_layout()
807 | for _, c in ipairs(Utils.clients()) do
808 | c.maximized = false
809 | c.border_width = 0
810 | c.width = Utils.width_factor(1, c)
811 | c.height = Utils.height_factor(1, c)
812 | Utils.placement(c, "top_left")
813 | end
814 | end
815 |
816 | function Utils.paper_horizontal_layout()
817 | local c1, c2 = Utils.two_clients()
818 |
819 | c1.width = Utils.width_factor(0.7, c1)
820 | c1.height = Utils.height_factor(1, c1)
821 |
822 | c2.width = Utils.width_factor(0.7, c2)
823 | c2.height = Utils.height_factor(1, c2)
824 |
825 | Utils.placement(c1, "left")
826 | Utils.placement(c2, "right")
827 | end
828 |
829 | function Utils.paper_vertical_layout()
830 | local c1, c2 = Utils.two_clients()
831 |
832 | c1.width = Utils.width_factor(1, c1)
833 | c1.height = Utils.height_factor(0.7, c1)
834 |
835 | c2.width = Utils.width_factor(1, c2)
836 | c2.height = Utils.height_factor(0.7, c2)
837 |
838 | Utils.placement(c1, "top")
839 | Utils.placement(c2, "bottom")
840 | end
841 |
842 | function Utils.horizontal_layout()
843 | local c1, c2 = Utils.two_clients()
844 |
845 | c1.width = Utils.width_factor(0.5, c1)
846 | c1.height = Utils.height_factor(1, c1)
847 |
848 | c2.width = Utils.width_factor(0.5, c2)
849 | c2.height = Utils.height_factor(1, c2)
850 |
851 | Utils.placement(c1, "left")
852 | Utils.placement(c2, "right")
853 | end
854 |
855 | function Utils.vertical_layout()
856 | local c1, c2 = Utils.two_clients()
857 |
858 | c1.width = Utils.width_factor(1, c1)
859 | c1.height = Utils.height_factor(0.5, c1)
860 |
861 | c2.width = Utils.width_factor(1, c2)
862 | c2.height = Utils.height_factor(0.5, c2)
863 |
864 | Utils.placement(c1, "top")
865 | Utils.placement(c2, "bottom")
866 | end
867 |
868 | function Utils.sort_index(s)
869 | local result = {}
870 | local unindexed = {}
871 |
872 | for _, c in pairs(client.get()) do
873 | if c.screen == s then
874 | if c.first_tag.index == s.selected_tag.index then
875 | if c.x_index > 0 then
876 | table.insert(result, c)
877 | else
878 | table.insert(unindexed, c)
879 | end
880 | end
881 | end
882 | end
883 |
884 | table.sort(result, function(a, b)
885 | return a.x_index < b.x_index
886 | end)
887 |
888 | for _, c in pairs(unindexed) do
889 | table.insert(result, c)
890 | end
891 |
892 | return result
893 | end
894 |
895 | function Utils.center_cursor()
896 | local screen = Utils.my_screen()
897 | local workarea = screen.workarea
898 |
899 | mouse.coords({
900 | x = workarea.x + workarea.width / 2,
901 | y = workarea.y + workarea.height / 2,
902 | })
903 | end
904 |
905 | function Utils.cursor_on_prev_screen()
906 | awful.screen.focus_relative(-1)
907 | Utils.center_cursor()
908 | end
909 |
910 | function Utils.cursor_on_next_screen()
911 | awful.screen.focus_relative(1)
912 | Utils.center_cursor()
913 | end
914 |
915 | function Utils.refresh_on_cursor()
916 | local c = mouse.object_under_pointer()
917 |
918 | if c then
919 | Utils.focus(c)
920 | Utils.keyboard(false, false, false, "F5")
921 | end
922 | end
923 |
924 | function Utils.home_on_cursor()
925 | local c = mouse.object_under_pointer()
926 |
927 | if c then
928 | Utils.focus(c)
929 | Utils.keyboard(true, false, false, "Home")
930 | end
931 | end
932 |
933 | function Utils.end_on_cursor()
934 | local c = mouse.object_under_pointer()
935 |
936 | if c then
937 | Utils.focus(c)
938 | Utils.keyboard(true, false, false, "End")
939 | end
940 | end
941 |
942 | function Utils.release_keys()
943 | Utils.key_release("Super_L")
944 | Utils.key_release("Super_R")
945 | Utils.key_release("Control_L")
946 | Utils.key_release("Control_R")
947 | Utils.key_release("Shift_L")
948 | Utils.key_release("Shift_R")
949 | Utils.key_release("Alt_L")
950 | Utils.key_release("Alt_R")
951 |
952 | for key, _ in pairs(keys_used) do
953 | Utils.key_release(key)
954 | end
955 | end
956 |
957 | function Utils.expand(c)
958 | Utils.maximize(c)
959 | c.width = Utils.width_factor(2, c)
960 | end
961 |
962 | function Utils.debounce(func, delay)
963 | return function(...)
964 | local args = {...}
965 | local timer = debounce_timers[func]
966 |
967 | -- Cancel the existing timer if it exists
968 | if timer then
969 | timer:stop()
970 | end
971 |
972 | -- Create a new timer
973 | timer = gears.timer({
974 | timeout = delay,
975 | autostart = true,
976 | single_shot = true,
977 | callback = function()
978 | func(table.unpack(args))
979 | end
980 | })
981 |
982 | -- Store the timer
983 | debounce_timers[func] = timer
984 | end
985 | end
986 |
987 | Utils.debounce_keys = Utils.debounce(function()
988 | Utils.release_keys()
989 | end, 0.15)
--------------------------------------------------------------------------------
/quick_actions.txt:
--------------------------------------------------------------------------------
1 | Players = python /home/yo/code/empris/empris.py
2 | Clipboard = clipton
3 | Screenshot (Region) = spectacle -r
4 | Screenshot (Window) = spectacle -a
5 | Screenshot (Monitor) = spectacle -m
--------------------------------------------------------------------------------
/rc.lua:
--------------------------------------------------------------------------------
1 | local awful = require("awful")
2 | local gears = require("gears")
3 | awful.util.shell = "dash"
4 |
5 | require("awful.autofocus")
6 | require("modules/notifications")
7 | require("modules/globals")
8 | require("modules/utils")
9 | require("modules/dropdowns")
10 | require("modules/frames")
11 | require("modules/bindings")
12 | require("modules/theme")
13 | require("modules/screens")
14 | require("modules/clients")
15 | require("modules/rules")
16 | require("modules/menupanels")
17 | require("modules/autostart")
18 |
19 | local timer = gears.timer({
20 | timeout = 2,
21 | call_now = false,
22 | autostart = true,
23 | single_shot = true,
24 | callback = function()
25 | Utils.msg("Setup")
26 | Frames.start()
27 | Dropdowns.hide_all()
28 | Utils.msg("Done")
29 | end,
30 | })
31 |
--------------------------------------------------------------------------------
/scripts/counter.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require "open3"
3 |
4 | def get_input(prompt, data)
5 | cmd = "rofi -dmenu -p '#{prompt}' -i"
6 | stdin, stdout, stderr, wait_thr = Open3.popen3(cmd)
7 | stdin.puts(data)
8 | stdin.close
9 | return stdout.read.strip
10 | end
11 |
12 | path = File.join(__dir__, "data/timer.data")
13 | data = ""
14 |
15 | File.open(path, "a+") do |file|
16 | data = file.read.strip
17 | end
18 |
19 | if ARGV.length >= 2
20 | title = ARGV[0]
21 | time = ARGV[1..-1].join(" ")
22 | else
23 | title = get_input("Enter Title", data)
24 |
25 | if title == ""
26 | exit
27 | end
28 | end
29 |
30 | lines = data.split("\n")
31 | lines.delete_if {|x| x == title}
32 | lines.unshift(title)
33 | File.write(path, lines.join("\n"))
34 |
35 | `awesome-client 'Utils.counter("#{title}")'`
--------------------------------------------------------------------------------
/scripts/data/commands.data:
--------------------------------------------------------------------------------
1 | ./utils/bundle.rb && ./utils/check.sh && ./utils/zip.rb && ./utils/tag.rb
2 | ./utils/bundle.rb && ./utils/check.sh && ./utils/dups.rb
--------------------------------------------------------------------------------
/scripts/desktop/readme.txt:
--------------------------------------------------------------------------------
1 | Add .desktop files to:
2 | ~/.local/share/applications
--------------------------------------------------------------------------------
/scripts/desktop/w_timer.desktop:
--------------------------------------------------------------------------------
1 | [Desktop Entry]
2 | Version=1.0
3 | Name=timer
4 | Comment=Time Stuff
5 | GenericName=Timer
6 | Exec=/home/yo/.config/awesome/scripts/timer.rb
7 | Icon=application-x-executable
8 | StartupNotify=true
9 | Terminal=false
10 | Type=Application
--------------------------------------------------------------------------------
/scripts/readme.txt:
--------------------------------------------------------------------------------
1 | timer.rb is used to start the widget timers on the panel.
2 |
3 | It will remember used timer names and save them to data/timers.data
4 |
5 | --------------------------
6 |
7 | For commands.rb create the file data/commands.data
8 |
9 | Inside that file fill it with lines like:
10 |
11 | dolphin ; some comand
12 | dolphin ; some other command
13 | tilix ; some command
14 |
15 | The left part is the `instance` the command on the right belong to.
16 |
17 | Then when you use the smart button on dolphin or tilix it will show their commands.
18 |
19 | In order for this to work, set `x_commands = true` in the rules of these clients.
20 |
21 | Else the smart button will minimize them or reset their rules.
22 |
23 | --------------------------
--------------------------------------------------------------------------------
/scripts/restart.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # Restart/redo last command
3 |
4 | # Delay to ensure things work
5 | delay = 0.125
6 |
7 | # Trigger click to focus correct location
8 | # For instance a specific terminal split
9 | `xdotool click 1`
10 |
11 | # Stop process if any
12 | sleep(delay)
13 | `xdotool key Ctrl+c`
14 |
15 | # I needed this for some reason
16 | sleep(delay)
17 | `xdotool key Ctrl+u`
18 |
19 | # Seek last command
20 | sleep(delay)
21 | `xdotool key Up`
22 |
23 | # Execute command
24 | sleep(delay)
25 | `xdotool key Return`
--------------------------------------------------------------------------------
/scripts/timer.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require "open3"
3 |
4 | def get_input(prompt, data)
5 | cmd = "rofi -dmenu -p '#{prompt}' -i"
6 | stdin, stdout, stderr, wait_thr = Open3.popen3(cmd)
7 | stdin.puts(data)
8 | stdin.close
9 | return stdout.read.strip
10 | end
11 |
12 | path = File.join(__dir__, "data/timer.data")
13 | data = ""
14 |
15 | File.open(path, "a+") do |file|
16 | data = file.read.strip
17 | end
18 |
19 | if ARGV.length >= 2
20 | title = ARGV[0]
21 | time = ARGV[1..-1].join(" ")
22 | else
23 | title = get_input("Enter Title", data)
24 |
25 | if title == ""
26 | exit
27 | end
28 |
29 | times = "5m\n10m\n15m\n20m\n30m\n1h\n2h"
30 | time = get_input("Enter Time", times)
31 |
32 | if time == ""
33 | exit
34 | end
35 | end
36 |
37 | n = time.gsub(/[^0-9]/, "").strip.to_i
38 | u = time.gsub(/[0-9]/, "").strip
39 |
40 | if u == "m" or u.include?("min")
41 | t = n
42 | elsif u == "s" or u.include?("sec")
43 | t = n / 60.0
44 | elsif u == "h" or u.include?("hour")
45 | t = n * 60.0
46 | else
47 | t = n
48 | end
49 |
50 | lines = data.split("\n")
51 | lines.delete_if {|x| x == title}
52 | lines.unshift(title)
53 | File.write(path, lines.join("\n"))
54 |
55 | `awesome-client 'Utils.timer("#{title}", #{t})'`
--------------------------------------------------------------------------------
/wallpaper.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/madprops/awesome-setup/f0e8856028168d11f63ecc58135c597af096a527/wallpaper.jpg
--------------------------------------------------------------------------------