Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
X11:Wayland
rootbar
rootbar-0.203.obscpio
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File rootbar-0.203.obscpio of Package rootbar
07070100000000000081A4000003E800000064000000015FAE52A6000000CF000000000000000000000000000000000000001900000000rootbar-0.203/.build.ymlimage: debian/sid packages: - build-essential - libwayland-dev - libgtk-3-dev - libjson-c-dev - libpulse-dev - pkg-config - meson tasks: - build: | cd rootbar meson build ninja -C build 07070100000001000081A4000003E800000064000000015FAE52A600000042000000000000000000000000000000000000001800000000rootbar-0.203/.hgignore^\.cproject$ ^\.project$ ^\.settings$ ^\.hgrepos$ ^build$ ^Debug$ 07070100000002000081A4000003E800000064000000015FAE52A600008864000000000000000000000000000000000000001900000000rootbar-0.203/COPYING.md### GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. ### Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. ### TERMS AND CONDITIONS #### 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. #### 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. #### 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. #### 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. #### 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. #### 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: - a) The work must carry prominent notices stating that you modified it, and giving a relevant date. - b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". - c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. - d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. #### 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: - a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. - b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. - c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. - d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. - e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. #### 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: - a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or - b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or - c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or - d) Limiting the use for publicity purposes of names of licensors or authors of the material; or - e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or - f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. #### 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. #### 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. #### 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. #### 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. #### 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. #### 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. #### 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. #### 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. #### 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. #### 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS ### How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) <year> <name of author> This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>. Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: <program> Copyright (C) <year> <name of author> This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands \`show w' and \`show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see <https://www.gnu.org/licenses/>. The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read <https://www.gnu.org/licenses/why-not-lgpl.html>. 07070100000003000081A4000003E800000064000000015FAE52A6000005EA000000000000000000000000000000000000001800000000rootbar-0.203/README.md# Root Bar Root Bar is a bar for wlroots based wayland compositors such as sway and was designed to address the lack of good bars for wayland. [![builds.sr.ht status](https://builds.sr.ht/~scoopta/rootbar.svg)](https://builds.sr.ht/~scoopta/rootbar?) ## Dependencies libwayland-dev libgtk-3-dev libjson-c-dev libpulse-dev pkg-config meson ## Building hg clone https://hg.sr.ht/~scoopta/rootbar cd rootbar meson build ninja -C build ## Installing sudo ninja -C build install ## Uninstalling sudo ninja -C build uninstall ## Documentation You can find documentation at https://bitbucket.org/Scoopta/root-bar/wiki/browse/ The documentation is a bit lackluster but you can find a sample config to make the bar look like polybar in the sample folder ## Bug Reports Please file bug reports at https://todo.sr.ht/~scoopta/rootbar ## Contributing Please submit patches to https://lists.sr.ht/~scoopta/rootbar You can find documentation here https://man.sr.ht/hg.sr.ht/email.md ## Packages If you're on Arch there's an unofficial AUR package https://aur.archlinux.org/packages/rootbar-hg/ ## Screenshots [![example 1](https://f.cloudninja.pw/Scaled_1.png)](https://f.cloudninja.pw/Rootbar_Example_1.png) [![example 2](https://f.cloudninja.pw/Scaled_2.png)](https://f.cloudninja.pw/Rootbar_Example_2.png) [![example 3](https://f.cloudninja.pw/Scaled_3.png)](https://f.cloudninja.pw/Rootbar_Example_3.png) [![example 4](https://f.cloudninja.pw/Scaled_4.png)](https://f.cloudninja.pw/Rootbar_Example_4.png) 07070100000004000041ED000003E800000064000000025FAE52A600000000000000000000000000000000000000000000001200000000rootbar-0.203/inc07070100000005000081A4000003E800000064000000015FAE52A6000004C6000000000000000000000000000000000000001800000000rootbar-0.203/inc/bar.h/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #ifndef BAR_H #define BAR_H #include <map.h> #include <utils.h> #include <config.h> #include <dlfcn.h> #include <stdio.h> #include <ctype.h> #include <stdint.h> #include <stdbool.h> #include <pthread.h> #include <gtk/gtk.h> #include <gdk/gdkwayland.h> #include <wayland-client.h> #include <xdg-output-unstable-v1-client-protocol.h> #include <wlr-layer-shell-unstable-v1-client-protocol.h> void bar_init(struct map* config, const char* bar_name, char* output_name, const char* config_location); #endif 07070100000006000081A4000003E800000064000000015FAE52A6000003C2000000000000000000000000000000000000001B00000000rootbar-0.203/inc/config.h/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #ifndef CONFIG_H #define CONFIG_H #include <map.h> #include <utils.h> #include <stdio.h> void config_load(struct map* map, const char* config); char* config_get(struct map* config, const char* prefix, const char* suffix, char* def_opt); #endif 07070100000007000081A4000003E800000064000000015FAE52A600000493000000000000000000000000000000000000001800000000rootbar-0.203/inc/map.h/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MAP_H #define MAP_H #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdbool.h> struct map* map_init(); struct map* map_init_void(); void map_free(); bool map_put(struct map* map, const char* key, char* value); bool map_put_void(struct map* map, const char* key, void* value); void* map_get(struct map* map, const char* key); bool map_contains(struct map* map, const char* key); size_t map_size(struct map* map); #endif 07070100000008000081A4000003E800000064000000015FAE52A6000008C7000000000000000000000000000000000000001D00000000rootbar-0.203/inc/sway_ipc.h/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #ifndef SWAY_IPC_H #define SWAY_IPC_H #include <map.h> #include <utils.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <unistd.h> #include <stdbool.h> #include <pthread.h> #include <sys/un.h> #include <sys/socket.h> #include <json-c/json_object.h> #include <json-c/json_tokener.h> enum sway_ipc_event { SWAY_IPC_EVENT_WORKSPACE, SWAY_IPC_EVENT_OUTPUT, SWAY_IPC_EVENT_MODE, SWAY_IPC_EVENT_WINDOW, SWAY_IPC_EVENT_BARCONFIG_UPDATE, SWAY_IPC_EVENT_BINDING, SWAY_IPC_EVENT_SHUTDOWN, SWAY_IPC_EVENT_TICK }; enum sway_ipc_message { SWAY_IPC_MESSAGE_RUN_COMMAND, SWAY_IPC_MESSAGE_GET_WORKSPACES, SWAY_IPC_MESSAGE_SUBSCRIBE, SWAY_IPC_MESSAGE_GET_OUTPUTS, SWAY_IPC_MESSAGE_GET_TREE, SWAY_IPC_MESSAGE_GET_MARKS, SWAY_IPC_MESSAGE_GET_BAR_CONFIG, SWAY_IPC_MESSAGE_GET_VERSION, SWAY_IPC_MESSAGE_GET_BINDING_MODES, SWAY_IPC_MESSAGE_GET_CONFIG, SWAY_IPC_MESSAGE_SEND_TICK }; enum sway_ipc_reply { SWAY_IPC_REPLY_COMMAND, SWAY_IPC_REPLY_WORKSPACES, SWAY_IPC_REPLY_SUBSCRIBE, SWAY_IPC_REPLY_OUTPUTS, SWAY_IPC_REPLY_TREE, SWAY_IPC_REPLY_MARKS, SWAY_IPC_REPLY_BAR_CONFIG, SWAY_IPC_REPLY_VERSION, SWAY_IPC_REPLY_BINDING_MODES, SWAY_IPC_REPLY_GET_CONFIG, SWAY_IPC_REPLY_TICK }; struct sway_ipc* sway_ipc_init(); void sway_ipc_subscribe(struct sway_ipc* this, enum sway_ipc_event event, void (*handler)(void* data, const char* str), void* data); char* sway_ipc_send_message(struct sway_ipc* this, enum sway_ipc_message message, const char* payload, enum sway_ipc_reply expected_reply); #endif 07070100000009000081A4000003E800000064000000015FAE52A60000040D000000000000000000000000000000000000001A00000000rootbar-0.203/inc/utils.h/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #ifndef UTIL_H #define UTIL_H #include <math.h> #include <time.h> #include <stdarg.h> #include <stdlib.h> #include <string.h> #include <sys/time.h> time_t utils_get_time_millis(); void utils_sleep_millis(time_t millis); char* utils_concat(size_t arg_count, ...); size_t utils_split(char* str, const char chr); #endif 0707010000000A000081A4000003E800000064000000015FAE52A600004D95000000000000000000000000000000000000004000000000rootbar-0.203/inc/wlr-layer-shell-unstable-v1-client-protocol.h/* Generated by wayland-scanner 1.16.0 */ #ifndef WLR_LAYER_SHELL_V1_UNSTABLE_V1_CLIENT_PROTOCOL_H #define WLR_LAYER_SHELL_V1_UNSTABLE_V1_CLIENT_PROTOCOL_H #include <stdint.h> #include <stddef.h> #include "wayland-client.h" #ifdef __cplusplus extern "C" { #endif /** * @page page_wlr_layer_shell_v1_unstable_v1 The wlr_layer_shell_v1_unstable_v1 protocol * @section page_ifaces_wlr_layer_shell_v1_unstable_v1 Interfaces * - @subpage page_iface_zwlr_layer_shell_v1 - create surfaces that are layers of the desktop * - @subpage page_iface_zwlr_layer_surface_v1 - layer metadata interface * @section page_copyright_wlr_layer_shell_v1_unstable_v1 Copyright * <pre> * * Copyright © 2017 Drew DeVault * * Permission to use, copy, modify, distribute, and sell this * software and its documentation for any purpose is hereby granted * without fee, provided that the above copyright notice appear in * all copies and that both that copyright notice and this permission * notice appear in supporting documentation, and that the name of * the copyright holders not be used in advertising or publicity * pertaining to distribution of the software without specific, * written prior permission. The copyright holders make no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied * warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF * THIS SOFTWARE. * </pre> */ struct wl_output; struct wl_surface; struct xdg_popup; struct zwlr_layer_shell_v1; struct zwlr_layer_surface_v1; /** * @page page_iface_zwlr_layer_shell_v1 zwlr_layer_shell_v1 * @section page_iface_zwlr_layer_shell_v1_desc Description * * Clients can use this interface to assign the surface_layer role to * wl_surfaces. Such surfaces are assigned to a "layer" of the output and * rendered with a defined z-depth respective to each other. They may also be * anchored to the edges and corners of a screen and specify input handling * semantics. This interface should be suitable for the implementation of * many desktop shell components, and a broad number of other applications * that interact with the desktop. * @section page_iface_zwlr_layer_shell_v1_api API * See @ref iface_zwlr_layer_shell_v1. */ /** * @defgroup iface_zwlr_layer_shell_v1 The zwlr_layer_shell_v1 interface * * Clients can use this interface to assign the surface_layer role to * wl_surfaces. Such surfaces are assigned to a "layer" of the output and * rendered with a defined z-depth respective to each other. They may also be * anchored to the edges and corners of a screen and specify input handling * semantics. This interface should be suitable for the implementation of * many desktop shell components, and a broad number of other applications * that interact with the desktop. */ extern const struct wl_interface zwlr_layer_shell_v1_interface; /** * @page page_iface_zwlr_layer_surface_v1 zwlr_layer_surface_v1 * @section page_iface_zwlr_layer_surface_v1_desc Description * * An interface that may be implemented by a wl_surface, for surfaces that * are designed to be rendered as a layer of a stacked desktop-like * environment. * * Layer surface state (size, anchor, exclusive zone, margin, interactivity) * is double-buffered, and will be applied at the time wl_surface.commit of * the corresponding wl_surface is called. * @section page_iface_zwlr_layer_surface_v1_api API * See @ref iface_zwlr_layer_surface_v1. */ /** * @defgroup iface_zwlr_layer_surface_v1 The zwlr_layer_surface_v1 interface * * An interface that may be implemented by a wl_surface, for surfaces that * are designed to be rendered as a layer of a stacked desktop-like * environment. * * Layer surface state (size, anchor, exclusive zone, margin, interactivity) * is double-buffered, and will be applied at the time wl_surface.commit of * the corresponding wl_surface is called. */ extern const struct wl_interface zwlr_layer_surface_v1_interface; #ifndef ZWLR_LAYER_SHELL_V1_ERROR_ENUM #define ZWLR_LAYER_SHELL_V1_ERROR_ENUM enum zwlr_layer_shell_v1_error { /** * wl_surface has another role */ ZWLR_LAYER_SHELL_V1_ERROR_ROLE = 0, /** * layer value is invalid */ ZWLR_LAYER_SHELL_V1_ERROR_INVALID_LAYER = 1, /** * wl_surface has a buffer attached or committed */ ZWLR_LAYER_SHELL_V1_ERROR_ALREADY_CONSTRUCTED = 2, }; #endif /* ZWLR_LAYER_SHELL_V1_ERROR_ENUM */ #ifndef ZWLR_LAYER_SHELL_V1_LAYER_ENUM #define ZWLR_LAYER_SHELL_V1_LAYER_ENUM /** * @ingroup iface_zwlr_layer_shell_v1 * available layers for surfaces * * These values indicate which layers a surface can be rendered in. They * are ordered by z depth, bottom-most first. Traditional shell surfaces * will typically be rendered between the bottom and top layers. * Fullscreen shell surfaces are typically rendered at the top layer. * Multiple surfaces can share a single layer, and ordering within a * single layer is undefined. */ enum zwlr_layer_shell_v1_layer { ZWLR_LAYER_SHELL_V1_LAYER_BACKGROUND = 0, ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM = 1, ZWLR_LAYER_SHELL_V1_LAYER_TOP = 2, ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY = 3, }; #endif /* ZWLR_LAYER_SHELL_V1_LAYER_ENUM */ #define ZWLR_LAYER_SHELL_V1_GET_LAYER_SURFACE 0 /** * @ingroup iface_zwlr_layer_shell_v1 */ #define ZWLR_LAYER_SHELL_V1_GET_LAYER_SURFACE_SINCE_VERSION 1 /** @ingroup iface_zwlr_layer_shell_v1 */ static inline void zwlr_layer_shell_v1_set_user_data(struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1, void *user_data) { wl_proxy_set_user_data((struct wl_proxy *) zwlr_layer_shell_v1, user_data); } /** @ingroup iface_zwlr_layer_shell_v1 */ static inline void * zwlr_layer_shell_v1_get_user_data(struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1) { return wl_proxy_get_user_data((struct wl_proxy *) zwlr_layer_shell_v1); } static inline uint32_t zwlr_layer_shell_v1_get_version(struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1) { return wl_proxy_get_version((struct wl_proxy *) zwlr_layer_shell_v1); } /** @ingroup iface_zwlr_layer_shell_v1 */ static inline void zwlr_layer_shell_v1_destroy(struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1) { wl_proxy_destroy((struct wl_proxy *) zwlr_layer_shell_v1); } /** * @ingroup iface_zwlr_layer_shell_v1 * * Create a layer surface for an existing surface. This assigns the role of * layer_surface, or raises a protocol error if another role is already * assigned. * * Creating a layer surface from a wl_surface which has a buffer attached * or committed is a client error, and any attempts by a client to attach * or manipulate a buffer prior to the first layer_surface.configure call * must also be treated as errors. * * You may pass NULL for output to allow the compositor to decide which * output to use. Generally this will be the one that the user most * recently interacted with. * * Clients can specify a namespace that defines the purpose of the layer * surface. */ static inline struct zwlr_layer_surface_v1 * zwlr_layer_shell_v1_get_layer_surface(struct zwlr_layer_shell_v1 *zwlr_layer_shell_v1, struct wl_surface *surface, struct wl_output *output, uint32_t layer, const char *namespace) { struct wl_proxy *id; id = wl_proxy_marshal_constructor((struct wl_proxy *) zwlr_layer_shell_v1, ZWLR_LAYER_SHELL_V1_GET_LAYER_SURFACE, &zwlr_layer_surface_v1_interface, NULL, surface, output, layer, namespace); return (struct zwlr_layer_surface_v1 *) id; } #ifndef ZWLR_LAYER_SURFACE_V1_ERROR_ENUM #define ZWLR_LAYER_SURFACE_V1_ERROR_ENUM enum zwlr_layer_surface_v1_error { /** * provided surface state is invalid */ ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SURFACE_STATE = 0, /** * size is invalid */ ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_SIZE = 1, /** * anchor bitfield is invalid */ ZWLR_LAYER_SURFACE_V1_ERROR_INVALID_ANCHOR = 2, }; #endif /* ZWLR_LAYER_SURFACE_V1_ERROR_ENUM */ #ifndef ZWLR_LAYER_SURFACE_V1_ANCHOR_ENUM #define ZWLR_LAYER_SURFACE_V1_ANCHOR_ENUM enum zwlr_layer_surface_v1_anchor { /** * the top edge of the anchor rectangle */ ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP = 1, /** * the bottom edge of the anchor rectangle */ ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM = 2, /** * the left edge of the anchor rectangle */ ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT = 4, /** * the right edge of the anchor rectangle */ ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT = 8, }; #endif /* ZWLR_LAYER_SURFACE_V1_ANCHOR_ENUM */ /** * @ingroup iface_zwlr_layer_surface_v1 * @struct zwlr_layer_surface_v1_listener */ struct zwlr_layer_surface_v1_listener { /** * suggest a surface change * * The configure event asks the client to resize its surface. * * Clients should arrange their surface for the new states, and * then send an ack_configure request with the serial sent in this * configure event at some point before committing the new surface. * * The client is free to dismiss all but the last configure event * it received. * * The width and height arguments specify the size of the window in * surface-local coordinates. * * The size is a hint, in the sense that the client is free to * ignore it if it doesn't resize, pick a smaller size (to satisfy * aspect ratio or resize in steps of NxM pixels). If the client * picks a smaller size and is anchored to two opposite anchors * (e.g. 'top' and 'bottom'), the surface will be centered on this * axis. * * If the width or height arguments are zero, it means the client * should decide its own window dimension. */ void (*configure)(void *data, struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t serial, uint32_t width, uint32_t height); /** * surface should be closed * * The closed event is sent by the compositor when the surface * will no longer be shown. The output may have been destroyed or * the user may have asked for it to be removed. Further changes to * the surface will be ignored. The client should destroy the * resource after receiving this event, and create a new surface if * they so choose. */ void (*closed)(void *data, struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1); }; /** * @ingroup iface_zwlr_layer_surface_v1 */ static inline int zwlr_layer_surface_v1_add_listener(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, const struct zwlr_layer_surface_v1_listener *listener, void *data) { return wl_proxy_add_listener((struct wl_proxy *) zwlr_layer_surface_v1, (void (**)(void)) listener, data); } #define ZWLR_LAYER_SURFACE_V1_SET_SIZE 0 #define ZWLR_LAYER_SURFACE_V1_SET_ANCHOR 1 #define ZWLR_LAYER_SURFACE_V1_SET_EXCLUSIVE_ZONE 2 #define ZWLR_LAYER_SURFACE_V1_SET_MARGIN 3 #define ZWLR_LAYER_SURFACE_V1_SET_KEYBOARD_INTERACTIVITY 4 #define ZWLR_LAYER_SURFACE_V1_GET_POPUP 5 #define ZWLR_LAYER_SURFACE_V1_ACK_CONFIGURE 6 #define ZWLR_LAYER_SURFACE_V1_DESTROY 7 /** * @ingroup iface_zwlr_layer_surface_v1 */ #define ZWLR_LAYER_SURFACE_V1_CONFIGURE_SINCE_VERSION 1 /** * @ingroup iface_zwlr_layer_surface_v1 */ #define ZWLR_LAYER_SURFACE_V1_CLOSED_SINCE_VERSION 1 /** * @ingroup iface_zwlr_layer_surface_v1 */ #define ZWLR_LAYER_SURFACE_V1_SET_SIZE_SINCE_VERSION 1 /** * @ingroup iface_zwlr_layer_surface_v1 */ #define ZWLR_LAYER_SURFACE_V1_SET_ANCHOR_SINCE_VERSION 1 /** * @ingroup iface_zwlr_layer_surface_v1 */ #define ZWLR_LAYER_SURFACE_V1_SET_EXCLUSIVE_ZONE_SINCE_VERSION 1 /** * @ingroup iface_zwlr_layer_surface_v1 */ #define ZWLR_LAYER_SURFACE_V1_SET_MARGIN_SINCE_VERSION 1 /** * @ingroup iface_zwlr_layer_surface_v1 */ #define ZWLR_LAYER_SURFACE_V1_SET_KEYBOARD_INTERACTIVITY_SINCE_VERSION 1 /** * @ingroup iface_zwlr_layer_surface_v1 */ #define ZWLR_LAYER_SURFACE_V1_GET_POPUP_SINCE_VERSION 1 /** * @ingroup iface_zwlr_layer_surface_v1 */ #define ZWLR_LAYER_SURFACE_V1_ACK_CONFIGURE_SINCE_VERSION 1 /** * @ingroup iface_zwlr_layer_surface_v1 */ #define ZWLR_LAYER_SURFACE_V1_DESTROY_SINCE_VERSION 1 /** @ingroup iface_zwlr_layer_surface_v1 */ static inline void zwlr_layer_surface_v1_set_user_data(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, void *user_data) { wl_proxy_set_user_data((struct wl_proxy *) zwlr_layer_surface_v1, user_data); } /** @ingroup iface_zwlr_layer_surface_v1 */ static inline void * zwlr_layer_surface_v1_get_user_data(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1) { return wl_proxy_get_user_data((struct wl_proxy *) zwlr_layer_surface_v1); } static inline uint32_t zwlr_layer_surface_v1_get_version(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1) { return wl_proxy_get_version((struct wl_proxy *) zwlr_layer_surface_v1); } /** * @ingroup iface_zwlr_layer_surface_v1 * * Sets the size of the surface in surface-local coordinates. The * compositor will display the surface centered with respect to its * anchors. * * If you pass 0 for either value, the compositor will assign it and * inform you of the assignment in the configure event. You must set your * anchor to opposite edges in the dimensions you omit; not doing so is a * protocol error. Both values are 0 by default. * * Size is double-buffered, see wl_surface.commit. */ static inline void zwlr_layer_surface_v1_set_size(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t width, uint32_t height) { wl_proxy_marshal((struct wl_proxy *) zwlr_layer_surface_v1, ZWLR_LAYER_SURFACE_V1_SET_SIZE, width, height); } /** * @ingroup iface_zwlr_layer_surface_v1 * * Requests that the compositor anchor the surface to the specified edges * and corners. If two orthoginal edges are specified (e.g. 'top' and * 'left'), then the anchor point will be the intersection of the edges * (e.g. the top left corner of the output); otherwise the anchor point * will be centered on that edge, or in the center if none is specified. * * Anchor is double-buffered, see wl_surface.commit. */ static inline void zwlr_layer_surface_v1_set_anchor(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t anchor) { wl_proxy_marshal((struct wl_proxy *) zwlr_layer_surface_v1, ZWLR_LAYER_SURFACE_V1_SET_ANCHOR, anchor); } /** * @ingroup iface_zwlr_layer_surface_v1 * * Requests that the compositor avoids occluding an area of the surface * with other surfaces. The compositor's use of this information is * implementation-dependent - do not assume that this region will not * actually be occluded. * * A positive value is only meaningful if the surface is anchored to an * edge, rather than a corner. The zone is the number of surface-local * coordinates from the edge that are considered exclusive. * * Surfaces that do not wish to have an exclusive zone may instead specify * how they should interact with surfaces that do. If set to zero, the * surface indicates that it would like to be moved to avoid occluding * surfaces with a positive excluzive zone. If set to -1, the surface * indicates that it would not like to be moved to accomodate for other * surfaces, and the compositor should extend it all the way to the edges * it is anchored to. * * For example, a panel might set its exclusive zone to 10, so that * maximized shell surfaces are not shown on top of it. A notification * might set its exclusive zone to 0, so that it is moved to avoid * occluding the panel, but shell surfaces are shown underneath it. A * wallpaper or lock screen might set their exclusive zone to -1, so that * they stretch below or over the panel. * * The default value is 0. * * Exclusive zone is double-buffered, see wl_surface.commit. */ static inline void zwlr_layer_surface_v1_set_exclusive_zone(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, int32_t zone) { wl_proxy_marshal((struct wl_proxy *) zwlr_layer_surface_v1, ZWLR_LAYER_SURFACE_V1_SET_EXCLUSIVE_ZONE, zone); } /** * @ingroup iface_zwlr_layer_surface_v1 * * Requests that the surface be placed some distance away from the anchor * point on the output, in surface-local coordinates. Setting this value * for edges you are not anchored to has no effect. * * The exclusive zone includes the margin. * * Margin is double-buffered, see wl_surface.commit. */ static inline void zwlr_layer_surface_v1_set_margin(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, int32_t top, int32_t right, int32_t bottom, int32_t left) { wl_proxy_marshal((struct wl_proxy *) zwlr_layer_surface_v1, ZWLR_LAYER_SURFACE_V1_SET_MARGIN, top, right, bottom, left); } /** * @ingroup iface_zwlr_layer_surface_v1 * * Set to 1 to request that the seat send keyboard events to this layer * surface. For layers below the shell surface layer, the seat will use * normal focus semantics. For layers above the shell surface layers, the * seat will always give exclusive keyboard focus to the top-most layer * which has keyboard interactivity set to true. * * Layer surfaces receive pointer, touch, and tablet events normally. If * you do not want to receive them, set the input region on your surface * to an empty region. * * Events is double-buffered, see wl_surface.commit. */ static inline void zwlr_layer_surface_v1_set_keyboard_interactivity(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t keyboard_interactivity) { wl_proxy_marshal((struct wl_proxy *) zwlr_layer_surface_v1, ZWLR_LAYER_SURFACE_V1_SET_KEYBOARD_INTERACTIVITY, keyboard_interactivity); } /** * @ingroup iface_zwlr_layer_surface_v1 * * This assigns an xdg_popup's parent to this layer_surface. This popup * should have been created via xdg_surface::get_popup with the parent set * to NULL, and this request must be invoked before committing the popup's * initial state. * * See the documentation of xdg_popup for more details about what an * xdg_popup is and how it is used. */ static inline void zwlr_layer_surface_v1_get_popup(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, struct xdg_popup *popup) { wl_proxy_marshal((struct wl_proxy *) zwlr_layer_surface_v1, ZWLR_LAYER_SURFACE_V1_GET_POPUP, popup); } /** * @ingroup iface_zwlr_layer_surface_v1 * * When a configure event is received, if a client commits the * surface in response to the configure event, then the client * must make an ack_configure request sometime before the commit * request, passing along the serial of the configure event. * * If the client receives multiple configure events before it * can respond to one, it only has to ack the last configure event. * * A client is not required to commit immediately after sending * an ack_configure request - it may even ack_configure several times * before its next surface commit. * * A client may send multiple ack_configure requests before committing, but * only the last request sent before a commit indicates which configure * event the client really is responding to. */ static inline void zwlr_layer_surface_v1_ack_configure(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1, uint32_t serial) { wl_proxy_marshal((struct wl_proxy *) zwlr_layer_surface_v1, ZWLR_LAYER_SURFACE_V1_ACK_CONFIGURE, serial); } /** * @ingroup iface_zwlr_layer_surface_v1 * * This request destroys the layer surface. */ static inline void zwlr_layer_surface_v1_destroy(struct zwlr_layer_surface_v1 *zwlr_layer_surface_v1) { wl_proxy_marshal((struct wl_proxy *) zwlr_layer_surface_v1, ZWLR_LAYER_SURFACE_V1_DESTROY); wl_proxy_destroy((struct wl_proxy *) zwlr_layer_surface_v1); } #ifdef __cplusplus } #endif #endif 0707010000000B000081A4000003E800000064000000015FAE52A6000034A2000000000000000000000000000000000000003B00000000rootbar-0.203/inc/xdg-output-unstable-v1-client-protocol.h/* Generated by wayland-scanner 1.16.0 */ #ifndef XDG_OUTPUT_UNSTABLE_V1_CLIENT_PROTOCOL_H #define XDG_OUTPUT_UNSTABLE_V1_CLIENT_PROTOCOL_H #include <stdint.h> #include <stddef.h> #include "wayland-client.h" #ifdef __cplusplus extern "C" { #endif /** * @page page_xdg_output_unstable_v1 The xdg_output_unstable_v1 protocol * Protocol to describe output regions * * @section page_desc_xdg_output_unstable_v1 Description * * This protocol aims at describing outputs in a way which is more in line * with the concept of an output on desktop oriented systems. * * Some information are more specific to the concept of an output for * a desktop oriented system and may not make sense in other applications, * such as IVI systems for example. * * Typically, the global compositor space on a desktop system is made of * a contiguous or overlapping set of rectangular regions. * * Some of the information provided in this protocol might be identical * to their counterparts already available from wl_output, in which case * the information provided by this protocol should be preferred to their * equivalent in wl_output. The goal is to move the desktop specific * concepts (such as output location within the global compositor space, * the connector name and types, etc.) out of the core wl_output protocol. * * Warning! The protocol described in this file is experimental and * backward incompatible changes may be made. Backward compatible * changes may be added together with the corresponding interface * version bump. * Backward incompatible changes are done by bumping the version * number in the protocol and interface names and resetting the * interface version. Once the protocol is to be declared stable, * the 'z' prefix and the version number in the protocol and * interface names are removed and the interface version number is * reset. * * @section page_ifaces_xdg_output_unstable_v1 Interfaces * - @subpage page_iface_zxdg_output_manager_v1 - manage xdg_output objects * - @subpage page_iface_zxdg_output_v1 - compositor logical output region * @section page_copyright_xdg_output_unstable_v1 Copyright * <pre> * * Copyright © 2017 Red Hat Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * </pre> */ struct wl_output; struct zxdg_output_manager_v1; struct zxdg_output_v1; /** * @page page_iface_zxdg_output_manager_v1 zxdg_output_manager_v1 * @section page_iface_zxdg_output_manager_v1_desc Description * * A global factory interface for xdg_output objects. * @section page_iface_zxdg_output_manager_v1_api API * See @ref iface_zxdg_output_manager_v1. */ /** * @defgroup iface_zxdg_output_manager_v1 The zxdg_output_manager_v1 interface * * A global factory interface for xdg_output objects. */ extern const struct wl_interface zxdg_output_manager_v1_interface; /** * @page page_iface_zxdg_output_v1 zxdg_output_v1 * @section page_iface_zxdg_output_v1_desc Description * * An xdg_output describes part of the compositor geometry. * * This typically corresponds to a monitor that displays part of the * compositor space. * @section page_iface_zxdg_output_v1_api API * See @ref iface_zxdg_output_v1. */ /** * @defgroup iface_zxdg_output_v1 The zxdg_output_v1 interface * * An xdg_output describes part of the compositor geometry. * * This typically corresponds to a monitor that displays part of the * compositor space. */ extern const struct wl_interface zxdg_output_v1_interface; #define ZXDG_OUTPUT_MANAGER_V1_DESTROY 0 #define ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT 1 /** * @ingroup iface_zxdg_output_manager_v1 */ #define ZXDG_OUTPUT_MANAGER_V1_DESTROY_SINCE_VERSION 1 /** * @ingroup iface_zxdg_output_manager_v1 */ #define ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT_SINCE_VERSION 1 /** @ingroup iface_zxdg_output_manager_v1 */ static inline void zxdg_output_manager_v1_set_user_data(struct zxdg_output_manager_v1 *zxdg_output_manager_v1, void *user_data) { wl_proxy_set_user_data((struct wl_proxy *) zxdg_output_manager_v1, user_data); } /** @ingroup iface_zxdg_output_manager_v1 */ static inline void * zxdg_output_manager_v1_get_user_data(struct zxdg_output_manager_v1 *zxdg_output_manager_v1) { return wl_proxy_get_user_data((struct wl_proxy *) zxdg_output_manager_v1); } static inline uint32_t zxdg_output_manager_v1_get_version(struct zxdg_output_manager_v1 *zxdg_output_manager_v1) { return wl_proxy_get_version((struct wl_proxy *) zxdg_output_manager_v1); } /** * @ingroup iface_zxdg_output_manager_v1 * * Using this request a client can tell the server that it is not * going to use the xdg_output_manager object anymore. * * Any objects already created through this instance are not affected. */ static inline void zxdg_output_manager_v1_destroy(struct zxdg_output_manager_v1 *zxdg_output_manager_v1) { wl_proxy_marshal((struct wl_proxy *) zxdg_output_manager_v1, ZXDG_OUTPUT_MANAGER_V1_DESTROY); wl_proxy_destroy((struct wl_proxy *) zxdg_output_manager_v1); } /** * @ingroup iface_zxdg_output_manager_v1 * * This creates a new xdg_output object for the given wl_output. */ static inline struct zxdg_output_v1 * zxdg_output_manager_v1_get_xdg_output(struct zxdg_output_manager_v1 *zxdg_output_manager_v1, struct wl_output *output) { struct wl_proxy *id; id = wl_proxy_marshal_constructor((struct wl_proxy *) zxdg_output_manager_v1, ZXDG_OUTPUT_MANAGER_V1_GET_XDG_OUTPUT, &zxdg_output_v1_interface, NULL, output); return (struct zxdg_output_v1 *) id; } /** * @ingroup iface_zxdg_output_v1 * @struct zxdg_output_v1_listener */ struct zxdg_output_v1_listener { /** * position of the output within the global compositor space * * The position event describes the location of the wl_output * within the global compositor space. * * The logical_position event is sent after creating an xdg_output * (see xdg_output_manager.get_xdg_output) and whenever the * location of the output changes within the global compositor * space. * @param x x position within the global compositor space * @param y y position within the global compositor space */ void (*logical_position)(void *data, struct zxdg_output_v1 *zxdg_output_v1, int32_t x, int32_t y); /** * size of the output in the global compositor space * * The logical_size event describes the size of the output in the * global compositor space. * * For example, a surface without any buffer scale, transformation * nor rotation set, with the size matching the logical_size will * have the same size as the corresponding output when displayed. * * Most regular Wayland clients should not pay attention to the * logical size and would rather rely on xdg_shell interfaces. * * Some clients such as Xwayland, however, need this to configure * their surfaces in the global compositor space as the compositor * may apply a different scale from what is advertised by the * output scaling property (to achieve fractional scaling, for * example). * * For example, for a wl_output mode 3840×2160 and a scale factor * 2: * * - A compositor not scaling the surface buffers will advertise a * logical size of 3840×2160, * * - A compositor automatically scaling the surface buffers will * advertise a logical size of 1920×1080, * * - A compositor using a fractional scale of 1.5 will advertise a * logical size to 2560×1620. * * For example, for a wl_output mode 1920×1080 and a 90 degree * rotation, the compositor will advertise a logical size of * 1080x1920. * * The logical_size event is sent after creating an xdg_output (see * xdg_output_manager.get_xdg_output) and whenever the logical size * of the output changes, either as a result of a change in the * applied scale or because of a change in the corresponding output * mode(see wl_output.mode) or transform (see wl_output.transform). * @param width width in global compositor space * @param height height in global compositor space */ void (*logical_size)(void *data, struct zxdg_output_v1 *zxdg_output_v1, int32_t width, int32_t height); /** * all information about the output have been sent * * This event is sent after all other properties of an xdg_output * have been sent. * * This allows changes to the xdg_output properties to be seen as * atomic, even if they happen via multiple events. */ void (*done)(void *data, struct zxdg_output_v1 *zxdg_output_v1); /** * name of this output * * Many compositors will assign names to their outputs, show them * to the user, allow them to be configured by name, etc. The * client may wish to know this name as well to offer the user * similar behaviors. * * The naming convention is compositor defined, but limited to * alphanumeric characters and dashes (-). Each name is unique * among all wl_output globals, but if a wl_output global is * destroyed the same name may be reused later. The names will also * remain consistent across sessions with the same hardware and * software configuration. * * Examples of names include 'HDMI-A-1', 'WL-1', 'X11-1', etc. * However, do not assume that the name is a reflection of an * underlying DRM connector, X11 connection, etc. * * The name event is sent after creating an xdg_output (see * xdg_output_manager.get_xdg_output). This event is only sent once * per xdg_output, and the name does not change over the lifetime * of the wl_output global. * @param name output name * @since 2 */ void (*name)(void *data, struct zxdg_output_v1 *zxdg_output_v1, const char *name); /** * human-readable description of this output * * Many compositors can produce human-readable descriptions of * their outputs. The client may wish to know this description as * well, to communicate the user for various purposes. * * The description is a UTF-8 string with no convention defined for * its contents. Examples might include 'Foocorp 11" Display' or * 'Virtual X11 output via :1'. * * The description event is sent after creating an xdg_output (see * xdg_output_manager.get_xdg_output). This event is only sent once * per xdg_output, and the description does not change over the * lifetime of the wl_output global. The description is optional, * and may not be sent at all. * @param description output description * @since 2 */ void (*description)(void *data, struct zxdg_output_v1 *zxdg_output_v1, const char *description); }; /** * @ingroup iface_zxdg_output_v1 */ static inline int zxdg_output_v1_add_listener(struct zxdg_output_v1 *zxdg_output_v1, const struct zxdg_output_v1_listener *listener, void *data) { return wl_proxy_add_listener((struct wl_proxy *) zxdg_output_v1, (void (**)(void)) listener, data); } #define ZXDG_OUTPUT_V1_DESTROY 0 /** * @ingroup iface_zxdg_output_v1 */ #define ZXDG_OUTPUT_V1_LOGICAL_POSITION_SINCE_VERSION 1 /** * @ingroup iface_zxdg_output_v1 */ #define ZXDG_OUTPUT_V1_LOGICAL_SIZE_SINCE_VERSION 1 /** * @ingroup iface_zxdg_output_v1 */ #define ZXDG_OUTPUT_V1_DONE_SINCE_VERSION 1 /** * @ingroup iface_zxdg_output_v1 */ #define ZXDG_OUTPUT_V1_NAME_SINCE_VERSION 2 /** * @ingroup iface_zxdg_output_v1 */ #define ZXDG_OUTPUT_V1_DESCRIPTION_SINCE_VERSION 2 /** * @ingroup iface_zxdg_output_v1 */ #define ZXDG_OUTPUT_V1_DESTROY_SINCE_VERSION 1 /** @ingroup iface_zxdg_output_v1 */ static inline void zxdg_output_v1_set_user_data(struct zxdg_output_v1 *zxdg_output_v1, void *user_data) { wl_proxy_set_user_data((struct wl_proxy *) zxdg_output_v1, user_data); } /** @ingroup iface_zxdg_output_v1 */ static inline void * zxdg_output_v1_get_user_data(struct zxdg_output_v1 *zxdg_output_v1) { return wl_proxy_get_user_data((struct wl_proxy *) zxdg_output_v1); } static inline uint32_t zxdg_output_v1_get_version(struct zxdg_output_v1 *zxdg_output_v1) { return wl_proxy_get_version((struct wl_proxy *) zxdg_output_v1); } /** * @ingroup iface_zxdg_output_v1 * * Using this request a client can tell the server that it is not * going to use the xdg_output object anymore. */ static inline void zxdg_output_v1_destroy(struct zxdg_output_v1 *zxdg_output_v1) { wl_proxy_marshal((struct wl_proxy *) zxdg_output_v1, ZXDG_OUTPUT_V1_DESTROY); wl_proxy_destroy((struct wl_proxy *) zxdg_output_v1); } #ifdef __cplusplus } #endif #endif 0707010000000C000081A4000003E800000064000000015FAE52A600000453000000000000000000000000000000000000001A00000000rootbar-0.203/meson.buildproject('rootbar', 'c', default_options : ['buildtype=release', 'warning_level=2']) cc = meson.get_compiler('c') inc = include_directories('inc') gtk = dependency('gtk+-3.0') json = dependency('json-c') pulse = dependency('libpulse') pulse_mainloop = dependency('libpulse-mainloop-glib') threads = dependency('threads') wayland = dependency('wayland-client') dl = cc.find_library('dl') add_project_arguments('-D_GNU_SOURCE', language : 'c') add_project_link_arguments('-rdynamic', language : 'c') executable(meson.project_name(), 'src/bar.c', 'src/config.c', 'src/main.c', 'src/map.c', 'src/sway_ipc.c', 'src/utils.c', 'plugins/battery.c', 'plugins/bind_mode.c', 'plugins/clock.c', 'plugins/cpu.c', 'plugins/external.c', 'plugins/image.c', 'plugins/memory.c', 'plugins/notification.c', 'plugins/text.c', 'plugins/volume.c', 'plugins/window.c', 'plugins/workspace.c', 'proto/wlr-layer-shell-unstable-v1-protocol.c', 'proto/xdg-output-unstable-v1-protocol.c', 'proto/xdg-shell-protocol.c', include_directories : inc, dependencies : [gtk, json, pulse, pulse_mainloop, threads, wayland, dl], install : true) 0707010000000D000041ED000003E800000064000000025FAE52A600000000000000000000000000000000000000000000001600000000rootbar-0.203/plugins0707010000000E000081A4000003E800000064000000015FAE52A600000912000000000000000000000000000000000000002000000000rootbar-0.203/plugins/battery.c/* * Copyright (C) 2019-2020 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #include <map.h> #include <utils.h> #include <gio/gio.h> static const char* arg_names[] = {"battery"}; enum args { ARGS_BATTERY }; struct battery { GDBusProxy* proxy; GError* err; }; void* rootbar_battery_init(struct map* props) { char* battery = map_get(props, arg_names[ARGS_BATTERY]); if(battery == NULL) { battery = "battery_BAT0"; } char* bus_path = utils_concat(2, "/org/freedesktop/UPower/devices/", battery); struct battery* this = malloc(sizeof(struct battery)); this->err = NULL; this->proxy = g_dbus_proxy_new_for_bus_sync(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, NULL, "org.freedesktop.UPower", bus_path, "org.freedesktop.DBus.Properties", NULL, NULL); free(bus_path); if(this->proxy == NULL) { fprintf(stderr, "Battery: Failed to connect to dbus\n"); } return this; } void rootbar_battery_get_info(void* data, const char* format, char* out, size_t size) { struct battery* this = data; if(this->proxy == NULL) { return; } GVariant* percentage = g_dbus_proxy_call_sync(this->proxy, "Get", g_variant_new("(ss)", "org.freedesktop.UPower.Device", "Percentage"), G_DBUS_CALL_FLAGS_NONE, 2000, NULL, &this->err); if(percentage == NULL) { this->proxy = NULL; fprintf(stderr, "Battery: Missing upower\n"); return; } GVariant* ret; double percent; g_variant_get(percentage, "(v)", &ret); g_variant_get(ret, "d", &percent); g_variant_unref(percentage); snprintf(out, size, format, percent, "%"); } const char** rootbar_battery_get_arg_names() { return arg_names; } size_t rootbar_battery_get_arg_count() { return sizeof(arg_names) / sizeof(char*); } 0707010000000F000081A4000003E800000064000000015FAE52A600000885000000000000000000000000000000000000002200000000rootbar-0.203/plugins/bind_mode.c/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #include <map.h> #include <sway_ipc.h> #include <stdbool.h> #include <json-c/json_object.h> #include <json-c/json_tokener.h> static const char* arg_names[] = {"hide_default"}; struct bind_mode { char* mode; bool hide_default; }; static void mode(void* data, const char* json_data) { struct bind_mode* this = data; struct json_object* json = json_tokener_parse(json_data); struct json_object* change = json_object_object_get(json, "change"); const char* mode = json_object_get_string(change); if(this->mode != NULL) { free(this->mode); } if(this->hide_default && strcmp(mode, "default") == 0) { this->mode = strdup(""); } else { this->mode = strdup(mode); } json_object_put(json); } void* rootbar_bind_mode_init(struct map* props) { struct sway_ipc* ipc = sway_ipc_init(); if(ipc == NULL) { return NULL; } struct bind_mode* this = calloc(1, sizeof(struct bind_mode)); char* hide_default = map_get(props, "hide_default"); this->hide_default = hide_default != NULL && strcmp(hide_default, "true") == 0; sway_ipc_subscribe(ipc, SWAY_IPC_EVENT_MODE, mode, this); return this; } const char** rootbar_bind_mode_get_arg_names() { return arg_names; } size_t rootbar_bind_mode_get_arg_count() { return sizeof(arg_names) / sizeof(char*); } void rootbar_bind_mode_get_info(void* data, const char* format, char* out, size_t size) { struct bind_mode* this = data; if(this == NULL) { return; } snprintf(out, size, format, this->mode); } 07070100000010000081A4000003E800000064000000015FAE52A600000435000000000000000000000000000000000000001E00000000rootbar-0.203/plugins/clock.c/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #include <time.h> #include <stdio.h> #include <stdlib.h> void rootbar_clock_get_info(void* data, const char* format, char* out, size_t size) { (void) data; time_t t = time(NULL); struct tm* tm = localtime(&t); char* tmp = malloc(size); strftime(tmp, size, format, tm); tmp[size - 1] = 0; snprintf(out, size, tmp, tm->tm_year + 10000 + 1900); free(tmp); } 07070100000011000081A4000003E800000064000000015FAE52A600000C30000000000000000000000000000000000000001C00000000rootbar-0.203/plugins/cpu.c/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #include <map.h> #include <utils.h> #include <time.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <pthread.h> static const char* arg_names[] = {"interval", "core"}; struct cpu { uint32_t percentage; time_t interval; const char* core; }; static void sample(struct cpu* this, uint64_t* total, uint64_t* idle) { FILE* stat = fopen("/proc/stat", "r"); char* line = NULL; size_t size = 0; char* cmp; if(this->core == NULL || strcmp(this->core, "total") == 0) { cmp = utils_concat(2, "cpu", " "); } else { cmp = utils_concat(2, "cpu", this->core); } while(getline(&line, &size, stat) != -1) { if(strncmp(line, cmp, 4) == 0) { char* space = strchr(line, ' '); size_t space_count = 0; while(space != NULL) { ++space_count; *space = 0; space = strchr(space + 1, ' '); } char* time = line + strlen(line); if(strcmp(cmp, "cpu ") == 0) { space_count -= 2; time += 2; } else { --space_count; ++time; } *total = 0; for(size_t count = 0; count < space_count; ++count) { if(count == 3) { *idle = strtol(time, NULL, 10); } *total += strtol(time, NULL, 10); time += strlen(time) + 1; } } } free(cmp); fclose(stat); free(line); } static void* poll(void* data) { struct cpu* this = data; while(true) { uint64_t total1, idle1, total2, idle2; sample(this, &total1, &idle1); utils_sleep_millis(this->interval); sample(this, &total2, &idle2); uint64_t total = total2 - total1; uint64_t idle = idle2 - idle1; float time_idle = (float) idle / total; float time_working = 1.f - time_idle; this->percentage = time_working * 100.f; } return NULL; } void* rootbar_cpu_init(struct map* props) { struct cpu* this = calloc(1, sizeof(struct cpu)); char* interval = map_get(props, "interval"); this->core = map_get(props, "core"); if(this->core != NULL) { this->core = strdup(this->core); } if(interval == NULL) { interval = "1000"; } this->interval = strtol(interval, NULL, 10); pthread_t thread; pthread_create(&thread, NULL, poll, this); return this; } void rootbar_cpu_get_info(void* data, const char* format, char* out, size_t size) { struct cpu* this = data; snprintf(out, size, format, this->percentage, "%"); } const char** rootbar_cpu_get_arg_names() { return arg_names; } size_t rootbar_cpu_get_arg_count() { return sizeof(arg_names) / sizeof(char*); } 07070100000012000081A4000003E800000064000000015FAE52A600000B57000000000000000000000000000000000000002100000000rootbar-0.203/plugins/external.c/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #include <map.h> #include <utils.h> #include <stdio.h> #include <errno.h> #include <fcntl.h> #include <unistd.h> #include <pthread.h> #include <sys/wait.h> static const char* arg_names[] = {"exec", "interval"}; struct external { const char* exec; char* ret; time_t interval; }; static void* poll(void* data) { struct external* this = data; while(true) { if(this->exec == NULL) { fprintf(stderr, "That's not a valid executable\n"); goto sleep; } int fds[2]; pipe(fds); if(fork() == 0) { close(fds[0]); close(STDOUT_FILENO); dup2(fds[1], STDOUT_FILENO); execl(this->exec, this->exec, NULL); fprintf(stderr, "%s cannot be found\n", this->exec); exit(errno); } close(fds[1]); size_t buf_s = fcntl(fds[0], F_GETPIPE_SZ); char* buf = calloc(1, buf_s); read(fds[0], buf, buf_s); close(fds[0]); while(waitpid(-1, NULL, WNOHANG) > 0); if(buf[0] == 0) { fprintf(stderr, "%s is being really quiet\n", this->exec); goto sleep; } buf[strlen(buf) - 1] = 0; if(this->ret != NULL) { free(this->ret); } this->ret = strdup(buf); free(buf); sleep: utils_sleep_millis(this->interval); } return NULL; } void* rootbar_external_init(struct map* props) { struct external* this = calloc(1, sizeof(struct external)); this->exec = strdup(map_get(props, "exec")); const char* interval = map_get(props, "interval"); if(interval == NULL) { interval = "1000"; } this->interval = strtol(interval, NULL, 10); pthread_t thread; pthread_create(&thread, NULL, poll, this); return this; } const char** rootbar_external_get_arg_names() { return arg_names; } size_t rootbar_external_get_arg_count() { return sizeof(arg_names) / sizeof(char*); } void rootbar_external_get_info(void* data, const char* format, char* out, size_t size) { struct external* this = data; snprintf(out, size, format, this->ret); } void rootbar_external_click(void* data, const char* button) { struct external* this = data; if(this->exec != NULL) { if(fork() == 0) { execlp(this->exec, this->exec, button, NULL); fprintf(stderr, "%s cannot be executed\n", this->exec); exit(errno); } while(waitpid(-1, NULL, WNOHANG) > 0); } } 07070100000013000081A4000003E800000064000000015FAE52A6000009D7000000000000000000000000000000000000001E00000000rootbar-0.203/plugins/image.c/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #include <map.h> #include <stdint.h> #include <stdbool.h> #include <gtk/gtk.h> #include <sys/inotify.h> static const char* arg_names[] = {"image"}; struct image { GtkImage* img; GtkBox* box; char* image; int64_t bar_height; pthread_t img_watch; }; static gboolean load_image(gpointer data) { struct image* this = data; GdkPixbuf* pixbuf = gdk_pixbuf_new_from_file(this->image, NULL); int img_height = gdk_pixbuf_get_height(pixbuf); if(img_height > this->bar_height) { float percent = (float) this->bar_height / img_height; int new_width = gdk_pixbuf_get_width(pixbuf) * percent; pixbuf = gdk_pixbuf_scale_simple(pixbuf, new_width, this->bar_height - 10, GDK_INTERP_BILINEAR); } if(this->img == NULL) { this->img = GTK_IMAGE(gtk_image_new_from_pixbuf(pixbuf)); gtk_container_add(GTK_CONTAINER(this->box), GTK_WIDGET(this->img)); } else { gtk_image_set_from_pixbuf(this->img, pixbuf); } return FALSE; } static void* image_watch(void* data) { struct image* this = data; int fd = inotify_init(); inotify_add_watch(fd, this->image, IN_MODIFY); struct inotify_event event; while(true) { read(fd, &event, sizeof(event)); g_idle_add(G_SOURCE_FUNC(load_image), this); } return NULL; } void rootbar_image_init(struct map* props, GtkBox* box) { struct image* this = calloc(1, sizeof(struct image)); char* image = map_get(props, "image"); if(image == NULL) { return; } this->image = strdup(image); this->bar_height = strtol(map_get(props, "_height"), NULL, 10); this->box = box; load_image(this); pthread_create(&this->img_watch, NULL, image_watch, this); } bool rootbar_image_is_advanced() { return true; } const char** rootbar_image_get_arg_names() { return arg_names; } size_t rootbar_image_get_arg_count() { return sizeof(arg_names) / sizeof(char*); } 07070100000014000081A4000003E800000064000000015FAE52A6000008D7000000000000000000000000000000000000001F00000000rootbar-0.203/plugins/memory.c/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #include <map.h> #include <stdio.h> #include <stdint.h> static const char* arg_names[] = {"percent"}; struct memory { bool percent; }; void* rootbar_memory_init(struct map* props) { struct memory* this = malloc(sizeof(struct memory)); const char* percent = map_get(props, "percent"); this->percent = percent != NULL && strcmp(percent, "true") == 0; return this; } const char** rootbar_memory_get_arg_names() { return arg_names; } size_t rootbar_memory_get_arg_count() { return sizeof(arg_names) / sizeof(char*); } void rootbar_memory_get_info(void* data, const char* format, char* out, size_t size) { struct memory* this = data; float gb, percentage; FILE* meminfo = fopen("/proc/meminfo", "r"); char* line = NULL; size_t line_s = 0; uint64_t mem_total = 0, mem_avail = 0; while(getline(&line, &line_s, meminfo) != -1) { const char* total = "MemTotal:"; const char* avail = "MemAvailable:"; char* info = strchr(line, ' '); while(*info == ' ') { ++info; } char* space = strchr(info, ' '); if(space != NULL) { *space = 0; } if(strncmp(line, total, strlen(total)) == 0) { mem_total = strtol(info, NULL, 10); } else if(strncmp(line, avail, strlen(avail)) == 0) { mem_avail = strtol(info, NULL, 10); } } fclose(meminfo); free(line); uint64_t used = mem_total - mem_avail; if(this->percent) { percentage = ((float) used / mem_total) * 100.f; snprintf(out, size, format, percentage, "%"); } else { float mb = used / 1024.f; gb = mb / 1024.f; snprintf(out, size, format, gb, "GB"); } } 07070100000015000081A4000003E800000064000000015FAE52A600004415000000000000000000000000000000000000002500000000rootbar-0.203/plugins/notification.c/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #include <map.h> #include <utils.h> #include <config.h> #include <errno.h> #include <stdio.h> #include <stdint.h> #include <unistd.h> #include <stdbool.h> #include <sys/wait.h> #include <gio/gio.h> static const char* arg_names[] = {"exec", "display", "whitelist", "blacklist", "timeout"}; struct notification { const char* display; char* summary, *body, *app_name; struct map* whitelist; struct map* blacklist; time_t timeout; }; bool running = false; const char* exec; char* _summary, *_body, *_app_name; uint32_t id; time_t notify_time = 0; static void dbus_method_call(GDBusConnection* connection, const gchar* sender, const gchar* object_path, const gchar* interface_name, const gchar* method_name, GVariant* parameters, GDBusMethodInvocation* invocation, gpointer data) { (void) sender; (void) data; if(strcmp(method_name, "GetServerInformation") == 0) { GVariant* ret = g_variant_new("(ssss)", "rootbar", "Scoopta", "0.0.1", "1.2"); g_dbus_method_invocation_return_value(invocation, ret); } else if(strcmp(method_name, "Notify") == 0) { const gchar* app_name, *app_icon, *summary, *body; uint32_t replaces_id; GVariantIter* actions; GVariant* hints; int32_t expire_timeout; g_variant_get(parameters, "(&su&s&s&sasa{sv}i)", &app_name, &replaces_id, &app_icon, &summary, &body, &actions, &hints, &expire_timeout); g_variant_iter_free(actions); if(_summary != NULL) { free(_summary); } if(_body != NULL) { free(_body); } if(_app_name != NULL) { free(_app_name); } _summary = strdup(summary); _body = strdup(body); _app_name = strdup(app_name); notify_time = utils_get_time_millis(); if(exec != NULL) { if(fork() == 0) { execlp(exec, exec, _app_name, _summary, _body, NULL); fprintf(stderr, "%s cannot be executed\n", exec); exit(errno); } while(waitpid(-1, NULL, WNOHANG) > 0); } GVariant* ret = g_variant_new("(u)", ++id); g_dbus_method_invocation_return_value(invocation, ret); } else if(strcmp(method_name, "GetCapabilities") == 0) { GVariantBuilder* builder = g_variant_builder_new(G_VARIANT_TYPE("as")); g_variant_builder_add(builder, "s", "body"); g_variant_builder_add(builder, "s", "actions"); GVariant* ret = g_variant_new("(as)", builder); g_variant_builder_unref(builder); g_dbus_method_invocation_return_value(invocation, ret); } else if(strcmp(method_name, "CloseNotification") == 0) { uint32_t id; g_variant_get(parameters, "(u)", &id); GVariant* param = g_variant_new("(uu)", id, 3); g_dbus_method_invocation_return_value(invocation, NULL); g_dbus_connection_emit_signal(connection, NULL, object_path, interface_name, "NotificationClosed", param, NULL); } } static void name_acquired(GDBusConnection* connection, const gchar* name, gpointer data) { (void) name; (void) data; //GetCapabilities return GDBusArgInfo* get_capabilities_ret = malloc(sizeof(GDBusArgInfo)); get_capabilities_ret->ref_count = -1; get_capabilities_ret->name = NULL; get_capabilities_ret->signature = "as"; get_capabilities_ret->annotations = NULL; //GetCapabilities args GDBusArgInfo** get_capabilities_args = calloc(2, sizeof(GDBusArgInfo*)); get_capabilities_args[0] = get_capabilities_ret; get_capabilities_args[1] = NULL; //GetCapabilities method GDBusMethodInfo* get_capabilities = malloc(sizeof(GDBusMethodInfo)); get_capabilities->ref_count = -1; get_capabilities->name = "GetCapabilities"; get_capabilities->in_args = NULL; get_capabilities->out_args = get_capabilities_args; get_capabilities->annotations = NULL; //Notify return GDBusArgInfo* notify_ret = malloc(sizeof(GDBusArgInfo)); notify_ret->ref_count = -1; notify_ret->name = NULL; notify_ret->signature = "u"; notify_ret->annotations = NULL; //Notify out args GDBusArgInfo** notify_out_args = calloc(2, sizeof(GDBusArgInfo*)); notify_out_args[0] = notify_ret; notify_out_args[1] = NULL; //Notify method app_name argument GDBusArgInfo* notify_app_name = malloc(sizeof(GDBusArgInfo)); notify_app_name->ref_count = -1; notify_app_name->name = "app_name"; notify_app_name->signature = "s"; notify_app_name->annotations = NULL; //Notify method replaces_id argument GDBusArgInfo* notify_replaces_id = malloc(sizeof(GDBusArgInfo)); notify_replaces_id->ref_count = -1; notify_replaces_id->name = "replaces_id"; notify_replaces_id->signature = "u"; notify_replaces_id->annotations = NULL; //Notify method app_icon argument GDBusArgInfo* notify_app_icon = malloc(sizeof(GDBusArgInfo)); notify_app_icon->ref_count = -1; notify_app_icon->name = "app_icon"; notify_app_icon->signature = "s"; notify_app_icon->annotations = NULL; //Notify method summary argument GDBusArgInfo* notify_summary = malloc(sizeof(GDBusArgInfo)); notify_summary->ref_count = -1; notify_summary->name = "summary"; notify_summary->signature = "s"; notify_summary->annotations = NULL; //Notify method body argument GDBusArgInfo* notify_body = malloc(sizeof(GDBusArgInfo)); notify_body->ref_count = -1; notify_body->name = "body"; notify_body->signature = "s"; notify_body->annotations = NULL; //Notify method actions argument GDBusArgInfo* notify_actions = malloc(sizeof(GDBusArgInfo)); notify_actions->ref_count = -1; notify_actions->name = "actions"; notify_actions->signature = "as"; notify_actions->annotations = NULL; //Notify method hints argument GDBusArgInfo* notify_hints = malloc(sizeof(GDBusArgInfo)); notify_hints->ref_count = -1; notify_hints->name = "hints"; notify_hints->signature = "a{sv}"; notify_hints->annotations = NULL; //Notify method expire_timeout argument GDBusArgInfo* notify_expire_timeout = malloc(sizeof(GDBusArgInfo)); notify_expire_timeout->ref_count = -1; notify_expire_timeout->name = "expire_timeout"; notify_expire_timeout->signature = "i"; notify_expire_timeout->annotations = NULL; //Notify method args GDBusArgInfo** notify_args = calloc(9, sizeof(GDBusArgInfo*)); notify_args[0] = notify_app_name; notify_args[1] = notify_replaces_id; notify_args[2] = notify_app_icon; notify_args[3] = notify_summary; notify_args[4] = notify_body; notify_args[5] = notify_actions; notify_args[6] = notify_hints; notify_args[7] = notify_expire_timeout; notify_args[8] = NULL; //Notify method GDBusMethodInfo* notify = malloc(sizeof(GDBusMethodInfo)); notify->ref_count = -1; notify->name = "Notify"; notify->in_args = notify_args; notify->out_args = notify_out_args; notify->annotations = NULL; //CloseNotification method notification_id argument GDBusArgInfo* close_notification_id = malloc(sizeof(GDBusArgInfo)); close_notification_id->ref_count = -1; close_notification_id->name = "id"; close_notification_id->signature = "u"; close_notification_id->annotations = NULL; //CloseNotification method args GDBusArgInfo** close_notification_args = calloc(2, sizeof(GDBusArgInfo*)); close_notification_args[0] = close_notification_id; close_notification_args[1] = NULL; //CloseNotification method GDBusMethodInfo* close_notification = malloc(sizeof(GDBusMethodInfo)); close_notification->ref_count = -1; close_notification->name = "CloseNotification"; close_notification->in_args = close_notification_args; close_notification->out_args = NULL; close_notification->annotations = NULL; //GetServerInformation name argument GDBusArgInfo* get_server_information_name = malloc(sizeof(GDBusArgInfo)); get_server_information_name->ref_count = -1; get_server_information_name->name = "name"; get_server_information_name->signature = "s"; get_server_information_name->annotations = NULL; //GetServerInformation vendor argument GDBusArgInfo* get_server_information_vendor = malloc(sizeof(GDBusArgInfo)); get_server_information_vendor->ref_count = -1; get_server_information_vendor->name = "vendor"; get_server_information_vendor->signature = "s"; get_server_information_vendor->annotations = NULL; //GetServerInformation version argument GDBusArgInfo* get_server_information_version = malloc(sizeof(GDBusArgInfo)); get_server_information_version->ref_count = -1; get_server_information_version->name = "version"; get_server_information_version->signature = "s"; get_server_information_version->annotations = NULL; //GetServerInformation spec_version argument GDBusArgInfo* get_server_information_spec_version = malloc(sizeof(GDBusArgInfo)); get_server_information_spec_version->ref_count = -1; get_server_information_spec_version->name = "spec_version"; get_server_information_spec_version->signature = "s"; get_server_information_spec_version->annotations = NULL; //GetServerInformation args GDBusArgInfo** get_server_information_args = calloc(5, sizeof(GDBusArgInfo*)); get_server_information_args[0] = get_server_information_name; get_server_information_args[1] = get_server_information_vendor; get_server_information_args[2] = get_server_information_version; get_server_information_args[3] = get_server_information_spec_version; get_server_information_args[4] = NULL; //GetServerInformation method GDBusMethodInfo* get_server_information = malloc(sizeof(GDBusMethodInfo)); get_server_information->ref_count = -1; get_server_information->name = "GetServerInformation"; get_server_information->in_args = NULL; get_server_information->out_args = get_server_information_args; get_server_information->annotations = NULL; //DBus methods GDBusMethodInfo** methods = calloc(5, sizeof(GDBusMethodInfo*)); methods[0] = get_capabilities; methods[1] = notify; methods[2] = close_notification; methods[3] = get_server_information; methods[4] = NULL; //NotificationClosed id argument GDBusArgInfo* notification_closed_id = malloc(sizeof(GDBusArgInfo)); notification_closed_id->ref_count = -1; notification_closed_id->name = "id"; notification_closed_id->signature = "u"; notification_closed_id->annotations = NULL; //NotificationClosed reason argument GDBusArgInfo* notification_closed_reason = malloc(sizeof(GDBusArgInfo)); notification_closed_reason->ref_count = -1; notification_closed_reason->name = "reason"; notification_closed_reason->signature = "u"; notification_closed_reason->annotations = NULL; //NotificationClosed args GDBusArgInfo** notification_closed_args = calloc(3, sizeof(GDBusArgInfo*)); notification_closed_args[0] = notification_closed_id; notification_closed_args[1] = notification_closed_reason; notification_closed_args[2] = NULL; //NotificationClosed signal GDBusSignalInfo* notification_closed = malloc(sizeof(GDBusSignalInfo)); notification_closed->ref_count = -1; notification_closed->name = "NotificationClosed"; notification_closed->args = notification_closed_args; notification_closed->annotations = NULL; //ActionInvoked id argument GDBusArgInfo* action_invoked_id = malloc(sizeof(GDBusArgInfo)); action_invoked_id->ref_count = -1; action_invoked_id->name = "id"; action_invoked_id->signature = "u"; action_invoked_id->annotations = NULL; //ActionInvoked action_key argument GDBusArgInfo* action_invoked_action_key = malloc(sizeof(GDBusArgInfo)); action_invoked_action_key->ref_count = -1; action_invoked_action_key->name = "action_key"; action_invoked_action_key->signature = "s"; action_invoked_action_key->annotations = NULL; //ActionInvoked args GDBusArgInfo** action_invoked_args = calloc(3, sizeof(GDBusArgInfo*)); action_invoked_args[0] = action_invoked_id; action_invoked_args[1] = action_invoked_action_key; action_invoked_args[2] = NULL; //ActionInvoked signal GDBusSignalInfo* action_invoked = malloc(sizeof(GDBusSignalInfo)); notification_closed->ref_count = -1; notification_closed->name = "ActionInvoked"; notification_closed->args = action_invoked_args; notification_closed->annotations = NULL; //DBus signals GDBusSignalInfo** signals = calloc(3, sizeof(GDBusSignalInfo*)); signals[0] = notification_closed; signals[1] = action_invoked; signals[2] = NULL; GDBusInterfaceInfo* interface = malloc(sizeof(GDBusInterfaceInfo)); interface->ref_count = -1; interface->name = "org.freedesktop.Notifications"; interface->methods = methods; interface->signals = signals; interface->signals = NULL; interface->properties = NULL; interface->annotations = NULL; GDBusInterfaceVTable vtable = { .method_call = dbus_method_call, .get_property = NULL, .set_property = NULL }; g_dbus_connection_register_object(connection, "/org/freedesktop/Notifications", interface, &vtable, NULL, NULL, NULL); free(signals); free(action_invoked); free(action_invoked_args); free(action_invoked_action_key); free(action_invoked_id); free(notification_closed); free(notification_closed_args); free(notification_closed_reason); free(notification_closed_id); } static void name_lost(GDBusConnection* connection, const gchar* name, gpointer data) { (void) connection; (void) data; fprintf(stderr, "Lost connection for %s\n", name); } void* rootbar_notification_init(struct map* props) { struct notification* this = calloc(1, sizeof(struct notification)); this->display = strdup(map_get(props, "display")); char* whitelist = map_get(props, "whitelist"); char* blacklist = map_get(props, "blacklist"); char* timeout = map_get(props, "timeout"); this->timeout = strtol(timeout == NULL ? "0" : timeout, NULL, 10); if(whitelist != NULL) { this->whitelist = map_init(); char* save_ptr; char* str = strtok_r(whitelist, ",", &save_ptr); do { map_put(this->whitelist, str, "true"); } while((str = strtok_r(NULL, ",", &save_ptr)) != NULL); } else if(blacklist != NULL) { this->blacklist = map_init(); char* save_ptr; char* str = strtok_r(blacklist, ",", &save_ptr); do { map_put(this->blacklist, str, "true"); } while((str = strtok_r(NULL, ",", &save_ptr)) != NULL); } if(!running) { running = true; exec = map_get(props, "exec"); if(exec != NULL) { exec = strdup(exec); } g_bus_own_name(G_BUS_TYPE_SESSION, "org.freedesktop.Notifications", G_BUS_NAME_OWNER_FLAGS_DO_NOT_QUEUE, NULL, name_acquired, name_lost, NULL, NULL); } return this; } const char** rootbar_notification_get_arg_names() { return arg_names; } size_t rootbar_notification_get_arg_count() { return sizeof(arg_names) / sizeof(char*); } static void close_notification(struct notification* this) { if(_app_name != NULL) { free(_app_name); } _app_name = NULL; if(this->app_name != NULL) { free(this->app_name); } this->app_name = NULL; if(this->body != NULL) { free(this->body); } this->body = NULL; if(this->summary != NULL) { free(this->summary); } this->summary = NULL; notify_time = 0; } static gboolean close_timeout(gpointer data) { close_notification(data); return G_SOURCE_REMOVE; } static void update_notif(struct notification* this) { if(this->app_name != NULL) { free(this->app_name); } if(this->body != NULL) { free(this->body); } if(this->summary != NULL) { free(this->summary); } this->app_name = strdup(_app_name); this->body = strdup(_body); this->summary = strdup(_summary); if(notify_time > 0 && this->timeout > 0) { time_t diff = utils_get_time_millis() - notify_time; if(diff >= this->timeout) { close_notification(this); } else { g_timeout_add(this->timeout - diff, G_SOURCE_FUNC(close_timeout), this); } } } void rootbar_notification_get_info(void* data, const char* format, char* out, size_t size) { struct notification* this = data; if(_app_name != NULL) { if(this->whitelist != NULL && map_contains(this->whitelist, _app_name)) { update_notif(this); } else if(this->blacklist != NULL && !map_contains(this->blacklist, _app_name)) { update_notif(this); } else if(this->whitelist == NULL && this->blacklist == NULL) { update_notif(this); } } char* info[3]; memset(info, 0, 3 * sizeof(char*)); if(this->display != NULL) { char* t_display = strdup(this->display); char* tmp_display = t_display; size_t comma_count = utils_split(tmp_display, ','); if(comma_count > 3) { fprintf(stderr, "That's too many display options\n"); free(t_display); return; } for(size_t count = 0; count < comma_count; ++count) { if(strcmp(tmp_display, "app_name") == 0 && this->app_name != NULL) { info[count] = this->app_name; } else if(strcmp(tmp_display, "summary") == 0 && this->summary != NULL) { info[count] = this->summary; } else if(strcmp(tmp_display, "body") == 0 && this->body != NULL) { info[count] = this->body; } tmp_display += strlen(tmp_display) + 1; } free(t_display); } if(info[0] == NULL) { strcpy(out, ""); } else { snprintf(out, size, format, info[0], info[1], info[2]); } } void rootbar_notification_click(void* data, const char* button) { if(strcmp(button, "left") != 0) { return; } close_notification(data); } 07070100000016000081A4000003E800000064000000015FAE52A600000847000000000000000000000000000000000000001D00000000rootbar-0.203/plugins/text.c/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #include <map.h> #include <errno.h> #include <stdio.h> #include <unistd.h> #include <stdbool.h> #include <sys/wait.h> static const char* arg_names[] = {"text", "exec", "pass_args"}; struct text { char* text, *exec; bool pass_args; }; void* rootbar_text_init(struct map* props) { struct text* this = calloc(1, sizeof(struct text)); this->text = strdup(map_get(props, "text")); char* exec = map_get(props, "exec"); if(exec != NULL) { this->exec = strdup(exec); } char* pass_args = map_get(props, "pass_args"); if(pass_args == NULL) { this->pass_args = false; } else { this->pass_args = strcmp(pass_args, "true") == 0; } return this; } const char** rootbar_text_get_arg_names() { return arg_names; } size_t rootbar_text_get_arg_count() { return sizeof(arg_names) / sizeof(char*); } void rootbar_text_get_info(void* data, const char* format, char* out, size_t size) { struct text* this = data; snprintf(out, size, format, this->text); } void rootbar_text_click(void* data, const char* button) { if(strcmp(button, "left") != 0) { return; } struct text* this = data; if(this->exec != NULL) { if(fork() == 0) { if(this->pass_args) { execlp(this->exec, this->exec, this->text, NULL); } else { execlp(this->exec, this->exec, NULL); } fprintf(stderr, "%s cannot be executed\n", this->exec); exit(errno); } while(waitpid(-1, NULL, WNOHANG) > 0); } } 07070100000017000081A4000003E800000064000000015FAE52A600000D5E000000000000000000000000000000000000001F00000000rootbar-0.203/plugins/volume.c/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #include <map.h> #include <stdio.h> #include <pulse/pulseaudio.h> #include <pulse/glib-mainloop.h> static const char* arg_names[] = {"sink", "iconify", "sink_name"}; struct volume { uint64_t sink; char* sink_name; float volume; bool mute; bool iconify; }; static void info(pa_context* ctx, const pa_sink_info* info, int32_t eol, void* data) { (void) ctx; (void) eol; if(info != NULL) { struct volume* this = data; this->volume = ((float) pa_cvolume_avg(&info->volume) / PA_VOLUME_NORM) * 100.f; this->mute = info->mute; } } static void subscribe(pa_context* ctx, pa_subscription_event_type_t event, uint32_t index, void* data) { struct volume* this = data; if((event & PA_SUBSCRIPTION_EVENT_FACILITY_MASK) == PA_SUBSCRIPTION_EVENT_SINK) { if(this->sink_name == NULL) { if(this->sink == index) { pa_context_get_sink_info_by_index(ctx, this->sink, info, this); } } else { pa_context_get_sink_info_by_name(ctx, this->sink_name, info, this); } } } static void ready(pa_context* ctx, void* data) { struct volume* this = data; if(pa_context_get_state(ctx) == PA_CONTEXT_READY) { pa_context_set_subscribe_callback(ctx, subscribe, data); pa_context_subscribe(ctx, PA_SUBSCRIPTION_MASK_SINK, NULL, NULL); if(this->sink_name == NULL) { pa_context_get_sink_info_by_index(ctx, this->sink, info, this); } else { pa_context_get_sink_info_by_name(ctx, this->sink_name, info, this); } } } void* rootbar_volume_init(struct map* props) { struct volume* this = calloc(1, sizeof(struct volume)); char* sink = map_get(props, "sink"); char* sink_name = map_get(props, "sink_name"); if(sink == NULL && sink_name == NULL) { fprintf(stderr, "No sink specified\n"); sink = "0"; } if(sink != NULL) { this->sink = strtol(sink, NULL, 10); } else if(sink_name != NULL) { this->sink_name = strdup(sink_name); } char* iconify = map_get(props, "iconify"); this->iconify = iconify != NULL && strcmp(iconify, "none") != 0; pa_glib_mainloop* loop = pa_glib_mainloop_new(NULL); pa_mainloop_api* api = pa_glib_mainloop_get_api(loop); pa_context* ctx = pa_context_new(api, NULL); pa_context_connect(ctx, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL); pa_context_set_state_callback(ctx, ready, this); return this; } const char** rootbar_volume_get_arg_names() { return arg_names; } size_t rootbar_volume_get_arg_count() { return sizeof(arg_names) / sizeof(char*); } void rootbar_volume_get_info(void* data, const char* format, char* out, size_t size) { struct volume* this = data; float volume; if(this->iconify && this->mute) { volume = -this->volume; } else { volume = this->volume; } snprintf(out, size, format, volume, this->mute ? "true" : "false"); } 07070100000018000081A4000003E800000064000000015FAE52A60000073F000000000000000000000000000000000000001F00000000rootbar-0.203/plugins/window.c/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #include <map.h> #include <sway_ipc.h> #include <stdbool.h> #include <json-c/json_object.h> #include <json-c/json_tokener.h> struct window { char* title; }; static void window(void* data, const char* json_data) { struct window* this = data; struct json_object* json = json_tokener_parse(json_data); struct json_object* container = json_object_object_get(json, "container"); struct json_object* name = json_object_object_get(container, "name"); if(!json_object_is_type(name, json_type_null)) { const char* title = json_object_get_string(name); if(this->title != NULL) { free(this->title); } this->title = strdup(title); } json_object_put(json); } void* rootbar_window_init(struct map* props) { (void) props; struct sway_ipc* ipc = sway_ipc_init(); if(ipc == NULL) { return NULL; } struct window* this = calloc(1, sizeof(struct window)); sway_ipc_subscribe(ipc, SWAY_IPC_EVENT_WINDOW, window, this); return this; } void rootbar_window_get_info(void* data, const char* format, char* out, size_t size) { struct window* this = data; if(this == NULL) { return; } snprintf(out, size, format, this->title); } 07070100000019000081A4000003E800000064000000015FAE52A600001FAA000000000000000000000000000000000000002200000000rootbar-0.203/plugins/workspace.c/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #include <sway_ipc.h> #include <stdbool.h> #include <gtk/gtk.h> #include <json-c/json_object.h> #include <json-c/json_tokener.h> static const char* arg_names[] = {"show_all", "name_only", "disable_clicks"}; struct tmp { struct workspace* this; #ifdef GTK4 GtkLabel* label; #else GtkEventBox* box; #endif const char* status; char* name; }; struct click_info { struct workspace* this; const char* name; }; struct workspace { const char* output_name, *plugin_name; GtkBox* box; bool show_all, name_only, disable_clicks; struct sway_ipc* ipc, *click_ipc; struct map* labels; const char* inactive, *urgent, *focused, *visible; }; static void for_each(GtkWidget* widget, gpointer data) { struct workspace* this = data; gtk_container_remove(GTK_CONTAINER(this->box), widget); #ifdef GTK4 GtkWidget* label = widget; #else GtkWidget* label = gtk_bin_get_child(GTK_BIN(widget)); #endif gtk_widget_set_name(label, this->inactive); } static gboolean idle_remove(gpointer data) { struct workspace* this = data; gtk_container_foreach(GTK_CONTAINER(this->box), for_each, this); return FALSE; } static gboolean idle_add(gpointer data) { struct tmp* tmp = data; #ifdef GTK4 GtkLabel* label = tmp->label; #else GtkLabel* label = GTK_LABEL(gtk_bin_get_child(GTK_BIN(tmp->box))); #endif gtk_widget_set_name(GTK_WIDGET(label), tmp->status); gtk_label_set_text(label, tmp->name); free(tmp->name); #ifdef GTK4 gtk_container_add(GTK_CONTAINER(tmp->this->box), GTK_WIDGET(tmp->label)); #else gtk_container_add(GTK_CONTAINER(tmp->this->box), GTK_WIDGET(tmp->box)); gtk_widget_show_all(GTK_WIDGET(tmp->this->box)); #endif free(tmp); return FALSE; } static gboolean click(GtkWidget* widget, GdkEvent* event, gpointer data) { (void) widget; (void) event; struct click_info* info = data; struct workspace* this = info->this; char* cmd = utils_concat(2, "workspace ", info->name); char* payload = sway_ipc_send_message(this->click_ipc, SWAY_IPC_MESSAGE_RUN_COMMAND, cmd, SWAY_IPC_REPLY_COMMAND); free(cmd); free(payload); return FALSE; } static gboolean enter(GtkWidget* widget, GdkEvent* event, gpointer data) { (void) event; (void) data; widget = gtk_bin_get_child(GTK_BIN(widget)); GtkWidget* parent = gtk_widget_get_parent(widget); while(parent != NULL) { gtk_widget_set_state_flags(parent, GTK_STATE_FLAG_PRELIGHT, TRUE); parent = gtk_widget_get_parent(parent); } gtk_widget_set_state_flags(widget, GTK_STATE_FLAG_PRELIGHT, TRUE); return FALSE; } static gboolean leave(GtkWidget* widget, GdkEvent* event, gpointer data) { (void) event; (void) data; widget = gtk_bin_get_child(GTK_BIN(widget)); GtkWidget* parent = gtk_widget_get_parent(widget); while(parent != NULL) { gtk_widget_set_state_flags(parent, GTK_STATE_FLAG_NORMAL, TRUE); parent = gtk_widget_get_parent(parent); } gtk_widget_set_state_flags(widget, GTK_STATE_FLAG_NORMAL, TRUE); return FALSE; } static void ask_workspaces(void* data, const char* ignored) { (void) ignored; struct workspace* this = data; char* payload = sway_ipc_send_message(this->ipc, SWAY_IPC_MESSAGE_GET_WORKSPACES, NULL, SWAY_IPC_REPLY_WORKSPACES); struct json_object* arr = json_tokener_parse(payload); free(payload); size_t arr_s = json_object_array_length(arr); g_idle_add(idle_remove, this); for(size_t count = 0; count < arr_s; ++count) { struct json_object* obj = json_object_array_get_idx(arr, count); const char* name = json_object_get_string(json_object_object_get(obj, "name")); const char* output = json_object_get_string(json_object_object_get(obj, "output")); bool urgent = json_object_get_boolean(json_object_object_get(obj, "urgent")); bool focused = json_object_get_boolean(json_object_object_get(obj, "focused")); bool visible = json_object_get_boolean(json_object_object_get(obj, "visible")); if(this->show_all || strcmp(output, this->output_name) == 0) { #ifdef GTK4 GtkLabel* label = map_get(this->labels, name); if(label == NULL) { label = GTK_LABEL(gtk_label_new(name)); g_object_ref(label); #else GtkEventBox* box = map_get(this->labels, name); if(box == NULL) { box = GTK_EVENT_BOX(gtk_event_box_new()); g_object_ref(box); GtkWidget* label = gtk_label_new(name); #endif GtkStyleContext* context = gtk_widget_get_style_context(GTK_WIDGET(label)); gtk_style_context_add_class(context, this->plugin_name); gtk_widget_set_name(GTK_WIDGET(label), this->inactive); #ifndef GTK4 gtk_container_add(GTK_CONTAINER(box), label); gtk_widget_add_events(GTK_WIDGET(box), GDK_BUTTON_PRESS); #endif if(!this->disable_clicks) { struct click_info* info = malloc(sizeof(struct click_info)); info->name = strdup(name); info->this = this; #ifdef GTK4 g_signal_connect(GTK_WIDGET(label), "button-press-event", G_CALLBACK(click), info); g_signal_connect(GTK_WIDGET(label), "enter-notify-event", G_CALLBACK(enter), NULL); g_signal_connect(GTK_WIDGET(label), "leave-notify-event", G_CALLBACK(leave), NULL); #else g_signal_connect(GTK_WIDGET(box), "button-press-event", G_CALLBACK(click), info); g_signal_connect(GTK_WIDGET(box), "enter-notify-event", G_CALLBACK(enter), NULL); g_signal_connect(GTK_WIDGET(box), "leave-notify-event", G_CALLBACK(leave), NULL); #endif } #ifdef GTK4 map_put_void(this->labels, name, label); #else map_put_void(this->labels, name, box); #endif } struct tmp* tmp = malloc(sizeof(struct tmp)); tmp->this = this; #ifdef GTK4 tmp->label = label; #else tmp->box = box; #endif if(this->name_only) { char* colon = strchr(name, ':'); if(colon != NULL) { name = colon + 1; } } tmp->name = strdup(name); if(urgent) { tmp->status = this->urgent; } else if(focused) { tmp->status = this->focused; } else if(visible) { tmp->status = this->visible; } else { tmp->status = this->inactive; } g_idle_add(idle_add, tmp); } } json_object_put(arr); } void rootbar_workspace_init(struct map* props, GtkBox* box) { struct workspace* this = calloc(1, sizeof(struct workspace)); this->ipc = sway_ipc_init(); if(this->ipc == NULL) { free(this); return; } this->click_ipc = sway_ipc_init(); this->output_name = strdup(map_get(props, "_output")); this->box = box; char* show_all = map_get(props, "show_all"); this->show_all = show_all != NULL && strcmp(show_all, "true") == 0; char* name_only = map_get(props, "name_only"); this->name_only = name_only != NULL && strcmp(name_only, "true") == 0; char* disable_clicks = map_get(props, "disable_clicks"); this->disable_clicks = disable_clicks != NULL && strcmp(disable_clicks, "true") == 0; this->plugin_name = strdup(map_get(props, "_plugin")); this->labels = map_init_void(); this->inactive = utils_concat(2, this->plugin_name, "-inactive"); this->urgent = utils_concat(2, this->plugin_name, "-urgent"); this->visible = utils_concat(2, this->plugin_name, "-visible"); this->focused = utils_concat(2, this->plugin_name, "-focused"); gtk_widget_set_name(GTK_WIDGET(box), this->plugin_name); ask_workspaces(this, NULL); sway_ipc_subscribe(this->ipc, SWAY_IPC_EVENT_WORKSPACE, ask_workspaces, this); } bool rootbar_workspace_is_advanced() { return true; } const char** rootbar_workspace_get_arg_names() { return arg_names; } size_t rootbar_workspace_get_arg_count() { return sizeof(arg_names) / sizeof(char*); } 0707010000001A000041ED000003E800000064000000025FAE52A600000000000000000000000000000000000000000000001400000000rootbar-0.203/proto0707010000001B000081A4000003E800000064000000015FAE52A600000B8F000000000000000000000000000000000000003B00000000rootbar-0.203/proto/wlr-layer-shell-unstable-v1-protocol.c/* Generated by wayland-scanner 1.16.0 */ /* * Copyright © 2017 Drew DeVault * * Permission to use, copy, modify, distribute, and sell this * software and its documentation for any purpose is hereby granted * without fee, provided that the above copyright notice appear in * all copies and that both that copyright notice and this permission * notice appear in supporting documentation, and that the name of * the copyright holders not be used in advertising or publicity * pertaining to distribution of the software without specific, * written prior permission. The copyright holders make no * representations about the suitability of this software for any * purpose. It is provided "as is" without express or implied * warranty. * * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF * THIS SOFTWARE. */ #include <stdlib.h> #include <stdint.h> #include "wayland-util.h" #ifndef __has_attribute # define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ #endif #if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) #define WL_PRIVATE __attribute__ ((visibility("hidden"))) #else #define WL_PRIVATE #endif extern const struct wl_interface wl_output_interface; extern const struct wl_interface wl_surface_interface; extern const struct wl_interface xdg_popup_interface; extern const struct wl_interface zwlr_layer_surface_v1_interface; static const struct wl_interface *types[] = { NULL, NULL, NULL, NULL, &zwlr_layer_surface_v1_interface, &wl_surface_interface, &wl_output_interface, NULL, NULL, &xdg_popup_interface, }; static const struct wl_message zwlr_layer_shell_v1_requests[] = { { "get_layer_surface", "no?ous", types + 4 }, }; WL_PRIVATE const struct wl_interface zwlr_layer_shell_v1_interface = { "zwlr_layer_shell_v1", 1, 1, zwlr_layer_shell_v1_requests, 0, NULL, }; static const struct wl_message zwlr_layer_surface_v1_requests[] = { { "set_size", "uu", types + 0 }, { "set_anchor", "u", types + 0 }, { "set_exclusive_zone", "i", types + 0 }, { "set_margin", "iiii", types + 0 }, { "set_keyboard_interactivity", "u", types + 0 }, { "get_popup", "o", types + 9 }, { "ack_configure", "u", types + 0 }, { "destroy", "", types + 0 }, }; static const struct wl_message zwlr_layer_surface_v1_events[] = { { "configure", "uuu", types + 0 }, { "closed", "", types + 0 }, }; WL_PRIVATE const struct wl_interface zwlr_layer_surface_v1_interface = { "zwlr_layer_surface_v1", 1, 8, zwlr_layer_surface_v1_requests, 2, zwlr_layer_surface_v1_events, }; 0707010000001C000081A4000003E800000064000000015FAE52A6000009F0000000000000000000000000000000000000003600000000rootbar-0.203/proto/xdg-output-unstable-v1-protocol.c/* Generated by wayland-scanner 1.16.0 */ /* * Copyright © 2017 Red Hat Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #include <stdlib.h> #include <stdint.h> #include "wayland-util.h" #ifndef __has_attribute # define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ #endif #if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) #define WL_PRIVATE __attribute__ ((visibility("hidden"))) #else #define WL_PRIVATE #endif extern const struct wl_interface wl_output_interface; extern const struct wl_interface zxdg_output_v1_interface; static const struct wl_interface *types[] = { NULL, NULL, &zxdg_output_v1_interface, &wl_output_interface, }; static const struct wl_message zxdg_output_manager_v1_requests[] = { { "destroy", "", types + 0 }, { "get_xdg_output", "no", types + 2 }, }; WL_PRIVATE const struct wl_interface zxdg_output_manager_v1_interface = { "zxdg_output_manager_v1", 2, 2, zxdg_output_manager_v1_requests, 0, NULL, }; static const struct wl_message zxdg_output_v1_requests[] = { { "destroy", "", types + 0 }, }; static const struct wl_message zxdg_output_v1_events[] = { { "logical_position", "ii", types + 0 }, { "logical_size", "ii", types + 0 }, { "done", "", types + 0 }, { "name", "2s", types + 0 }, { "description", "2s", types + 0 }, }; WL_PRIVATE const struct wl_interface zxdg_output_v1_interface = { "zxdg_output_v1", 2, 1, zxdg_output_v1_requests, 5, zxdg_output_v1_events, }; 0707010000001D000081A4000003E800000064000000015FAE52A60000144D000000000000000000000000000000000000002900000000rootbar-0.203/proto/xdg-shell-protocol.c/* Generated by wayland-scanner 1.16.0 */ /* * Copyright © 2008-2013 Kristian Høgsberg * Copyright © 2013 Rafael Antognolli * Copyright © 2013 Jasper St. Pierre * Copyright © 2010-2013 Intel Corporation * Copyright © 2015-2017 Samsung Electronics Co., Ltd * Copyright © 2015-2017 Red Hat Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #include <stdlib.h> #include <stdint.h> #include "wayland-util.h" #ifndef __has_attribute # define __has_attribute(x) 0 /* Compatibility with non-clang compilers. */ #endif #if (__has_attribute(visibility) || defined(__GNUC__) && __GNUC__ >= 4) #define WL_PRIVATE __attribute__ ((visibility("hidden"))) #else #define WL_PRIVATE #endif extern const struct wl_interface wl_output_interface; extern const struct wl_interface wl_seat_interface; extern const struct wl_interface wl_surface_interface; extern const struct wl_interface xdg_popup_interface; extern const struct wl_interface xdg_positioner_interface; extern const struct wl_interface xdg_surface_interface; extern const struct wl_interface xdg_toplevel_interface; static const struct wl_interface *types[] = { NULL, NULL, NULL, NULL, &xdg_positioner_interface, &xdg_surface_interface, &wl_surface_interface, &xdg_toplevel_interface, &xdg_popup_interface, &xdg_surface_interface, &xdg_positioner_interface, &xdg_toplevel_interface, &wl_seat_interface, NULL, NULL, NULL, &wl_seat_interface, NULL, &wl_seat_interface, NULL, NULL, &wl_output_interface, &wl_seat_interface, NULL, }; static const struct wl_message xdg_wm_base_requests[] = { { "destroy", "", types + 0 }, { "create_positioner", "n", types + 4 }, { "get_xdg_surface", "no", types + 5 }, { "pong", "u", types + 0 }, }; static const struct wl_message xdg_wm_base_events[] = { { "ping", "u", types + 0 }, }; WL_PRIVATE const struct wl_interface xdg_wm_base_interface = { "xdg_wm_base", 2, 4, xdg_wm_base_requests, 1, xdg_wm_base_events, }; static const struct wl_message xdg_positioner_requests[] = { { "destroy", "", types + 0 }, { "set_size", "ii", types + 0 }, { "set_anchor_rect", "iiii", types + 0 }, { "set_anchor", "u", types + 0 }, { "set_gravity", "u", types + 0 }, { "set_constraint_adjustment", "u", types + 0 }, { "set_offset", "ii", types + 0 }, }; WL_PRIVATE const struct wl_interface xdg_positioner_interface = { "xdg_positioner", 2, 7, xdg_positioner_requests, 0, NULL, }; static const struct wl_message xdg_surface_requests[] = { { "destroy", "", types + 0 }, { "get_toplevel", "n", types + 7 }, { "get_popup", "n?oo", types + 8 }, { "set_window_geometry", "iiii", types + 0 }, { "ack_configure", "u", types + 0 }, }; static const struct wl_message xdg_surface_events[] = { { "configure", "u", types + 0 }, }; WL_PRIVATE const struct wl_interface xdg_surface_interface = { "xdg_surface", 2, 5, xdg_surface_requests, 1, xdg_surface_events, }; static const struct wl_message xdg_toplevel_requests[] = { { "destroy", "", types + 0 }, { "set_parent", "?o", types + 11 }, { "set_title", "s", types + 0 }, { "set_app_id", "s", types + 0 }, { "show_window_menu", "ouii", types + 12 }, { "move", "ou", types + 16 }, { "resize", "ouu", types + 18 }, { "set_max_size", "ii", types + 0 }, { "set_min_size", "ii", types + 0 }, { "set_maximized", "", types + 0 }, { "unset_maximized", "", types + 0 }, { "set_fullscreen", "?o", types + 21 }, { "unset_fullscreen", "", types + 0 }, { "set_minimized", "", types + 0 }, }; static const struct wl_message xdg_toplevel_events[] = { { "configure", "iia", types + 0 }, { "close", "", types + 0 }, }; WL_PRIVATE const struct wl_interface xdg_toplevel_interface = { "xdg_toplevel", 2, 14, xdg_toplevel_requests, 2, xdg_toplevel_events, }; static const struct wl_message xdg_popup_requests[] = { { "destroy", "", types + 0 }, { "grab", "ou", types + 22 }, }; static const struct wl_message xdg_popup_events[] = { { "configure", "iiii", types + 0 }, { "popup_done", "", types + 0 }, }; WL_PRIVATE const struct wl_interface xdg_popup_interface = { "xdg_popup", 2, 2, xdg_popup_requests, 2, xdg_popup_events, }; 0707010000001E000041ED000003E800000064000000025FAE52A600000000000000000000000000000000000000000000001500000000rootbar-0.203/sample0707010000001F000081A4000003E800000064000000015FAE52A6000001C4000000000000000000000000000000000000001C00000000rootbar-0.203/sample/configbars=primary primary-output=DP-1 primary-left=ws primary-right=memory,cpu primary-center=clock ws-dso=workspace ws-show_all=true ws-name_only=false clock-dso=clock clock-length=50 clock-format=%a %b %e | %I:%M %p cpu-dso=cpu cpu-format=<span color="\#7E7F80">cpu</span> %u%% cpu-allow_markup=true cpu-length=50 memory-dso=memory memory-percent=true memory-format=<span color="\#7E7F80">mem</span> %.0f%s memory-allow_markup=true memory-length=50 07070100000020000081A4000003E800000064000000015FAE52A6000002F3000000000000000000000000000000000000001F00000000rootbar-0.203/sample/style.csswindow { background-color: #2F343F; color: #C9C9CB; font-family: "iosevka"; } label { margin-left: 5px; margin-right: 5px; border-bottom: 3px solid rgba(0,0,0,0); } #left { margin-left: 25px; } #right { margin-right: 25px; } .ws { margin: 0; padding-left: 15px; padding-right: 15px; } #ws-focused { background-color: #444444; border-bottom: 3px solid #FFB52A; } #clock { border-bottom: 3px solid #C62828; } #cpu { border-bottom: 3px solid #D84315; margin-left: 0; } #memory { border-bottom: 3px solid #EF6C00; margin-left: 0; } #cput { color: #7E7F80; margin-right: 0; padding-right: 5px; border-bottom: 3px solid #D84315; } #memt { color: #7E7F80; margin-right: 0; padding-right: 5px; border-bottom: 3px solid #EF6C00; } 07070100000021000041ED000003E800000064000000025FAE52A600000000000000000000000000000000000000000000001200000000rootbar-0.203/src07070100000022000081A4000003E800000064000000015FAE52A6000050C8000000000000000000000000000000000000001800000000rootbar-0.203/src/bar.c/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #include <bar.h> struct output_node { char* name; struct wl_output* output; int32_t width, height; struct bar* this; struct wl_list link; }; enum iconify_mode { ICONIFY_MODE_REPLACE, ICONIFY_MODE_ADD, ICONIFY_MODE_NONE }; struct plugin_node { void* plugin; GtkWidget* widget; char* format; uint64_t length; void (*get_info)(void* data, const char* format, char* out, size_t size); void (*click)(void* data, const char* button); enum iconify_mode iconify; char* icon, *negative_icon; uint64_t icon_interval; bool allow_markup; struct wl_list link; }; struct bar { struct output_node* output; struct wl_list outputs; struct zxdg_output_manager_v1* output_manager; struct zwlr_layer_shell_v1* shell; struct zwlr_layer_surface_v1* surface; uint64_t width, height; const char* location; const char* bar_float; bool disable_clicks; GtkWidget* window; struct wl_list plugins; uint64_t interval; int32_t top_margin, right_margin, left_margin, bottom_margin; }; static void nop() {} static void add_interface(void* data, struct wl_registry* registry, uint32_t name, const char* interface, uint32_t version) { struct bar* this = data; if(strcmp(interface, wl_output_interface.name) == 0) { struct output_node* node = malloc(sizeof(struct output_node)); node->output = wl_registry_bind(registry, name, &wl_output_interface, version); node->this = this; wl_list_insert(&this->outputs, &node->link); } else if(strcmp(interface, zxdg_output_manager_v1_interface.name) == 0) { this->output_manager = wl_registry_bind(registry, name, &zxdg_output_manager_v1_interface, version); } else if(strcmp(interface, zwlr_layer_shell_v1_interface.name) == 0) { this->shell = wl_registry_bind(registry, name, &zwlr_layer_shell_v1_interface, version); } } static void get_name(void* data, struct zxdg_output_v1* output, const char* name) { (void) output; struct output_node* node = data; node->name = malloc(strlen(name) + 1); strcpy(node->name, name); } static void set_size(struct bar* this) { gtk_window_set_default_size(GTK_WINDOW(this->window), this->width, this->height); gtk_window_resize(GTK_WINDOW(this->window), this->width, this->height); } static void get_res(void* data, struct zxdg_output_v1* output, int32_t width, int32_t height) { (void) output; struct output_node* node = data; struct bar* this = node->this; node->width = width; node->height = height; if(this->output == node) { this->width = width; set_size(this); } } static void config_surface(void* data, struct zwlr_layer_surface_v1* surface, uint32_t serial, uint32_t width, uint32_t height) { (void) data; (void) width; (void) height; zwlr_layer_surface_v1_ack_configure(surface, serial); } static void setup_surface(struct bar* this) { zwlr_layer_surface_v1_set_size(this->surface, this->width, this->height); enum zwlr_layer_surface_v1_anchor location = strcmp(this->location, "bottom") == 0 ? ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM : ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP; if(this->bar_float == NULL) { zwlr_layer_surface_v1_set_exclusive_zone(this->surface, this->height); zwlr_layer_surface_v1_set_anchor(this->surface, ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | location | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT); } else { zwlr_layer_surface_v1_set_exclusive_zone(this->surface, 0); enum zwlr_layer_surface_v1_anchor bar_float = strcmp(this->bar_float, "left") == 0 ? ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT : ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT; enum zwlr_layer_surface_v1_anchor anchor = location | bar_float; zwlr_layer_surface_v1_set_anchor(this->surface, anchor); } zwlr_layer_surface_v1_set_margin(this->surface, this->top_margin, this->right_margin, this->bottom_margin, this->left_margin); set_size(this); gtk_window_set_resizable(GTK_WINDOW(this->window), FALSE); gtk_window_set_decorated(GTK_WINDOW(this->window), FALSE); if(this->disable_clicks) { cairo_region_t* region = cairo_region_create(); gdk_window_input_shape_combine_region(gtk_widget_get_window(this->window), region, 0, 0); cairo_region_destroy(region); } } static gboolean _click(GtkWidget* widget, GdkEvent* event, gpointer data) { (void) widget; (void) event; struct plugin_node* node = data; if(node->click != NULL && (event->button.type == GDK_BUTTON_PRESS || event->scroll.type == GDK_SCROLL)) { const char* button = NULL; if(event->button.type == GDK_BUTTON_PRESS) { switch(event->button.button) { case 1: button = "left"; break; case 3: button = "right"; break; } } else if(event->scroll.type == GDK_SCROLL) { switch(event->scroll.direction) { case GDK_SCROLL_UP: button = "scroll_up"; break; case GDK_SCROLL_DOWN: button = "scroll_down"; break; case GDK_SCROLL_RIGHT: button = "scroll_right"; break; case GDK_SCROLL_LEFT: button = "scroll_left"; break; default: return FALSE; } } if(button == NULL) { return FALSE; } node->click(node->plugin, button); } return FALSE; } static gboolean enter(GtkWidget* widget, GdkEvent* event, gpointer data) { (void) event; struct plugin_node* node = data; if(node != NULL) { widget = node->widget; } GtkWidget* parent = gtk_widget_get_parent(widget); while(parent != NULL) { gtk_widget_set_state_flags(parent, GTK_STATE_FLAG_PRELIGHT, TRUE); parent = gtk_widget_get_parent(parent); } gtk_widget_set_state_flags(widget, GTK_STATE_FLAG_PRELIGHT, TRUE); return FALSE; } static gboolean leave(GtkWidget* widget, GdkEvent* event, gpointer data) { (void) event; struct plugin_node* node = data; if(node != NULL) { widget = node->widget; } GtkWidget* parent = gtk_widget_get_parent(widget); while(parent != NULL) { gtk_widget_set_state_flags(parent, GTK_STATE_FLAG_NORMAL, TRUE); parent = gtk_widget_get_parent(parent); } gtk_widget_set_state_flags(widget, GTK_STATE_FLAG_NORMAL, TRUE); return FALSE; } static gboolean idle_add(gpointer data) { struct bar* this = data; struct plugin_node* node; wl_list_for_each(node, &this->plugins, link) { char output[node->length + 1]; node->get_info(node->plugin, node->format, output, node->length + 1); size_t out_s = strlen(output); int64_t num = 0; size_t num_offset = 0; for(size_t count = 0; count < out_s; ++count) { if(isdigit(output[count]) || (output[count] == '-' && isdigit(output[count + 1]))) { num = strtol(output + count, NULL, 10); num_offset = count; break; } } if(node->iconify == ICONIFY_MODE_NONE || node->icon == NULL) { if(node->iconify != ICONIFY_MODE_NONE && node->icon == NULL) { fprintf(stderr, "I was told to use an icon but none was specified, plz help"); } } else if(node->iconify == ICONIFY_MODE_ADD) { bool neg = num < 0; if(neg) { num *= -1; } uint64_t icon_num = num / node->icon_interval; size_t chr_len; if(neg) { chr_len = strlen(node->negative_icon); } else { chr_len = strlen(node->icon); } size_t required = chr_len * icon_num; if(required >= node->length) { icon_num = node->length / chr_len; } output[num_offset] = 0; for(size_t count = 0; count < icon_num; ++count) { if(neg) { strcat(output, node->negative_icon); } else { strcat(output, node->icon); } } } if(strlen(output) == node->length) { for(size_t count = 0; count < 3; ++count) { output[node->length - 1 - count] = '.'; } } char* lf = strchr(output, '\n'); if(lf != NULL) { *lf = 0; } gtk_widget_set_visible(node->widget, strlen(output) > 0); if(node->allow_markup) { gtk_label_set_markup(GTK_LABEL(node->widget), output); } else { gtk_label_set_text(GTK_LABEL(node->widget), output); } } return TRUE; } static void* get_plugin_proc(const char* prefix, const char* suffix) { char* proc_name = utils_concat(3, "rootbar_", prefix, suffix); void* proc = dlsym(RTLD_DEFAULT, proc_name); free(proc_name); return proc; } static void load_plugin(struct bar* this, struct map* config, char* plugin_name, char* position, char* output_name, const char* config_location, GtkWidget* left, GtkWidget* center_box, GtkWidget* right, size_t* left_count, size_t* center_count, size_t* right_count) { char* dso_name = config_get(config, plugin_name, "-dso", NULL); if(dso_name == NULL) { fprintf(stderr, "No DSO specified for %s\n", plugin_name); return; } char* dso = strstr(dso_name, ".so"); void* (*init)(struct map* props); void (*init_adv)(struct map* props, GtkBox* box); const char** (*get_arg_names)(); size_t (*get_arg_count)(); bool (*is_advanced)(); void (*get_info)(void* data, const char* format, char* out, size_t size); void (*click)(void* data, const char* button); if(dso == NULL) { void* init_ptr = get_plugin_proc(dso_name, "_init"); init = init_ptr; init_adv = init_ptr; get_arg_names = get_plugin_proc(dso_name, "_get_arg_names"); get_arg_count = get_plugin_proc(dso_name, "_get_arg_count"); is_advanced = get_plugin_proc(dso_name, "_is_advanced"); get_info = get_plugin_proc(dso_name, "_get_info"); click = get_plugin_proc(dso_name, "_click"); } else { char* plugins_dir = utils_concat(2, config_location, "/plugins/"); char* full_name = utils_concat(2, plugins_dir, dso_name); void* plugin = dlopen(full_name, RTLD_LAZY | RTLD_LOCAL); free(full_name); free(plugins_dir); void* init_ptr = dlsym(plugin, "init"); init = init_ptr; init_adv = init_ptr; get_arg_names = dlsym(plugin, "get_arg_names"); get_arg_count = dlsym(plugin, "get_arg_count"); is_advanced = dlsym(plugin, "is_advanced"); get_info = dlsym(plugin, "get_info"); click = dlsym(plugin, "click"); } bool is_adv = is_advanced != NULL && is_advanced(); if(get_info == NULL && !is_adv) { fprintf(stderr, "%s has no get_info function\n", plugin_name); return; } const char** arg_names = NULL; size_t arg_count = 0; if(get_arg_names != NULL && get_arg_count != NULL) { arg_names = get_arg_names(); arg_count = get_arg_count(); } struct map* props = map_init(); for(size_t count = 0; count < arg_count; ++count) { const char* arg = arg_names[count]; char* hyphen_name = utils_concat(2, "-", arg); map_put(props, arg, config_get(config, plugin_name, hyphen_name, NULL)); free(hyphen_name); } GtkWidget* bar_widget, *user_widget; if(is_adv) { bar_widget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); user_widget = bar_widget; map_put(props, "_output", output_name); map_put(props, "_plugin", plugin_name); char width[5]; char height[5]; snprintf(width, 4, "%lu\n", this->width); snprintf(height, 4, "%lu\n", this->height); map_put(props, "_width", width); map_put(props, "_height", height); init_adv(props, GTK_BOX(bar_widget)); } else { void* plugin = NULL; if(init != NULL) { plugin = init(props); } struct plugin_node* node = malloc(sizeof(struct plugin_node)); char* iconify = config_get(config, plugin_name, "-iconify", "none"); if(strcmp(iconify, "replace") == 0) { node->iconify = ICONIFY_MODE_REPLACE; } else if(strcmp(iconify, "add") == 0) { node->iconify = ICONIFY_MODE_ADD; } else { node->iconify = ICONIFY_MODE_NONE; } if(node->iconify != ICONIFY_MODE_NONE) { node->icon = config_get(config, plugin_name, "-icon", NULL); node->negative_icon = config_get(config, plugin_name, "-negative_icon", NULL); node->icon_interval = strtol(config_get(config, plugin_name, "-icon_interval", "10"), NULL, 10); } user_widget = gtk_label_new(NULL); #ifdef GTK4 bar_widget = user_widget; #else bar_widget = gtk_event_box_new(); gtk_container_add(GTK_CONTAINER(bar_widget), user_widget); #endif gtk_widget_add_events(GTK_WIDGET(bar_widget), GDK_SCROLL_MASK); g_signal_connect(GTK_WIDGET(bar_widget), "button-press-event", G_CALLBACK(_click), node); g_signal_connect(GTK_WIDGET(bar_widget), "scroll-event", G_CALLBACK(_click), node); g_signal_connect(GTK_WIDGET(bar_widget), "enter-notify-event", G_CALLBACK(enter), node); g_signal_connect(GTK_WIDGET(bar_widget), "leave-notify-event", G_CALLBACK(leave), node); node->widget = user_widget; node->plugin = plugin; node->format = config_get(config, plugin_name, "-format", "%s"); node->length = strtol(config_get(config, plugin_name, "-length", "15"), NULL, 10); node->allow_markup = strcmp(config_get(config, plugin_name, "-allow_markup", "false"), "true") == 0; node->get_info = get_info; node->click = click; wl_list_insert(&this->plugins, &node->link); } map_free(props); gtk_widget_set_name(user_widget, plugin_name); if(strcmp(position, "left") == 0) { ++*left_count; #ifdef GTK4 gtk_box_pack_start(GTK_BOX(left), bar_widget); #else gtk_box_pack_start(GTK_BOX(left), bar_widget, false, false, 0); #endif } else if(strcmp(position, "center") == 0) { ++*center_count; #ifdef GTK4 gtk_box_pack_start(GTK_BOX(center_box), bar_widget); #else gtk_box_pack_start(GTK_BOX(center_box), bar_widget, false, false, 0); #endif } else if(strcmp(position, "right") == 0) { ++*right_count; #ifdef GTK4 gtk_box_pack_end(GTK_BOX(right), bar_widget); #else gtk_box_pack_end(GTK_BOX(right), bar_widget, false, false, 0); #endif } } void bar_init(struct map* config, const char* bar_name, char* output_name, const char* config_location) { if(output_name == NULL) { fprintf(stderr, "No output specified for %s\n", bar_name); return; } struct bar* this = calloc(1, sizeof(struct bar)); wl_list_init(&this->outputs); wl_list_init(&this->plugins); this->location = config_get(config, bar_name, "-location", "top"); this->bar_float = config_get(config, bar_name, "-float", NULL); this->interval = strtol(config_get(config, bar_name, "-interval", "1000"), NULL, 10); this->height = strtol(config_get(config, bar_name, "-height", "30"), NULL, 10); this->disable_clicks = strcmp(config_get(config, bar_name, "-disable_clicks", "false"), "true") == 0; GdkDisplay* disp = gdk_display_get_default(); struct wl_display* wl = gdk_wayland_display_get_wl_display(disp); struct wl_registry* registry = wl_display_get_registry(wl); struct wl_registry_listener reg_listener = { .global = add_interface, .global_remove = nop }; wl_registry_add_listener(registry, ®_listener, this); wl_display_roundtrip(wl); struct output_node* node; wl_list_for_each(node, &this->outputs, link) { struct zxdg_output_v1* xdg_output = zxdg_output_manager_v1_get_xdg_output(this->output_manager, node->output); struct zxdg_output_v1_listener* xdg_listener = malloc(sizeof(struct zxdg_output_v1_listener)); xdg_listener->description = nop; xdg_listener->done = nop; xdg_listener->logical_position = nop; xdg_listener->logical_size = get_res; xdg_listener->name = get_name; zxdg_output_v1_add_listener(xdg_output, xdg_listener, node); } wl_display_roundtrip(wl); wl_list_for_each(node, &this->outputs, link) { if(strcmp(output_name, node->name) == 0) { this->output = node; } } if(this->output == NULL) { fprintf(stderr, "I would use %s but it doesn't seem to exist\n", output_name); return; } const char* width_str = config_get(config, bar_name, "-width", NULL); if(width_str == NULL) { this->width = this->output->width; } else { this->width = strtol(width_str, NULL, 10); } this->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(this->window, "enter-notify-event", G_CALLBACK(enter), NULL); g_signal_connect(this->window, "leave-notify-event", G_CALLBACK(leave), NULL); gtk_widget_realize(this->window); GdkWindow* gdk_win = gtk_widget_get_window(this->window); gdk_wayland_window_set_use_custom_surface(gdk_win); gtk_widget_set_name(this->window, bar_name); this->top_margin = strtol(config_get(config, bar_name, "-top_margin", "0"), NULL, 10); this->right_margin = strtol(config_get(config, bar_name, "-right_margin", "0"), NULL, 10); this->left_margin = strtol(config_get(config, bar_name, "-left_margin", "0"), NULL, 10); this->bottom_margin = strtol(config_get(config, bar_name, "-bottom_margin", "0"), NULL, 10); struct wl_surface* wl_surface = gdk_wayland_window_get_wl_surface(gdk_win); this->surface = zwlr_layer_shell_v1_get_layer_surface(this->shell, wl_surface, this->output->output, ZWLR_LAYER_SHELL_V1_LAYER_TOP, "rootbar"); setup_surface(this); struct zwlr_layer_surface_v1_listener* surface_listener = malloc(sizeof(struct zwlr_layer_surface_v1_listener)); surface_listener->configure = config_surface; surface_listener->closed = nop; zwlr_layer_surface_v1_add_listener(this->surface, surface_listener, NULL); wl_surface_commit(wl_surface); wl_display_roundtrip(wl); GtkContainer* root = GTK_CONTAINER(gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0)); gtk_box_set_homogeneous(GTK_BOX(root), TRUE); gtk_container_add(GTK_CONTAINER(this->window), GTK_WIDGET(root)); gtk_widget_set_name(GTK_WIDGET(root), "root"); GtkWidget* left = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_widget_set_name(left, "left"); #ifdef GTK4 GtkWidget* center = gtk_center_box_new(); #else GtkWidget* center = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); #endif GtkWidget* center_box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_widget_set_name(center_box, "center"); GtkWidget* right = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 0); gtk_widget_set_name(right, "right"); char* plugin_names = config_get(config, bar_name, "-plugins", NULL); char* left_plugins = config_get(config, bar_name, "-left", NULL); char* center_plugins = config_get(config, bar_name, "-center", NULL); char* right_plugins = config_get(config, bar_name, "-right", NULL); if(plugin_names == NULL && left_plugins == NULL && center_plugins == NULL && right_plugins == NULL) { return; } size_t left_count = 0; size_t center_count = 0; size_t right_count = 0; size_t comma_count; char* plugin_name; if(plugin_names != NULL) { comma_count = utils_split(plugin_names, ','); plugin_name = plugin_names; for(size_t count = 0; count < comma_count; ++count) { char* position = config_get(config, plugin_name, "-position", "right"); load_plugin(this, config, plugin_name, position, output_name, config_location, left, center_box, right, &left_count, ¢er_count, &right_count); plugin_name += strlen(plugin_name) + 1; } } if(left_plugins != NULL) { comma_count = utils_split(left_plugins, ','); plugin_name = left_plugins; for(size_t count = 0; count < comma_count; ++count) { load_plugin(this, config, plugin_name, "left", output_name, config_location, left, center_box, right, &left_count, ¢er_count, &right_count); plugin_name += strlen(plugin_name) + 1; } } if(center_plugins != NULL) { comma_count = utils_split(center_plugins, ','); plugin_name = center_plugins; for(size_t count = 0; count < comma_count; ++count) { load_plugin(this, config, plugin_name, "center", output_name, config_location, left, center_box, right, &left_count, ¢er_count, &right_count); plugin_name += strlen(plugin_name) + 1; } } if(right_plugins != NULL) { comma_count = utils_split(right_plugins, ','); plugin_name = right_plugins; for(size_t count = 0; count < comma_count; ++count) { load_plugin(this, config, plugin_name, "right", output_name, config_location, left, center_box, right, &left_count, ¢er_count, &right_count); plugin_name += strlen(plugin_name) + 1; } } gdk_threads_add_timeout(this->interval, idle_add, this); if(left_count != 0) { gtk_container_add(root, left); } if(center_count != 0) { if(left_count == 0) { gtk_container_add(root, center_box); } else if(right_count == 0) { gtk_container_add(root, center_box); } else { #ifdef GTK4 gtk_center_box_set_center_widget(GTK_CENTER_BOX(center), center_box); #else gtk_box_set_center_widget(GTK_BOX(center), center_box); #endif gtk_container_add(root, center); } } if(right_count != 0) { gtk_container_add(root, right); } #ifdef GTK4 gtk_widget_show(this->window); #else gtk_widget_show_all(this->window); #endif } 07070100000023000081A4000003E800000064000000015FAE52A600000836000000000000000000000000000000000000001B00000000rootbar-0.203/src/config.c/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> void config_load(struct map* map, const char* config) { FILE* file = fopen(config, "r"); char* line = NULL; size_t size = 0; while(getline(&line, &size, file) != -1) { char* hash = strchr(line, '#'); if(hash != NULL) { if(hash == line || *(hash - 1) != '\\') { *hash = 0; } } char* backslash = strchr(line, '\\'); size_t backslash_count = 0; while(backslash != NULL) { ++backslash_count; backslash = strchr(backslash + 1, '\\'); } char* new_line = calloc(1, size - backslash_count); size_t line_size = strlen(line); size_t new_line_count = 0; for(size_t count = 0; count < line_size; ++count) { if(line[count] == '\\') { continue; } new_line[new_line_count++] = line[count]; } free(line); line = new_line; char* equals = strchr(line, '='); if(equals == NULL) { continue; } *equals = 0; char* key = equals - 1; while(*key == ' ') { --key; } *(key + 1) = 0; char* value = equals + 1; while(*value == ' ') { ++value; } size_t len = strlen(value); *(value + len - 1) = 0; map_put(map, line, value); } free(line); fclose(file); } char* config_get(struct map* config, const char* prefix, const char* suffix, char* def_opt) { char* key = utils_concat(2, prefix, suffix); char* opt = map_get(config, key); free(key); if(opt == NULL) { opt = def_opt; } return opt; } 07070100000024000081A4000003E800000064000000015FAE52A60000274B000000000000000000000000000000000000001900000000rootbar-0.203/src/main.c/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #include <bar.h> #include <map.h> #include <config.h> #include <stdio.h> #include <stdint.h> #include <unistd.h> #include <signal.h> #include <getopt.h> #include <pthread.h> #include <gtk/gtk.h> #include <sys/inotify.h> #include <wayland-client.h> static char* CONFIG_LOCATION; static char* COLORS_LOCATION; static struct map* config; static char** _argv; static char* config_path; static char* stylesheet; static char* color_path; static pthread_t css_notify; static void print_usage(char** argv) { char* slash = strrchr(argv[0], '/'); uint64_t offset; if(slash == NULL) { offset = 0; } else { offset = (slash - argv[0]) + 1; } printf("%s [options]\n", argv[0] + offset); printf("Options:\n"); printf("--help\t-h\tDisplays this help message\n"); printf("--fork\t-f\tForks the bar so you can close the terminal\n"); printf("--bar\t-b\tSpecifies the bar to run, runs all if not specified\n"); printf("--conf\t-c\tSelects a config file to use\n"); printf("--style\t-s\tSelects a stylesheet to use\n"); printf("--color\t-C\tSelects a colors file to use\n"); exit(0); } static gboolean reload(gpointer data) { (void) data; execvp(_argv[0], _argv); return FALSE; } static gboolean reload_css(gpointer data) { (void) data; if(access(stylesheet, R_OK) == 0) { FILE* file = fopen(stylesheet, "r"); fseek(file, 0, SEEK_END); ssize_t size = ftell(file); fseek(file, 0, SEEK_SET); char* data = malloc(size + 1); fread(data, 1, size, file); fclose(file); data[size] = 0; struct wl_list lines; struct node { char* line; struct wl_list link; }; wl_list_init(&lines); if(access(color_path, R_OK) == 0) { file = fopen(color_path, "r"); char* line = NULL; size_t line_size = 0; ssize_t line_l = 0; while((line_l = getline(&line, &line_size, file)) != -1) { struct node* entry = malloc(sizeof(struct node)); line[line_l - 1] = 0; entry->line = malloc(line_l + 1); strcpy(entry->line, line); wl_list_insert(&lines, &entry->link); } fclose(file); free(line); } ssize_t count = wl_list_length(&lines) - 1; if(count > 99) { fprintf(stderr, "Woah there that's a lot of colors. Try having no more than 99, thanks\n"); exit(1); } struct node* node; wl_list_for_each(node, &lines, link) { //Do --rootbar-color replace const char* color = node->line; const char* rootbar_color = "--rootbar-color"; char count_str[3]; snprintf(count_str, 3, "%lu", count--); char* needle = utils_concat(2, rootbar_color, count_str); size_t color_len = strlen(color); size_t needle_len = strlen(needle); if(color_len > needle_len) { free(needle); fprintf(stderr, "What color format is this, try #FFFFFF, kthxbi\n"); continue; } char* replace = strstr(data, needle); while(replace != NULL) { memcpy(replace, color, color_len); memset(replace + color_len, ' ', needle_len - color_len); replace = strstr(data, needle); } free(needle); //Do --rootbar-rgb-color replace if(color_len < 7) { fprintf(stderr, "What color format is this, try #FFFFFF, kthxbi\n"); continue; } const char* rootbar_rgb_color = "--rootbar-rgb-color"; needle = utils_concat(2, rootbar_rgb_color, count_str); needle_len = strlen(needle); replace = strstr(data, needle); while(replace != NULL) { char r[3]; char g[3]; char b[3]; memcpy(r, color + 1, 2); memcpy(g, color + 3, 2); memcpy(b, color + 5, 2); r[2] = 0; g[2] = 0; b[2] = 0; char rgb[14]; snprintf(rgb, 14, "%ld, %ld, %ld", strtol(r, NULL, 16), strtol(g, NULL, 16), strtol(b, NULL, 16)); size_t rgb_len = strlen(rgb); memcpy(replace, rgb, rgb_len); memset(replace + rgb_len, ' ', needle_len - rgb_len); replace = strstr(data, needle); } free(needle); } GtkCssProvider* css = gtk_css_provider_new(); #ifdef GTK4 gtk_css_provider_load_from_data(css, data, strlen(data)); #else gtk_css_provider_load_from_data(css, data, strlen(data), NULL); #endif free(data); struct node* tmp; wl_list_for_each_safe(node, tmp, &lines, link) { free(node->line); wl_list_remove(&node->link); free(node); } gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(css), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } return FALSE; } static void* watch_css(void* data) { (void) data; int fd = inotify_init(); int css_wd = inotify_add_watch(fd, stylesheet, IN_MODIFY | IN_IGNORED); int color_wd = inotify_add_watch(fd, color_path, IN_MODIFY | IN_IGNORED); struct inotify_event event; while(true) { read(fd, &event, sizeof(event)); if(event.mask == IN_IGNORED) { if(event.wd == css_wd) { if(access(stylesheet, R_OK) == 0) { css_wd = inotify_add_watch(fd, stylesheet, IN_MODIFY | IN_IGNORED); } } else if(event.wd == color_wd) { if(access(color_path, R_OK) == 0) { color_wd = inotify_add_watch(fd, color_path, IN_MODIFY | IN_IGNORED); } } } g_idle_add(G_SOURCE_FUNC(reload_css), NULL); } return NULL; } static void sig(int32_t signum) { switch(signum) { case SIGINT: exit(0); break; case SIGUSR1: g_idle_add(G_SOURCE_FUNC(reload), NULL); break; case SIGUSR2: g_idle_add(G_SOURCE_FUNC(reload_css), NULL); break; } } int main(int argc, char** argv) { _argv = argv; const struct option opts[] = { { .name = "help", .has_arg = no_argument, .flag = NULL, .val = 'h' }, { .name = "fork", .has_arg = no_argument, .flag = NULL, .val = 'f' }, { .name = "bar", .has_arg = required_argument, .flag = NULL, .val = 'b' }, { .name = "conf", .has_arg = required_argument, .flag = NULL, .val = 'c' }, { .name = "style", .has_arg = required_argument, .flag = NULL, .val = 's' }, { .name = "color", .has_arg = required_argument, .flag = NULL, .val = 'C' }, { .name = NULL, .has_arg = 0, .flag = NULL, .val = 0 } }; char* bar_name = NULL; const char* config_str = NULL; char* style_str = NULL; char* color_str = NULL; char opt; while((opt = getopt_long(argc, argv, "hfb:c:s:C:", opts, NULL)) != -1) { switch(opt) { case 'h': print_usage(argv); break; case 'f': if(fork() > 0) { exit(0); } fclose(stdout); fclose(stderr); fclose(stdin); break; case 'b': bar_name = optarg; break; case 'c': config_str = optarg; break; case 's': style_str = optarg; break; case 'C': color_str = optarg; break; } } if(bar_name == NULL) { bar_name = "all"; } const char* home_dir = getenv("HOME"); const char* xdg_conf = getenv("XDG_CONFIG_HOME"); if(xdg_conf == NULL) { CONFIG_LOCATION = utils_concat(2, home_dir, "/.config/rootbar"); } else { CONFIG_LOCATION = utils_concat(2, xdg_conf, "/rootbar"); } const char* xdg_cache = getenv("XDG_CACHE_HOME"); if(xdg_cache == NULL) { COLORS_LOCATION = utils_concat(2, home_dir, "/.cache/wal/colors"); } else { COLORS_LOCATION = utils_concat(2, xdg_cache, "/wal/colors"); } config = map_init(); //Check if --conf was specified if(config_str == NULL) { const char* config_f = "/config"; config_path = utils_concat(2, CONFIG_LOCATION, config_f); } else { config_path = strdup(config_str); } if(access(config_path, R_OK) == 0) { config_load(config, config_path); } else { fprintf(stderr, "I could be wrong but I think your config is missing\n"); exit(1); } free(config_path); //Check if --style was specified if(style_str == NULL) { style_str = map_get(config, "stylesheet"); if(style_str == NULL) { const char* style_f = "/style.css"; stylesheet = utils_concat(2, CONFIG_LOCATION, style_f); } else { if(style_str[0] == '/') { stylesheet = strdup(style_str); } else { stylesheet = utils_concat(3, CONFIG_LOCATION, "/", style_str); } } } else { stylesheet = strdup(style_str); } //Check if --color was specified if(color_str == NULL) { color_str = map_get(config, "colors"); if(color_str == NULL) { color_path = strdup(COLORS_LOCATION); } else { if(color_str[0] == '/') { color_path = strdup(color_str); } else { color_path = utils_concat(3, CONFIG_LOCATION, "/", color_str); } } } else { color_path = strdup(color_str); } free(COLORS_LOCATION); #ifdef GTK4 gtk_init(); #else gtk_init(&argc, &argv); #endif reload_css(NULL); if(strcmp(bar_name, "all") == 0) { char* bars = map_get(config, "bars"); if(bars == NULL) { fprintf(stderr, "It would be cool if you specified some bars in your config\n"); exit(1); } size_t comma_count = utils_split(bars, ','); char* bar = bars; for(size_t count = 0; count < comma_count; ++count) { bar_init(config, bar, config_get(config, bar, "-output", NULL), CONFIG_LOCATION); bar += strlen(bar) + 1; } } else { bar_init(config, bar_name, config_get(config, bar_name, "-output", NULL), CONFIG_LOCATION); } struct sigaction sigact; memset(&sigact, 0, sizeof(sigact)); sigact.sa_handler = sig; sigaction(SIGINT, &sigact, NULL); sigaction(SIGUSR1, &sigact, NULL); sigaction(SIGUSR2, &sigact, NULL); char* css_watch = map_get(config, "watch_css"); if(css_watch != NULL && strcmp(css_watch, "true") == 0) { pthread_create(&css_notify, NULL, watch_css, NULL); } gtk_main(); return 0; } 07070100000025000081A4000003E800000064000000015FAE52A600000BF5000000000000000000000000000000000000001800000000rootbar-0.203/src/map.c/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #include <map.h> struct map { char* key; void* value; size_t size; bool mman; struct map* head, *left, *right; }; struct map* map_init() { struct map* map = calloc(1, sizeof(struct map)); map->head = map; map->mman = true; return map; } struct map* map_init_void() { struct map* map = map_init(); map->mman = false; return map; } void map_free(struct map* map) { if(map->left != NULL) { map_free(map->left); } if(map->right != NULL) { map_free(map->right); } if(map->key != NULL) { free(map->key); } if(map->value != NULL && map->head->mman) { free(map->value); } free(map); } static void put(struct map* map, const char* key, void* value) { if(map->key == NULL) { map->key = strdup(key); if(value != NULL && map->head->mman) { map->value = strdup(value); } else { map->value = value; } ++map->head->size; } else if(strcmp(key, map->key) < 0) { if(map->left == NULL) { map->left = map_init(); map->left->head = map->head; } put(map->left, key, value); } else if(strcmp(key, map->key) > 0) { if(map->right == NULL) { map->right = map_init(); map->right->head = map->head; } put(map->right, key, value); } else { if(map->value != NULL && map->head->mman) { free(map->value); } if(value != NULL && map->head->mman) { map->value = strdup(value); } else { map->value = value; } } } bool map_put(struct map* map, const char* key, char* value) { if(map->head->mman) { put(map, key, value); return true; } else { fprintf(stderr, "This is an unmanaged map please use map_put_void\n"); return false; } } bool map_put_void(struct map* map, const char* key, void* value) { if(map->head->mman) { fprintf(stderr, "This is an managed map please use map_put\n"); return false; } else { put(map, key, value); return true; } } void* map_get(struct map* map, const char* key) { if(map->key == NULL) { return NULL; } else if(strcmp(key, map->key) < 0) { if(map->left == NULL) { return NULL; } return map_get(map->left, key); } else if(strcmp(key, map->key) > 0) { if(map->right == NULL) { return NULL; } return map_get(map->right, key); } else { return map->value; } } bool map_contains(struct map* map, const char* key) { return map_get(map, key) != NULL; } size_t map_size(struct map* map) { return map->size; } 07070100000026000081A4000003E800000064000000015FAE52A6000018C3000000000000000000000000000000000000001D00000000rootbar-0.203/src/sway_ipc.c/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #include <sway_ipc.h> static const char* MAGIC = "i3-ipc"; static char* event_names[] = {"workspace", "output", "mode", "window", "barconfig_update", "binding", "shutdown", "tick"}; struct sway_ipc { int32_t event_sock, msg_sock; struct map* events; bool stop_events; pthread_cond_t _stop_events; pthread_mutex_t mutex; }; struct handler { void (*handle)(void* data, const char* str); void* data; }; static void* poll(void* data) { struct sway_ipc* this = data; size_t magic_s = strlen(MAGIC); while(true) { size_t buff_s = 8 + magic_s; void* buffer = malloc(buff_s); recv(this->event_sock, buffer, buff_s, 0); if(strncmp(buffer, MAGIC, magic_s) == 0) { uint32_t* arr = (uint32_t*) (buffer + magic_s); uint32_t length = arr[0]; uint32_t type = arr[1]; if(length > 0) { free(buffer); buffer = malloc(length + 1); recv(this->event_sock, buffer, length, 0); ((char*) buffer)[length] = 0; } if(type >> 31 == 1) { struct handler* handler = map_get(this->events, event_names[type & 0xF]); handler->handle(handler->data, buffer); } free(buffer); while(this->stop_events) { pthread_mutex_lock(&this->mutex); pthread_cond_wait(&this->_stop_events, &this->mutex); pthread_mutex_unlock(&this->mutex); } } } return NULL; } static void stop_events(struct sway_ipc* this) { this->stop_events = true; size_t magic_s = strlen(MAGIC); size_t buff_s = 8 + magic_s; void* buffer = malloc(buff_s); strcpy(buffer, MAGIC); uint32_t* arr = (uint32_t*) (buffer + magic_s); arr[0] = 0; arr[1] = SWAY_IPC_MESSAGE_SEND_TICK; write(this->event_sock, buffer, buff_s); free(buffer); utils_sleep_millis(100); } static void start_events(struct sway_ipc* this) { this->stop_events = false; pthread_mutex_lock(&this->mutex); pthread_cond_broadcast(&this->_stop_events); pthread_mutex_unlock(&this->mutex); } void sway_ipc_subscribe(struct sway_ipc* this, enum sway_ipc_event event, void (*handler)(void* data, const char* str), void* data) { stop_events(this); size_t magic_s = strlen(MAGIC); struct json_object* arr = json_object_new_array(); json_object_array_add(arr, json_object_new_string(event_names[event])); const char* payload = json_object_to_json_string(arr); size_t payload_s = strlen(payload); size_t buff_s = 8 + magic_s + payload_s; void* buffer = malloc(buff_s); strcpy(buffer, MAGIC); uint32_t* int_buff = (uint32_t*) (buffer + magic_s); int_buff[0] = payload_s; int_buff[1] = SWAY_IPC_MESSAGE_SUBSCRIBE; memcpy(buffer + 8 + magic_s, payload, payload_s); json_object_put(arr); write(this->event_sock, buffer, buff_s); free(buffer); buff_s = 8 + magic_s; buffer = malloc(buff_s); recv(this->event_sock, buffer, buff_s, 0); if(strncmp(buffer, MAGIC, magic_s) != 0) { fprintf(stderr, "Invalid magic\n"); free(buffer); return; } int_buff = (uint32_t*) (buffer + magic_s); uint32_t length = int_buff[0]; uint32_t type = int_buff[1]; free(buffer); if(type != SWAY_IPC_REPLY_SUBSCRIBE) { fprintf(stderr, "Invalid reply\n"); return; } if(length == 0) { fprintf(stderr, "Payload length of 0"); return; } buffer = malloc(length + 1); recv(this->event_sock, buffer, length, 0); ((char*) buffer)[length] = 0; struct json_object* json = json_tokener_parse(buffer); struct json_object* success = json_object_object_get(json, "success"); if(!json_object_get_boolean(success)) { fprintf(stderr, "Failed to subscribe to event\n"); json_object_put(json); free(buffer); return; } json_object_put(json); free(buffer); struct handler* handle = malloc(sizeof(struct handler)); handle->handle = handler; handle->data = data; map_put_void(this->events, event_names[event], handle); start_events(this); } char* sway_ipc_send_message(struct sway_ipc* this, enum sway_ipc_message message, const char* payload, enum sway_ipc_reply expected_reply) { if(payload == NULL) { payload = ""; } size_t magic_s = strlen(MAGIC); size_t payload_s = strlen(payload); size_t buff_s = 8 + magic_s + payload_s; void* buffer = malloc(buff_s); memcpy(buffer, MAGIC, magic_s); uint32_t* int_buff = (uint32_t*) (buffer + magic_s); int_buff[0] = payload_s; int_buff[1] = message; memcpy(buffer + magic_s + 8, payload, payload_s); write(this->msg_sock, buffer, buff_s); free(buffer); buff_s = 8 + magic_s; buffer = malloc(buff_s); recv(this->msg_sock, buffer, buff_s, 0); if(strncmp(buffer, MAGIC, magic_s) != 0) { fprintf(stderr, "Invalid magic\n"); free(buffer); return NULL; } int_buff = (uint32_t*) (buffer + magic_s); uint32_t length = int_buff[0]; uint32_t type = int_buff[1]; if(length > 0) { free(buffer); buffer = malloc(length + 1); recv(this->msg_sock, buffer, length, 0); ((char*) buffer)[length] = 0; } if(type != expected_reply) { free(buffer); fprintf(stderr, "Unexpected reply\n"); return NULL; } return buffer; } struct sway_ipc* sway_ipc_init() { const char* swaysock = getenv("SWAYSOCK"); if(swaysock == NULL) { return NULL; } struct sway_ipc* this = malloc(sizeof(struct sway_ipc)); this->event_sock = socket(AF_UNIX, SOCK_STREAM, 0); this->msg_sock = socket(AF_UNIX, SOCK_STREAM, 0); this->events = map_init_void(); pthread_cond_init(&this->_stop_events, NULL); pthread_mutex_init(&this->mutex, NULL); struct sockaddr_un addr = { .sun_family = AF_UNIX }; strncpy(addr.sun_path, swaysock, sizeof(addr.sun_path) - 1); connect(this->event_sock, (struct sockaddr*) &addr, sizeof(addr)); connect(this->msg_sock, (struct sockaddr*) &addr, sizeof(addr)); pthread_t thread; pthread_create(&thread, NULL, poll, this); return this; } 07070100000027000081A4000003E800000064000000015FAE52A60000069B000000000000000000000000000000000000001A00000000rootbar-0.203/src/utils.c/* * Copyright (C) 2019 Scoopta * This file is part of Root Bar * Root Bar is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Root Bar is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Root Bar. If not, see <http://www.gnu.org/licenses/>. */ #include <utils.h> time_t utils_get_time_millis() { struct timeval time; gettimeofday(&time, NULL); return (time.tv_sec * 1000) + (time.tv_usec / 1000); } void utils_sleep_millis(time_t millis) { struct timespec time; time.tv_sec = millis / 1000; time.tv_nsec = (millis % 1000) * pow(1000, 2); nanosleep(&time, NULL); } char* utils_concat(size_t arg_count, ...) { va_list args; va_start(args, arg_count); size_t buf_s = 1; for(size_t count = 0; count < arg_count; ++count) { buf_s += strlen(va_arg(args, char*)); } va_end(args); va_start(args, arg_count); char* buffer = malloc(buf_s); strcpy(buffer, va_arg(args, char*)); for(size_t count = 0; count < arg_count - 1; ++count) { strcat(buffer, va_arg(args, char*)); } va_end(args); return buffer; } size_t utils_split(char* str, const char chr) { char* split = strchr(str, chr); size_t count = 1; for(; split != NULL; ++count) { *split = 0; split = strchr(split + 1, chr); } return count; } 07070100000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000B00000000TRAILER!!!369 blocks
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor