documentation initialization

This commit is contained in:
Felix Kratz 2022-05-12 15:21:03 +02:00
parent e256e37dd4
commit d33450bbe5
107 changed files with 896 additions and 8291 deletions

11
.gitignore vendored
View file

@ -1,12 +1 @@
bin
todo.md
notifications.md
.ccls-cache
.DS_Store
.ccls
.cache
.cmake
CMakeCache.txt
CMakeFiles/
cmake_install.cmake
compile_commands.json

17
404.html Normal file
View file

@ -0,0 +1,17 @@
<!doctype html>
<html lang="en" dir="ltr" class="plugin-docs plugin-id-default">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="generator" content="Docusaurus v2.0.0-beta.18">
<title data-rh="true">Page Not Found | SketchyBar</title><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:url" content="https://sketchybar.github.io//404.html"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docusaurus_tag" content="default"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="docsearch:docusaurus_tag" content="default"><meta data-rh="true" property="og:title" content="Page Not Found | SketchyBar"><link data-rh="true" rel="icon" href="/img/favicon.ico"><link data-rh="true" rel="canonical" href="https://sketchybar.github.io//404.html"><link data-rh="true" rel="alternate" href="https://sketchybar.github.io//404.html" hreflang="en"><link data-rh="true" rel="alternate" href="https://sketchybar.github.io//404.html" hreflang="x-default"><link rel="stylesheet" href="/assets/css/styles.d31a9c85.css">
<link rel="preload" href="/assets/js/runtime~main.f11b668e.js" as="script">
<link rel="preload" href="/assets/js/main.06e9279c.js" as="script">
</head>
<body class="navigation-with-keyboard">
<script>!function(){function e(e){document.documentElement.setAttribute("data-theme",e)}var t=function(){var e=null;try{e=localStorage.getItem("theme")}catch(e){}return e}();null!==t?e(t):window.matchMedia("(prefers-color-scheme: dark)").matches?e("dark"):(window.matchMedia("(prefers-color-scheme: light)").matches,e("light"))}()</script><div id="__docusaurus">
<div role="region"><a href="#" class="skipToContent_ZgBM">Skip to main content</a></div><nav class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Navigation bar toggle" class="navbar__toggle clean-btn" type="button" tabindex="0"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/logo.svg" alt="SketchyBar Logo" class="themedImage_W2Cr themedImage--light_TfLj"><img src="/img/logo.svg" alt="SketchyBar Logo" class="themedImage_W2Cr themedImage--dark_oUvU"></div><b class="navbar__title">SketchyBar</b></a></div><div class="navbar__items navbar__items--right"><a class="navbar__item navbar__link" href="/features">Features</a><a class="navbar__item navbar__link" href="/setup">Setup &amp; Installation</a><a class="navbar__item navbar__link" href="/config/bar">Configuration</a><a href="https://github.com/FelixKratz/SketchyBar" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link"></a><div class="toggle_S7eR colorModeToggle_vKtC"><button class="clean-btn toggleButton_rCf9 toggleButtonDisabled_Pu9x" type="button" disabled="" title="Switch between dark and light mode (currently light mode)" aria-label="Switch between dark and light mode (currently light mode)"><svg viewBox="0 0 24 24" width="24" height="24" class="lightToggleIcon_v35p"><path fill="currentColor" d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"></path></svg><svg viewBox="0 0 24 24" width="24" height="24" class="darkToggleIcon_nQuB"><path fill="currentColor" d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"></path></svg></button></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div class="main-wrapper"><main class="container margin-vert--xl"><div class="row"><div class="col col--6 col--offset-3"><h1 class="hero__title">Page Not Found</h1><p>We could not find what you were looking for.</p><p>Please contact the owner of the site that linked you to the original URL and let them know their link is broken.</p></div></div></main></div></div>
<script src="/assets/js/runtime~main.f11b668e.js"></script>
<script src="/assets/js/main.06e9279c.js"></script>
</body>
</html>

View file

@ -1,674 +0,0 @@
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>.

578
README.md
View file

@ -1,578 +0,0 @@
<p align="center">
<img src="images/Sbar.svg" />
</p>
<p align="center">
<a href="https://opensource.org/licenses/"><img src="https://img.shields.io/badge/License-GPL%20v3-blue.svg"></a>
<a href="https://github.com/FelixKratz/SketchyBar/releases"><img src="https://img.shields.io/github/v/release/FelixKratz/SketchyBar.svg?style=flat&color=orange" /></a>
<a href="https://github.com/FelixKratz/SketchyBar/releases"><img src="https://img.shields.io/github/commits-since/FelixKratz/SketchyBar/latest.svg?color=orange"></a>
<a href="https://en.wikipedia.org/wiki/Free_and_open-source_software"><img src="https://img.shields.io/badge/FOSS-100%25-green.svg?style=flat"></a>
</p>
<p align="center">
This bar project aims to create a highly flexible, customizable, fast and powerful status bar replacement for users that like playing around with
shell scripts.
</p>
![](images/example.png)
<p align="center">
More example setups <a href="https://github.com/FelixKratz/SketchyBar/discussions/47">here</a>.
</p>
Table of Contents
=================
* [Table of Contents](#table-of-contents)
* [Features](#features)
* [Installation](#installation)
* [Stable Version](#stable-version)
* [Plugins and Fonts](#plugins-and-fonts)
* [Global configuration of the bar](#global-configuration-of-the-bar)
* [Items and their properties](#items-and-their-properties)
* [Adding items to sketchybar](#adding-items-to-sketchybar)
* [Changing item properties](#changing-item-properties)
* [Changing the default values for all further items](#changing-the-default-values-for-all-further-items)
* [Components -- Special Items with special properties](#components----special-items-with-special-properties)
* [Data Graph -- Draws an arbitrary graph into the bar](#data-graph----draws-an-arbitrary-graph-into-the-bar)
* [Space -- Associate mission control spaces with an item](#space----associate-mission-control-spaces-with-an-item)
* [Item Bracket -- Group Items in e.g. colored sections](#item-bracket----group-items-in-eg-colored-sections)
* [Item Alias -- Mirror items of the original macOS status bar into sketchybar](#item-alias----mirror-items-of-the-original-macos-status-bar-into-sketchybar)
* [Popup Menus](#popup-menus)
* [Batching of configuration commands](#batching-of-configuration-commands)
* [Events and Scripting](#events-and-scripting)
* [Creating custom events](#creating-custom-events)
* [Triggering custom events](#triggering-custom-events)
* [Forcing all shell scripts to run and the bar to refresh](#forcing-all-shell-scripts-to-run-and-the-bar-to-refresh)
* [Querying](#querying)
* [Bar Properties](#bar-properties)
* [Item Properties](#item-properties)
* [Default Properties](#default-properties)
* [Event Properties](#event-properties)
* [Item Reordering](#item-reordering)
* [Moving Items to specific positions](#moving-items-to-specific-positions)
* [Item Cloning](#item-cloning)
* [Renaming Items](#renaming-items)
* [Removing Items](#removing-items)
* [Performance optimizations](#performance-optimizations)
* [Credits](#credits)
## Features
* Performance friendly
* No accessibility permissions needed
* Fully scriptable
* Highly configurable
* Supports drawing native macOS menu bar applications
* Powerful event system (items can subscribe to many system events)
* Popup Menus
* Mouse Support
* Many visual features
* Support for graphs
* Per display and per space individualization
The configuration of the bar takes place in a confiuration file where almost everything can be configured.
Basically, the bar itself is a rectangle that can hold arbitrarily many *items*, which can be configured to do awesome stuff.
An *item* will occupy a space in the bar and can be equipped to show an *icon* and a *label*. The *icon* and *label* can be changed through
*scripts* that can be attached to the *item*. It is also possible to *subscribe* an *item* to certain *events* for their *script* execution action,
which makes very powerful items possible.
Furthermore, an *item* can be assigned to mission control spaces or displays, such that they only show on a certain space or display, which makes multi-desktop configuration
of the bar possible and opens the possibility to create individualized bar configuration on a per display and per space level.
These simple ingredients make *items* almost endlessly customizable and can be used to display arbitrary information and perform useful actions. For some examples see my sketchybarrc and
the plugins folder.
Some special features can not be accomplished with a simple *item*, this is where the *components* come into play. They basically are *items* with
extra steps. They contain all the properties a regular item does, but they can do specialized tasks a simple item can not. For example, there
is a *graph* component, which can be used to display graphs in the bar.
For more details on how the configuration works, see the configuration section below.
## Installation
### Stable Version
```bash
brew tap FelixKratz/formulae
brew install sketchybar
```
Do not forget to copy the example configuration files to your home directory (the brew installation specific commands are listed in the caveats section after the brew install is finished).
Run the bar via
```bash
brew services start sketchybar
```
### Plugins and Fonts
When you use additional plugins, make sure that they are referenced in the rc with the correct path and that they are made executable via
```bash
chmod +x name/of/plugin.sh
```
The default plugin folder is located in `~/.config/sketchybar/plugins`.
All plugins must work with absolute paths because relative paths will not be resolved correctly.
Have a look at the [discussion](https://github.com/FelixKratz/SketchyBar/discussions/12) about plugins and share your own if you want to.
You should of course vet the code from all plugins before executing them to make sure they are not harming your computer.
If you have problems with missing fonts you might need to install the Hack Nerd Font:
```bash
brew tap homebrew/cask-fonts
brew install --cask font-hack-nerd-font
```
## Global configuration of the bar
For an example configuration see the supplied default *sketchybarrc*. The configuration file resides in `~/.config/sketchybar/`, where everything can be freely configured. It is also possible to play around with properties in a terminal and change them while the bar is running, once you find a fitting value you can include it in the `sketchybarrc` file such that the configuration is restored on restart. The global bar properties can be configured by invoking:
```bash
sketchybar --bar <setting>=<value> ... <setting>=<value>
```
where possible settings are:
| \<setting\> | \<value\> | default | description |
| :-------: | :------: | :-------: | ----------- |
| `color` | `<argb_hex>` | `0x44000000` | Color of the bar |
| `border_color` | `<argb_hex>` | `0xffff0000` | Color of the bars border |
| `position` | `top`, `bottom` | `top` | Position of the bar on the screen |
| `height` | `<integer>` | `25` | Height of the bar |
| `margin` | `<integer>` | `0` | Margin around the bar |
| `y_offset` | `<integer>` | `0` | Vertical offset of the bar from its default position |
| `corner_radius` | `<positive_integer>` | `0` | Corner radius of the bar |
| `border_width` | `<positive_integer>` | `0` | Border width of the bars border |
| `blur_radius` | `<positive_integer>` | `0` | Blur radius applied to the background of the bar |
| `padding_left` | `<positive_integer>` | `0` | Padding between the left bar border and the leftmost item |
| `padding_right` | `<positive_integer>` | `0` | Padding between the right bar border and the rightmost item |
| `display` | `main`, `all` | `all` | Display to show the bar on |
| `hidden` | `<boolean>`, `current` | `off` | If all / the current bar is hidden |
| `topmost` | `<boolean>` | `off` | If the bar should be drawn on top of `everything` |
| `font_smoothing` | `<boolean>` | `off` | If fonts should be smoothened |
| `shadow` | `<boolean>` | `off` | If the bar should draw a shadow |
## Items and their properties
Items are the main building blocks of sketchybar and can be configured in a number of ways. Items have the following basic structure: <br>
<img src="images/bar_item.svg" width="300"> <br>
### Adding items to sketchybar
```bash
sketchybar --add item <name> <position>
```
where the `<name>` should not contain whitespaces (or must be quoted), it can be used to further configure the item.
The `<position>` is the placement in the bar and can be either *left*, *right* or *center*. The items will appear in the bar in the order
in which they are added, but can be moved later on.
| `<name>` | `<string>` |
| ----- | --------- |
| `<position>` | `left`, `right`, `center`, (`q`, `e` [#120](https://github.com/FelixKratz/SketchyBar/issues/120)) |
### Changing item properties
```bash
sketchybar --set <name> <property>=<value> ... <property>=<value>
```
where the *name* is used to target the item with this name.
(The *name* can be a regular expression inside of two '/': */\<regex\>/*)
A list of properties available to the *set* command is listed below (components might have additional properties, see the respective component section for them):
* Geometry Properties:
| \<property\> | \<value\> | default | description |
| :-------: | :------: | :-------: | ----------- |
| `position` | `left`, `right`, `center` | | Position of the item in the bar |
| `associated_space` | `<positive_integer list>` | `0` | Spaces to show this item on |
| `associated_display` | `<positive_integer list>` | `0` | Displays to show this item on |
| `ignore_association` | `<boolean>` | `off` | Ignores all space / display associations while on (Only on HEAD) |
| `y_offset` | `<integer>` | `0` | Vertical offset applied to the item |
| `width` | `<positive_integer>` or `dynamic` | `dynamic` | Makes the *item* use a fixed *width* given in points |
| `align` | `center`, `left`, `right` | `left` | Aligns the `item` content in its container when it has a fixed `width` larger than the content width |
* Drawing properties:
| \<property\> | \<value\> | default | description |
| :-------: | :------: | :-------: | ----------- |
| `drawing` | `<boolean>` | `on` | If the item should be drawn into the bar |
| `lazy` | `<boolean>` | `off` | Changes do not trigger a redraw of the bar, item is refreshed when the bar is redrawn anyways |
* Icon properties:
| \<property\> | \<value\> | default | description |
| :-------: | :------: | :-------: | ----------- |
| `icon` | `<string>` | | Icon of the item |
| `icon.<text_property>` | | | Icons support all *text* properties |
* Label properties:
| \<property\> | \<value\> | default | description |
| :-------: | :------: | :-------: | ----------- |
| `label` | `<string>` | | Label of the item |
| `label.<text_property>` | | | Labels support all *text* properties |
* Scripting properties:
| \<property\> | \<value\> | default | description |
| :-------: | :------: | :-------: | ----------- |
| `script` | `<path>`, `<string>` | | Script to run on an `event` |
| `click_script` | `<path>`, `<string>` | | Script to run on a mouse click (Difference to `mouse.clicked` event: [#109](https://github.com/FelixKratz/SketchyBar/discussions/109)) |
| `update_freq` | `<positive_integer>` | `1` | Time in seconds between routine script executions |
| `updates` | `<boolean>`, `when_shown` | `on` | If and when the item updates e.g. via script execution |
* Text properties:
| \<text_property\> | \<value\> | default | description |
| :-------: | :------: | :-------: | ----------- |
| `drawing` | `<boolean>` | `on` | If the text is rendered |
| `highlight` | `<boolean>` | `off` | If the text uses the `highlight_color` or the regular `color` |
| `color` | `<argb_hex>` | `0xffffffff` | Color used to render the text |
| `highlight_color` | `<argb_hex>` | `0xff000000` | Highlight color of the text (e.g. for active space icon |
| `padding_left` | `<integer>` | `0` | Padding to the left of the `text` |
| `padding_right` | `<integer>` | `0` | Padding to the right of the `text` |
| `y_offset` | `<integer>` | `0` | Vertical offset applied to the `text` |
| `font` | `<family>:<type>:<size>` | `Hack Nerd Font:Bold:14.0` | The font to be used for the `text` |
| `width` | `<positive_integer>` or `dynamic` | `dynamic` | Makes the `text` use a fixed `width` given in points |
| `align` | `center`, `left`, `right` | `left` | Aligns the `text` in its container when it has a fixed `width` larger than the content width |
| `background.<background_property>` | | | Texts support all `background` properties |
| `shadow.<shadow_property>` | | | Texts support all `shadow` properties |
* Background properties:
| \<background_property\> | \<value\> | default | description |
| :-------: | :------: | :-------: | ----------- |
| `drawing` | `<boolean>` | `off` | If the `background` should be rendered |
| `color` | `<argb_hex>` | `0x00000000` | Fill color of the `background` |
| `border_color` | `<argb_hex>` | `0x00000000` | Color of the backgrounds border |
| `border_width` | `<positive_integer>` | `0` | Width of the background border |
| `height` | `<positive_integer>` | `0` | Overrides the `height` of the background |
| `corner_radius` | `<positive_integer>` | `0` | Corner radius of the background |
| `padding_left` | `<integer>` | `0` | Padding to the left of the `background` |
| `padding_right` | `<integer>` | `0` | Padding to the right of the `background` |
| `y_offset` | `<integer>` | `0` | Vertical offset applied to the `background` |
| `image` | `<path>` | | The path to a png or jpeg image file |
| `image.<image_property>` | | | Backgrounds support all `image` properties |
| `shadow.<shadow_property>` | | | Backgrounds support all `shadow` properties |
* Image properties (Can be resource intensive if many large images are drawn):
| \<image_property\> | \<value\> | default | description |
| :-------: | :------: | :-------: | ----------- |
| `drawing` | `<boolean>` | `off` | If the image should draw |
| `scale` | `<positive_integer>` | `0` | The scale factor that should be applied to the image |
* Shadow properties:
| \<shadow_property\> | \<value\> | default | description |
| :-------: | :------: | :-------: | ----------- |
| `drawing` | `<boolean>` | `off` | If the shadow should be drawn |
| `color` | `<argb_hex>` | `0xff000000` | Color of the shadow |
| `angle` | `<positive_integer>` | `30` | Angle of the shadow |
| `distance` | `<positive_integer>` | `5` | Distance of the shadow |
### Changing the default values for all further items
It is possible to change the *defaults* at every point in the configuration. All item created *after* changing the defaults will
inherit these properties from the default item.
```bash
sketchybar --default <property>=<value> ... <property>=<value>
```
this works for all item properties.
### Type nomenclature
| `type` | `values` |
| ----- | --------- |
| `<boolean>` | `on`, `off`, `yes`, `no`, `true`, `false`, `1`, `0`, `toggle` |
| `<argb_hex>` | Color as an 8 digit hex with alpha, red, green and blue channels |
| `<path>` | An absolute file path |
| `<string>` | Any UTF-8 string or symbol |
| `<float>` | A floating point number |
| `<integer>` | An integer |
| `<positive_integer>` | A positive integer |
| `<positive_integer list>` | A comma separated list of positive integers |
## Components -- Special Items with special properties
Components are essentially items, but with special properties.
Currently there are the components (more details in the corresponding sections below):
* *graph*: showing a graph,
* *space*: representing a mission control space
* *bracket*: brackets together other items
* *alias*: a default menu bar item
### Data Graph -- Draws an arbitrary graph into the bar
```bash
sketchybar --add graph <name> <position> <width in points>
```
Additional graph properties:
* *graph.color*: color of the associated graph
* *graph.fill_color*: optional property to override the automatically calculated fill color of the graph
* *graph.line_width*: sets the line width of the associated graph
| \<property\> | \<value\> | default | description |
| :-------: | :------: | :-------: | ----------- |
| `graph.color` | `<argb_hex>` | `0xcccccc` | Color of the graph line |
| `graph.fill_color` | `<argb_hex>` | `0xcccccc` | Fill color of the graph |
| `graph.line_width` | `<float>` | `0.5` | Width of the line in points |
Push data points into the graph via:
```bash
sketchybar --push <name> <data point>
```
where the `data point` is a floating point number between 0 and 1.
### Space -- Associate mission control spaces with an item
```bash
sketchybar --add space <name> <position>
```
The space component overrides the definition of the following properties and they must be set to correctly associate a mission control space with this item:
* *associated_space*: Which space this item represents
* *associated_display*: On which display the *associated_space* is shown.
The space component has additional variables available in *scripts*:
```bash
$SELECTED
$SID
$DID
```
where *$SELECTED* has the value *true* if the associated space is selected and *false* if the selected space is not selected, while
`$SID` holds the space id and `$DID` the display id.
By default the space component invokes the following script:
```bash
sketchybar --set $NAME icon.highlight=$SELECTED
```
which you can freely configure to your liking by supplying a different script to the space component:
```bash
sketchybar --set <name> script=<script/path>
```
For performance reasons the space script is only run on change.
### Item Bracket -- Group Items in e.g. colored sections
It is possible to bracket together items via the command (see [this](https://github.com/FelixKratz/SketchyBar/discussions/12#discussioncomment-1455842) discussion for an example):
```bash
sketchybar --add bracket <name> <first item name> ... <n-th item name>
```
The first item must always be the one listed earliest in the config. It is now possible to
set properties for the bracket, just as for any item or component. Brackets currently only support all background features.
E.g., if I wanted a colored background around *all* my space components (which are named *code*, *writing*, *reading* and *entertainment*) I would set it up like this:
```bash
sketchybar --add bracket primary_spaces code \
writing \
reading \
entertainment \
\
--set primary_spaces background.color=0xffffffff \
background.corner_radius=4 \
background.height=20
```
this draws a white background below all my space components. I plan to expand the capability of item brackets significantly in the future.
### Item Alias -- Mirror items of the original macOS status bar into sketchybar
It is possible to create an alias for default menu bar items (such as MeetingBar, etc.) in sketchybar. The default menu bar can be set to autohide and this should still work.
It is now possible to create an alias of a default menu bar item with the following syntax:
```bash
sketchybar --add alias <application_name> <position>
```
this operation requires *screen capture permissions*, which should be granted in the system preferences.
This will put the default item into sketchybar.
Aliases currently are not clickable but can be modified with all the options available for simple items.
The command can be overloaded by providing a *window_owner* and a *window_name*
```bash
sketchybar --add alias <window_owner>,<window_name> <position>
```
this way the default system items can also be slurped into sketchybar, e.g.: <br>
"Control Center,Bluetooth" <br>
"Control Center,WiFi" <br>
Or the individual widgets of [Stats](https://github.com/exelban/stats):<br>
"Stats,CPU_Mini"<br>
etc...<br>
All further default menu items currently available on your system can be found via the command:
```bash
sketchybar --query default_menu_items
```
You can override the color of an alias via the property (HEAD only):
```bash
sketchybar --set <name> alias.color=<rgba_hex>
```
## Popup Menus
<img src="https://user-images.githubusercontent.com/22680421/146688291-b8bc5e77-e6a2-42ee-bd9f-b3709c63d936.png" width="300"> <br>
Popup menus are a powerful way to make further `items` accessible in a small popup window below any bar item.
Every item has a popup available with the properties:
| \<property\> | \<value\> | default | description |
| :-------: | :------: | :-------: | ----------- |
| `popup.drawing` | `<boolean>` | `off` | If the `popup` should be rendered |
| `popup.horizontal` | `<boolean>` | `off` | If the `popup` should render horizontally |
| `popup.height` | `<positive_integer>` | bar height | The vertical spacing between items in a popup (Only on HEAD) |
| `popup.y_offset` | `<integer>` | `0` | Vertical offset applied to the `popup` |
| `popup.align` | `left`, `right`, `center` | `left` | Alignment of the popup with its parent item in the bar |
| `popup.background.<background_property>` | | | Popups have a background and support all properties |
Items can be added to a popup menu by setting the `position` of those items to `popup.<name>` where `<name>` is the name of the item containing the popup.
You can find a demo implementation of this [here](https://github.com/FelixKratz/SketchyBar/discussions/12?sort=new#discussioncomment-1843975).
## Batching of configuration commands
It is possible to batch commands together into a single call to sketchybar, this can be helpful to
keep the configuration file a bit cleaner and also to reduce startup times.
Assume 5 individual configuration calls to sketchybar:
```bash
sketchybar --bar position=top
sketchybar --bar margin=5
sketchybar --add item demo left
sketchybar --set demo label=Hello
sketchybar --subscribe demo system_woke
```
after each configuration command the bar is redrawn (if needed), thus it is more perfomant to append these calls into a single command like so:
```bash
sketchybar --bar position=top \
margin=5 \
--add item demo left \
--set demo label=Hello \
--subscribe demo system_woke
```
The backslash at the end of the first 4 lines is the default bash way to join lines together and should not be followed by a whitespace.
## Events and Scripting
Any item can *subscribe* to arbitrary *events*, when the *event* happens, all items subscribed to the *event* will execute their *script*.
This can be used to create more reactive and performant items which react to events rather than polling for a change.
```bash
sketchybar --subscribe <name> <event> ... <event>
```
where the events are:
| \<event\> | description |
| :-------: | :------: |
| `front_app_switched` | When the front application changes (not triggered if a different window of the same app is focused) |
| `space_change` | When the active mission control space changes |
| `display_change` | When the active display is changed |
| `system_will_sleep` | When the system prepares to sleep |
| `system_woke` | When the system has awaken from sleep |
| `mouse.entered` | When the mouse enters over an item |
| `mouse.exited` | When the mouse leaves an item |
| `mouse.clicked` | When an item is clicked |
When an item is subscribed to these events the *script* is run and it gets passed the `$SENDER` variable, which holds exactly the above names, to distinguish between the different events.
It is thus possible to have a script that reacts to each event differently e.g. via a switch for the `$SENDER` variable in the *script*.
Alternatively a fixed *update_freq* can be *--set*, such that the event is routinely run to poll for change.
When an item invokes a script, the script has access to some environment variables, such as:
```bash
$NAME
$SENDER
```
Where `$NAME` is the name of the item that has invoked the script and `$SENDER` is the reason why the script is executed.
If an item is *clicked* the script has access to the additional variables:
```bash
$BUTTON
$MODIFIER
```
where the `$BUTTON` can be *left*, *right* or *other* and specifies the mouse button that was used to click the item, while the `$MODIFIER` is either *shift*, *ctrl*, *alt* or *cmd* and
specifies the modifier key held down while clicking the item.
Some events send additional information in the `$INFO` variable
All scripts are forced to terminate after 60 seconds and do not run while the system is sleeping.
### Creating custom events
This allows to define events which are triggered by a different application (see Trigger custom events). Items can also subscribe to these events for their script execution.
```bash
sketchybar --add event <name> [optional: <NSDistributedNotificationName>]
```
Optional: You can subscribe to the notifications sent to the NSDistributedNotificationCenter e.g.
the notification Spotify sends on track change: *com.spotify.client.PlaybackStateChanged* ([example](https://github.com/FelixKratz/SketchyBar/discussions/12#discussioncomment-1455842)), or the
notification sent by the system when a bluetooth device connected, or disconnected: *com.apple.bluetooth.state* ([example](https://github.com/FelixKratz/SketchyBar/discussions/12#discussioncomment-1465761))
to create more responsive items. Custom events that subscribe to NSDistributedNotificationCenter notifications will receive additional notification information in the `$INFO` variable if available.
### Triggering custom events
This triggers a custom event that has been added before
```bash
sketchybar --trigger <event> [Optional: <envvar>=<value> ... <envvar>=<value>]
```
Optionaly you can add environment variables to the trigger command witch are passed to the script, e.g.:
```bash
sketchybar --trigger demo VAR=Test
```
will trigger the demo event and `$VAR` will be available as an environment variable in the scripts that this event invokes.
This could be used to link the powerful event system of yabai to sketchybar by triggering the custom action via a yabai event.
### Forcing all shell scripts to run and the bar to refresh
```bash
sketchybar --update
```
## Querying
*SketchyBar* can be queried for information about a number of things.
### Bar Properties
Information about the bar can be queried via:
```bash
sketchybar --query bar
```
The output is a json structure containing relevant information about the configuration settings of the bar.
### Item Properties
Information about an item can be queried via:
```bash
sketchybar --query <name>
```
The output is a json structure containing relevant information about the configuration of the item.
### Default Properties
Information about the current defaults.
```bash
sketchybar --query defaults
```
### Event Properties
Information about the events.
```bash
sketchybar --query events
```
## Item Reordering
It is possible to reorder items by invoking
```bash
sketchybar --reorder <name> ... <name>
```
where a new order can be supplied for arbitrary items. Only the specified items get reordered, by swapping them around, everything else stays the same. E.g. if you want to swap two items
simply call
```bash
sketchybar --reorder <item 1> <item 2>
```
## Moving Items to specific positions
It is possible to move items and order them next to a reference item. <br>
Move Item *<name>* to appear *before* item *<reference name>*:
```bash
sketchybar --move <name> before <reference name>
```
Move Item *<name>* to appear *after* item *<reference name>*:
```bash
sketchybar --move <name> after <reference name>
```
## Item Cloning
It is possible to clone another item instead of adding a completely blank item
```bash
sketchybar --clone <name> <parent name> [optional: before/after]
```
the new item will inherit *all* properties of the parent item. The optional *before* and *after* modifiers can be used
to move the item *before*, or *after* the parent, equivalently to a --move command.
## Renaming Items
It is possible to rename any item. The new name should obviously not be in use by another item:
```bash
sketchybar --rename <old name> <new name>
```
## Removing Items
It is possible to remove any item by invoking, the item will be completely destroyed and removed from brackets
```bash
sketchybar --remove <name>
```
the `<name>` can again be a regex: `/<regex>/`.
## Performance optimizations
*SketchyBar* can be configured to have a *very* small performance footprint. In the following I will highlight some optimizations that can be used to reduce the footprint further.
* Batch together configuration commands where ever possible.
* Set items to be *lazy*, e.g. I have an alias component in my bar that updates every *2* seconds, thus I set all *non-reactive* items to *lazy=on*,
and only the ones that should react to change instantaneously to *lazy=off*.
* Set *updates=when_shown* for items that do not need to run their script if they are not rendered.
* Reduce the *update_freq* of *scripts* and *aliases* and use event-driven scripting when ever possible.
* Do not add *aliases* to apps that are not always running, otherwise sketchybar searches for them continously.
## Credits
This project was forked from *[spacebar](https://github.com/cmacrae/spacebar)* and completely reimagined and rewritten. <br>
The original idea is based on the status bar that was included in *[yabai](https://github.com/koekeishiya/yabai)* before getting removed.

View file

@ -1,66 +0,0 @@
# v1.4.x -> v2.0.0
This document highlights the steps needed to update an existing sketchybar configuration to v2.0.0.
## Command Structure
* The *batch* command does not exist anymore, you can simply remove all occurences of *batch* in your configuration and all should still work.
* The *non-batch* version of all commands has been removed and superseded. Now *all* commands are prefixed with *--*
and contain *<key>=<value>* pairs. If you have used the batch syntax exclusively, you do not need to change anything, except removing all occurences of *batch*.
* The keyword *component* has been trimmed, simply delete all occurences of *component* in the configuration.
## Renamed Properties
*--set*:
* *icon_font* -> *icon.font*
* *icon_color* -> *icon.color*
* *icon_highlight_color* -> *icon.highlight_color*
* *icon_padding_left* -> *icon.padding_left*
* *icon_padding_right* -> *icon.padding_right*
* *icon_highlight* -> *icon.highlight*
* *label_font* -> *label.font*
* *label_color* -> *label.color*
* *label_highlight_color* -> *label.highlight_color*
* *label_padding_left* -> *label.padding_left*
* *label_padding_right* -> *label.padding_right*
* *label_highlight* -> *label.highlight*
* *draws_background* -> *background.drawing*
* *background_color* -> *background.color*
* *background_height* -> *background.height*
* *background_border_color* -> *background.border_color*
* *background_corner_radius* -> *background.corner_radius*
* *background_border_width* -> *background.border_width*
* *background_padding_left* -> *background.padding_left*
* *background_padding_right* -> *background.padding_right*
* *graph_color* -> *graph.color*
* *graph_fill_color* -> *graph.fill_color*
* *graph_line_width* -> *graph.line_width*
Easy renaming: simply find and replace the follwing strings
* *icon_* -> *icon.*
* *label_* -> *label.*
* *background_* -> *background.*
* *graph_* -> *graph.*
* *draws_background* -> *background.drawing*
*--bar*:
* *bar_color* -> *color*
## Removed Modifiers
* *nospace* modifier has been removed in favour of the *width* property. Set *width=0* for equivalent behaviour
## Removed/Renamed Domains
* *config* -> *--bar*
* *set* -> *--set*
* *add* -> *--add*
* *query* -> *--query*
* *update* -> *--update*
* *push* -> *--push*
* *trigger* -> *--trigger*
* *subscribe* -> *--subscribe*
* *default* -> *--default*
* *freeze*
* *remove*
## Replaced Properites
* *scripting*, replaced with *updates*
* *enabled*, replaced with *updates* and *drawing*

File diff suppressed because one or more lines are too long

View file

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 MiB

View file

Before

Width:  |  Height:  |  Size: 1,020 KiB

After

Width:  |  Height:  |  Size: 1,020 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
"use strict";(self.webpackChunksketchybar_site=self.webpackChunksketchybar_site||[]).push([[233],{3905:function(e,t,r){r.d(t,{Zo:function(){return p},kt:function(){return m}});var n=r(7294);function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach((function(t){i(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function u(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var c=n.createContext({}),l=function(e){var t=n.useContext(c),r=t;return e&&(r="function"==typeof e?e(t):a(a({},t),e)),r},p=function(e){var t=l(e.components);return n.createElement(c.Provider,{value:t},e.children)},s={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},f=n.forwardRef((function(e,t){var r=e.components,i=e.mdxType,o=e.originalType,c=e.parentName,p=u(e,["components","mdxType","originalType","parentName"]),f=l(r),m=i,y=f["".concat(c,".").concat(m)]||f[m]||s[m]||o;return r?n.createElement(y,a(a({ref:t},p),{},{components:r})):n.createElement(y,a({ref:t},p))}));function m(e,t){var r=arguments,i=t&&t.mdxType;if("string"==typeof e||i){var o=r.length,a=new Array(o);a[0]=f;var u={};for(var c in t)hasOwnProperty.call(t,c)&&(u[c]=t[c]);u.originalType=e,u.mdxType="string"==typeof e?e:i,a[1]=u;for(var l=2;l<o;l++)a[l]=r[l];return n.createElement.apply(null,a)}return n.createElement.apply(null,r)}f.displayName="MDXCreateElement"},9930:function(e,t,r){r.r(t),r.d(t,{assets:function(){return p},contentTitle:function(){return c},default:function(){return m},frontMatter:function(){return u},metadata:function(){return l},toc:function(){return s}});var n=r(7462),i=r(3366),o=(r(7294),r(3905)),a=["components"],u={id:"querying",title:"Querying Information",sidebar_position:1},c=void 0,l={unversionedId:"config/querying",id:"config/querying",title:"Querying Information",description:"Querying",source:"@site/docs/config/Querying.md",sourceDirName:"config",slug:"/config/querying",permalink:"/config/querying",tags:[],version:"current",sidebarPosition:1,frontMatter:{id:"querying",title:"Querying Information",sidebar_position:1},sidebar:"docs",previous:{title:"Events & Scripting",permalink:"/config/events"},next:{title:"Type Nomenclature",permalink:"/config/types"}},p={},s=[{value:"Querying",id:"querying",level:2},{value:"Bar Properties",id:"bar-properties",level:3},{value:"Item Properties",id:"item-properties",level:3},{value:"Default Properties",id:"default-properties",level:3},{value:"Event Properties",id:"event-properties",level:3}],f={toc:s};function m(e){var t=e.components,r=(0,i.Z)(e,a);return(0,o.kt)("wrapper",(0,n.Z)({},f,r,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h2",{id:"querying"},"Querying"),(0,o.kt)("p",null,(0,o.kt)("em",{parentName:"p"},"SketchyBar")," can be queried for information about a number of things."),(0,o.kt)("h3",{id:"bar-properties"},"Bar Properties"),(0,o.kt)("p",null,"Information about the bar can be queried via:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-bash"},"sketchybar --query bar\n")),(0,o.kt)("p",null,"The output is a json structure containing relevant information about the configuration settings of the bar."),(0,o.kt)("h3",{id:"item-properties"},"Item Properties"),(0,o.kt)("p",null,"Information about an item can be queried via:"),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-bash"},"sketchybar --query <name>\n")),(0,o.kt)("p",null,"The output is a json structure containing relevant information about the configuration of the item."),(0,o.kt)("h3",{id:"default-properties"},"Default Properties"),(0,o.kt)("p",null,"Information about the current defaults."),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-bash"},"sketchybar --query defaults\n")),(0,o.kt)("h3",{id:"event-properties"},"Event Properties"),(0,o.kt)("p",null,"Information about the events."),(0,o.kt)("pre",null,(0,o.kt)("code",{parentName:"pre",className:"language-bash"},"sketchybar --query events\n")))}m.isMDXComponent=!0}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
"use strict";(self.webpackChunksketchybar_site=self.webpackChunksketchybar_site||[]).push([[869],{3905:function(e,t,r){r.d(t,{Zo:function(){return p},kt:function(){return d}});var n=r(7294);function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function a(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?o(Object(r),!0).forEach((function(t){i(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):o(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function c(e,t){if(null==e)return{};var r,n,i=function(e,t){if(null==e)return{};var r,n,i={},o=Object.keys(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var s=n.createContext({}),u=function(e){var t=n.useContext(s),r=t;return e&&(r="function"==typeof e?e(t):a(a({},t),e)),r},p=function(e){var t=u(e.components);return n.createElement(s.Provider,{value:t},e.children)},l={inlineCode:"code",wrapper:function(e){var t=e.children;return n.createElement(n.Fragment,{},t)}},f=n.forwardRef((function(e,t){var r=e.components,i=e.mdxType,o=e.originalType,s=e.parentName,p=c(e,["components","mdxType","originalType","parentName"]),f=u(r),d=i,m=f["".concat(s,".").concat(d)]||f[d]||l[d]||o;return r?n.createElement(m,a(a({ref:t},p),{},{components:r})):n.createElement(m,a({ref:t},p))}));function d(e,t){var r=arguments,i=t&&t.mdxType;if("string"==typeof e||i){var o=r.length,a=new Array(o);a[0]=f;var c={};for(var s in t)hasOwnProperty.call(t,s)&&(c[s]=t[s]);c.originalType=e,c.mdxType="string"==typeof e?e:i,a[1]=c;for(var u=2;u<o;u++)a[u]=r[u];return n.createElement.apply(null,a)}return n.createElement.apply(null,r)}f.displayName="MDXCreateElement"},2883:function(e,t,r){r.r(t),r.d(t,{assets:function(){return p},contentTitle:function(){return s},default:function(){return d},frontMatter:function(){return c},metadata:function(){return u},toc:function(){return l}});var n=r(7462),i=r(3366),o=(r(7294),r(3905)),a=["components"],c={id:"credits",title:"Credits",sidebar_position:1},s=void 0,u={unversionedId:"credits",id:"credits",title:"Credits",description:"Credits",source:"@site/docs/Credits.md",sourceDirName:".",slug:"/credits",permalink:"/credits",tags:[],version:"current",sidebarPosition:1,frontMatter:{id:"credits",title:"Credits",sidebar_position:1},sidebar:"docs",previous:{title:"Tips & Tricks",permalink:"/config/tricks"}},p={},l=[{value:"Credits",id:"credits",level:2}],f={toc:l};function d(e){var t=e.components,r=(0,i.Z)(e,a);return(0,o.kt)("wrapper",(0,n.Z)({},f,r,{components:t,mdxType:"MDXLayout"}),(0,o.kt)("h2",{id:"credits"},"Credits"),(0,o.kt)("p",null,"This project was forked from ",(0,o.kt)("em",{parentName:"p"},(0,o.kt)("a",{parentName:"em",href:"https://github.com/cmacrae/spacebar"},"spacebar"))," and completely reimagined and rewritten.\nThe original idea is based on the status bar that was included in ",(0,o.kt)("em",{parentName:"p"},(0,o.kt)("a",{parentName:"em",href:"https://github.com/koekeishiya/yabai"},"yabai"))," before getting removed."))}d.isMDXComponent=!0}}]);

View file

@ -0,0 +1 @@
"use strict";(self.webpackChunksketchybar_site=self.webpackChunksketchybar_site||[]).push([[608],{4608:function(e,t,n){n.r(t),n.d(t,{default:function(){return i}});var a=n(7294),l=n(2600),o=n(5999),r=n(5979);function i(){return a.createElement(a.Fragment,null,a.createElement(r.d,{title:(0,o.I)({id:"theme.NotFound.title",message:"Page Not Found"})}),a.createElement(l.Z,null,a.createElement("main",{className:"container margin-vert--xl"},a.createElement("div",{className:"row"},a.createElement("div",{className:"col col--6 col--offset-3"},a.createElement("h1",{className:"hero__title"},a.createElement(o.Z,{id:"theme.NotFound.title",description:"The title of the 404 page"},"Page Not Found")),a.createElement("p",null,a.createElement(o.Z,{id:"theme.NotFound.p1",description:"The first paragraph of the 404 page"},"We could not find what you were looking for.")),a.createElement("p",null,a.createElement(o.Z,{id:"theme.NotFound.p2",description:"The 2nd paragraph of the 404 page"},"Please contact the owner of the site that linked you to the original URL and let them know their link is broken.")))))))}}}]);

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
"use strict";(self.webpackChunksketchybar_site=self.webpackChunksketchybar_site||[]).push([[699],{3769:function(e){e.exports=JSON.parse('{"plugin":{"name":"docusaurus-plugin-content-docs","id":"default"}}')}}]);

View file

@ -0,0 +1 @@
"use strict";(self.webpackChunksketchybar_site=self.webpackChunksketchybar_site||[]).push([[53],{1109:function(e){e.exports=JSON.parse('{"pluginId":"default","version":"current","label":"Next","banner":null,"badge":false,"className":"docs-version-current","isLast":true,"docsSidebars":{"docs":[{"type":"link","label":"Features","href":"/features","docId":"features"},{"type":"link","label":"Setup","href":"/setup","docId":"setup"},{"type":"category","label":"Configuration","items":[{"type":"link","label":"Bar Properties","href":"/config/bar","docId":"config/bar"},{"type":"link","label":"Item Properties","href":"/config/items","docId":"config/items"},{"type":"link","label":"Special Components","href":"/config/components","docId":"config/components"},{"type":"link","label":"Popup Menus","href":"/config/popups","docId":"config/popups"},{"type":"link","label":"Events & Scripting","href":"/config/events","docId":"config/events"},{"type":"link","label":"Querying Information","href":"/config/querying","docId":"config/querying"},{"type":"link","label":"Type Nomenclature","href":"/config/types","docId":"config/types"},{"type":"link","label":"Tips & Tricks","href":"/config/tricks","docId":"config/tricks"}],"collapsed":true,"collapsible":true},{"type":"link","label":"Credits","href":"/credits","docId":"credits"}]},"docs":{"config/bar":{"id":"config/bar","title":"Bar Properties","description":"Configuration of the bar","sidebar":"docs"},"config/components":{"id":"config/components","title":"Special Components","description":"Components -- Special Items with special properties","sidebar":"docs"},"config/events":{"id":"config/events","title":"Events & Scripting","description":"Events and Scripting","sidebar":"docs"},"config/items":{"id":"config/items","title":"Item Properties","description":"Items and their properties","sidebar":"docs"},"config/popups":{"id":"config/popups","title":"Popup Menus","description":"Popup Menus","sidebar":"docs"},"config/querying":{"id":"config/querying","title":"Querying Information","description":"Querying","sidebar":"docs"},"config/tricks":{"id":"config/tricks","title":"Tips & Tricks","description":"Batching of configuration commands","sidebar":"docs"},"config/types":{"id":"config/types","title":"Type Nomenclature","description":"Type nomenclature","sidebar":"docs"},"credits":{"id":"credits","title":"Credits","description":"Credits","sidebar":"docs"},"features":{"id":"features","title":"Features","description":"Features","sidebar":"docs"},"setup":{"id":"setup","title":"Setup","description":"Installation","sidebar":"docs"}}}')}}]);

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
"use strict";(self.webpackChunksketchybar_site=self.webpackChunksketchybar_site||[]).push([[524],{5745:function(e){e.exports=JSON.parse('{"plugin":{"name":"docusaurus-plugin-content-pages","id":"default"}}')}}]);

View file

@ -0,0 +1 @@
"use strict";(self.webpackChunksketchybar_site=self.webpackChunksketchybar_site||[]).push([[195],{489:function(e,t,a){a.r(t),a.d(t,{default:function(){return o}});var n=a(7294),s=a(2600),r=a(9960),c=a.p+"assets/images/main-712611be7f4afc7df5661a3c186736e4.png";function l(){return n.createElement("div",{className:"container banner"},n.createElement("div",{className:"banner_left"},n.createElement("img",{className:"banner_logo",src:"/img/logo.svg",alt:"SketchyBar logo"}),n.createElement(r.Z,{className:"button button--secondary button--lg install_btn",to:"/features"},"Features"),n.createElement(r.Z,{className:"button button--secondary button--lg install_btn",to:"/setup"},"Install")),n.createElement("div",{className:"banner__right"},n.createElement("img",{src:c,className:"banner__right--screenshot",alt:"SketchyBar banner screenshot"})))}function m(){return n.createElement(s.Z,{description:"A highly customizable macOS statusbar replacement"},n.createElement("main",{className:"homepage"},n.createElement(l,null)))}function o(){return n.createElement(m,null)}}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,53 @@
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/* NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress
* @license MIT */
/**
* Prism: Lightweight, robust, elegant syntax highlighting
*
* @license MIT <https://opensource.org/licenses/MIT>
* @author Lea Verou <https://lea.verou.me>
* @namespace
* @public
*/
/** @license React v0.20.2
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.13.1
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v17.0.2
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v17.0.2
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

View file

@ -0,0 +1 @@
!function(){"use strict";var e,t,n,r,o,f={},c={};function u(e){var t=c[e];if(void 0!==t)return t.exports;var n=c[e]={exports:{}};return f[e].call(n.exports,n,n.exports,u),n.exports}u.m=f,e=[],u.O=function(t,n,r,o){if(!n){var f=1/0;for(b=0;b<e.length;b++){n=e[b][0],r=e[b][1],o=e[b][2];for(var c=!0,i=0;i<n.length;i++)(!1&o||f>=o)&&Object.keys(u.O).every((function(e){return u.O[e](n[i])}))?n.splice(i--,1):(c=!1,o<f&&(f=o));if(c){e.splice(b--,1);var a=r();void 0!==a&&(t=a)}}return t}o=o||0;for(var b=e.length;b>0&&e[b-1][2]>o;b--)e[b]=e[b-1];e[b]=[n,r,o]},u.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(t,{a:t}),t},n=Object.getPrototypeOf?function(e){return Object.getPrototypeOf(e)}:function(e){return e.__proto__},u.t=function(e,r){if(1&r&&(e=this(e)),8&r)return e;if("object"==typeof e&&e){if(4&r&&e.__esModule)return e;if(16&r&&"function"==typeof e.then)return e}var o=Object.create(null);u.r(o);var f={};t=t||[null,n({}),n([]),n(n)];for(var c=2&r&&e;"object"==typeof c&&!~t.indexOf(c);c=n(c))Object.getOwnPropertyNames(c).forEach((function(t){f[t]=function(){return e[t]}}));return f.default=function(){return e},u.d(o,f),o},u.d=function(e,t){for(var n in t)u.o(t,n)&&!u.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},u.f={},u.e=function(e){return Promise.all(Object.keys(u.f).reduce((function(t,n){return u.f[n](e,t),t}),[]))},u.u=function(e){return"assets/js/"+({19:"1a25ec0b",53:"935f2afb",141:"73510e92",195:"c4f5d8e4",233:"22ff8bbe",514:"1be78505",524:"a6c7dbe9",571:"f4bf9ed0",581:"3847b3ea",616:"db7c2498",699:"87e2ffe1",785:"37f332e7",869:"5f0ea8a9",878:"9392bc75",882:"dc9b5e88",918:"17896441",958:"2c8facf9"}[e]||e)+"."+{19:"a2c9216d",53:"aa23d385",141:"750a7e3c",195:"34ba96af",233:"f2b8c717",514:"62412478",524:"f987e5a5",571:"959aaba8",581:"d28952c4",608:"8233eb48",616:"3ee1b777",699:"0d7a1933",785:"27f622aa",869:"b31dd741",878:"919f18bf",882:"adc23360",918:"178a2d6d",958:"be288262"}[e]+".js"},u.miniCssF=function(e){},u.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),u.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r={},o="sketchybar-site:",u.l=function(e,t,n,f){if(r[e])r[e].push(t);else{var c,i;if(void 0!==n)for(var a=document.getElementsByTagName("script"),b=0;b<a.length;b++){var d=a[b];if(d.getAttribute("src")==e||d.getAttribute("data-webpack")==o+n){c=d;break}}c||(i=!0,(c=document.createElement("script")).charset="utf-8",c.timeout=120,u.nc&&c.setAttribute("nonce",u.nc),c.setAttribute("data-webpack",o+n),c.src=e),r[e]=[t];var l=function(t,n){c.onerror=c.onload=null,clearTimeout(s);var o=r[e];if(delete r[e],c.parentNode&&c.parentNode.removeChild(c),o&&o.forEach((function(e){return e(n)})),t)return t(n)},s=setTimeout(l.bind(null,void 0,{type:"timeout",target:c}),12e4);c.onerror=l.bind(null,c.onerror),c.onload=l.bind(null,c.onload),i&&document.head.appendChild(c)}},u.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.p="/",u.gca=function(e){return e={17896441:"918","1a25ec0b":"19","935f2afb":"53","73510e92":"141",c4f5d8e4:"195","22ff8bbe":"233","1be78505":"514",a6c7dbe9:"524",f4bf9ed0:"571","3847b3ea":"581",db7c2498:"616","87e2ffe1":"699","37f332e7":"785","5f0ea8a9":"869","9392bc75":"878",dc9b5e88:"882","2c8facf9":"958"}[e]||e,u.p+u.u(e)},function(){var e={303:0,532:0};u.f.j=function(t,n){var r=u.o(e,t)?e[t]:void 0;if(0!==r)if(r)n.push(r[2]);else if(/^(303|532)$/.test(t))e[t]=0;else{var o=new Promise((function(n,o){r=e[t]=[n,o]}));n.push(r[2]=o);var f=u.p+u.u(t),c=new Error;u.l(f,(function(n){if(u.o(e,t)&&(0!==(r=e[t])&&(e[t]=void 0),r)){var o=n&&("load"===n.type?"missing":n.type),f=n&&n.target&&n.target.src;c.message="Loading chunk "+t+" failed.\n("+o+": "+f+")",c.name="ChunkLoadError",c.type=o,c.request=f,r[1](c)}}),"chunk-"+t,t)}},u.O.j=function(t){return 0===e[t]};var t=function(t,n){var r,o,f=n[0],c=n[1],i=n[2],a=0;if(f.some((function(t){return 0!==e[t]}))){for(r in c)u.o(c,r)&&(u.m[r]=c[r]);if(i)var b=i(u)}for(t&&t(n);a<f.length;a++)o=f[a],u.o(e,o)&&e[o]&&e[o][0](),e[o]=0;return u.O(b)},n=self.webpackChunksketchybar_site=self.webpackChunksketchybar_site||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))}()}();

17
config/bar.html Normal file

File diff suppressed because one or more lines are too long

24
config/components.html Normal file

File diff suppressed because one or more lines are too long

24
config/events.html Normal file

File diff suppressed because one or more lines are too long

23
config/items.html Normal file

File diff suppressed because one or more lines are too long

19
config/popups.html Normal file

File diff suppressed because one or more lines are too long

17
config/querying.html Normal file

File diff suppressed because one or more lines are too long

20
config/tricks.html Normal file

File diff suppressed because one or more lines are too long

17
config/types.html Normal file

File diff suppressed because one or more lines are too long

18
credits.html Normal file

File diff suppressed because one or more lines are too long

27
features.html Normal file

File diff suppressed because one or more lines are too long

543
img/bar_item.svg Normal file
View file

@ -0,0 +1,543 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
width="131.92081mm"
height="125.12489mm"
viewBox="0 0 131.9208 125.12489"
version="1.1"
id="svg5"
inkscape:version="1.1.1 (c3084ef, 2021-09-22)"
sodipodi:docname="bar_item.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<sodipodi:namedview
id="namedview7"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageshadow="2"
inkscape:pageopacity="0.0"
inkscape:pagecheckerboard="0"
inkscape:document-units="mm"
showgrid="false"
inkscape:zoom="1.3237108"
inkscape:cx="211.90429"
inkscape:cy="246.27736"
inkscape:window-width="1512"
inkscape:window-height="922"
inkscape:window-x="7"
inkscape:window-y="32"
inkscape:window-maximized="0"
inkscape:current-layer="layer1" />
<defs
id="defs2">
<marker
style="overflow:visible"
id="marker43227"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="StopL"
inkscape:isstock="true">
<path
transform="scale(0.8)"
style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,5.65 V -5.65"
id="path43225" />
</marker>
<marker
style="overflow:visible"
id="StopL"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="StopL"
inkscape:isstock="true">
<path
transform="scale(0.8)"
style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,5.65 V -5.65"
id="path24947" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path24778" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart-9"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path24778-4" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart-3"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path24778-0" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart-9-4"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path24778-4-8" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart-9-1"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path24778-4-4" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart-8"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path24778-8" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart-5"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path24778-9" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart-5-3"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path24778-9-2" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart-5-3-8"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path24778-9-2-6" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart-80"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path24778-2" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart-5-4"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path24778-9-8" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart-5-3-3"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path24778-9-2-9" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart-5-3-8-0"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path24778-9-2-6-5" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart-9-2"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path24778-4-2" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart-8-7"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path24778-8-3" />
</marker>
<marker
style="overflow:visible"
id="Arrow1Lstart-9-1-7"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="Arrow1Lstart"
inkscape:isstock="true">
<path
transform="matrix(0.8,0,0,0.8,10,0)"
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,0 5,-5 -12.5,0 5,5 Z"
id="path24778-4-4-9" />
</marker>
<marker
style="overflow:visible"
id="StopL-0"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="StopL"
inkscape:isstock="true">
<path
transform="scale(0.8)"
style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,5.65 V -5.65"
id="path24947-2" />
</marker>
<marker
style="overflow:visible"
id="marker43227-3"
refX="0"
refY="0"
orient="auto"
inkscape:stockid="StopL"
inkscape:isstock="true">
<path
transform="scale(0.8)"
style="fill:none;fill-opacity:0.75;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
d="M 0,5.65 V -5.65"
id="path43225-9" />
</marker>
</defs>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(138.94063,-46.690483)">
<g
id="g7420">
<rect
style="fill:#ffffff;fill-rule:evenodd;stroke-width:0.268058"
id="rect209"
width="131.92081"
height="125.12489"
x="-138.94063"
y="46.690483" />
<rect
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:1.113;stroke-miterlimit:4;stroke-dasharray:none"
id="rect846"
width="27.408617"
height="16.318636"
x="-77.946716"
y="91.290627" />
<rect
style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:1.113;stroke-miterlimit:4;stroke-dasharray:none"
id="rect846-4"
width="24.343248"
height="16.318634"
x="-119.64159"
y="91.290627" />
<rect
style="fill:none;fill-opacity:1;stroke:#0000e2;stroke-width:1.113;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect846-2-6"
width="8.6758165"
height="16.318634"
x="-86.622536"
y="91.290627"
ry="0" />
<rect
style="fill:none;fill-opacity:1;stroke:#0000e2;stroke-width:1.113;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect846-2-6-9"
width="8.6758165"
height="16.318634"
x="-50.538097"
y="91.290627"
ry="0" />
<rect
style="fill:none;fill-opacity:1;stroke:#d30000;stroke-width:1.113;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect846-2-6-9-4"
width="8.6758165"
height="16.318634"
x="-128.31741"
y="91.290627"
ry="0" />
<rect
style="fill:none;fill-opacity:1;stroke:#d30000;stroke-width:1.113;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect846-2-6-9-4-1"
width="8.6758165"
height="16.318634"
x="-95.298347"
y="91.290627"
ry="0" />
<rect
style="fill:none;fill-opacity:1;stroke:#81009c;stroke-width:1.113;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect846-2-6-9-4-5"
width="8.6758165"
height="16.318634"
x="-136.99323"
y="91.290627"
ry="0" />
<rect
style="fill:none;fill-opacity:1;stroke:#81009c;stroke-width:1.113;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect846-2-6-9-4-5-5"
width="8.6758165"
height="16.318634"
x="-41.862278"
y="91.290627"
ry="0" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="-76.910706"
y="104.05661"
id="text2862"><tspan
sodipodi:role="line"
id="tspan2860"
style="stroke-width:0.264583"
x="-76.910706"
y="104.05661">label</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="-118.40323"
y="103.22858"
id="text2862-1"><tspan
sodipodi:role="line"
id="tspan2860-3"
style="stroke-width:0.264583"
x="-118.40323"
y="103.22858">icon</tspan></text>
<rect
style="fill:none;fill-opacity:1;stroke:#008700;stroke-width:1.113;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect16332"
width="86.852066"
height="33.378441"
x="-128.68135"
y="83.280235"
ry="8.5149078" />
<path
style="fill:none;stroke:#000000;stroke-width:0.265;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow1Lstart-80)"
d="m -124.53956,108.79124 c 0,0 -9.17781,36.63641 2.63321,36.92925"
id="path19280"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.265;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow1Lstart-5-4)"
d="m -134.6284,89.217992 c 0,0 -6.00905,-16.478055 4.14215,-18.59951"
id="path19280-5"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.265;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow1Lstart-5-3-3)"
d="m -36.37067,89.008781 c 0,0 18.43567,-25.531658 5.1984,-27.200433"
id="path19280-5-7"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.265;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow1Lstart-5-3-8-0)"
d="m -14.50913,94.5804 c 0,0 30.42847,-41.52206 -41.7734,-41.791674"
id="path19280-5-7-9"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.265;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow1Lstart-9-2)"
d="m -92.388588,109.09018 c -5.116769,6.64156 -36.013732,16.86992 -29.570372,27.41933"
id="path19280-3"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.265;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow1Lstart-8-7)"
d="m -80.131668,109.73949 c 16.701748,22.269 48.010778,17.32207 27.228838,48.09537"
id="path19280-7"
sodipodi:nodetypes="cc" />
<path
style="fill:none;stroke:#000000;stroke-width:0.265;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow1Lstart-9-1-7)"
d="m -45.56639,109.58575 c 0.11567,7.22382 10.46142,58.21472 -1.95688,57.44712"
id="path19280-3-1"
sodipodi:nodetypes="cc" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:7.05556px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="-119.86571"
y="147.86565"
id="text21979"><tspan
sodipodi:role="line"
id="tspan21977"
style="font-size:7.05556px;stroke-width:0.264583"
x="-119.86571"
y="147.86565">icon.padding_left</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:7.05556px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="-119.80067"
y="139.34509"
id="text21979-3"><tspan
sodipodi:role="line"
id="tspan21977-6"
style="font-size:7.05556px;stroke-width:0.264583"
x="-119.80067"
y="139.34509">icon.padding_right</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:7.05556px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="-128.46992"
y="72.668251"
id="text21979-8"><tspan
sodipodi:role="line"
id="tspan21977-5"
style="font-size:7.05556px;stroke-width:0.264583"
x="-128.46992"
y="72.668251">background.padding_left</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:7.05556px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="-128.40488"
y="64.147705"
id="text21979-3-89"><tspan
sodipodi:role="line"
id="tspan21977-6-9"
style="font-size:7.05556px;stroke-width:0.264583"
x="-128.40488"
y="64.147705">background.padding_right</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:7.05556px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="-128.27788"
y="55.620605"
id="text21979-3-89-3"><tspan
sodipodi:role="line"
id="tspan21977-6-9-3"
style="font-size:7.05556px;stroke-width:0.264583"
x="-128.27788"
y="55.620605">background.height</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:7.05556px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="-120.35081"
y="168.78734"
id="text21979-2"><tspan
sodipodi:role="line"
id="tspan21977-1"
style="font-size:7.05556px;stroke-width:0.264583"
x="-120.35081"
y="168.78734">label.padding_right</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:7.05556px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583"
x="-120.28577"
y="160.26678"
id="text21979-3-8"><tspan
sodipodi:role="line"
id="tspan21977-6-7"
style="font-size:7.05556px;stroke-width:0.264583"
x="-120.28577"
y="160.26678">label.padding_left</tspan></text>
<path
style="fill:none;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;marker-start:url(#StopL-0);marker-end:url(#marker43227-3)"
d="M -16.19854,116.102 -16.39842,84.32108"
id="path43215"
sodipodi:nodetypes="cc" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 20 KiB

View file

@ -0,0 +1,4 @@
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" data-prefix="fab" data-icon="github" class="svg-inline--fa fa-github fa-w-16" viewBox="0 0 496 496">
<path fill="#fff" d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

4
img/brand-github.svg Normal file
View file

@ -0,0 +1,4 @@
<?xml version="1.0"?>
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" data-prefix="fab" data-icon="github" class="svg-inline--fa fa-github fa-w-16" viewBox="0 0 496 496">
<path fill="#222" d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
img/examples.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 MiB

View file

@ -4,11 +4,11 @@
<svg
height="115.15997pt"
version="1.1"
viewBox="0 0 560.41772 115.15997"
width="560.41772pt"
viewBox="0 0 115.16031 115.15996"
width="115.16031pt"
id="svg507"
sodipodi:docname="Sbar.svg"
inkscape:version="1.1.1 (c3084ef, 2021-09-22)"
sodipodi:docname="icon.svg"
inkscape:version="1.1.2 (b8e25be8, 2022-02-05)"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:xlink="http://www.w3.org/1999/xlink"
@ -33,7 +33,7 @@
inkscape:window-width="1512"
inkscape:window-height="922"
inkscape:window-x="0"
inkscape:window-y="32"
inkscape:window-y="4"
inkscape:window-maximized="0"
inkscape:current-layer="svg507" />
<metadata
@ -128,10 +128,10 @@
id="rect1298"
width="106.65637"
height="106.65603"
x="4.2519684"
y="4.2519684"
x="4.2519698"
y="4.2519698"
inkscape:path-effect="#path-effect975"
d="M 19.251968,4.2519684 H 95.90834 a 15,15 45 0 1 15,14.9999996 v 76.656029 a 15,15 135 0 1 -15,15.000003 H 19.251968 A 15,15 45 0 1 4.2519684,95.907997 V 19.251968 A 15,15 135 0 1 19.251968,4.2519684 Z"
d="M 19.25197,4.2519698 H 95.908342 A 15,15 45 0 1 110.90834,19.25197 V 95.907999 A 15,15 135 0 1 95.908342,110.908 H 19.25197 A 15,15 45 0 1 4.2519698,95.907999 V 19.25197 A 15,15 135 0 1 19.25197,4.2519698 Z"
sodipodi:type="rect" />
<g
id="text_13"
@ -182,138 +182,4 @@
style="stroke-width:0.75"
x="166.78131"
y="55.378704" /></text>
<g
id="text_13-8"
style="fill:#9dd274;fill-opacity:1;stroke-linecap:butt;stroke-linejoin:round"
transform="matrix(7.5429152,0,0,7.5429152,-2084.689,-1400.5033)">
<!-- $\mathbf{SketchyBar}$ -->
<g
style="fill:#9dd274;fill-opacity:1"
transform="matrix(0.1,0,0,-0.1,295.2,197.01)"
id="g13254">
<defs
id="defs13232">
<path
d="M 25.40625,44.1875 C 15.5,46.390625 15.203125,53.59375 15.203125,55 c 0,5.09375 3.296875,10.984375 13,10.984375 9.703125,0 18.390625,-4.6875 20.5,-17.796875 C 49,46.09375 49,46 50.90625,46 53,46 53,46.296875 53,48.59375 V 67.390625 C 53,69.296875 53,70 51.5,70 c -0.703125,0 -1,-0.109375 -1.90625,-1.109375 L 45.296875,64 c -2.5,2.09375 -7.5,6 -17.203125,6 C 13.796875,70 6.203125,61 6.203125,50.09375 c 0,-6.703125 3.59375,-11.40625 5,-12.796875 5.203125,-5.203125 8,-5.796875 18.390625,-8.109375 10,-2.1875 11.203125,-2.390625 13.40625,-4.5 1.296875,-1.296875 4.203125,-4.09375 4.203125,-9.1875 0,-4.3125 -2.109375,-12.203125 -13.296875,-12.203125 -8.8125,0 -22.703125,3 -23.5,17.59375 C 10.296875,22.6875 10.296875,23 8.296875,23 6.203125,23 6.203125,22.6875 6.203125,20.390625 V 1.59375 c 0,-1.90625 0,-2.59375 1.5,-2.59375 C 8.40625,-1 8.5,-0.90625 9.5,0 10.59375,1.09375 11.5,2.390625 14,4.890625 19.796875,0.296875 28,-1 34,-1 49.59375,-1 56.203125,9.59375 56.203125,20.1875 56.203125,29.59375 50,38.59375 39.09375,41.09375 Z"
id="path13782" />
<path
d="M 33.203125,27.71875 45.796875,37.8125 C 47,38.796875 48.09375,39.6875 55,39.6875 V 44 c -2.59375,-0.203125 -4.59375,-0.203125 -8.296875,-0.203125 -2.609375,0 -8.203125,0 -10.5,0.203125 v -4.3125 c 1.203125,0 3.59375,-0.296875 3.59375,-1.078125 0,-0.40625 -0.59375,-0.796875 -0.796875,-1 L 20.796875,23.171875 V 70 L 3.5,69.1875 v -4.296875 c 6.203125,0 6.90625,0 6.90625,-4.09375 v -56.5 H 3.5 V 0 c 2.296875,0.1875 9.203125,0.1875 11.90625,0.1875 2.6875,0 9.59375,0 11.890625,-0.1875 V 4.296875 H 20.40625 v 13.25 c 1.59375,1.1875 3.09375,2.46875 5.296875,4.25 L 37.796875,6.375 C 38.5,5.578125 38.5,5.375 38.5,5.28125 38.5,4.296875 36.5,4.296875 35.09375,4.296875 V 0 c 2.40625,0.1875 9,0.1875 11.703125,0.1875 5.109375,0 6.5,0 10.703125,-0.1875 v 4.296875 c -1.59375,0 -3.59375,0 -4.703125,0.09375 C 51.40625,4.6875 51,4.984375 49.90625,6.375 Z"
id="path13784" />
<path
d="m 45.203125,22 c 2.296875,0 2.890625,0 2.890625,2.5 0,2.96875 -0.6875,10.375 -5.296875,15.015625 C 38.59375,43.6875 33,45 27.203125,45 11.59375,45 3.09375,34.875 3.09375,22.390625 3.09375,8.171875 13.40625,-1 28.5,-1 c 15.09375,0 19.59375,10.703125 19.59375,12.421875 0,1.53125 -1.5,1.53125 -2.09375,1.53125 -1.59375,0 -1.703125,-0.3125 -2.296875,-1.625 C 41.09375,4.71875 34.5,2.59375 29.703125,2.59375 15.203125,2.59375 15.09375,16.296875 15.09375,22 Z M 15.09375,24.890625 c 0.203125,4.046875 0.3125,7.90625 2.40625,11.46875 1.90625,3.15625 5.40625,5.328125 9.703125,5.328125 10.703125,0 11.59375,-11.859375 11.703125,-16.796875 z"
id="path13786" />
<path
d="M 21.09375,39.6875 H 35.5 V 44 H 21.09375 v 19 h -4.1875 C 16.796875,53.140625 12,43.296875 2.09375,42.984375 V 39.6875 h 8.109375 V 11.890625 C 10.203125,1.296875 18.40625,-1 25.59375,-1 33,-1 37.40625,4.59375 37.40625,12 v 5.296875 H 33.203125 V 12.09375 c 0,-6.59375 -3,-9.5 -6.109375,-9.5 -6,0 -6,6.703125 -6,9 z"
id="path13788" />
<path
d="m 46.796875,11.3125 c 0,1.203125 -1.09375,1.203125 -2.09375,1.203125 C 43.09375,12.515625 43,12.421875 42.5,11.21875 41.796875,9.3125 39.09375,2.59375 29.90625,2.59375 c -14.109375,0 -14.109375,15.234375 -14.109375,19.75 0,5.90625 0.109375,19.046875 13.203125,19.046875 0.703125,0 6.59375,-0.203125 6.59375,-0.703125 0,-0.09375 -0.09375,-0.203125 -0.296875,-0.296875 -0.296875,-0.296875 -1.59375,-1.8125 -1.59375,-4.3125 0,-4.21875 3.390625,-5.921875 5.890625,-5.921875 2.109375,0 5.90625,1.3125 5.90625,6.015625 C 45.5,44.390625 34,45 28.59375,45 10.796875,45 3.796875,33.375 3.796875,21.84375 3.796875,8.203125 13.296875,-1 28,-1 43.703125,-1 46.796875,10.609375 46.796875,11.3125 Z"
id="path13790" />
<path
d="M 53.09375,30.59375 C 53.09375,40.09375 49,45 38,45 27.90625,45 23,37.890625 21.59375,34.890625 H 21.5 V 70 L 4.203125,69.1875 v -4.296875 c 6.203125,0 6.890625,0 6.890625,-4.015625 V 4.296875 H 4.203125 V 0 C 6.5,0.1875 13.703125,0.1875 16.5,0.1875 c 2.796875,0 10.09375,0 12.40625,-0.1875 V 4.296875 H 22 V 25.59375 c 0,10.796875 8,16.09375 14.40625,16.09375 3.6875,0 5.796875,-2.390625 5.796875,-10 V 4.296875 h -6.90625 V 0 c 2.296875,0.1875 9.5,0.1875 12.296875,0.1875 2.8125,0 10.109375,0 12.40625,-0.1875 v 4.296875 h -6.90625 z"
id="path13792" />
<path
d="m 49.5,37.5 c 0.59375,1.390625 1,2.1875 7.40625,2.1875 V 44 C 53.5,43.796875 53.09375,43.796875 49,43.796875 c -2.703125,0 -2.90625,0 -8.59375,0.203125 v -4.3125 c 0.09375,0 4.796875,0 4.796875,-1.296875 0,-0.296875 -0.296875,-0.890625 -0.40625,-1.1875 L 33.09375,12.1875 l -12.796875,27.5 h 5.5 V 44 c -2.390625,-0.203125 -9.203125,-0.203125 -12,-0.203125 -2.890625,0 -8.796875,0 -11.390625,0.203125 v -4.3125 h 6.390625 l 18.5,-39.8125 c -0.5,-1.1875 -1.890625,-4.078125 -2.390625,-5.265625 -2.109375,-4.46875 -5.3125,-11.3125 -12.3125,-11.3125 -0.390625,0 -1.59375,0 -2.6875,0.59375 0.1875,0.09375 3.1875,1.28125 3.1875,5.0625 0,3.28125 -2.390625,5.359375 -5.390625,5.359375 -3.109375,0 -5.5,-2.078125 -5.5,-5.453125 C 2.203125,-15.8125 6.59375,-20 12.59375,-20 c 8.203125,0 13.609375,7.359375 15.609375,11.734375 z"
id="path13794" />
<path
d="M 3.90625,69 V 64.6875 H 14.5 V 4.296875 H 3.90625 V 0 h 45.1875 c 16.5,0 24.609375,8.890625 24.609375,18.5 0,9.5 -8.296875,16.390625 -20.40625,17.296875 C 67.703125,38.515625 70.5,46.828125 70.5,51.609375 70.5,60.9375 62.09375,69 46.09375,69 Z M 26.796875,37.296875 V 64.6875 H 44.90625 c 10.296875,0 12.390625,-7.90625 12.390625,-12.984375 0,-7.109375 -3.890625,-14.40625 -15.59375,-14.40625 z m 0,-33 V 34 h 19.90625 C 58.40625,34 60.09375,23.1875 60.09375,18.6875 c 0,-6.296875 -3.390625,-14.390625 -14.890625,-14.390625 z"
id="path13796" />
<path
d="M 46,29.59375 C 46,38.796875 38.703125,45 24.59375,45 19,45 7.203125,44.484375 7.203125,36.09375 c 0,-4.203125 3.203125,-6 5.890625,-6 3,0 5.90625,2.09375 5.90625,5.890625 0,1.90625 -0.703125,3.703125 -2.40625,4.8125 3.3125,0.890625 5.703125,0.890625 7.609375,0.890625 6.796875,0 10.890625,-3.796875 10.890625,-12 v -4 C 19.296875,25.6875 3.40625,21.28125 3.40625,10.125 3.40625,1 15,-1 21.90625,-1 29.59375,-1 34.5,3.203125 36.5,7.625 c 0,-3.71875 0,-8.03125 10.09375,-8.03125 h 5.109375 c 2.09375,0 2.890625,0 2.890625,2.203125 0,2.109375 -0.890625,2.109375 -2.296875,2.109375 C 46,4 46,5.609375 46,7.921875 Z M 35.09375,13.546875 c 0,-9.453125 -8.390625,-11.25 -11.59375,-11.25 -4.90625,0 -9,3.3125 -9,7.9375 0,9.140625 10.796875,12.25 20.59375,12.765625 z"
id="path13798" />
<path
d="m 20.796875,22.5 c 0,3.296875 0.703125,19.1875 12.40625,19.1875 -1.40625,-1.09375 -2.109375,-2.796875 -2.109375,-4.59375 0,-4.09375 3.3125,-5.796875 5.8125,-5.796875 2.5,0 5.796875,1.703125 5.796875,5.796875 C 42.703125,42.1875 37.5,45 32.703125,45 24.796875,45 21.40625,38.09375 20,33.890625 H 19.90625 V 45 L 3.5,44.1875 v -4.296875 c 6.203125,0 6.90625,0 6.90625,-3.890625 V 4.296875 H 3.5 V 0 c 2.296875,0.1875 9.796875,0.1875 12.59375,0.1875 2.90625,0 11,0 13.40625,-0.1875 v 4.296875 h -8.703125 z"
id="path13800" />
</defs>
<use
transform="scale(0.996264)"
xlink:href="#CMBX12-83"
id="use13234"
x="0"
y="0"
width="100%"
height="100%"
style="fill:#9dd274;fill-opacity:1" />
<use
transform="matrix(0.996264,0,0,0.996264,62.266501,0)"
xlink:href="#CMBX12-107"
id="use13236"
x="0"
y="0"
width="100%"
height="100%"
style="fill:#9dd274;fill-opacity:1" />
<use
transform="matrix(0.996264,0,0,0.996264,118.30635,0)"
xlink:href="#CMBX12-101"
id="use13238"
x="0"
y="0"
width="100%"
height="100%"
style="fill:#9dd274;fill-opacity:1" />
<use
transform="matrix(0.996264,0,0,0.996264,169.44562,0)"
xlink:href="#CMBX12-116"
id="use13240"
x="0"
y="0"
width="100%"
height="100%"
style="fill:#9dd274;fill-opacity:1" />
<use
transform="matrix(0.996264,0,0,0.996264,213.03217,0)"
xlink:href="#CMBX12-99"
id="use13242"
x="0"
y="0"
width="100%"
height="100%"
style="fill:#9dd274;fill-opacity:1" />
<use
transform="matrix(0.996264,0,0,0.996264,259.73204,0)"
xlink:href="#CMBX12-104"
id="use13244"
x="0"
y="0"
width="100%"
height="100%"
style="fill:#9dd274;fill-opacity:1" />
<use
transform="matrix(0.996264,0,0,0.996264,318.88522,0)"
xlink:href="#CMBX12-121"
id="use13246"
x="0"
y="0"
width="100%"
height="100%"
style="fill:#9dd274;fill-opacity:1" />
<use
transform="matrix(0.996264,0,0,0.996264,378.03839,0)"
xlink:href="#CMBX12-66"
id="use13248"
x="0"
y="0"
width="100%"
height="100%"
style="fill:#9dd274;fill-opacity:1" />
<use
transform="matrix(0.996264,0,0,0.996264,457.71653,0)"
xlink:href="#CMBX12-97"
id="use13250"
x="0"
y="0"
width="100%"
height="100%"
style="fill:#9dd274;fill-opacity:1" />
<use
transform="matrix(0.996264,0,0,0.996264,512.19972,0)"
xlink:href="#CMBX12-114"
id="use13252"
x="0"
y="0"
width="100%"
height="100%"
style="fill:#9dd274;fill-opacity:1" />
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 14 KiB

BIN
img/main.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1,020 KiB

17
index.html Normal file
View file

@ -0,0 +1,17 @@
<!doctype html>
<html lang="en" dir="ltr" class="plugin-pages plugin-id-default">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="generator" content="Docusaurus v2.0.0-beta.18">
<title data-rh="true">SketchyBar · A highly customizable macOS statusbar replacement</title><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:url" content="https://sketchybar.github.io//"><meta data-rh="true" name="docusaurus_locale" content="en"><meta data-rh="true" name="docusaurus_tag" content="default"><meta data-rh="true" name="docsearch:language" content="en"><meta data-rh="true" name="docsearch:docusaurus_tag" content="default"><meta data-rh="true" name="description" content="A highly customizable macOS statusbar replacement"><meta data-rh="true" property="og:description" content="A highly customizable macOS statusbar replacement"><link data-rh="true" rel="icon" href="/img/favicon.ico"><link data-rh="true" rel="canonical" href="https://sketchybar.github.io//"><link data-rh="true" rel="alternate" href="https://sketchybar.github.io//" hreflang="en"><link data-rh="true" rel="alternate" href="https://sketchybar.github.io//" hreflang="x-default"><script data-rh="true">function maybeInsertBanner(){window.__DOCUSAURUS_INSERT_BASEURL_BANNER&&insertBanner()}function insertBanner(){var n=document.getElementById("docusaurus-base-url-issue-banner-container");if(n){n.innerHTML='\n<div id="docusaurus-base-url-issue-banner" style="border: thick solid red; background-color: rgb(255, 230, 179); margin: 20px; padding: 20px; font-size: 20px;">\n <p style="font-weight: bold; font-size: 30px;">Your Docusaurus site did not load properly.</p>\n <p>A very common reason is a wrong site <a href="https://docusaurus.io/docs/docusaurus.config.js/#baseurl" style="font-weight: bold;">baseUrl configuration</a>.</p>\n <p>Current configured baseUrl = <span style="font-weight: bold; color: red;">/</span> (default value)</p>\n <p>We suggest trying baseUrl = <span id="docusaurus-base-url-issue-banner-suggestion-container" style="font-weight: bold; color: green;"></span></p>\n</div>\n';var e=document.getElementById("docusaurus-base-url-issue-banner-suggestion-container"),s=window.location.pathname,r="/"===s.substr(-1)?s:s+"/";e.innerHTML=r}}window.__DOCUSAURUS_INSERT_BASEURL_BANNER=!0,document.addEventListener("DOMContentLoaded",maybeInsertBanner)</script><link rel="stylesheet" href="/assets/css/styles.d31a9c85.css">
<link rel="preload" href="/assets/js/runtime~main.f11b668e.js" as="script">
<link rel="preload" href="/assets/js/main.06e9279c.js" as="script">
</head>
<body class="navigation-with-keyboard">
<script>!function(){function e(e){document.documentElement.setAttribute("data-theme",e)}var t=function(){var e=null;try{e=localStorage.getItem("theme")}catch(e){}return e}();null!==t?e(t):window.matchMedia("(prefers-color-scheme: dark)").matches?e("dark"):(window.matchMedia("(prefers-color-scheme: light)").matches,e("light"))}()</script><div id="__docusaurus">
<div id="docusaurus-base-url-issue-banner-container"></div><div role="region"><a href="#" class="skipToContent_ZgBM">Skip to main content</a></div><nav class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Navigation bar toggle" class="navbar__toggle clean-btn" type="button" tabindex="0"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><div class="navbar__logo"><img src="/img/logo.svg" alt="SketchyBar Logo" class="themedImage_W2Cr themedImage--light_TfLj"><img src="/img/logo.svg" alt="SketchyBar Logo" class="themedImage_W2Cr themedImage--dark_oUvU"></div><b class="navbar__title">SketchyBar</b></a></div><div class="navbar__items navbar__items--right"><a class="navbar__item navbar__link" href="/features">Features</a><a class="navbar__item navbar__link" href="/setup">Setup &amp; Installation</a><a class="navbar__item navbar__link" href="/config/bar">Configuration</a><a href="https://github.com/FelixKratz/SketchyBar" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link"></a><div class="toggle_S7eR colorModeToggle_vKtC"><button class="clean-btn toggleButton_rCf9 toggleButtonDisabled_Pu9x" type="button" disabled="" title="Switch between dark and light mode (currently light mode)" aria-label="Switch between dark and light mode (currently light mode)"><svg viewBox="0 0 24 24" width="24" height="24" class="lightToggleIcon_v35p"><path fill="currentColor" d="M12,9c1.65,0,3,1.35,3,3s-1.35,3-3,3s-3-1.35-3-3S10.35,9,12,9 M12,7c-2.76,0-5,2.24-5,5s2.24,5,5,5s5-2.24,5-5 S14.76,7,12,7L12,7z M2,13l2,0c0.55,0,1-0.45,1-1s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S1.45,13,2,13z M20,13l2,0c0.55,0,1-0.45,1-1 s-0.45-1-1-1l-2,0c-0.55,0-1,0.45-1,1S19.45,13,20,13z M11,2v2c0,0.55,0.45,1,1,1s1-0.45,1-1V2c0-0.55-0.45-1-1-1S11,1.45,11,2z M11,20v2c0,0.55,0.45,1,1,1s1-0.45,1-1v-2c0-0.55-0.45-1-1-1C11.45,19,11,19.45,11,20z M5.99,4.58c-0.39-0.39-1.03-0.39-1.41,0 c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0s0.39-1.03,0-1.41L5.99,4.58z M18.36,16.95 c-0.39-0.39-1.03-0.39-1.41,0c-0.39,0.39-0.39,1.03,0,1.41l1.06,1.06c0.39,0.39,1.03,0.39,1.41,0c0.39-0.39,0.39-1.03,0-1.41 L18.36,16.95z M19.42,5.99c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06c-0.39,0.39-0.39,1.03,0,1.41 s1.03,0.39,1.41,0L19.42,5.99z M7.05,18.36c0.39-0.39,0.39-1.03,0-1.41c-0.39-0.39-1.03-0.39-1.41,0l-1.06,1.06 c-0.39,0.39-0.39,1.03,0,1.41s1.03,0.39,1.41,0L7.05,18.36z"></path></svg><svg viewBox="0 0 24 24" width="24" height="24" class="darkToggleIcon_nQuB"><path fill="currentColor" d="M9.37,5.51C9.19,6.15,9.1,6.82,9.1,7.5c0,4.08,3.32,7.4,7.4,7.4c0.68,0,1.35-0.09,1.99-0.27C17.45,17.19,14.93,19,12,19 c-3.86,0-7-3.14-7-7C5,9.07,6.81,6.55,9.37,5.51z M12,3c-4.97,0-9,4.03-9,9s4.03,9,9,9s9-4.03,9-9c0-0.46-0.04-0.92-0.1-1.36 c-0.98,1.37-2.58,2.26-4.4,2.26c-2.98,0-5.4-2.42-5.4-5.4c0-1.81,0.89-3.42,2.26-4.4C12.92,3.04,12.46,3,12,3L12,3z"></path></svg></button></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div class="main-wrapper"><main class="homepage"><div class="container banner"><div class="banner_left"><img class="banner_logo" src="/img/logo.svg" alt="SketchyBar logo"><a class="button button--secondary button--lg install_btn" href="/features">Features</a><a class="button button--secondary button--lg install_btn" href="/setup">Install</a></div><div class="banner__right"><img src="/assets/images/main-712611be7f4afc7df5661a3c186736e4.png" class="banner__right--screenshot" alt="SketchyBar banner screenshot"></div></div></main></div></div>
<script src="/assets/js/runtime~main.f11b668e.js"></script>
<script src="/assets/js/main.06e9279c.js"></script>
</body>
</html>

View file

@ -1,56 +0,0 @@
CFLAGS = -std=c99 -Wall -DNDEBUG -Ofast -ffast-math -fvisibility=hidden
LIBS = -framework Carbon -framework Cocoa -F/System/Library/PrivateFrameworks -framework SkyLight
ODIR = bin
SRC = src
_OBJ = alias.o background.o bar_item.o custom_events.o event.o graph.o \
image.o mouse.o shadow.o text.o message.o mouse.o ax.o bar.o window.o \
bar_manager.o display.o event_loop.o group.o mach.o popup.o workspace.om
OBJ = $(patsubst %, $(ODIR)/%, $(_OBJ))
.PHONY: all clean arm x86 profile leak universal
all: clean universal
leak: CFLAGS=-std=c99 -Wall -DDEBUG -g
leak: clean arm64
leak:
/usr/libexec/PlistBuddy -c "Add :com.apple.security.get-task-allow bool true" bin/tmp.entitlements
codesign -s - --entitlements bin/tmp.entitlements -f ./bin/sketchybar
leaks -atExit -- ./bin/sketchybar
x86: CFLAGS+=-target x86_64-apple-macos10.13
x86: $(ODIR)/sketchybar
arm64: CFLAGS+=-target arm64-apple-macos11
arm64: $(ODIR)/sketchybar
universal:
$(MAKE) x86
mv $(ODIR)/sketchybar $(ODIR)/sketchybar_x86
rm -rf $(ODIR)/*.o*
$(MAKE) arm64
mv $(ODIR)/sketchybar $(ODIR)/sketchybar_arm64
lipo -create -output $(ODIR)/sketchybar $(ODIR)/sketchybar_x86 $(ODIR)/sketchybar_arm64
debug: CFLAGS=-std=c99 -Wall -DDEBUG -g
debug: arm64
asan: CFLAGS=-std=c99 -Wall -DDEBUG -g -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer
asan: clean arm64
./bin/sketchybar
$(ODIR)/sketchybar: $(SRC)/sketchybar.m $(OBJ) | $(ODIR)
$(CC) $(CFLAGS) $^ -o $@ $(LIBS)
$(ODIR)/%.o: $(SRC)/%.c $(SRC)/%.h | $(ODIR)
$(CC) -c -o $@ $< $(CFLAGS)
$(ODIR)/%.om: $(SRC)/%.m $(SRC)/%.h | $(ODIR)
$(CC) -c -o $@ $< $(CFLAGS)
$(ODIR):
mkdir $(ODIR)
clean:
rm -rf $(ODIR)

View file

@ -1,4 +0,0 @@
#!/usr/bin/env bash
sketchybar --set $NAME label="$(date '+%d/%m %H:%M')"

View file

@ -1,9 +0,0 @@
#!/usr/bin/env bash
CORE_COUNT=$(sysctl -n machdep.cpu.thread_count)
CPU_INFO=$(ps -eo pcpu,user)
CPU_SYS=$(echo "$CPU_INFO" | grep -v $(whoami) | sed "s/[^ 0-9\.]//g" | awk "{sum+=\$1} END {print sum/(100.0 * $CORE_COUNT)}")
CPU_USER=$(echo "$CPU_INFO" | grep $(whoami) | sed "s/[^ 0-9\.]//g" | awk "{sum+=\$1} END {print sum/(100.0 * $CORE_COUNT)}")
sketchybar --push cpu_sys $CPU_SYS \
--push cpu_user $CPU_USER

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
NOTIFICATIONS="$(gh api notifications | jq '.[]')"
if [ "$NOTIFICATIONS" = "" ]; then
sketchybar --set $NAME icon=
else
sketchybar --set $NAME icon=
fi

View file

@ -1,11 +0,0 @@
#!/usr/bin/env bash
COUNT=0
COUNT=$(curl https://github.com/users/FelixKratz/contributions | grep $(date '+%Y-%m-%d') | sed -nr 's/.*data-count=\"([^"]+).*/\1/p')
echo $COUNT
if [ $COUNT -gt 0 ]; then
sketchybar --set $NAME icon.color=0xff48aa2a label.padding_left=4 label="$COUNT"
else
sketchybar --set $NAME icon.color=0xaaffffff label.padding_left=0 label=""
fi

View file

@ -1,11 +0,0 @@
#!/usr/bin/env bash
RUNNING=$(osascript -e 'if application "Mail" is running then return 0')
COUNT=0
if [ $RUNNING == 0 ]; then
COUNT=$(osascript -e 'tell application "Mail" to return the unread count of inbox')
sketchybar --set $NAME label="$COUNT"
else
sketchybar --set $NAME label=
fi

View file

@ -1,24 +0,0 @@
#!/usr/bin/env bash
RUNNING=$(osascript -e 'if application "Spotify" is running then return 0')
if [ "$RUNNING" == "" ]; then
RUNNING=1
fi
PLAYING=1
TRACK=""
ALBUM=""
ARTIST=""
if [ "$(osascript -e 'if application "Spotify" is running then tell application "Spotify" to get player state')" == "playing" ]; then
PLAYING=0
TRACK=$(osascript -e 'tell application "Spotify" to get name of current track')
ARTIST=$(osascript -e 'tell application "Spotify" to get artist of current track')
ALBUM=$(osascript -e 'tell application "Spotify" to get album of current track')
fi
if [ $RUNNING -eq 0 ] && [ $PLAYING -eq 0 ]; then
if [ "$ARTIST" == "" ]; then
sketchybar --set $NAME label="$TRACK$ALBUM"
else
sketchybar --set $NAME label="$TRACK$ARTIST"
fi
else
sketchybar --set $NAME label=""
fi

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
TOPMEM=$(ps axo "rss,ucomm" | sort -nr | tail +1 | head -n1 | awk '{printf "%.0fMB %s\n", $1 / 1024, $2}' | sed -e 's/com.apple.//g')
MEM=$(echo $TOPMEM | sed -nr 's/([^MB]+).*/\1/p')
if [ $MEM -gt 2048 ]; then
sketchybar --set $NAME label="$TOPMEM"
else
sketchybar --set $NAME label=""
fi

View file

@ -1,11 +0,0 @@
#!/usr/bin/env bash
TOPPROC=$(ps axo "%cpu,ucomm" | sort -nr | tail +1 | head -n1 | awk '{printf "%.0f%% %s\n", $1, $2}' | sed -e 's/com.apple.//g')
CPUP=$(echo $TOPPROC | sed -nr 's/([^\%]+).*/\1/p')
if [ $CPUP -gt 75 ]; then
sketchybar --set $NAME label="$TOPPROC"
else
sketchybar --set $NAME label=""
fi

21
setup.html Normal file

File diff suppressed because one or more lines are too long

1
sitemap.xml Normal file
View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"><url><loc>https://sketchybar.github.io/</loc><changefreq>weekly</changefreq><priority>0.5</priority></url><url><loc>https://sketchybar.github.io/config/bar</loc><changefreq>weekly</changefreq><priority>0.5</priority></url><url><loc>https://sketchybar.github.io/config/components</loc><changefreq>weekly</changefreq><priority>0.5</priority></url><url><loc>https://sketchybar.github.io/config/events</loc><changefreq>weekly</changefreq><priority>0.5</priority></url><url><loc>https://sketchybar.github.io/config/items</loc><changefreq>weekly</changefreq><priority>0.5</priority></url><url><loc>https://sketchybar.github.io/config/popups</loc><changefreq>weekly</changefreq><priority>0.5</priority></url><url><loc>https://sketchybar.github.io/config/querying</loc><changefreq>weekly</changefreq><priority>0.5</priority></url><url><loc>https://sketchybar.github.io/config/tricks</loc><changefreq>weekly</changefreq><priority>0.5</priority></url><url><loc>https://sketchybar.github.io/config/types</loc><changefreq>weekly</changefreq><priority>0.5</priority></url><url><loc>https://sketchybar.github.io/credits</loc><changefreq>weekly</changefreq><priority>0.5</priority></url><url><loc>https://sketchybar.github.io/features</loc><changefreq>weekly</changefreq><priority>0.5</priority></url><url><loc>https://sketchybar.github.io/setup</loc><changefreq>weekly</changefreq><priority>0.5</priority></url></urlset>

View file

@ -1,141 +0,0 @@
# This is a demo config to bring across some of the most important commands more easily.
# For a more advanced configuration example see https://github.com/FelixKratz/SketchyBar/discussions/47#discussioncomment-2027233
############## BAR ##############
sketchybar --bar height=25 \
blur_radius=50 \
position=top \
padding_left=10 \
padding_right=10 \
color=0x44000000
############## GLOBAL DEFAULTS ##############
sketchybar --default updates=when_shown \
drawing=on \
icon.font="Hack Nerd Font:Bold:17.0" \
icon.color=0xffffffff \
label.font="Hack Nerd Font:Bold:14.0" \
label.color=0xffffffff
############## SPACE DEFAULTS ##############
sketchybar --default label.padding_left=2 \
label.padding_right=2 \
icon.padding_left=8 \
label.padding_right=8
############## PRIMARY DISPLAY SPACES ##############
sketchybar --add space code left \
--set code associated_display=1 \
associated_space=1 \
icon.font="Hack Nerd Font:Bold:20.0" \
icon= \
icon.highlight_color=0xff48aa2a \
label=code \
click_script="yabai -m space --focus 1" \
\
--add space tex left \
--set tex associated_display=1 \
associated_space=2 \
icon= \
icon.highlight_color=0xfffab402 \
label=tex \
click_script="yabai -m space --focus 2"
############## SECONDARY DISPLAY SPACES ##############
sketchybar --add space misc left \
--set misc associated_display=2 \
associated_space=5 \
icon.font="Hack Nerd Font:Bold:20.0" \
icon= \
icon.highlight_color=0xff48aa2a \
label=misc \
click_script="yabai -m space --focus 5"
############## ITEM DEFAULTS ###############
sketchybar --default label.padding_left=2 \
icon.padding_right=2 \
icon.padding_left=6 \
label.padding_right=6
############## LEFT ITEMS ##############
sketchybar --add item space_separator left \
--set space_separator icon= \
associated_space=1 \
icon.padding_left=15 \
label.padding_right=15 \
icon.font="Hack Nerd Font:Bold:15.0" \
\
--add item gitNotifications left \
--set gitNotifications associated_space=1 \
update_freq=300 \
icon.font="Hack Nerd Font:Bold:18.0" \
icon= \
script="~/.config/sketchybar/plugins/gitNotifications.sh" \
click_script="open https://github.com/notifications" \
--subscribe gitNotifications system_woke \
\
--add item githubIndicator left \
--set githubIndicator associated_space=1 \
update_freq=1000 \
icon.font="Hack Nerd Font:Bold:18.0" \
icon= \
click_script="open https://github.com" \
script="~/.config/sketchybar/plugins/githubIndicator.sh" \
--subscribe githubIndicator system_woke \
\
--add item topmem left \
--set topmem associated_space=1 \
icon.padding_left=10 \
update_freq=15 \
script="~/.config/sketchybar/plugins/topmem.sh"
############## RIGHT ITEMS ##############
sketchybar --add item clock right \
--set clock update_freq=10 \
script="~/.config/sketchybar/plugins/clock.sh" \
\
--add item mailIndicator right \
--set mailIndicator associated_space=1,2,3 \
update_freq=30 \
script="~/.config/sketchybar/plugins/mailIndicator.sh" \
icon.font="Hack Nerd Font:Bold:20.0" \
icon= \
click_script="osascript -e 'tell application \"Mail\" to activate'"
# Creating Graphs
sketchybar --add graph cpu_user right 200 \
--set cpu_user graph.color=0xffffffff \
update_freq=2 \
width=0 \
associated_space=1 \
label.padding_left=0 \
icon= \
script="~/.config/sketchybar/plugins/cpu_graph.sh" \
lazy=on \
\
--add graph cpu_sys right 200 \
--set cpu_sys label.padding_left=0 \
associated_space=1 \
icon= \
graph.color=0xff48aa2a \
\
--add item topproc right \
--set topproc associated_space=1 \
label.padding_right=10 \
update_freq=15 \
script="~/.config/sketchybar/plugins/topproc.sh"
###################### CENTER ITEMS ###################
# Adding custom events which can listen on distributed notifications from other running processes
sketchybar --add event spotify_change "com.spotify.client.PlaybackStateChanged" \
--add item spotifyIndicator center \
--set spotifyIndicator script="~/.config/sketchybar/plugins/spotifyIndicator.sh" \
--set spotifyIndicator click_script="osascript -e 'tell application \"Spotify\" to pause'" \
--subscribe spotifyIndicator spotify_change
############## FINALIZING THE SETUP ##############
sketchybar --update
echo "sketchybar configuration loaded.."

View file

@ -1,233 +0,0 @@
#include "alias.h"
void print_all_menu_items(FILE* rsp) {
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
if (__builtin_available(macOS 11.0, *)) CGRequestScreenCaptureAccess();
#endif
CFArrayRef window_list = CGWindowListCopyWindowInfo(kCGWindowListOptionAll,
kCGNullWindowID );
int window_count = CFArrayGetCount(window_list);
printf("[\n");
fprintf(rsp, "[\n");
int counter = 0;
for (int i = 0; i < window_count; ++i) {
CFDictionaryRef dictionary = CFArrayGetValueAtIndex(window_list, i);
if (!dictionary) continue;
CFStringRef owner_ref = CFDictionaryGetValue(dictionary,
kCGWindowOwnerName);
CFNumberRef owner_pid_ref = CFDictionaryGetValue(dictionary,
kCGWindowOwnerPID);
CFStringRef name_ref = CFDictionaryGetValue(dictionary, kCGWindowName);
if (!name_ref) continue;
if (!owner_ref) continue;
if (!owner_pid_ref) continue;
CFNumberRef layer_ref = CFDictionaryGetValue(dictionary, kCGWindowLayer);
if (!layer_ref) continue;
long long int layer = 0;
CFNumberGetValue(layer_ref, CFNumberGetType(layer_ref), &layer);
uint64_t owner_pid = 0;
CFNumberGetValue(owner_pid_ref,
CFNumberGetType(owner_pid_ref),
&owner_pid );
if (layer != MENUBAR_LAYER) continue;
char* owner = cfstring_copy(owner_ref);
char* name = cfstring_copy(name_ref);
if (strcmp(name, "") == 0) continue;
if (counter++ > 0) {
fprintf(rsp, ", \n");
printf(", \n");
}
fprintf(rsp, "\t\"%s,%s\"", owner, name);
printf("\t\"%s,%s\"", owner, name);
free(owner);
free(name);
}
printf("\n]\n");
fprintf(rsp, "\n]\n");
CFRelease(window_list);
}
void alias_get_permission(struct alias* alias) {
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 110000
if (__builtin_available(macOS 11.0, *))
alias->permission = CGRequestScreenCaptureAccess();
#endif
}
void alias_init(struct alias* alias) {
alias->name = NULL;
alias->owner = NULL;
alias->wid = 0;
alias->color_override = false;
alias->color = rgba_color_from_hex(0xffff0000);
image_init(&alias->image);
}
void alias_setup(struct alias* alias, char* owner, char* name) {
alias->name = name;
alias->owner = owner;
alias_get_permission(alias);
alias_update_image(alias);
}
uint32_t alias_get_length(struct alias* alias) {
if (alias->image.image_ref) return alias->image.bounds.size.width;
return 0;
}
uint32_t alias_get_height(struct alias* alias) {
if (alias->image.image_ref) return alias->image.bounds.size.height;
return 0;
}
void alias_find_window(struct alias* alias) {
CFArrayRef window_list = CGWindowListCopyWindowInfo(kCGWindowListOptionAll,
kCGNullWindowID );
int window_count = CFArrayGetCount(window_list);
for (int i = 0; i < window_count; ++i) {
CFDictionaryRef dictionary = CFArrayGetValueAtIndex(window_list, i);
if (!dictionary) continue;
CFStringRef owner_ref = CFDictionaryGetValue(dictionary,
kCGWindowOwnerName);
CFNumberRef owner_pid_ref = CFDictionaryGetValue(dictionary,
kCGWindowOwnerPID);
CFStringRef name_ref = CFDictionaryGetValue(dictionary, kCGWindowName);
if (!name_ref) continue;
if (!owner_ref) continue;
char* owner = cfstring_copy(owner_ref);
char* name = cfstring_copy(name_ref);
if (!(alias->owner && strcmp(alias->owner, owner) == 0
&& ((alias->name && strcmp(alias->name, name) == 0)
|| (!alias->name && strcmp(name, "") != 0) ))) {
free(owner);
free(name);
continue;
}
free(owner);
free(name);
CFNumberRef layer_ref = CFDictionaryGetValue(dictionary, kCGWindowLayer);
if (!layer_ref) continue;
uint64_t layer = 0;
CFNumberGetValue(layer_ref, CFNumberGetType(layer_ref), &layer);
if (layer != MENUBAR_LAYER) continue;
CFNumberGetValue(owner_pid_ref,
CFNumberGetType(owner_pid_ref),
&alias->pid );
CFNumberRef window_id_ref = CFDictionaryGetValue(dictionary,
kCGWindowNumber);
if (!window_id_ref) continue;
CFDictionaryRef bounds = CFDictionaryGetValue(dictionary, kCGWindowBounds);
if (!bounds) continue;
CGRectMakeWithDictionaryRepresentation(bounds, &alias->image.bounds);
CFNumberGetValue(window_id_ref,
CFNumberGetType(window_id_ref),
&alias->wid );
CFRelease(window_list);
return;
}
alias->wid = 0;
CFRelease(window_list);
}
bool alias_update_image(struct alias* alias) {
if (alias->wid == 0) alias_find_window(alias);
if (alias->wid == 0) return false;
CGRect bounds = CGRectNull;
SLSGetScreenRectForWindow(g_connection, alias->wid, &bounds);
bounds.size.width = (uint32_t) (bounds.size.width + 0.5);
CGImageRef tmp_ref = NULL;
SLSCaptureWindowsContentsToRectWithOptions(g_connection,
&alias->wid,
true,
CGRectNull,
1 << 8,
&tmp_ref );
if (!tmp_ref) {
alias->wid = 0;
return false;
}
return image_set_image(&alias->image, tmp_ref, bounds, false);
}
void alias_draw(struct alias* alias, CGContextRef context) {
if (alias->color_override) {
CGContextSaveGState(context);
image_draw(&alias->image, context);
CGContextClipToMask(context, alias->image.bounds, alias->image.image_ref);
CGContextSetRGBFillColor(context,
alias->color.r,
alias->color.g,
alias->color.b,
alias->color.a );
CGContextFillRect(context, alias->image.bounds);
CGContextRestoreGState(context);
}
else {
image_draw(&alias->image, context);
}
}
void alias_destroy(struct alias* alias) {
image_destroy(&alias->image);
if (alias->name) free(alias->name);
if (alias->owner) free(alias->owner);
alias->name = NULL;
alias->owner = NULL;
}
void alias_calculate_bounds(struct alias* alias, uint32_t x, uint32_t y) {
image_calculate_bounds(&alias->image, x, y);
}
bool alias_parse_sub_domain(struct alias* alias, FILE* rsp, struct token property, char* message) {
struct key_value_pair key_value_pair = get_key_value_pair(property.text,'.');
if (key_value_pair.key && key_value_pair.value) {
struct token subdom = { key_value_pair.key, strlen(key_value_pair.key) };
struct token entry = { key_value_pair.value, strlen(key_value_pair.value)};
if (token_equals(subdom, SUB_DOMAIN_SHADOW))
return shadow_parse_sub_domain(&alias->image.shadow,
rsp,
entry,
message );
else {
fprintf(rsp, "Invalid subdomain: %s \n", subdom.text);
printf("Invalid subdomain: %s \n", subdom.text);
}
}
else if (token_equals(property, PROPERTY_COLOR)) {
alias->color = rgba_color_from_hex(token_to_uint32t(get_token(&message)));
alias->color_override = true;
return true;
} else {
fprintf(rsp, "Unknown property: %s \n", property.text);
printf("Unknown property: %s \n", property.text);
}
return false;
}

View file

@ -1,38 +0,0 @@
#pragma once
#include <stdbool.h>
#include "misc/helpers.h"
#include "image.h"
#define MENUBAR_LAYER 0x19
extern void SLSCaptureWindowsContentsToRectWithOptions(uint32_t cid, uint64_t* wid, bool meh, CGRect bounds, uint32_t flags, CGImageRef* image);
extern int SLSGetScreenRectForWindow(uint32_t cid, uint32_t wid, CGRect* out);
struct alias {
bool permission;
char* name;
char* owner;
pid_t pid;
uint64_t wid;
bool color_override;
struct rgba_color color;
struct image image;
};
void alias_init(struct alias* alias);
void alias_setup(struct alias* alias, char* owner, char* name);
bool alias_update_image(struct alias* alias);
void alias_find_window(struct alias* alias);
uint32_t alias_get_length(struct alias* alias);
uint32_t alias_get_height(struct alias* alias);
void alias_calculate_bounds(struct alias* alias, uint32_t x, uint32_t y);
void alias_draw(struct alias* alias, CGContextRef context);
void alias_destroy(struct alias* alias);
void print_all_menu_items(FILE* rsp);
bool alias_parse_sub_domain(struct alias* alias, FILE* rsp, struct token property, char* message);

View file

@ -1,62 +0,0 @@
#include "ax.h"
void ax_init(struct ax* ax, bool check_privileges) {
ax->elements = NULL;
ax->element_count = 0;
if (check_privileges) {
const void *keys[] = { kAXTrustedCheckOptionPrompt };
const void *values[] = { kCFBooleanTrue };
CFDictionaryRef options;
options = CFDictionaryCreate(kCFAllocatorDefault,
keys, values, sizeof(keys) / sizeof(*keys),
&kCFCopyStringDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks );
ax->is_privileged = AXIsProcessTrustedWithOptions(options);
CFRelease(options);
} else ax->is_privileged = g_ax.is_privileged;
}
void ax_perform_click(AXUIElementRef element) {
if (!element) return;
AXUIElementPerformAction(element, kAXPressAction);
}
AXUIElementRef ax_get_extra_menu_item(struct ax* ax, pid_t pid, char* name) {
AXUIElementRef extra_menus_ref = NULL;
AXUIElementRef extra_menu = NULL;
CFArrayRef children_ref = NULL;
AXUIElementRef app = AXUIElementCreateApplication(pid);
AXError error = AXUIElementCopyAttributeValue(app,
kAXExtrasMenuBarAttribute,
(CFTypeRef*)&extra_menus_ref);
if (app) CFRelease(app);
if (error == kAXErrorSuccess) {
error = AXUIElementCopyAttributeValue(extra_menus_ref,
kAXVisibleChildrenAttribute,
(CFTypeRef*)&children_ref);
uint32_t count = CFArrayGetCount(children_ref);
if (count == 1 || (count > 0 && !name)) {
extra_menu = CFRetain(CFArrayGetValueAtIndex(children_ref, 0));
} else {
// Loop through array and find correct item via name...
}
CFRelease(extra_menus_ref);
CFRelease(children_ref);
}
return extra_menu;
}
void ax_clear(struct ax* ax) {
for (int i = 0; i < ax->element_count; i++) {
if (ax->elements[i]) CFRelease(ax->elements[i]);
}
if (ax->elements) free(ax->elements);
}

View file

@ -1,14 +0,0 @@
#pragma once
#include <Carbon/Carbon.h>
struct ax {
bool is_privileged;
uint32_t element_count;
AXUIElementRef* elements;
};
struct ax g_ax;
void ax_init(struct ax* ax, bool check_privileges);
void ax_clear(struct ax* ax);
void ax_get_menu_item(struct ax* ax, pid_t pid, char* name);

View file

@ -1,189 +0,0 @@
#include "background.h"
#include "image.h"
#include "misc/helpers.h"
#include "shadow.h"
void background_init(struct background* background) {
background->enabled = false;
background->overrides_height = false;
background->bounds.size.height = 25;
background->bounds.size.width = 0;
background->border_width = 0;
background->padding_left = 0;
background->padding_right = 0;
background->corner_radius = 0;
background->y_offset = 0;
background->color = rgba_color_from_hex(0x00000000);
background->border_color = rgba_color_from_hex(0x00000000);
shadow_init(&background->shadow);
image_init(&background->image);
}
bool background_set_color(struct background* background, uint32_t color) {
struct rgba_color target_color = rgba_color_from_hex(color);
if (background->color.r == target_color.r
&& background->color.g == target_color.g
&& background->color.b == target_color.b
&& background->color.a == target_color.a) return false;
background->color = target_color;
background_set_enabled(background, true);
return true;
}
bool background_set_border_color(struct background* background, uint32_t color) {
struct rgba_color target_color = rgba_color_from_hex(color);
if (background->border_color.r == target_color.r
&& background->border_color.g == target_color.g
&& background->border_color.b == target_color.b
&& background->border_color.a == target_color.a) return false;
background->border_color = target_color;
return true;
}
bool background_set_enabled(struct background* background, bool enabled) {
if (background->enabled == enabled) return false;
background->enabled = enabled;
return true;
}
bool background_set_height(struct background* background, uint32_t height) {
if (background->bounds.size.height == height) return false;
background->bounds.size.height = height;
background->overrides_height = height != 0;
return true;
}
bool background_set_border_width(struct background* background, uint32_t border_width) {
if (background->border_width == border_width) return false;
background->border_width = border_width;
return true;
}
bool background_set_corner_radius(struct background* background, uint32_t corner_radius) {
if (background->corner_radius == corner_radius) return false;
background->corner_radius = corner_radius;
return true;
}
bool background_set_padding_left(struct background* background, uint32_t pad) {
if (background->padding_left == pad) return false;
background->padding_left = pad;
return true;
}
bool background_set_padding_right(struct background* background, uint32_t pad) {
if (background->padding_right == pad) return false;
background->padding_right = pad;
return true;
}
bool background_set_yoffset(struct background* background, int offset) {
if (background->y_offset == offset) return false;
background->y_offset = offset;
return true;
}
void background_calculate_bounds(struct background* background, uint32_t x, uint32_t y) {
background->bounds.origin.x = x;
background->bounds.origin.y = y - background->bounds.size.height / 2;
if (background->image.enabled)
image_calculate_bounds(&background->image, x, y);
}
void background_draw(struct background* background, CGContextRef context) {
if (!background->enabled) return;
CGRect background_bounds = background->bounds;
background_bounds.origin.y += background->y_offset;
if (background->shadow.enabled) {
CGRect bounds = shadow_get_bounds(&background->shadow, background_bounds);
draw_rect(context,
bounds,
&background->shadow.color,
background->corner_radius,
background->border_width,
&background->shadow.color,
false );
}
if (background->image.enabled)
image_draw(&background->image, context);
draw_rect(context,
background_bounds,
&background->color,
background->corner_radius,
background->border_width,
&background->border_color,
false );
}
void background_clear_pointers(struct background* background) {
image_clear_pointers(&background->image);
}
void background_destroy(struct background* background) {
image_destroy(&background->image);
background_clear_pointers(background);
}
bool background_parse_sub_domain(struct background* background, FILE* rsp, struct token property, char* message) {
if (token_equals(property, PROPERTY_DRAWING))
return background_set_enabled(background,
evaluate_boolean_state(get_token(&message),
background->enabled));
else if (token_equals(property, PROPERTY_HEIGHT))
return background_set_height(background,
token_to_uint32t(get_token(&message)));
else if (token_equals(property, PROPERTY_CORNER_RADIUS))
return background_set_corner_radius(background,
token_to_uint32t(get_token(&message)));
else if (token_equals(property, PROPERTY_BORDER_WIDTH))
return background_set_border_width(background,
token_to_uint32t(get_token(&message)));
else if (token_equals(property, PROPERTY_COLOR))
return background_set_color(background,
token_to_uint32t(get_token(&message)));
else if (token_equals(property, PROPERTY_BORDER_COLOR))
return background_set_border_color(background,
token_to_uint32t(get_token(&message)));
else if (token_equals(property, PROPERTY_PADDING_LEFT))
return background_set_padding_left(background,
token_to_int(get_token(&message)));
else if (token_equals(property, PROPERTY_PADDING_RIGHT))
return background_set_padding_right(background,
token_to_int(get_token(&message)));
else if (token_equals(property, PROPERTY_YOFFSET))
return background_set_yoffset(background,
token_to_int(get_token(&message)));
else if (token_equals(property, SUB_DOMAIN_IMAGE))
return image_load(&background->image,
token_to_string(get_token(&message)),
rsp );
else {
struct key_value_pair key_value_pair = get_key_value_pair(property.text,
'.' );
if (key_value_pair.key && key_value_pair.value) {
struct token subdom = {key_value_pair.key,strlen(key_value_pair.key)};
struct token entry = {key_value_pair.value,strlen(key_value_pair.value)};
if (token_equals(subdom, SUB_DOMAIN_SHADOW))
return shadow_parse_sub_domain(&background->shadow,
rsp,
entry,
message );
else if (token_equals(subdom, SUB_DOMAIN_IMAGE))
return image_parse_sub_domain(&background->image, rsp, entry, message);
else {
fprintf(rsp, "Invalid subdomain: %s \n", subdom.text);
printf("Invalid subdomain: %s \n", subdom.text);
}
}
else {
fprintf(rsp, "Unknown property: %s \n", property.text);
printf("Unknown property: %s \n", property.text);
}
}
return false;
}

View file

@ -1,37 +0,0 @@
#pragma once
#include "image.h"
struct background {
bool enabled;
bool overrides_height;
int padding_left;
int padding_right;
int y_offset;
uint32_t border_width;
uint32_t corner_radius;
CGRect bounds;
struct image image;
struct shadow shadow;
struct rgba_color color;
struct rgba_color border_color;
};
void background_init(struct background* background);
bool background_set_color(struct background* background, uint32_t color);
bool background_set_border_color(struct background* background, uint32_t color);
bool background_set_enabled(struct background* background, bool enabled);
bool background_set_height(struct background* background, uint32_t height);
bool background_set_border_width(struct background* background, uint32_t border_width);
bool background_set_corner_radius(struct background* background, uint32_t corner_radius);
bool background_set_padding_left(struct background* background, uint32_t pad);
bool background_set_padding_right(struct background* background, uint32_t pad);
void background_calculate_bounds(struct background* background, uint32_t x, uint32_t y);
void background_draw(struct background* background, CGContextRef context);
void background_clear_pointers(struct background* background);
void background_destroy(struct background* background);
bool background_parse_sub_domain(struct background* background, FILE* rsp, struct token property, char* message);

243
src/bar.c
View file

@ -1,243 +0,0 @@
#include "bar.h"
#include "bar_manager.h"
#include "event.h"
#include "event_loop.h"
#include "display.h"
#include "window.h"
void bar_draw_graph(struct bar* bar, struct bar_item* bar_item, uint32_t x, bool right_to_left) {
if (!bar_item->has_graph) return;
}
bool bar_draws_item(struct bar* bar, struct bar_item* bar_item) {
if (!bar_item->drawing || !bar->shown) return false;
if (bar_item->associated_display > 0
&& (!(bar_item->associated_display & (1 << bar->adid)))
&& !bar_item->ignore_association)
return false;
if (bar_item->associated_space > 0
&& (!(bar_item->associated_space & (1 << bar->sid))
&& !bar_item->ignore_association)
&& (bar_item->type != BAR_COMPONENT_SPACE) )
return false;
if (bar_item->position == POSITION_POPUP)
return false;
return true;
}
void bar_calculate_popup_anchor_for_bar_item(struct bar* bar, struct bar_item* bar_item) {
if (bar->adid != g_bar_manager.active_adid) return;
if (!bar_item->popup.overrides_cell_size)
bar_item->popup.cell_size = bar->window.frame.size.height;
popup_calculate_bounds(&bar_item->popup);
CGPoint anchor = bar->window.origin;
if (bar_item->popup.align == POSITION_CENTER) {
anchor.x += bar_item->icon.bounds.origin.x
+ bar_item->background.padding_left / 2
+ (bar_item_get_length(bar_item, false)
- bar_item->popup.background.bounds.size.width) / 2;
} else if (bar_item->popup.align == POSITION_LEFT) {
anchor.x += bar_item->icon.bounds.origin.x
- bar_item->background.padding_left;
} else {
anchor.x += bar_item->icon.bounds.origin.x
+ bar_item_get_length(bar_item, false)
- bar_item->popup.background.bounds.size.width;
}
anchor.y += (g_bar_manager.position == POSITION_BOTTOM
? (-bar->window.frame.size.height
- bar_item->popup.background.bounds.size.height)
: bar->window.frame.size.height);
popup_set_anchor(&bar_item->popup, anchor, bar->adid);
}
void bar_draw(struct bar* bar) {
SLSDisableUpdate(g_connection);
SLSOrderWindow(g_connection, bar->window.id, -1, 0);
SLSRemoveAllTrackingAreas(g_connection, bar->window.id);
draw_rect(bar->window.context,
bar->window.frame,
&g_bar_manager.background.color,
g_bar_manager.background.corner_radius,
g_bar_manager.background.border_width,
&g_bar_manager.background.border_color,
true );
if (g_bar_manager.background.image.enabled) {
image_draw(&g_bar_manager.background.image, bar->window.context);
}
for (int i = 0; i < g_bar_manager.bar_item_count; i++) {
struct bar_item* bar_item = g_bar_manager.bar_items[i];
if (!(bar_item->position == POSITION_POPUP))
bar_item_remove_associated_bar(bar_item, bar->adid);
if (!bar_draws_item(bar, bar_item)) continue;
bar_item_append_associated_bar(bar_item, bar->adid);
if (bar_item->update_mask & UPDATE_MOUSE_ENTERED
|| bar_item->update_mask & UPDATE_MOUSE_EXITED) {
CGRect tracking_rect = cgrect_mirror_y(bar_item_construct_bounding_rect(
bar_item),
bar->window.frame.size.height / 2.);
tracking_rect.origin.y -= tracking_rect.size.height;
SLSAddTrackingRect(g_connection, bar->window.id, tracking_rect);
}
bar_item_set_bounding_rect_for_display(bar_item,
bar->adid,
bar->window.origin,
bar->window.frame.size.height);
bar_item_draw(bar_item, bar->window.context);
if (bar_item->popup.drawing && bar->adid == g_bar_manager.active_adid)
popup_draw(&bar_item->popup);
}
CGContextFlush(bar->window.context);
SLSOrderWindow(g_connection, bar->window.id, 1, bar->window.id);
SLSReenableUpdate(g_connection);
}
void bar_calculate_bounds(struct bar* bar) {
if (bar->hidden) return;
if (bar->sid == 0) return;
uint32_t center_length = bar_manager_length_for_bar_side(&g_bar_manager,
bar,
POSITION_CENTER);
uint32_t bar_left_first_item_x = g_bar_manager.background.padding_left;
uint32_t bar_right_first_item_x = bar->window.frame.size.width
- g_bar_manager.background.padding_right;
uint32_t bar_center_first_item_x = (bar->window.frame.size.width
- 2*g_bar_manager.margin
- center_length) / 2 - 1;
uint32_t bar_center_right_first_item_x = (bar->window.frame.size.width
+ bar->notch_width) / 2 - 1;
uint32_t bar_center_left_first_item_x = (bar->window.frame.size.width
- bar->notch_width) / 2 - 1;
uint32_t* next_position = NULL;
uint32_t y = bar->window.frame.size.height / 2;
for (int i = 0; i < g_bar_manager.bar_item_count; i++) {
struct bar_item* bar_item = g_bar_manager.bar_items[i];
if (!bar_draws_item(bar, bar_item)) continue;
uint32_t bar_item_display_length = bar_item_get_length(bar_item, true);
bool rtl = false;
if (bar_item->position == POSITION_LEFT)
next_position = &bar_left_first_item_x;
else if (bar_item->position == POSITION_CENTER)
next_position = &bar_center_first_item_x;
else if (bar_item->position == POSITION_RIGHT)
next_position = &bar_right_first_item_x, rtl = true;
else if (bar_item->position == POSITION_CENTER_RIGHT)
next_position = &bar_center_right_first_item_x;
else if (bar_item->position == POSITION_CENTER_LEFT)
next_position = &bar_center_left_first_item_x, rtl = true;
else
continue;
if (bar_item->position == POSITION_RIGHT
|| bar_item->position == POSITION_CENTER_LEFT)
*next_position -= bar_item_display_length
+ bar_item->background.padding_left
+ bar_item->background.padding_right;
bar_item->graph.rtl = rtl;
uint32_t bar_item_length = bar_item_calculate_bounds(bar_item,
bar->window.frame.size.height
- (g_bar_manager.background.border_width + 1),
*next_position,
y );
if (bar_item->popup.drawing)
bar_calculate_popup_anchor_for_bar_item(bar, bar_item);
if (bar_item->position == POSITION_RIGHT
|| bar_item->position == POSITION_CENTER_LEFT) {
*next_position += bar_item->has_const_width
? bar_item_display_length
+ bar_item->background.padding_left
+ bar_item->background.padding_right
- bar_item->custom_width
: 0;
} else
*next_position += bar_item->has_const_width
? bar_item->custom_width
: (bar_item_length + bar_item->background.padding_left
+ bar_item->background.padding_right );
}
}
CGRect bar_get_frame(struct bar *bar) {
CGRect bounds = display_bounds(bar->did);
bounds.size.width -= 2*g_bar_manager.margin;
CGPoint origin = bounds.origin;
origin.x += g_bar_manager.margin;
origin.y += g_bar_manager.y_offset;
if (g_bar_manager.position == POSITION_BOTTOM) {
origin.y = CGRectGetMaxY(bounds)
- g_bar_manager.background.bounds.size.height
- 2*g_bar_manager.y_offset;
} else if (display_menu_bar_visible() && !g_bar_manager.topmost) {
CGRect menu = display_menu_bar_rect(bar->did);
origin.y += menu.size.height;
}
return (CGRect) {{origin.x, origin.y},{bounds.size.width,
g_bar_manager.background.bounds.size.height}};
}
void bar_resize(struct bar* bar) {
if (bar->hidden) return;
window_resize(&bar->window, bar_get_frame(bar));
bar_calculate_bounds(bar);
bar_draw(bar);
}
void bar_set_hidden(struct bar* bar, bool hidden) {
if (bar->hidden == hidden) return;
if (hidden) window_close(&bar->window);
else bar_create_window(bar);
bar->hidden = hidden;
}
void bar_create_window(struct bar* bar) {
window_create(&bar->window, bar_get_frame(bar));
window_set_blur_radius(&bar->window, g_bar_manager.blur_radius);
if (!g_bar_manager.shadow) window_disable_shadow(&bar->window);
window_set_level(&bar->window, g_bar_manager.window_level);
context_set_font_smoothing(bar->window.context, g_bar_manager.font_smoothing);
}
struct bar *bar_create(uint32_t did) {
struct bar *bar = malloc(sizeof(struct bar));
memset(bar, 0, sizeof(struct bar));
bar->hidden = false;
bar->did = did;
bar->sid = mission_control_index(display_space_id(did));
bar->notch_width = CGDisplayIsBuiltin(did) ? g_bar_manager.notch_width : 0;
bar->shown = true;
bar_create_window(bar);
return bar;
}
void bar_destroy(struct bar *bar) {
window_close(&bar->window);
free(bar);
}

View file

@ -1,36 +0,0 @@
#pragma once
#include "bar_item.h"
#include "misc/helpers.h"
#include "window.h"
#define ALIGN_NONE 0
#define ALIGN_LEFT 1
#define ALIGN_RIGHT 2
#define ALIGN_TOP 3
#define ALIGN_BOTTOM 4
#define ALIGN_CENTER 5
struct bar {
bool shown;
bool hidden;
uint32_t did;
uint32_t sid;
uint32_t adid;
uint32_t notch_width;
struct window window;
};
struct bar *bar_create(uint32_t did);
void bar_create_window(struct bar* bar);
void bar_close_window(struct bar* bar);
void bar_destroy(struct bar* bar);
void bar_set_hidden(struct bar* bar, bool hidden);
void bar_calculate_bounds(struct bar* bar);
void bar_resize(struct bar* bar);
void bar_draw(struct bar* bar);
bool bar_draws_item(struct bar* bar, struct bar_item* bar_item);
void context_set_font_smoothing(CGContextRef context, bool smoothing);

View file

@ -1,799 +0,0 @@
#include "bar_item.h"
#include "bar_manager.h"
struct bar_item* bar_item_create() {
struct bar_item* bar_item = malloc(sizeof(struct bar_item));
memset(bar_item, 0, sizeof(struct bar_item));
return bar_item;
}
void bar_item_clear_pointers(struct bar_item* bar_item) {
bar_item->name = NULL;
bar_item->script = NULL;
bar_item->click_script = NULL;
bar_item->bounding_rects = NULL;
bar_item->group = NULL;
bar_item->num_rects = 0;
bar_item->signal_args.env_vars.vars = NULL;
bar_item->signal_args.env_vars.count = 0;
text_clear_pointers(&bar_item->icon);
text_clear_pointers(&bar_item->label);
background_clear_pointers(&bar_item->background);
}
void bar_item_inherit_from_item(struct bar_item* bar_item, struct bar_item* ancestor) {
text_destroy(&bar_item->icon);
text_destroy(&bar_item->label);
char* name = bar_item->name;
char* script = bar_item->script;
char* click_script = bar_item->click_script;
memcpy(bar_item, ancestor, sizeof(struct bar_item));
bar_item_clear_pointers(bar_item);
bar_item->name = name;
bar_item->script = script;
bar_item->click_script = click_script;
text_set_font(&bar_item->icon, string_copy(ancestor->icon.font_name), true);
text_set_font(&bar_item->label, string_copy(ancestor->label.font_name),true);
text_set_string(&bar_item->icon, string_copy(ancestor->icon.string), true);
text_set_string(&bar_item->label, string_copy(ancestor->label.string), true);
if (ancestor->script)
bar_item_set_script(bar_item, string_copy(ancestor->script));
if (ancestor->click_script)
bar_item_set_click_script(bar_item, string_copy(ancestor->click_script));
image_copy(&bar_item->background.image,
ancestor->background.image.image_ref);
image_copy(&bar_item->icon.background.image,
ancestor->icon.background.image.image_ref);
image_copy(&bar_item->label.background.image,
ancestor->label.background.image.image_ref);
if (bar_item->type == BAR_COMPONENT_SPACE) {
env_vars_set(&bar_item->signal_args.env_vars,
string_copy("SELECTED"),
string_copy("false") );
env_vars_set(&bar_item->signal_args.env_vars,
string_copy("SID"),
string_copy(env_vars_get_value_for_key(&ancestor->signal_args.env_vars,
"DID") ));
env_vars_set(&bar_item->signal_args.env_vars,
string_copy("DID"),
string_copy(env_vars_get_value_for_key(&ancestor->signal_args.env_vars,
"DID") ));
}
}
void bar_item_init(struct bar_item* bar_item, struct bar_item* default_item) {
bar_item->needs_update = true;
bar_item->lazy = false;
bar_item->drawing = true;
bar_item->updates = true;
bar_item->updates_only_when_shown = false;
bar_item->selected = false;
bar_item->mouse_over = false;
bar_item->ignore_association = false;
bar_item->counter = 0;
bar_item->type = BAR_ITEM;
bar_item->update_frequency = 0;
bar_item->position = POSITION_LEFT;
bar_item->align = POSITION_LEFT;
bar_item->associated_display = 0;
bar_item->associated_space = 0;
bar_item->associated_bar = 0;
bar_item->has_const_width = false;
bar_item->custom_width = 0;
bar_item->y_offset = 0;
bar_item->num_rects = 0;
bar_item->bounding_rects = NULL;
bar_item->group = NULL;
bar_item->has_alias = false;
bar_item->has_graph = false;
bar_item->name = NULL;
bar_item->script = NULL;
bar_item->click_script = NULL;
text_init(&bar_item->icon);
text_init(&bar_item->label);
background_init(&bar_item->background);
env_vars_init(&bar_item->signal_args.env_vars);
popup_init(&bar_item->popup);
graph_init(&bar_item->graph);
alias_init(&bar_item->alias);
if (default_item) bar_item_inherit_from_item(bar_item, default_item);
}
void bar_item_append_associated_space(struct bar_item* bar_item, uint32_t bit) {
if (bar_item->associated_space & bit) return;
bar_item->associated_space |= bit;
if (bar_item->type == BAR_COMPONENT_SPACE) {
bar_item->associated_space = bit;
char sid_str[32];
sprintf(sid_str, "%u", get_set_bit_position(bit));
env_vars_set(&bar_item->signal_args.env_vars,
string_copy("SID"),
string_copy(sid_str) );
}
}
void bar_item_append_associated_display(struct bar_item* bar_item, uint32_t bit) {
if (bar_item->associated_display & bit) return;
bar_item->associated_display |= bit;
if (bar_item->type == BAR_COMPONENT_SPACE) {
bar_item->associated_display = bit;
char did_str[32];
sprintf(did_str, "%u", get_set_bit_position(bit));
env_vars_set(&bar_item->signal_args.env_vars,
string_copy("DID"),
string_copy(did_str) );
}
}
bool bar_item_is_shown(struct bar_item* bar_item) {
if (bar_item->associated_bar & UINT32_MAX) return true;
else return false;
}
void bar_item_append_associated_bar(struct bar_item* bar_item, uint32_t adid) {
bar_item->associated_bar |= (1 << (adid - 1));
}
void bar_item_remove_associated_bar(struct bar_item* bar_item, uint32_t adid) {
bar_item->associated_bar &= ~(1 << (adid - 1));
bar_item_remove_bounding_rect_for_display(bar_item, adid);
}
void bar_item_reset_associated_bar(struct bar_item* bar_item) {
bar_item->associated_bar = 0;
for (uint32_t adid = 1; adid <= bar_item->num_rects; adid++)
bar_item_remove_bounding_rect_for_display(bar_item, adid);
}
bool bar_item_update(struct bar_item* bar_item, char* sender, bool forced, struct env_vars* env_vars) {
if ((!bar_item->updates || (bar_item->update_frequency == 0 && !sender))
&& !forced ) {
return false;
}
bar_item->counter++;
bool scheduled_update_needed = bar_item->update_frequency
<= bar_item->counter;
bool should_update = bar_item->updates_only_when_shown
? bar_item_is_shown(bar_item)
: true;
if (((scheduled_update_needed || sender) && should_update) || forced) {
bar_item->counter = 0;
// Script Update
if (bar_item->script && strlen(bar_item->script) > 0) {
if (!env_vars)
env_vars = &bar_item->signal_args.env_vars;
else {
for (int i = 0; i < bar_item->signal_args.env_vars.count; i++) {
env_vars_set(env_vars,
string_copy(bar_item->signal_args.env_vars.vars[i]->key),
string_copy(bar_item->signal_args.env_vars.vars[i]->value));
}
env_vars_set(env_vars,
string_copy("NAME"),
string_copy(bar_item->name));
}
if (sender)
env_vars_set(env_vars, string_copy("SENDER"), string_copy(sender));
else
env_vars_set(env_vars,
string_copy("SENDER"),
string_copy(forced ? "forced" : "routine"));
fork_exec(bar_item->script, env_vars);
}
// Alias Update
if (bar_item->has_alias && alias_update_image(&bar_item->alias)) {
bar_item_needs_update(bar_item);
return true;
}
}
return false;
}
void bar_item_needs_update(struct bar_item* bar_item) {
bar_item->needs_update = true;
}
void bar_item_clear_needs_update(struct bar_item* bar_item) {
bar_item->needs_update = false;
}
void bar_item_set_name(struct bar_item* bar_item, char* name) {
if (!name) return;
if (bar_item->name && strcmp(bar_item->name, name) == 0) {
free(name);
return;
}
if (name != bar_item->name && bar_item->name) free(bar_item->name);
bar_item->name = name;
env_vars_set(&bar_item->signal_args.env_vars,
string_copy("NAME"),
string_copy(name) );
}
void bar_item_set_type(struct bar_item* bar_item, char type) {
bar_item->type = type;
if (type == BAR_COMPONENT_SPACE) {
if (!bar_item->script) {
bar_item_set_script(bar_item,
string_copy("sketchybar -m --set $NAME icon.highlight=$SELECTED"));
}
bar_item->update_mask |= UPDATE_SPACE_CHANGE;
bar_item->updates = false;
env_vars_set(&bar_item->signal_args.env_vars,
string_copy("SELECTED"),
string_copy("false") );
env_vars_set(&bar_item->signal_args.env_vars,
string_copy("SID"),
string_copy("0") );
env_vars_set(&bar_item->signal_args.env_vars,
string_copy("DID"),
string_copy("0") );
}
else if (type == BAR_COMPONENT_ALIAS) {
bar_item->update_frequency = 1;
bar_item->has_alias = true;
bar_item->updates_only_when_shown = true;
}
else if (type == BAR_COMPONENT_GRAPH) {
bar_item->has_graph = true;
}
else if (type == BAR_COMPONENT_GROUP) {
bar_item->drawing = false;
bar_item->group = group_create();
group_init(bar_item->group);
group_add_member(bar_item->group, bar_item);
}
}
void bar_item_set_position(struct bar_item* bar_item, char position) {
bar_item->position = position;
if (position != POSITION_POPUP)
bar_item->align = position;
}
void bar_item_set_script(struct bar_item* bar_item, char* script) {
if (!script) return;
if (bar_item->script && strcmp(bar_item->script, script) == 0) {
free(script);
return;
}
if (script != bar_item->script && bar_item->script)
free(bar_item->script);
char* path = resolve_path(script);
bar_item->script = path;
}
void bar_item_set_click_script(struct bar_item* bar_item, char* script) {
if (!script) return;
if (bar_item->click_script && strcmp(bar_item->click_script, script) == 0) {
free(script);
return;
}
if (script != bar_item->click_script && bar_item->click_script)
free(bar_item->click_script);
char* path = resolve_path(script);
bar_item->click_script = path;
}
void bar_item_set_drawing(struct bar_item* bar_item, bool state) {
if (bar_item->drawing == state) return;
bar_item->drawing = state;
bar_item_needs_update(bar_item);
}
void bar_item_on_click(struct bar_item* bar_item, uint32_t type, uint32_t modifier) {
if (!bar_item) return;
env_vars_set(&bar_item->signal_args.env_vars,
string_copy("BUTTON"),
string_copy(get_type_description(type)));
env_vars_set(&bar_item->signal_args.env_vars,
string_copy("MODIFIER"),
string_copy(get_modifier_description(modifier)));
if (bar_item->click_script && strlen(bar_item->click_script) > 0)
fork_exec(bar_item->click_script, &bar_item->signal_args.env_vars);
if (bar_item->update_mask & UPDATE_MOUSE_CLICKED)
bar_item_update(bar_item, COMMAND_SUBSCRIBE_MOUSE_CLICKED, true, NULL);
}
void bar_item_mouse_entered(struct bar_item* bar_item) {
bar_item->mouse_over = true;
if (bar_item->update_mask & UPDATE_MOUSE_ENTERED)
bar_item_update(bar_item, COMMAND_SUBSCRIBE_MOUSE_ENTERED, true, NULL);
}
void bar_item_mouse_exited(struct bar_item* bar_item) {
if (bar_item->mouse_over && (bar_item->update_mask & UPDATE_MOUSE_EXITED))
bar_item_update(bar_item, COMMAND_SUBSCRIBE_MOUSE_EXITED, true, NULL);
bar_item->mouse_over = false;
}
void bar_item_set_yoffset(struct bar_item* bar_item, int offset) {
if (bar_item->y_offset == offset) return;
bar_item->y_offset = offset;
bar_item_needs_update(bar_item);
}
uint32_t bar_item_get_content_length(struct bar_item* bar_item) {
int length = text_get_length(&bar_item->icon, false)
+ text_get_length(&bar_item->label, false)
+ (bar_item->has_graph ? graph_get_length(&bar_item->graph) : 0)
+ (bar_item->has_alias ? alias_get_length(&bar_item->alias) : 0);
return length > 0 ? length : 0;
}
uint32_t bar_item_get_length(struct bar_item* bar_item, bool ignore_override) {
uint32_t content_length = bar_item_get_content_length(bar_item);
if (bar_item->background.enabled && bar_item->background.image.enabled
&& bar_item->background.image.bounds.size.width > content_length ) {
content_length = bar_item->background.image.bounds.size.width;
}
if (bar_item->has_const_width && (!ignore_override
|| bar_item->custom_width
> content_length )) {
return bar_item->custom_width;
}
return content_length;
}
uint32_t bar_item_get_height(struct bar_item* bar_item) {
uint32_t label_height = text_get_height(&bar_item->label);
uint32_t icon_height = text_get_height(&bar_item->icon);
uint32_t alias_height = alias_get_height(&bar_item->alias);
uint32_t text_height = label_height > icon_height
? label_height
: icon_height;
uint32_t item_height = text_height > alias_height
? text_height
: alias_height;
if (bar_item->background.enabled && bar_item->background.image.enabled
&& bar_item->background.image.bounds.size.height > item_height ) {
return bar_item->background.image.bounds.size.height;
}
return item_height;
}
void bar_item_remove_bounding_rect_for_display(struct bar_item* bar_item, uint32_t adid) {
if (bar_item->num_rects >= adid && bar_item->bounding_rects[adid - 1]) {
free(bar_item->bounding_rects[adid - 1]);
bar_item->bounding_rects[adid - 1] = NULL;
}
}
CGRect bar_item_construct_bounding_rect(struct bar_item* bar_item) {
CGRect bounding_rect;
bounding_rect.origin = bar_item->icon.bounds.origin;
bounding_rect.origin.y = bar_item->icon.bounds.origin.y
< bar_item->label.bounds.origin.y
? bar_item->icon.bounds.origin.y
: bar_item->label.bounds.origin.y;
if (bar_item->has_alias
&& bounding_rect.origin.y > bar_item->alias.image.bounds.origin.y) {
bounding_rect.origin.y = bar_item->alias.image.bounds.origin.y;
}
bounding_rect.size.width = bar_item_get_length(bar_item, true);
bounding_rect.size.height = bar_item_get_height(bar_item);
return bounding_rect;
}
void bar_item_set_bounding_rect_for_display(struct bar_item* bar_item, uint32_t adid, CGPoint bar_origin, uint32_t height) {
if (adid <= 0) return;
if (bar_item->num_rects < adid) {
bar_item->bounding_rects = (CGRect**) realloc(bar_item->bounding_rects,
sizeof(CGRect*) * adid );
memset(bar_item->bounding_rects + bar_item->num_rects,
0,
sizeof(CGRect*) * (adid - bar_item->num_rects) );
bar_item->num_rects = adid;
}
if (!bar_item->bounding_rects[adid - 1]) {
bar_item->bounding_rects[adid - 1] = malloc(sizeof(CGRect));
memset(bar_item->bounding_rects[adid - 1], 0, sizeof(CGRect));
}
CGRect rect = CGRectInset(bar_item_construct_bounding_rect(bar_item), -1,-1);
bar_item->bounding_rects[adid - 1]->origin.x = rect.origin.x + bar_origin.x;
bar_item->bounding_rects[adid - 1]->origin.y = -rect.origin.y
- rect.size.height
+ bar_origin.y
+ height;
bar_item->bounding_rects[adid - 1]->size = rect.size;
}
uint32_t bar_item_calculate_bounds(struct bar_item* bar_item, uint32_t bar_height, uint32_t x, uint32_t y) {
uint32_t content_x = x;
uint32_t bar_item_length = bar_item_get_length(bar_item, false);
uint32_t bar_item_content_length = bar_item_get_content_length(bar_item);
if (bar_item_length > bar_item_content_length) {
if (bar_item->align == POSITION_CENTER)
content_x += (bar_item_length - bar_item_content_length) / 2;
else if (bar_item->align == POSITION_RIGHT)
content_x += bar_item_length - bar_item_content_length;
}
uint32_t icon_position = content_x + bar_item->background.padding_left;
uint32_t label_position = icon_position + text_get_length(&bar_item->icon,
false );
uint32_t sandwich_position = label_position;
if (bar_item->has_graph) {
label_position += graph_get_length(&bar_item->graph);
} else if (bar_item->has_alias) {
label_position += alias_get_length(&bar_item->alias);
}
if (bar_item->group && group_is_first_member(bar_item->group, bar_item))
group_calculate_bounds(bar_item->group,
(bar_item->position == POSITION_RIGHT
|| bar_item->position == POSITION_CENTER_LEFT)
? (icon_position
- group_get_length(bar_item->group)
+ bar_item_length )
: icon_position,
y,
bar_item->position == POSITION_RIGHT
|| bar_item->position == POSITION_CENTER_LEFT);
text_calculate_bounds(&bar_item->icon,
icon_position,
y + bar_item->y_offset);
text_calculate_bounds(&bar_item->label,
label_position,
y + bar_item->y_offset);
if (bar_item->has_alias)
alias_calculate_bounds(&bar_item->alias,
sandwich_position,
y + bar_item->y_offset);
if (bar_item->has_graph) {
bar_item->graph.bounds.size.height = bar_item->background.enabled
? (bar_item->background.bounds.size.height
- bar_item->background.border_width - 1)
: (bar_height
- (g_bar_manager.background.border_width + 1));
graph_calculate_bounds(&bar_item->graph, sandwich_position, y + bar_item->y_offset);
}
if (bar_item->background.enabled) {
bar_item->background.bounds.size.height = bar_item->background.overrides_height
? bar_item->background.bounds.size.height
: (bar_height
- (g_bar_manager.background.border_width + 1));
bar_item->background.bounds.size.width = bar_item_length;
background_calculate_bounds(&bar_item->background,
x + bar_item->background.padding_left,
y + bar_item->y_offset );
}
return bar_item_length;
}
void bar_item_draw(struct bar_item* bar_item, CGContextRef context) {
if (bar_item->group && group_is_first_member(bar_item->group, bar_item))
group_draw(bar_item->group, context);
background_draw(&bar_item->background, context);
text_draw(&bar_item->icon, context);
text_draw(&bar_item->label, context);
if (bar_item->has_alias)
alias_draw(&bar_item->alias, context);
if (bar_item->has_graph)
graph_draw(&bar_item->graph, context);
}
void bar_item_destroy(struct bar_item* bar_item) {
if (bar_item->name) free(bar_item->name);
if (bar_item->script) free(bar_item->script);
if (bar_item->click_script) free(bar_item->click_script);
text_destroy(&bar_item->icon);
text_destroy(&bar_item->label);
if (bar_item->bounding_rects) {
for (int adid = 1; adid <= bar_item->num_rects; adid++) {
bar_item_remove_bounding_rect_for_display(bar_item, adid);
}
free(bar_item->bounding_rects);
}
if (bar_item->has_graph) {
graph_destroy(&bar_item->graph);
}
if (bar_item->has_alias) {
alias_destroy(&bar_item->alias);
}
if (bar_item->group && bar_item->type == BAR_COMPONENT_GROUP)
group_destroy(bar_item->group);
else if (bar_item->group)
group_remove_member(bar_item->group, bar_item);
env_vars_destroy(&bar_item->signal_args.env_vars);
popup_destroy(&bar_item->popup);
background_destroy(&bar_item->background);
free(bar_item);
}
void bar_item_serialize(struct bar_item* bar_item, FILE* rsp) {
fprintf(rsp, "{\n"
"\t\"name\": \"%s\",\n"
"\t\"type\": \"%c\",\n"
"\t\"text\": {\n"
"\t\t\"icon\": \"%s\",\n"
"\t\t\"label\": \"%s\",\n"
"\t\t\"icon.font\": \"%s\",\n"
"\t\t\"label.font\": \"%s\"\n"
"\t},\n"
"\t\"geometry\": {\n"
"\t\t\"position\": \"%c\",\n"
"\t\t\"fixed_width\": %d,\n"
"\t\t\"background.padding_left\": %d,\n"
"\t\t\"background.padding_right\": %d,\n"
"\t\t\"icon.padding_left\": %d,\n"
"\t\t\"icon.padding_right\": %d,\n"
"\t\t\"label.padding_left\": %d,\n"
"\t\t\"label.padding_right\": %d\n"
"\t},\n"
"\t\"style\": {\n"
"\t\t\"icon.color\": \"0x%x\",\n"
"\t\t\"icon.highlight_color:\": \"0x%x\",\n"
"\t\t\"label.color\": \"0x%x\",\n"
"\t\t\"label.highlight_color:\": \"0x%x\",\n"
"\t\t\"background.drawing\": %d,\n"
"\t\t\"background.height\": %u,\n"
"\t\t\"background.corner_radius\": %u,\n"
"\t\t\"background.border_width\": %u,\n"
"\t\t\"background.color\": \"0x%x\",\n"
"\t\t\"background.border_color\": \"0x%x\"\n"
"\t},\n"
"\t\"state\": {\n"
"\t\t\"drawing\": %d,\n"
"\t\t\"updates\": %d,\n"
"\t\t\"lazy\": %d,\n"
"\t\t\"associated_bar_mask\": %u,\n"
"\t\t\"associated_display_mask\": %u,\n"
"\t\t\"associated_space_mask\": %u,\n"
"\t\t\"update_mask\": %llu\n"
"\t},\n"
"\t\"bounding_rects\": {\n",
bar_item->name,
bar_item->type,
bar_item->icon.string,
bar_item->label.string,
bar_item->icon.font_name,
bar_item->label.font_name,
bar_item->position,
bar_item->has_const_width ? bar_item->custom_width : -1,
bar_item->background.padding_left,
bar_item->background.padding_right,
bar_item->icon.padding_left,
bar_item->icon.padding_right,
bar_item->label.padding_left,
bar_item->label.padding_right,
hex_from_rgba_color(bar_item->icon.color),
hex_from_rgba_color(bar_item->icon.highlight_color),
hex_from_rgba_color(bar_item->label.color),
hex_from_rgba_color(bar_item->label.highlight_color),
bar_item->background.enabled,
(uint32_t)bar_item->background.bounds.size.height,
bar_item->background.corner_radius,
bar_item->background.border_width,
hex_from_rgba_color(bar_item->background.color),
hex_from_rgba_color(bar_item->background.border_color),
bar_item->drawing,
bar_item->updates,
bar_item->lazy,
bar_item->associated_bar,
bar_item->associated_display,
bar_item->associated_space,
bar_item->update_mask);
int counter = 0;
for (int i = 0; i < bar_item->num_rects; i++) {
if (!bar_item->bounding_rects[i]) continue;
if (counter++ > 0) fprintf(rsp, ",\n");
fprintf(rsp, "\t\t\"display-%d\": {\n"
"\t\t\t\"origin\": [ %f, %f ],\n"
"\t\t\t\"size\": [ %f, %f ]\n\t\t}",
i + 1,
bar_item->bounding_rects[i]->origin.x,
bar_item->bounding_rects[i]->origin.y,
bar_item->bounding_rects[i]->size.width,
bar_item->bounding_rects[i]->size.height);
}
fprintf(rsp, "\n\t}");
if (bar_item->type == BAR_COMPONENT_GROUP && bar_item->group) {
group_serialize(bar_item->group, rsp);
} else if (bar_item->type == BAR_COMPONENT_GRAPH) {
graph_serialize(&bar_item->graph, rsp);
}
fprintf(rsp, "\n}\n");
}
void bar_item_parse_set_message(struct bar_item* bar_item, char* message, FILE* rsp) {
bool needs_update = false;
struct token property = get_token(&message);
struct key_value_pair key_value_pair = get_key_value_pair(property.text, '.');
if (key_value_pair.key && key_value_pair.value) {
struct token subdom = { key_value_pair.key, strlen(key_value_pair.key) };
struct token entry = { key_value_pair.value, strlen(key_value_pair.value) };
if (token_equals(subdom, SUB_DOMAIN_ICON))
needs_update = text_parse_sub_domain(&bar_item->icon, rsp, entry, message);
else if (token_equals(subdom, SUB_DOMAIN_LABEL))
needs_update = text_parse_sub_domain(&bar_item->label, rsp, entry, message);
else if (token_equals(subdom, SUB_DOMAIN_BACKGROUND))
needs_update = background_parse_sub_domain(&bar_item->background, rsp, entry, message);
else if (token_equals(subdom, SUB_DOMAIN_GRAPH))
needs_update = graph_parse_sub_domain(&bar_item->graph, rsp, entry, message);
else if (token_equals(subdom, SUB_DOMAIN_POPUP))
needs_update = popup_parse_sub_domain(&bar_item->popup, rsp, entry, message);
else if (token_equals(subdom, SUB_DOMAIN_ALIAS))
needs_update = alias_parse_sub_domain(&bar_item->alias, rsp, entry, message);
else {
fprintf(rsp, "Invalid subdomain: %s \n", subdom.text);
printf("Invalid subdomain: %s \n", subdom.text);
}
}
else if (token_equals(property, PROPERTY_ICON)) {
needs_update = text_set_string(&bar_item->icon, token_to_string(get_token(&message)), false);
} else if (token_equals(property, PROPERTY_LABEL)) {
needs_update = text_set_string(&bar_item->label, token_to_string(get_token(&message)), false);
} else if (token_equals(property, PROPERTY_UPDATES)) {
struct token token = get_token(&message);
if (token_equals(token, ARGUMENT_UPDATES_WHEN_SHOWN)) {
bar_item->updates = true;
bar_item->updates_only_when_shown = true;
}
else {
bar_item->updates = evaluate_boolean_state(token, bar_item->updates);
bar_item->updates_only_when_shown = false;
}
} else if (token_equals(property, PROPERTY_DRAWING)) {
bar_item_set_drawing(bar_item, evaluate_boolean_state(get_token(&message), bar_item->drawing));
} else if (token_equals(property, PROPERTY_WIDTH)) {
struct token token = get_token(&message);
if (token_equals(token, ARGUMENT_DYNAMIC))
bar_item->has_const_width = false;
else {
bar_item->has_const_width = true;
bar_item->custom_width = token_to_uint32t(token);
}
needs_update = true;
} else if (token_equals(property, PROPERTY_SCRIPT)) {
bar_item_set_script(bar_item, token_to_string(get_token(&message)));
} else if (token_equals(property, PROPERTY_CLICK_SCRIPT)) {
bar_item_set_click_script(bar_item, token_to_string(get_token(&message)));
} else if (token_equals(property, PROPERTY_UPDATE_FREQ)) {
bar_item->update_frequency = token_to_uint32t(get_token(&message));
} else if (token_equals(property, PROPERTY_POSITION)) {
struct token position = get_token(&message);
bar_item_set_position(bar_item, position.text[0]);
struct key_value_pair key_value_pair = get_key_value_pair(position.text, '.');
if (key_value_pair.key && key_value_pair.value) {
if (key_value_pair.key[0] == POSITION_POPUP) {
int item_index_for_name = bar_manager_get_item_index_for_name(&g_bar_manager, key_value_pair.value);
if (item_index_for_name < 0) {
fprintf(rsp, "Name: %s not found in bar items \n", key_value_pair.value);
printf("Name: %s not found in bar items \n", key_value_pair.value);
return;
}
struct bar_item* target_item = g_bar_manager.bar_items[item_index_for_name];
popup_add_item(&target_item->popup, bar_item);
}
}
needs_update = true;
} else if (token_equals(property, PROPERTY_ALIGN)) {
struct token position = get_token(&message);
if (bar_item->align != position.text[0]) {
bar_item->align = position.text[0];
needs_update = true;
}
} else if (token_equals(property, PROPERTY_ASSOCIATED_SPACE)) {
struct token token = get_token(&message);
uint32_t prev = bar_item->associated_space;
bar_item->associated_space = 0;
for (int i = 0; i < token.length; i++) {
int sep = -1;
if (token.text[i] == ',') token.text[i] = '\0', sep = i;
bar_item_append_associated_space(bar_item, 1 << strtoul(&token.text[sep + 1], NULL, 0));
}
needs_update = prev != bar_item->associated_space;
} else if (token_equals(property, PROPERTY_ASSOCIATED_DISPLAY)) {
struct token token = get_token(&message);
uint32_t prev = bar_item->associated_display;
bar_item->associated_display = 0;
for (int i = 0; i < token.length; i++) {
int sep = -1;
if (token.text[i] == ',') token.text[i] = '\0', sep = i;
bar_item_append_associated_display(bar_item, 1 << strtoul(&token.text[sep + 1], NULL, 0));
}
needs_update = prev != bar_item->associated_display;
} else if (token_equals(property, PROPERTY_YOFFSET)) {
bar_item_set_yoffset(bar_item, token_to_int(get_token(&message)));
} else if (token_equals(property, PROPERTY_CACHE_SCRIPTS)) {
printf("cache_scripts property is deprecated.\n");
} else if (token_equals(property, PROPERTY_LAZY)) {
bar_item->lazy = evaluate_boolean_state(get_token(&message), bar_item->lazy);
} else if (token_equals(property, PROPERTY_IGNORE_ASSOCIATION)) {
bar_item->ignore_association = evaluate_boolean_state(get_token(&message),
bar_item->ignore_association);
needs_update = true;
} else if (token_equals(property, COMMAND_DEFAULT_RESET)) {
bar_item_init(&g_bar_manager.default_item, NULL);
} else {
fprintf(rsp, "Invalid propery: %s \n", property.text);
printf("Invalid propery: %s \n", property.text);
}
if (needs_update) bar_item_needs_update(bar_item);
}
void bar_item_parse_subscribe_message(struct bar_item* bar_item, char* message) {
struct token event = get_token(&message);
while (event.text && event.length > 0) {
bar_item->update_mask |= custom_events_get_flag_for_name(&g_bar_manager.custom_events,
event.text );
event = get_token(&message);
}
}

View file

@ -1,118 +0,0 @@
#pragma once
#include "alias.h"
#include "custom_events.h"
#include "graph.h"
#include "group.h"
#include "misc/env_vars.h"
#include "misc/helpers.h"
#include "popup.h"
#include "text.h"
struct bar_item {
char type;
char* name;
// Update Modifiers
uint32_t counter;
bool needs_update;
bool updates;
bool updates_only_when_shown;
bool lazy;
bool selected;
bool mouse_over;
bool ignore_association;
// Drawing Modifiers
bool drawing;
bool has_const_width;
char align;
uint32_t custom_width;
// These are 32bit masks where the ith bit represents the ith screen/display/bar association
uint32_t associated_bar;
uint32_t associated_display;
uint32_t associated_space;
uint32_t update_frequency;
char* script;
char* click_script;
struct signal_args signal_args;
// The position in the bar: l,r,c
char position;
int y_offset;
// Background
struct background background;
// Icon properties
struct text icon;
// Label properties
struct text label;
// Graph Data
bool has_graph;
struct graph graph;
// Alias Data
bool has_alias;
struct alias alias;
// Group Properties
struct group* group;
// Update Events
uint64_t update_mask;
// Bounding Boxes for click events and background drawing (individual per display)
uint32_t num_rects;
CGRect** bounding_rects;
// Popup
struct popup popup;
};
struct bar_item* bar_item_create();
void bar_item_inherit_from_item(struct bar_item* bar_item, struct bar_item* ancestor);
void bar_item_init(struct bar_item* bar_item, struct bar_item* default_item);
void bar_item_destroy(struct bar_item* bar_item);
bool bar_item_update(struct bar_item* bar_item, char* sender, bool forced, struct env_vars* env_vars);
bool bar_item_is_shown(struct bar_item* bar_item);
void bar_item_append_associated_space(struct bar_item* bar_item, uint32_t bit);
void bar_item_append_associated_display(struct bar_item* bar_item, uint32_t bit);
void bar_item_append_associated_bar(struct bar_item* bar_item, uint32_t adid);
void bar_item_remove_associated_bar(struct bar_item* bar_item, uint32_t adid);
void bar_item_reset_associated_bar(struct bar_item* bar_item);
void bar_item_set_name(struct bar_item* bar_item, char* name);
void bar_item_set_type(struct bar_item* bar_item, char type);
void bar_item_set_position(struct bar_item* bar_item, char position);
void bar_item_set_script(struct bar_item* bar_item, char* script);
void bar_item_set_click_script(struct bar_item* bar_item, char* script);
void bar_item_set_drawing(struct bar_item* bar_item, bool state);
void bar_item_set_yoffset(struct bar_item* bar_item, int offset);
uint32_t bar_item_get_length(struct bar_item* bar_item, bool ignore_override);
uint32_t bar_item_get_height(struct bar_item* bar_item);
void bar_item_needs_update(struct bar_item* bar_item);
void bar_item_clear_needs_update(struct bar_item* bar_item);
void bar_item_on_click(struct bar_item* bar_item, uint32_t type, uint32_t modifier);
void bar_item_mouse_entered(struct bar_item* bar_item);
void bar_item_mouse_exited(struct bar_item* bar_item);
void bar_item_remove_bounding_rect_for_display(struct bar_item* bar_item, uint32_t adid);
CGRect bar_item_construct_bounding_rect(struct bar_item* bar_item);
void bar_item_set_bounding_rect_for_display(struct bar_item* bar_item, uint32_t adid, CGPoint bar_origin, uint32_t height);
uint32_t bar_item_calculate_bounds(struct bar_item* bar_item, uint32_t bar_height, uint32_t x, uint32_t y);
void bar_item_draw(struct bar_item* bar_item, CGContextRef context);
void bar_item_serialize(struct bar_item* bar_item, FILE* rsp);
void bar_item_parse_set_message(struct bar_item* bar_item, char* message, FILE* rsp);
void bar_item_parse_subscribe_message(struct bar_item* bar_item, char* message);

View file

@ -1,609 +0,0 @@
#include "bar_manager.h"
#include "event.h"
#include "event_loop.h"
#include "misc/env_vars.h"
#include "misc/helpers.h"
extern struct event_loop g_event_loop;
static CLOCK_CALLBACK(clock_handler) {
struct event *event = event_create(&g_event_loop, SHELL_REFRESH, NULL);
event_loop_post(&g_event_loop, event);
}
void bar_manager_init(struct bar_manager* bar_manager) {
bar_manager->font_smoothing = false;
bar_manager->any_bar_hidden = false;
bar_manager->bars = NULL;
bar_manager->bar_count = 0;
bar_manager->bar_item_count = 0;
bar_manager->display = DISPLAY_ALL;
bar_manager->position = POSITION_TOP;
bar_manager->y_offset = 0;
bar_manager->shadow = false;
bar_manager->blur_radius = 0;
bar_manager->margin = 0;
bar_manager->frozen = false;
bar_manager->sleeps = false;
bar_manager->window_level = kCGNormalWindowLevelKey;
bar_manager->topmost = false;
bar_manager->picky_redraw = false;
bar_manager->notch_width = 200;
bar_manager->active_adid = display_arrangement(display_active_display_id());
background_init(&bar_manager->background);
bar_manager->background.bounds.size.height = 25;
bar_manager->background.padding_left = 20;
bar_manager->background.padding_right = 20;
bar_manager->background.border_color = rgba_color_from_hex(0xffff0000);
bar_manager->background.color = rgba_color_from_hex(0x44000000);
bar_item_init(&bar_manager->default_item, NULL);
bar_item_set_name(&bar_manager->default_item, string_copy("defaults"));
custom_events_init(&bar_manager->custom_events);
int shell_refresh_frequency = 1;
bar_manager->clock = CFRunLoopTimerCreate(NULL,
CFAbsoluteTimeGetCurrent()
+ shell_refresh_frequency,
shell_refresh_frequency,
0,
0,
clock_handler,
NULL );
CFRunLoopAddTimer(CFRunLoopGetMain(),
bar_manager->clock,
kCFRunLoopCommonModes);
}
void bar_manager_sort(struct bar_manager* bar_manager, struct bar_item** ordering, uint32_t count) {
int index = 0;
for (int i = 0; i < bar_manager->bar_item_count; i++) {
for (int j = 0; j < count; j++) {
if (bar_manager->bar_items[i] == ordering[j]
&& bar_manager->bar_items[i] != ordering[index]) {
bar_manager->bar_items[i] = ordering[index];
index++;
bar_item_needs_update(bar_manager->bar_items[i]);
break;
}
else if (bar_manager->bar_items[i] == ordering[j]
&& bar_manager->bar_items[i] == ordering[index]) {
index++;
break;
}
}
}
}
int bar_manager_get_item_index_for_name(struct bar_manager* bar_manager, char* name) {
for (int i = 0; i < bar_manager->bar_item_count; i++) {
if (strcmp(bar_manager->bar_items[i]->name, name) == 0) {
return i;
}
}
return -1;
}
int bar_manager_get_item_index_by_address(struct bar_manager* bar_manager, struct bar_item* bar_item) {
for (int i = 0; i < bar_manager->bar_item_count; i++) {
if (bar_manager->bar_items[i] == bar_item) {
return i;
}
}
return -1;
}
void bar_manager_move_item(struct bar_manager* bar_manager, struct bar_item* item, struct bar_item* reference, bool before) {
if (bar_manager->bar_item_count <= 0) return;
struct bar_item* tmp[bar_manager->bar_item_count];
int count = 0;
for (int i = 0; i < bar_manager->bar_item_count; i++) {
if (bar_manager->bar_items[i] == item) continue;
if (bar_manager->bar_items[i] == reference && before) {
tmp[count++] = item;
tmp[count++] = bar_manager->bar_items[i];
continue;
} else if (bar_manager->bar_items[i] == reference && !before) {
tmp[count++] = bar_manager->bar_items[i];
tmp[count++] = item;
continue;
}
tmp[count++] = bar_manager->bar_items[i];
}
bar_manager->bar_items = realloc(
bar_manager->bar_items,
sizeof(struct bar_item*)*bar_manager->bar_item_count);
memcpy(bar_manager->bar_items,
tmp,
sizeof(struct bar_item*)*bar_manager->bar_item_count);
}
void bar_manager_remove_item(struct bar_manager* bar_manager, struct bar_item* bar_item) {
if (bar_manager->bar_item_count <= 0 || !bar_item
|| bar_manager_get_item_index_by_address(bar_manager, bar_item) < 0) {
return;
}
if (bar_item->position == POSITION_POPUP) {
for (int i = 0; i < bar_manager->bar_item_count; i++) {
popup_remove_item(&bar_manager->bar_items[i]->popup, bar_item);
}
}
if (bar_manager->bar_item_count == 1) {
free(bar_manager->bar_items);
bar_manager->bar_items = NULL;
bar_manager->bar_item_count = 0;
} else {
struct bar_item* tmp[bar_manager->bar_item_count - 1];
int count = 0;
for (int i = 0; i < bar_manager->bar_item_count; i++) {
if (bar_manager->bar_items[i] == bar_item) continue;
tmp[count++] = bar_manager->bar_items[i];
}
bar_manager->bar_item_count--;
bar_manager->bar_items = realloc(
bar_manager->bar_items,
sizeof(struct bar_item*)*bar_manager->bar_item_count);
memcpy(bar_manager->bar_items,
tmp,
sizeof(struct bar_item*)*bar_manager->bar_item_count);
}
bar_item_destroy(bar_item);
}
bool bar_manager_set_background_blur(struct bar_manager* bar_manager, uint32_t radius) {
if (bar_manager->blur_radius == radius) return false;
bar_manager->blur_radius = radius;
for (int i = 0; i < bar_manager->bar_count; i++) {
window_set_blur_radius(&bar_manager->bars[i]->window, radius);
}
return true;
}
bool bar_manager_set_position(struct bar_manager* bar_manager, char pos) {
if (bar_manager->position == pos) return false;
bar_manager->position = pos;
return true;
}
bool bar_manager_set_display(struct bar_manager* bar_manager, char display) {
if (bar_manager->display == display) return false;
bar_manager->display = display;
for (int i = 0; i < bar_manager->bar_count; ++i)
bar_destroy(bar_manager->bars[i]);
bar_manager_begin(bar_manager);
return true;
}
bool bar_manager_set_shadow(struct bar_manager* bar_manager, bool shadow) {
if (bar_manager->shadow == shadow) return false;
bar_manager->shadow = shadow;
for (int i = 0; i < bar_manager->bar_count; ++i)
bar_destroy(bar_manager->bars[i]);
bar_manager_begin(bar_manager);
return true;
}
bool bar_manager_set_notch_width(struct bar_manager* bar_manager, uint32_t width) {
if (bar_manager->notch_width == width) return false;
bar_manager->notch_width = width;
for (int i = 0; i < bar_manager->bar_count; ++i)
bar_destroy(bar_manager->bars[i]);
bar_manager_begin(bar_manager);
return true;
}
bool bar_manager_set_font_smoothing(struct bar_manager* bar_manager, bool smoothing) {
if (bar_manager->font_smoothing == smoothing) return false;
bar_manager->font_smoothing = smoothing;
for (int i = 0; i < bar_manager->bar_count; i++)
context_set_font_smoothing(bar_manager->bars[i]->window.context, smoothing);
return true;
}
bool bar_manager_set_hidden(struct bar_manager *bar_manager, uint32_t adid, bool hidden) {
bar_manager->any_bar_hidden = false;
if (adid > 0) {
bar_set_hidden(bar_manager->bars[adid - 1], hidden);
bar_manager->any_bar_hidden |= hidden;
}
else {
for (int i = 0; i < bar_manager->bar_count; i++) {
bar_set_hidden(bar_manager->bars[i], hidden);
bar_manager->any_bar_hidden |= hidden;
}
}
if (hidden) {
for (int i = 0; i < bar_manager->bar_item_count; i++) {
popup_set_drawing(&bar_manager->bar_items[i]->popup, false);
}
}
return true;
}
bool bar_manager_set_topmost(struct bar_manager *bar_manager, bool topmost) {
for (int i = 0; i < bar_manager->bar_count; i++)
bar_destroy(bar_manager->bars[i]);
if (topmost) bar_manager->window_level = kCGScreenSaverWindowLevelKey;
else bar_manager->window_level = kCGNormalWindowLevelKey;
bar_manager_begin(bar_manager);
bar_manager->topmost = topmost;
return true;
}
void bar_manager_freeze(struct bar_manager *bar_manager) {
bar_manager->frozen = true;
}
void bar_manager_unfreeze(struct bar_manager *bar_manager) {
bar_manager->frozen = false;
}
uint32_t bar_manager_length_for_bar_side(struct bar_manager* bar_manager, struct bar* bar, char side) {
uint32_t total_length = 0;
for (int i = 0; i < bar_manager->bar_item_count; i++) {
struct bar_item* bar_item = bar_manager->bar_items[i];
if (bar_item->position == side && bar_draws_item(bar, bar_item))
total_length += bar_item_get_length(bar_item, false)
+ (bar_item->has_const_width
? 0
: bar_item->background.padding_left
+ bar_item->background.padding_right);
}
return total_length;
}
bool bar_manager_bar_needs_redraw(struct bar_manager* bar_manager, struct bar* bar) {
for (int i = 0; i < bar_manager->bar_item_count; i++) {
struct bar_item* bar_item = bar_manager->bar_items[i];
bool is_associated_space_shown = (bar_item->associated_space & (1 << bar->sid))
|| bar_item->associated_space == 0;
bool is_associated_display_shown = (bar_item->associated_display & (1 << bar->adid));
if ((bar_item->drawing || (!bar_item->drawing
&& bar_item->associated_bar != 0))
&& bar_item->needs_update && (is_associated_space_shown
|| is_associated_display_shown)
&& (!bar_item->lazy || bar_manager->picky_redraw) ) {
return true;
}
}
return false;
}
void bar_manager_clear_needs_update(struct bar_manager* bar_manager) {
for (int i = 0; i < bar_manager->bar_item_count; i++)
bar_item_clear_needs_update(bar_manager->bar_items[i]);
}
void bar_manager_clear_association_for_bar(struct bar_manager* bar_manager, struct bar* bar) {
for (int i = 0; i < bar_manager->bar_item_count; i++)
bar_item_remove_associated_bar(bar_manager->bar_items[i], bar->adid);
}
void bar_manager_reset_bar_association(struct bar_manager* bar_manager) {
for (int i = 0; i < bar_manager->bar_item_count; i++)
bar_item_reset_associated_bar(bar_manager->bar_items[i]);
}
void bar_manager_refresh(struct bar_manager* bar_manager, bool forced) {
if (bar_manager->frozen) return;
if (forced) bar_manager_reset_bar_association(bar_manager);
for (int i = 0; i < bar_manager->bar_count; ++i) {
if (forced
|| bar_manager_bar_needs_redraw(bar_manager, bar_manager->bars[i])) {
bar_calculate_bounds(bar_manager->bars[i]);
bar_draw(bar_manager->bars[i]);
}
}
bar_manager_clear_needs_update(bar_manager);
}
void bar_manager_resize(struct bar_manager* bar_manager) {
for (int i = 0; i < bar_manager->bar_count; ++i)
bar_resize(bar_manager->bars[i]);
}
struct bar_item* bar_manager_create_item(struct bar_manager* bar_manager) {
bar_manager->bar_items = (struct bar_item**) realloc(
bar_manager->bar_items,
sizeof(struct bar_item*) * (bar_manager->bar_item_count + 1));
bar_manager->bar_item_count += 1;
struct bar_item* bar_item = bar_item_create();
bar_item_init(bar_item, &bar_manager->default_item);
bar_manager->bar_items[bar_manager->bar_item_count - 1] = bar_item;
return bar_item;
}
void bar_manager_update_alias_components(struct bar_manager* bar_manager, bool forced) {
for (int i = 0; i < bar_manager->bar_item_count; i++) {
if ((!bar_item_is_shown(bar_manager->bar_items[i]) && !forced)
|| bar_manager->bar_items[i]->type != BAR_COMPONENT_ALIAS ) {
continue;
}
bar_item_update(bar_manager->bar_items[i], NULL, forced, NULL);
}
}
void bar_manager_update_space_components(struct bar_manager* bar_manager, bool forced) {
for (int i = 0; i < bar_manager->bar_item_count; i++) {
struct bar_item* bar_item = bar_manager->bar_items[i];
if (bar_item->type != BAR_COMPONENT_SPACE) continue;
for (int j = 0; j < bar_manager->bar_count; j++) {
struct bar* bar = bar_manager->bars[j];
uint32_t did = bar->adid;
if (((1 << did) & bar_item->associated_display)) {
uint32_t sid = bar->sid;
if (sid == 0) continue;
if ((!bar_item->selected || forced)
&& bar_item->associated_space & (1 << sid)) {
bar_item->selected = true;
bar_item->updates = true;
env_vars_set(&bar_item->signal_args.env_vars,
string_copy("SELECTED"),
string_copy("true") );
}
else if ((bar_item->selected || forced)
&& !(bar_item->associated_space & (1 << sid))) {
bar_item->selected = false;
bar_item->updates = true;
env_vars_set(&bar_item->signal_args.env_vars,
string_copy("SELECTED"),
string_copy("false") );
}
else {
bar_item->updates = false;
}
}
}
}
}
void bar_manager_update(struct bar_manager* bar_manager, bool forced) {
if ((bar_manager->frozen && !forced) || bar_manager->sleeps) return;
bool needs_refresh = false;
for (int i = 0; i < bar_manager->bar_item_count; i++) {
needs_refresh |= bar_item_update(bar_manager->bar_items[i],
NULL,
forced,
NULL );
}
if (needs_refresh) bar_manager_refresh(bar_manager, false);
}
void bar_manager_begin(struct bar_manager *bar_manager) {
if (bar_manager->display == DISPLAY_MAIN) {
uint32_t did = display_main_display_id();
bar_manager->bar_count = 1;
bar_manager->bars = (struct bar **) realloc(
bar_manager->bars,
sizeof(struct bar *) * bar_manager->bar_count);
memset(bar_manager->bars, 0, sizeof(struct bar*) * bar_manager->bar_count);
bar_manager->bars[0] = bar_create(did);
bar_manager->bars[0]->adid = 1;
}
else {
bar_manager->bar_count = display_active_display_count();
bar_manager->bars = (struct bar **) realloc(
bar_manager->bars,
sizeof(struct bar *) * bar_manager->bar_count);
memset(bar_manager->bars, 0, sizeof(struct bar*) * bar_manager->bar_count);
for (uint32_t index=1; index <= bar_manager->bar_count; index++) {
uint32_t did = display_arrangement_display_id(index);
bar_manager->bars[index - 1] = bar_create(did);
bar_manager->bars[index - 1]->adid = index;
}
}
}
struct bar_item* bar_manager_get_item_by_point(struct bar_manager* bar_manager, CGPoint point, uint32_t adid) {
for (int i = 0; i < bar_manager->bar_item_count; i++) {
struct bar_item* bar_item = bar_manager->bar_items[i];
if (!bar_item->drawing || bar_item->num_rects < adid
|| bar_item->bounding_rects[adid - 1] == NULL) {
continue;
}
if (cgrect_contains_point(bar_item->bounding_rects[adid - 1], &point)) {
return bar_item;
}
}
return NULL;
}
void bar_manager_custom_events_trigger(struct bar_manager* bar_manager, char* name, struct env_vars* env_vars) {
uint64_t flag = custom_events_get_flag_for_name(&bar_manager->custom_events,
name );
for (int i = 0; i < bar_manager->bar_item_count; i++) {
struct bar_item* bar_item = bar_manager->bar_items[i];
if (bar_item->update_mask & flag)
bar_item_update(bar_item, name, false, env_vars);
}
}
void bar_manager_display_changed(struct bar_manager* bar_manager) {
bar_manager->active_adid = display_arrangement(display_active_display_id());
for (int i = 0; i < bar_manager->bar_count; ++i)
bar_destroy(bar_manager->bars[i]);
bar_manager_begin(bar_manager);
bar_manager_refresh(bar_manager, true);
}
void bar_manager_handle_mouse_entered(struct bar_manager* bar_manager, struct bar_item* bar_item) {
if (!bar_item || bar_item->mouse_over) return;
for (int i = 0; i < bar_manager->bar_item_count; i++)
bar_item_mouse_exited(bar_item);
bar_item_mouse_entered(bar_item);
}
void bar_manager_handle_mouse_exited(struct bar_manager* bar_manager) {
for (int i = 0; i < bar_manager->bar_item_count; i++)
bar_item_mouse_exited(bar_manager->bar_items[i]);
}
void bar_manager_handle_front_app_switch(struct bar_manager* bar_manager, char* info) {
struct env_vars env_vars;
env_vars_init(&env_vars);
if (info) env_vars_set(&env_vars, string_copy("INFO"), info);
bar_manager_custom_events_trigger(bar_manager,
COMMAND_SUBSCRIBE_FRONT_APP_SWITCHED,
&env_vars );
env_vars_destroy(&env_vars);
}
void bar_manager_handle_space_change(struct bar_manager* bar_manager) {
struct env_vars env_vars;
env_vars_init(&env_vars);
char info[18 * bar_manager->bar_count + 4];
info[0] = '{';
info[1] = '\n';
uint32_t cursor = 2;
for (int i = 0; i < bar_manager->bar_count; i++) {
bar_manager->bars[i]->sid = mission_control_index(
display_space_id(bar_manager->bars[i]->did));
bar_manager->bars[i]->shown = SLSSpaceGetType(g_connection,
bar_manager->bars[i]->sid)
!= 4;
snprintf(info + cursor, 18 * bar_manager->bar_count + 4 - cursor,
"\t\"display-%d\": %d\n",
bar_manager->bars[i]->adid,
bar_manager->bars[i]->sid );
cursor = strlen(info);
}
info[cursor] = '}';
info[cursor + 1] = '\0';
env_vars_set(&env_vars, string_copy("INFO"), string_copy(info));
bar_manager_update_space_components(bar_manager, false);
bar_manager_custom_events_trigger(bar_manager,
COMMAND_SUBSCRIBE_SPACE_CHANGE,
&env_vars );
env_vars_destroy(&env_vars);
bar_manager_refresh(bar_manager, true);
}
void bar_manager_handle_display_change(struct bar_manager* bar_manager) {
bar_manager->active_adid = display_arrangement(display_active_display_id());
bar_manager_custom_events_trigger(bar_manager,
COMMAND_SUBSCRIBE_DISPLAY_CHANGE,
NULL );
}
void bar_manager_handle_system_will_sleep(struct bar_manager* bar_manager) {
bar_manager_custom_events_trigger(bar_manager,
COMMAND_SUBSCRIBE_SYSTEM_WILL_SLEEP,
NULL );
bar_manager->sleeps = true;
}
void bar_manager_handle_system_woke(struct bar_manager* bar_manager) {
bar_manager->sleeps = false;
bar_manager_update_space_components(bar_manager, false);
bar_manager_custom_events_trigger(bar_manager,
COMMAND_SUBSCRIBE_SYSTEM_WOKE,
NULL );
bar_manager_refresh(bar_manager, true);
}
void bar_manager_handle_notification(struct bar_manager* bar_manager, struct notification* notification) {
char* name = custom_events_get_name_for_notification(&bar_manager->custom_events, notification->name);
if (!name) {
notification_destroy(notification);
return;
}
struct env_vars env_vars;
env_vars_init(&env_vars);
if (notification->info) env_vars_set(&env_vars,
string_copy("INFO"),
string_copy(notification->info));
bar_manager_custom_events_trigger(bar_manager, name, &env_vars);
env_vars_destroy(&env_vars);
notification_destroy(notification);
}
void bar_manager_destroy(struct bar_manager* bar_manager) {
for (int i = 0; i < bar_manager->bar_item_count; i++) {
bar_item_destroy(bar_manager->bar_items[i]);
}
if (bar_manager->bar_items) free(bar_manager->bar_items);
for (int i = 0; i < bar_manager->bar_count; i++) {
bar_destroy(bar_manager->bars[i]);
}
custom_events_destroy(&bar_manager->custom_events);
background_destroy(&bar_manager->background);
if (bar_manager->bars) free(bar_manager->bars);
}
void bar_manager_serialize(struct bar_manager* bar_manager, FILE* rsp) {
fprintf(rsp, "{\n"
"\t\"geometry\": {\n"
"\t\t\"position\": \"%c\",\n"
"\t\t\"height\": %u,\n"
"\t\t\"margin\": %d,\n"
"\t\t\"y_offset\": %d,\n"
"\t\t\"corner_radius\": %u,\n"
"\t\t\"border_width\": %u,\n"
"\t\t\"padding_left\": %u,\n"
"\t\t\"padding_right\": %u\n"
"\t},\n"
"\t\"style\": {\n"
"\t\t\"color\": \"0x%x\",\n"
"\t\t\"border_color\": \"0x%x\",\n"
"\t\t\"blur_radius\": %u\n"
"\t},\n"
"\t\"state\": {\n"
"\t\t\"frozen\": %d,\n"
"\t\t\"topmost\": %d,\n"
"\t\t\"shadow\": %d,\n"
"\t\t\"font_smoothing\": %d\n"
"\t},\n"
"\t\"items\": [\n",
bar_manager->position,
(uint32_t)bar_manager->background.bounds.size.height,
bar_manager->margin,
bar_manager->y_offset,
bar_manager->background.corner_radius,
bar_manager->background.border_width,
bar_manager->background.padding_left,
bar_manager->background.padding_right,
hex_from_rgba_color(bar_manager->background.color),
hex_from_rgba_color(bar_manager->background.border_color),
bar_manager->blur_radius,
bar_manager->frozen,
bar_manager->topmost,
bar_manager->shadow,
bar_manager->font_smoothing);
for (int i = 0; i < bar_manager->bar_item_count; i++) {
fprintf(rsp, "\t\t \"%s\"", bar_manager->bar_items[i]->name);
if (i < bar_manager->bar_item_count - 1) fprintf(rsp, ",\n");
}
fprintf(rsp, "\n\t]\n}\n");
}

View file

@ -1,85 +0,0 @@
#pragma once
#include "bar.h"
#include "bar_item.h"
#define CLOCK_CALLBACK(name) void name(CFRunLoopTimerRef timer, void *context)
typedef CLOCK_CALLBACK(clock_callback);
struct bar_manager {
CFRunLoopTimerRef clock;
bool frozen;
bool sleeps;
bool shadow;
bool topmost;
bool picky_redraw;
bool font_smoothing;
bool any_bar_hidden;
char display;
char position;
int y_offset;
int margin;
uint32_t blur_radius;
uint32_t notch_width;
uint32_t active_adid;
uint32_t window_level;
struct bar** bars;
int bar_count;
struct bar_item** bar_items;
struct bar_item default_item;
int bar_item_count;
struct background background;
struct custom_events custom_events;
};
struct bar_manager g_bar_manager;
void bar_manager_init(struct bar_manager* bar_manager);
void bar_manager_begin(struct bar_manager* bar_manager);
struct bar_item* bar_manager_create_item(struct bar_manager* bar_manager);
void bar_manager_remove_item(struct bar_manager* bar_manager, struct bar_item* bar_item);
void bar_manager_move_item(struct bar_manager* bar_manager, struct bar_item* item, struct bar_item* reference, bool before);
void bar_manager_handle_notification(struct bar_manager* bar_manager, struct notification* notification);
void bar_manager_update(struct bar_manager* bar_manager, bool forced);
void bar_manager_update_space_components(struct bar_manager* bar_manager, bool forced);
bool bar_manager_set_background_blur(struct bar_manager* bar_manager, uint32_t radius);
bool bar_manager_set_position(struct bar_manager* bar_manager, char pos);
bool bar_manager_set_spaces(struct bar_manager* bar_manager, bool value);
bool bar_manager_set_spaces_for_all_displays(struct bar_manager* bar_manager, bool value);
bool bar_manager_set_display(struct bar_manager* bar_manager, char display);
bool bar_manager_set_hidden(struct bar_manager* bar_manager, uint32_t sid, bool hidden);
bool bar_manager_set_topmost(struct bar_manager* bar_manager, bool topmost);
bool bar_manager_set_shadow(struct bar_manager* bar_manager, bool shadow);
bool bar_manager_set_font_smoothing(struct bar_manager* bar_manager, bool smoothing);
bool bar_manager_set_notch_width(struct bar_manager* bar_manager, uint32_t width);
void bar_manager_sort(struct bar_manager* bar_manager, struct bar_item** ordering, uint32_t count);
struct bar_item* bar_manager_get_item_by_point(struct bar_manager* bar_manager, CGPoint point, uint32_t adid);
int bar_manager_get_item_index_for_name(struct bar_manager* bar_manager, char* name);
uint32_t bar_manager_length_for_bar_side(struct bar_manager* bar_manager, struct bar* bar, char side);
void bar_manager_freeze(struct bar_manager* bar_manager);
void bar_manager_unfreeze(struct bar_manager* bar_manager);
void bar_manager_display_changed(struct bar_manager* bar_manager);
void bar_manager_refresh(struct bar_manager* bar_manager, bool forced);
void bar_manager_resize(struct bar_manager* bar_manager);
void bar_manager_handle_mouse_entered(struct bar_manager* bar_manager, struct bar_item* bar_item);
void bar_manager_handle_mouse_exited(struct bar_manager* bar_manager);
void bar_manager_handle_front_app_switch(struct bar_manager* bar_manager, char* info);
void bar_manager_handle_space_change(struct bar_manager* bar_manager);
void bar_manager_handle_display_change(struct bar_manager* bar_manager);
void bar_manager_handle_system_woke(struct bar_manager* bar_manager);
void bar_manager_handle_system_will_sleep(struct bar_manager* bar_manager);
void bar_manager_custom_events_trigger(struct bar_manager* bar_manager, char* name, struct env_vars* env_vars);
void bar_manager_destroy(struct bar_manager* bar_manager);
void bar_manager_serialize(struct bar_manager* bar_manager, FILE* rsp);

View file

@ -1,88 +0,0 @@
#include "custom_events.h"
struct custom_event* custom_event_create(void) {
return malloc(sizeof(struct custom_event));
}
void custom_event_init(struct custom_event* custom_event, char* name, char* notification) {
custom_event->name = name;
custom_event->notification = notification;
}
void custom_event_destroy(struct custom_event* custom_event) {
if (custom_event->name) free(custom_event->name);
if (custom_event->notification) free(custom_event->notification);
free(custom_event);
}
void custom_events_init(struct custom_events* custom_events) {
custom_events->count = 0;
// System Events
custom_events_append(custom_events, string_copy(COMMAND_SUBSCRIBE_FRONT_APP_SWITCHED), NULL);
custom_events_append(custom_events, string_copy(COMMAND_SUBSCRIBE_SPACE_CHANGE), NULL);
custom_events_append(custom_events, string_copy(COMMAND_SUBSCRIBE_DISPLAY_CHANGE), NULL);
custom_events_append(custom_events, string_copy(COMMAND_SUBSCRIBE_SYSTEM_WOKE), NULL);
custom_events_append(custom_events, string_copy(COMMAND_SUBSCRIBE_MOUSE_ENTERED), NULL);
custom_events_append(custom_events, string_copy(COMMAND_SUBSCRIBE_MOUSE_EXITED), NULL);
custom_events_append(custom_events, string_copy(COMMAND_SUBSCRIBE_MOUSE_CLICKED), NULL);
custom_events_append(custom_events, string_copy(COMMAND_SUBSCRIBE_SYSTEM_WILL_SLEEP), NULL);
}
void custom_events_append(struct custom_events* custom_events, char* name, char* notification) {
if (custom_events_get_flag_for_name(custom_events, name) > 0) {
if (name) free(name);
if (notification) free(notification);
return;
}
custom_events->count++;
custom_events->events = (struct custom_event**) realloc(
custom_events->events,
sizeof(struct custom_event*) * custom_events->count);
custom_events->events[custom_events->count - 1] = custom_event_create();
custom_events->events[custom_events->count - 1]->name = name;
custom_events->events[custom_events->count - 1]->notification = notification;
if (notification)
workspace_create_custom_observer(&g_workspace_context, notification);
}
uint64_t custom_events_get_flag_for_name(struct custom_events* custom_events, char* name) {
for (int i = 0; i < custom_events->count; i++) {
if (strcmp(name, custom_events->events[i]->name) == 0) {
return 1ULL << i;
}
}
return 0;
}
char* custom_events_get_name_for_notification(struct custom_events* custom_events, char* notification) {
for (int i = 0; i < custom_events->count; i++) {
if (!custom_events->events[i]->notification) continue;
if (strcmp(notification, custom_events->events[i]->notification) == 0) {
return custom_events->events[i]->name;
}
}
return NULL;
}
void custom_events_destroy(struct custom_events* custom_events) {
for (int i = 0; i < custom_events->count; i++) {
custom_event_destroy(custom_events->events[i]);
}
free(custom_events->events);
}
void custom_events_serialize(struct custom_events* custom_events, FILE* rsp) {
fprintf(rsp, "{\n");
for (int i = 0; i < custom_events->count; i++) {
fprintf(rsp, "\t\"%s\": {\n"
"\t\t\"bit\": %llu,\n"
"\t\t\"notification\": \"%s\"\n",
custom_events->events[i]->name,
1ULL << i,
custom_events->events[i]->notification);
if (i < custom_events->count - 1) fprintf(rsp, "\t},\n");
}
fprintf(rsp, "\t}\n}\n");
}

View file

@ -1,34 +0,0 @@
#pragma once
#include "misc/helpers.h"
#define UPDATE_FRONT_APP_SWITCHED 1ULL
#define UPDATE_SPACE_CHANGE 1ULL << 1
#define UPDATE_DISPLAY_CHANGE 1ULL << 2
#define UPDATE_SYSTEM_WOKE 1ULL << 3
#define UPDATE_MOUSE_ENTERED 1ULL << 4
#define UPDATE_MOUSE_EXITED 1ULL << 5
#define UPDATE_MOUSE_CLICKED 1ULL << 6
#define UPDATE_SYSTEM_WILL_SLEEP 1ULL << 7
extern void* g_workspace_context;
extern void workspace_create_custom_observer(void** context, char* name);
struct custom_event {
char* name;
char* notification;
};
void custom_event_init(struct custom_event* custom_event, char* name, char* notification);
struct custom_events {
uint32_t count;
struct custom_event** events;
};
void custom_events_init(struct custom_events* custom_events);
void custom_events_append(struct custom_events* custom_events, char* name, char* notification);
uint64_t custom_events_get_flag_for_name(struct custom_events* custom_events, char* name);
char* custom_events_get_name_for_notification(struct custom_events* custom_events, char* notification);
void custom_events_destroy(struct custom_events* custom_events);
void custom_events_serialize(struct custom_events* custom_events, FILE* rsp);

View file

@ -1,200 +0,0 @@
#include "display.h"
extern struct event_loop g_event_loop;
extern int g_connection;
static DISPLAY_EVENT_HANDLER(display_handler) {
if (flags & kCGDisplayAddFlag) {
struct event *event = event_create(&g_event_loop,
DISPLAY_ADDED,
(void *)(intptr_t) did);
event_loop_post(&g_event_loop, event);
} else if (flags & kCGDisplayRemoveFlag) {
struct event *event = event_create(&g_event_loop,
DISPLAY_REMOVED,
(void *)(intptr_t) did);
event_loop_post(&g_event_loop, event);
} else if (flags & kCGDisplayMovedFlag) {
struct event *event = event_create(&g_event_loop,
DISPLAY_MOVED,
(void *)(intptr_t) did);
event_loop_post(&g_event_loop, event);
} else if (flags & kCGDisplayDesktopShapeChangedFlag) {
struct event *event = event_create(&g_event_loop,
DISPLAY_RESIZED,
(void *)(intptr_t) did);
event_loop_post(&g_event_loop, event);
}
}
CFStringRef display_uuid(uint32_t did) {
CFUUIDRef uuid_ref = CGDisplayCreateUUIDFromDisplayID(did);
if (!uuid_ref) return NULL;
CFStringRef uuid_str = CFUUIDCreateString(NULL, uuid_ref);
CFRelease(uuid_ref);
return uuid_str;
}
CGRect display_bounds(uint32_t did) {
return CGDisplayBounds(did);
}
uint64_t display_space_id(uint32_t did) {
CFStringRef uuid = display_uuid(did);
if (!uuid) return 0;
uint64_t sid = SLSManagedDisplayGetCurrentSpace(g_connection, uuid);
CFRelease(uuid);
return sid;
}
uint64_t *display_space_list(uint32_t did, int *count) {
CFStringRef uuid = display_uuid(did);
if (!uuid) return NULL;
CFArrayRef display_spaces_ref = SLSCopyManagedDisplaySpaces(g_connection);
if (!display_spaces_ref) return NULL;
uint64_t *space_list = NULL;
int display_spaces_count = CFArrayGetCount(display_spaces_ref);
for (int i = 0; i < display_spaces_count; ++i) {
CFDictionaryRef display_ref = CFArrayGetValueAtIndex(display_spaces_ref, i);
CFStringRef identifier = CFDictionaryGetValue(display_ref,
CFSTR("Display Identifier"));
if (!CFEqual(uuid, identifier)) continue;
CFArrayRef spaces_ref = CFDictionaryGetValue(display_ref, CFSTR("Spaces"));
int spaces_count = CFArrayGetCount(spaces_ref);
space_list = malloc(sizeof(uint64_t) * spaces_count);
*count = spaces_count;
for (int j = 0; j < spaces_count; ++j) {
CFDictionaryRef space_ref = CFArrayGetValueAtIndex(spaces_ref, j);
CFNumberRef sid_ref = CFDictionaryGetValue(space_ref, CFSTR("id64"));
CFNumberGetValue(sid_ref, CFNumberGetType(sid_ref), &space_list[j]);
}
}
CFRelease(display_spaces_ref);
CFRelease(uuid);
return space_list;
}
int display_arrangement(uint32_t did) {
CFStringRef uuid = display_uuid(did);
if (!uuid) return 0;
CFArrayRef displays = SLSCopyManagedDisplays(g_connection);
if (!displays) return 0;
int result = 0;
int displays_count = CFArrayGetCount(displays);
for (int i = 0; i < displays_count; ++i) {
if (CFEqual(CFArrayGetValueAtIndex(displays, i), uuid)) {
result = i + 1;
break;
}
}
CFRelease(displays);
CFRelease(uuid);
return result;
}
uint32_t display_main_display_id(void) {
return CGMainDisplayID();
}
CFStringRef display_active_display_uuid(void) {
return SLSCopyActiveMenuBarDisplayIdentifier(g_connection);
}
uint32_t display_active_display_id(void) {
uint32_t result = 0;
CFStringRef uuid = display_active_display_uuid();
CFUUIDRef uuid_ref = CFUUIDCreateFromString(NULL, uuid);
result = CGDisplayGetDisplayIDFromUUID(uuid_ref);
CFRelease(uuid_ref);
CFRelease(uuid);
return result;
}
CFStringRef display_arrangement_display_uuid(int arrangement) {
CFStringRef result = NULL;
CFArrayRef displays = SLSCopyManagedDisplays(g_connection);
int displays_count = CFArrayGetCount(displays);
for (int i = 0; i < displays_count; ++i) {
if ((i+1) != arrangement) continue;
result = CFRetain(CFArrayGetValueAtIndex(displays, i));
break;
}
CFRelease(displays);
return result;
}
uint32_t display_arrangement_display_id(int arrangement) {
uint32_t result = 0;
CFArrayRef displays = SLSCopyManagedDisplays(g_connection);
int displays_count = CFArrayGetCount(displays);
for (int i = 0; i < displays_count; ++i) {
if ((i+1) != arrangement) continue;
CFUUIDRef uuid_ref = CFUUIDCreateFromString(NULL,
CFArrayGetValueAtIndex(displays, i));
result = CGDisplayGetDisplayIDFromUUID(uuid_ref);
CFRelease(uuid_ref);
break;
}
CFRelease(displays);
return result;
}
bool display_menu_bar_visible(void) {
int status = 0;
SLSGetMenuBarAutohideEnabled(g_connection, &status);
return !status;
}
CGRect display_menu_bar_rect(uint32_t did) {
CGRect bounds = {};
SLSGetRevealedMenuBarBounds(&bounds, g_connection, display_space_id(did));
return bounds;
}
uint32_t display_active_display_count(void) {
uint32_t count;
CGGetActiveDisplayList(0, NULL, &count);
return count;
}
uint32_t *display_active_display_list(uint32_t *count) {
int display_count = display_active_display_count();
uint32_t *result = malloc(sizeof(uint32_t) * display_count);
CGGetActiveDisplayList(display_count, result, count);
return result;
}
bool display_begin() {
return CGDisplayRegisterReconfigurationCallback(display_handler, NULL)
== kCGErrorSuccess;
}
bool display_end() {
return CGDisplayRemoveReconfigurationCallback(display_handler, NULL)
== kCGErrorSuccess;
}

View file

@ -1,33 +0,0 @@
#pragma once
#include "event.h"
#include "event_loop.h"
#include "misc/helpers.h"
#define DISPLAY_EVENT_HANDLER(name) void name(uint32_t did, CGDisplayChangeSummaryFlags flags, void *context)
typedef DISPLAY_EVENT_HANDLER(display_callback);
extern CFUUIDRef CGDisplayCreateUUIDFromDisplayID(uint32_t did);
extern CFArrayRef SLSCopyManagedDisplays(int cid);
extern uint64_t SLSManagedDisplayGetCurrentSpace(int cid, CFStringRef uuid);
extern CFStringRef SLSCopyBestManagedDisplayForRect(int cid, CGRect rect);
extern CGError SLSGetCurrentCursorLocation(int cid, CGPoint *point);
extern CFStringRef SLSCopyActiveMenuBarDisplayIdentifier(int cid);
extern CGError SLSGetMenuBarAutohideEnabled(int cid, int *enabled);
extern CGError SLSGetRevealedMenuBarBounds(CGRect *rect, int cid, uint64_t sid);
extern CFStringRef SLSCopyBestManagedDisplayForPoint(int cid, CGPoint point);
uint32_t display_main_display_id(void);
uint32_t display_active_display_id(void);
uint32_t display_arrangement_display_id(int arrangement);
bool display_menu_bar_visible(void);
CGRect display_menu_bar_rect(uint32_t did);
uint32_t display_active_display_count(void);
bool display_begin(void);
bool display_end(void);
CFStringRef display_uuid(uint32_t did);
CGRect display_bounds(uint32_t did);
uint64_t display_space_id(uint32_t did);
uint64_t *display_space_list(uint32_t did, int *count);
int display_arrangement(uint32_t did);

View file

@ -1,152 +0,0 @@
#include "event.h"
#include "event_loop.h"
extern struct event_loop g_event_loop;
extern struct bar_manager g_bar_manager;
extern int g_connection;
enum event_type event_type_from_string(const char *str) {
for (int i = EVENT_TYPE_UNKNOWN + 1; i < EVENT_TYPE_COUNT; ++i) {
if (string_equals(str, event_type_str[i])) return i;
}
return EVENT_TYPE_UNKNOWN;
}
struct event *event_create(struct event_loop *event_loop, enum event_type type, void *context) {
struct event *event = memory_pool_push(&event_loop->pool, struct event);
event->type = type;
event->context = context;
event->info = 0;
return event;
}
EVENT_CALLBACK(EVENT_HANDLER_DISTRIBUTED_NOTIFICATION) {
debug("%s\n", context);
bar_manager_handle_notification(&g_bar_manager, context);
return EVENT_SUCCESS;
}
EVENT_CALLBACK(EVENT_HANDLER_APPLICATION_FRONT_SWITCHED) {
debug("%s\n", __FUNCTION__);
bar_manager_handle_front_app_switch(&g_bar_manager, context);
return EVENT_SUCCESS;
}
EVENT_CALLBACK(EVENT_HANDLER_SPACE_CHANGED) {
debug("%s\n", __FUNCTION__);
bar_manager_handle_space_change(&g_bar_manager);
return EVENT_SUCCESS;
}
EVENT_CALLBACK(EVENT_HANDLER_DISPLAY_CHANGED) {
debug("%s\n", __FUNCTION__);
bar_manager_handle_display_change(&g_bar_manager);
return EVENT_SUCCESS;
}
EVENT_CALLBACK(EVENT_HANDLER_DISPLAY_ADDED) {
debug("%s\n", __FUNCTION__);
bar_manager_handle_display_change(&g_bar_manager);
bar_manager_display_changed(&g_bar_manager);
return EVENT_SUCCESS;
}
EVENT_CALLBACK(EVENT_HANDLER_DISPLAY_REMOVED) {
debug("%s\n", __FUNCTION__);
bar_manager_handle_display_change(&g_bar_manager);
bar_manager_display_changed(&g_bar_manager);
return EVENT_SUCCESS;
}
EVENT_CALLBACK(EVENT_HANDLER_DISPLAY_MOVED) {
debug("%s\n", __FUNCTION__);
bar_manager_handle_display_change(&g_bar_manager);
bar_manager_display_changed(&g_bar_manager);
return EVENT_SUCCESS;
}
EVENT_CALLBACK(EVENT_HANDLER_DISPLAY_RESIZED) {
debug("%s\n", __FUNCTION__);
bar_manager_handle_display_change(&g_bar_manager);
bar_manager_display_changed(&g_bar_manager);
return EVENT_SUCCESS;
}
EVENT_CALLBACK(EVENT_HANDLER_MENU_BAR_HIDDEN_CHANGED) {
debug("%s:\n", __FUNCTION__);
bar_manager_resize(&g_bar_manager);
return EVENT_SUCCESS;
}
EVENT_CALLBACK(EVENT_HANDLER_SYSTEM_WOKE) {
debug("%s:\n", __FUNCTION__);
bar_manager_handle_system_woke(&g_bar_manager);
return EVENT_SUCCESS;
}
EVENT_CALLBACK(EVENT_HANDLER_SYSTEM_WILL_SLEEP) {
debug("%s:\n", __FUNCTION__);
bar_manager_handle_system_will_sleep(&g_bar_manager);
return EVENT_SUCCESS;
}
EVENT_CALLBACK(EVENT_HANDLER_SHELL_REFRESH) {
debug("%s\n", __FUNCTION__);
bar_manager_update(&g_bar_manager, false);
return EVENT_SUCCESS;
}
EVENT_CALLBACK(EVENT_HANDLER_MACH_MESSAGE) {
debug("%s\n", __FUNCTION__);
if (context) handle_message_mach(context);
mach_msg_destroy(&((struct mach_buffer*) context)->message.header);
free(context);
return EVENT_SUCCESS;
}
EVENT_CALLBACK(EVENT_HANDLER_MOUSE_UP) {
debug("%s\n", __FUNCTION__);
CGPoint point = CGEventGetLocation(context);
CGEventType type = CGEventGetType(context);
uint32_t modifier_keys = CGEventGetFlags(context);
uint32_t adid = display_arrangement(display_active_display_id());
debug("EVENT_HANDLER_MOUSE_UP: D#%d (x: %.0f, y: %.0f) -> ",
adid,
point.x,
point.y );
struct bar_item* bar_item = bar_manager_get_item_by_point(&g_bar_manager,
point,
adid );
debug("item: %s\n", bar_item ? bar_item->name : "NULL");
bar_item_on_click(bar_item, type, modifier_keys);
CFRelease(context);
return EVENT_SUCCESS;
}
EVENT_CALLBACK(EVENT_HANDLER_MOUSE_ENTERED) {
debug("%s\n", __FUNCTION__);
CGPoint point = CGEventGetLocation(context);
uint32_t adid = display_arrangement(display_active_display_id());
debug("EVENT_HANDLER_MOUSE_ENTERED: D#%d (x: %.0f, y: %.0f) -> ",
adid,
point.x,
point.y );
struct bar_item* bar_item = bar_manager_get_item_by_point(&g_bar_manager,
point,
adid );
debug("item: %s\n", bar_item ? bar_item->name : "NULL");
bar_manager_handle_mouse_entered(&g_bar_manager, bar_item);
CFRelease(context);
return EVENT_SUCCESS;
}
EVENT_CALLBACK(EVENT_HANDLER_MOUSE_EXITED) {
debug("%s\n", __FUNCTION__);
debug("EVENT_HANDLER_MOUSE_EXITED \n");
bar_manager_handle_mouse_exited(&g_bar_manager);
CFRelease(context);
return EVENT_SUCCESS;
}

View file

@ -1,116 +0,0 @@
#pragma once
#include <Carbon/Carbon.h>
#include <mach/mach.h>
#include "misc/memory_pool.h"
#include "bar_manager.h"
#include "misc/log.h"
#include "message.h"
struct event_loop;
extern OSStatus SLSFindWindowByGeometry(int cid, int zero, int one, int zero_again, CGPoint *screen_point, CGPoint *window_point, uint32_t *wid, int *wcid);
#define EVENT_CALLBACK(name) uint32_t name(void *context)
typedef EVENT_CALLBACK(event_callback);
EVENT_CALLBACK(EVENT_HANDLER_APPLICATION_FRONT_SWITCHED);
EVENT_CALLBACK(EVENT_HANDLER_SPACE_CHANGED);
EVENT_CALLBACK(EVENT_HANDLER_DISPLAY_ADDED);
EVENT_CALLBACK(EVENT_HANDLER_DISPLAY_REMOVED);
EVENT_CALLBACK(EVENT_HANDLER_DISPLAY_MOVED);
EVENT_CALLBACK(EVENT_HANDLER_DISPLAY_RESIZED);
EVENT_CALLBACK(EVENT_HANDLER_DISPLAY_CHANGED);
EVENT_CALLBACK(EVENT_HANDLER_MENU_BAR_HIDDEN_CHANGED);
EVENT_CALLBACK(EVENT_HANDLER_SYSTEM_WOKE);
EVENT_CALLBACK(EVENT_HANDLER_SYSTEM_WILL_SLEEP);
EVENT_CALLBACK(EVENT_HANDLER_SHELL_REFRESH);
EVENT_CALLBACK(EVENT_HANDLER_MACH_MESSAGE);
EVENT_CALLBACK(EVENT_HANDLER_MOUSE_UP);
EVENT_CALLBACK(EVENT_HANDLER_MOUSE_ENTERED);
EVENT_CALLBACK(EVENT_HANDLER_MOUSE_EXITED);
EVENT_CALLBACK(EVENT_HANDLER_DISTRIBUTED_NOTIFICATION);
#define EVENT_QUEUED 0x0
#define EVENT_PROCESSED 0x1
#define EVENT_SUCCESS 0x0
#define EVENT_FAILURE 0x1
#define EVENT_MOUSE_IGNORE 0x2
#define event_status(e) ((e) & 0x1)
#define event_result(e) ((e) >> 0x1)
enum event_type {
EVENT_TYPE_UNKNOWN,
APPLICATION_FRONT_SWITCHED,
SPACE_CHANGED,
DISPLAY_ADDED,
DISPLAY_REMOVED,
DISPLAY_MOVED,
DISPLAY_RESIZED,
DISPLAY_CHANGED,
MENU_BAR_HIDDEN_CHANGED,
SYSTEM_WOKE,
SYSTEM_WILL_SLEEP,
SHELL_REFRESH,
MACH_MESSAGE,
MOUSE_UP,
MOUSE_ENTERED,
MOUSE_EXITED,
DISTRIBUTED_NOTIFICATION,
EVENT_TYPE_COUNT
};
static const char *event_type_str[] = {
[EVENT_TYPE_UNKNOWN] = "event_type_unknown",
[APPLICATION_FRONT_SWITCHED] = "application_front_switched",
[SPACE_CHANGED] = "space_changed",
[DISPLAY_ADDED] = "display_added",
[DISPLAY_REMOVED] = "display_removed",
[DISPLAY_MOVED] = "display_moved",
[DISPLAY_RESIZED] = "display_resized",
[DISPLAY_CHANGED] = "display_changed",
[MENU_BAR_HIDDEN_CHANGED] = "menu_bar_hidden_changed",
[SYSTEM_WOKE] = "system_woke",
[SYSTEM_WILL_SLEEP] = "system_will_sleep",
[SHELL_REFRESH] = "shell_refresh",
[MACH_MESSAGE] = "mach_message",
[MOUSE_UP] = "mouse_up",
[MOUSE_ENTERED] = "mouse_entered",
[MOUSE_EXITED] = "mouse_exited",
[DISTRIBUTED_NOTIFICATION] = "distributed_notification",
[EVENT_TYPE_COUNT] = "event_type_count"
};
static event_callback *event_handler[] = {
[APPLICATION_FRONT_SWITCHED] = EVENT_HANDLER_APPLICATION_FRONT_SWITCHED,
[SPACE_CHANGED] = EVENT_HANDLER_SPACE_CHANGED,
[DISPLAY_ADDED] = EVENT_HANDLER_DISPLAY_ADDED,
[DISPLAY_REMOVED] = EVENT_HANDLER_DISPLAY_REMOVED,
[DISPLAY_MOVED] = EVENT_HANDLER_DISPLAY_MOVED,
[DISPLAY_RESIZED] = EVENT_HANDLER_DISPLAY_RESIZED,
[DISPLAY_CHANGED] = EVENT_HANDLER_DISPLAY_CHANGED,
[MOUSE_UP] = EVENT_HANDLER_MOUSE_UP,
[MOUSE_ENTERED] = EVENT_HANDLER_MOUSE_ENTERED,
[MOUSE_EXITED] = EVENT_HANDLER_MOUSE_EXITED,
[DISTRIBUTED_NOTIFICATION] = EVENT_HANDLER_DISTRIBUTED_NOTIFICATION,
[MENU_BAR_HIDDEN_CHANGED] = EVENT_HANDLER_MENU_BAR_HIDDEN_CHANGED,
[SYSTEM_WOKE] = EVENT_HANDLER_SYSTEM_WOKE,
[SYSTEM_WILL_SLEEP] = EVENT_HANDLER_SYSTEM_WILL_SLEEP,
[SHELL_REFRESH] = EVENT_HANDLER_SHELL_REFRESH,
[MACH_MESSAGE] = EVENT_HANDLER_MACH_MESSAGE,
};
struct event {
void *context;
volatile uint32_t *info;
enum event_type type;
};
struct event *event_create(struct event_loop *event_loop, enum event_type type, void *context);
void event_destroy(struct event_loop *event_loop, struct event *event);
enum event_type event_type_from_string(const char *str);

View file

@ -1,144 +0,0 @@
#include "event_loop.h"
#include "event.h"
#ifdef STATS
struct cycle_counter {
uint64_t cycle_count;
uint64_t hit_count;
};
static struct cycle_counter queue_counters[2];
static struct cycle_counter event_counters[EVENT_TYPE_COUNT];
static inline void cycle_counter_tick(const char *name, struct cycle_counter *counter, uint64_t elapsed_cycles) {
uint64_t cycle_count = __sync_add_and_fetch(&counter->cycle_count, elapsed_cycles);
uint64_t hit_count = __sync_add_and_fetch(&counter->hit_count, 1);
fprintf(stdout, "%30s: hits %'25lld | cur %'25lld | avg %'25lld\n",
name, hit_count, elapsed_cycles, cycle_count / hit_count)
}
#endif
static bool queue_init(struct queue *queue) {
if (!memory_pool_init(&queue->pool, QUEUE_POOL_SIZE)) return false;
queue->head = memory_pool_push(&queue->pool, struct queue_item);
queue->head->data = NULL;
queue->head->next = NULL;
queue->tail = queue->head;
#ifdef DEBUG
queue->count = 0;
#endif
return true;
};
static void queue_push(struct queue *queue, struct event *event) {
bool success;
struct queue_item *tail, *new_tail;
#ifdef STATS
uint64_t begin_cycles = __rdtsc();
#endif
new_tail = memory_pool_push(&queue->pool, struct queue_item);
new_tail->data = event;
new_tail->next = NULL;
__asm__ __volatile__ ("" ::: "memory");
do {
tail = queue->tail;
success = __sync_bool_compare_and_swap(&tail->next, NULL, new_tail);
if (!success) __sync_bool_compare_and_swap(&queue->tail, tail, tail->next);
} while (!success);
__sync_bool_compare_and_swap(&queue->tail, tail, new_tail);
#ifdef DEBUG
uint64_t count = __sync_add_and_fetch(&queue->count, 1);
assert(count > 0 && count < QUEUE_MAX_COUNT);
#endif
#ifdef STATS
cycle_counter_tick(__FUNCTION__, &queue_counters[0], __rdtsc() - begin_cycles);
#endif
}
static struct event *queue_pop(struct queue *queue) {
struct queue_item *head;
#ifdef STATS
uint64_t begin_cycles = __rdtsc();
#endif
do {
head = queue->head;
if (!head->next) return NULL;
} while (!__sync_bool_compare_and_swap(&queue->head, head, head->next));
#ifdef DEBUG
uint64_t count = __sync_sub_and_fetch(&queue->count, 1);
assert(count >= 0 && count < QUEUE_MAX_COUNT);
#endif
#ifdef STATS
cycle_counter_tick(__FUNCTION__, &queue_counters[1], __rdtsc() - begin_cycles);
#endif
return head->next->data;
}
static void *event_loop_run(void *context) {
struct event_loop *event_loop = (struct event_loop *) context;
struct queue *queue = (struct queue *) &event_loop->queue;
while (event_loop->is_running) {
struct event *event = queue_pop(queue);
if (event) {
#ifdef STATS
uint64_t begin_cycles = __rdtsc();
#endif
uint32_t result = event_handler[event->type](event->context);
#ifdef STATS
cycle_counter_tick(event_type_str[event->type], &event_counters[event->type], __rdtsc() - begin_cycles);
#endif
if (event->info) *event->info = (result << 0x1) | EVENT_PROCESSED;
} else {
sem_wait(event_loop->semaphore);
}
}
return NULL;
}
void event_loop_post(struct event_loop *event_loop, struct event *event) {
assert(event_loop->is_running);
queue_push(&event_loop->queue, event);
sem_post(event_loop->semaphore);
}
bool event_loop_init(struct event_loop *event_loop) {
if (!queue_init(&event_loop->queue)) return false;
if (!memory_pool_init(&event_loop->pool, EVENT_POOL_SIZE)) return false;
event_loop->is_running = false;
#ifdef DEBUG
event_loop->count = 0;
#endif
#ifdef STATS
setlocale(LC_ALL, ""); // For fprintf digit grouping
#endif
event_loop->semaphore = sem_open("skybar_event_loop_semaphore", O_CREAT, 0600, 0);
sem_unlink("skybar_event_loop_semaphore");
return event_loop->semaphore != SEM_FAILED;
}
bool event_loop_begin(struct event_loop *event_loop) {
if (event_loop->is_running) return false;
event_loop->is_running = true;
pthread_create(&event_loop->thread, NULL, &event_loop_run, event_loop);
return true;
}
bool event_loop_end(struct event_loop *event_loop) {
if (!event_loop->is_running) return false;
event_loop->is_running = false;
pthread_join(event_loop->thread, NULL);
return true;
}

View file

@ -1,43 +0,0 @@
#pragma once
#include <semaphore.h>
#include <pthread.h>
#include "misc/memory_pool.h"
struct event;
#define EVENT_POOL_SIZE KILOBYTES(128)
#define EVENT_MAX_COUNT ((EVENT_POOL_SIZE) / (sizeof(struct event)))
#define QUEUE_POOL_SIZE KILOBYTES(16)
#define QUEUE_MAX_COUNT ((QUEUE_POOL_SIZE) / (sizeof(struct queue_item)))
struct queue_item {
struct event *data;
struct queue_item *next;
};
struct queue {
struct memory_pool pool;
struct queue_item *head;
struct queue_item *tail;
#ifdef DEBUG
volatile uint64_t count;
#endif
};
struct event_loop {
bool is_running;
pthread_t thread;
sem_t *semaphore;
struct queue queue;
struct memory_pool pool;
#ifdef DEBUG
volatile uint64_t count;
#endif
};
struct event_loop g_event_loop;
bool event_loop_init(struct event_loop *event_loop);
bool event_loop_begin(struct event_loop *event_loop);
bool event_loop_end(struct event_loop *event_loop);
void event_loop_post(struct event_loop *event_loop, struct event *event);

View file

@ -1,150 +0,0 @@
#include "graph.h"
void graph_init(struct graph* graph) {
graph->width = 0;
graph->cursor = 0;
graph->line_color = rgba_color_from_hex(0xcccccc);
graph->fill_color = rgba_color_from_hex(0xcccccc);
graph->line_width = 0.5;
graph->fill = true;
graph->overrides_fill_color = false;
graph->enabled = true;
}
void graph_setup(struct graph* graph, uint32_t width) {
graph->width = width;
graph->y = malloc(sizeof(float) * width);
memset(graph->y, 0, sizeof(float) * width);
}
float graph_get_y(struct graph* graph, uint32_t i) {
if (!graph->enabled) return 0.f;
return graph->y[ (graph->cursor + i)%graph->width ];
}
void graph_push_back(struct graph* graph, float y) {
if (!graph->enabled) return;
graph->y[graph->cursor] = y;
++graph->cursor;
graph->cursor %= graph->width;
}
uint32_t graph_get_length(struct graph* graph) {
if (graph->enabled) return graph->width;
return 0;
}
void graph_calculate_bounds(struct graph* graph, uint32_t x, uint32_t y) {
graph->bounds.origin.x = x;
graph->bounds.origin.y = y - graph->bounds.size.height / 2
+ graph->line_width;
}
void graph_draw(struct graph* graph, CGContextRef context) {
uint32_t x = graph->bounds.origin.x + (graph->rtl ? graph->width : 0);
uint32_t y = graph->bounds.origin.y;
uint32_t height = graph->bounds.size.height;
uint32_t sample_width = 1;
bool fill = graph->fill;
CGContextSaveGState(context);
CGContextSetRGBStrokeColor(context,
graph->line_color.r,
graph->line_color.g,
graph->line_color.b,
graph->line_color.a );
if (graph->overrides_fill_color)
CGContextSetRGBFillColor(context,
graph->fill_color.r,
graph->fill_color.g,
graph->fill_color.b,
graph->fill_color.a );
else
CGContextSetRGBFillColor(context,
graph->line_color.r,
graph->line_color.g,
graph->line_color.b,
0.2 * graph->line_color.a);
CGContextSetLineWidth(context, graph->line_width);
CGMutablePathRef p = CGPathCreateMutable();
uint32_t start_x = x;
if (graph->rtl) {
CGPathMoveToPoint(p,
NULL,
x,
y + graph_get_y(graph, graph->width - 1) * height);
for (int i = graph->width - 1; i > 0; --i, x -= sample_width) {
CGPathAddLineToPoint(p, NULL, x, y + graph_get_y(graph, i) * height);
}
}
else {
CGPathMoveToPoint(p, NULL, x, y + graph_get_y(graph, 0) * height);
for (int i = graph->width - 1; i > 0; --i, x += sample_width) {
CGPathAddLineToPoint(p, NULL, x, y + graph_get_y(graph, i) * height);
}
}
CGContextAddPath(context, p);
CGContextStrokePath(context);
if (fill) {
if (graph->rtl) {
CGPathAddLineToPoint(p, NULL, x + sample_width, y);
}
else {
CGPathAddLineToPoint(p, NULL, x - sample_width, y);
}
CGPathAddLineToPoint(p, NULL, start_x, y);
CGPathCloseSubpath(p);
CGContextAddPath(context, p);
CGContextFillPath(context);
}
CGPathRelease(p);
CGContextRestoreGState(context);
}
void graph_serialize(struct graph* graph, FILE* rsp) {
fprintf(rsp, ",\n"
"\t\"graph\": {\n"
"\t\t\"graph.color\": \"0x%x\",\n"
"\t\t\"graph.fill_color\": \"0x%x\",\n"
"\t\t\"graph.line_width\": \"%f\",\n"
"\t\t\"data\": [\n",
hex_from_rgba_color(graph->line_color),
hex_from_rgba_color(graph->fill_color),
graph->line_width);
int counter = 0;
for (int i = 0; i < graph->width; i++) {
if (counter++ > 0) fprintf(rsp, ",\n");
fprintf(rsp, "\t\t\t\"%f\"",
graph->y[i]);
}
fprintf(rsp, "\n\t]\n\t}");
}
void graph_destroy(struct graph* graph) {
if (!graph->enabled) return;
free(graph->y);
}
bool graph_parse_sub_domain(struct graph* graph, FILE* rsp, struct token property, char* message) {
if (token_equals(property, PROPERTY_COLOR)) {
graph->line_color = rgba_color_from_hex(token_to_uint32t(get_token(&message)));
return true;
} else if (token_equals(property, PROPERTY_FILL_COLOR)) {
graph->fill_color = rgba_color_from_hex(token_to_uint32t(get_token(&message)));
graph->overrides_fill_color = true;
return true;
} else if (token_equals(property, PROPERTY_LINE_WIDTH)) {
graph->line_width = token_to_float(get_token(&message));
return true;
}
else {
fprintf(rsp, "Unknown property: %s \n", property.text);
printf("Unknown property: %s \n", property.text);
}
return false;
}

View file

@ -1,31 +0,0 @@
#pragma once
#include "misc/helpers.h"
struct graph {
bool rtl;
bool fill;
bool enabled;
bool overrides_fill_color;
float* y;
uint32_t width;
uint32_t cursor;
float line_width;
CGRect bounds;
struct rgba_color line_color;
struct rgba_color fill_color;
};
void graph_init(struct graph* graph);
void graph_setup(struct graph* graph, uint32_t width);
void graph_push_back(struct graph* graph, float y);
float graph_get_y(struct graph* graph, uint32_t i);
uint32_t graph_get_length(struct graph* graph);
void graph_calculate_bounds(struct graph* graph, uint32_t x, uint32_t y);
void graph_draw(struct graph* graph, CGContextRef context);
void graph_destroy(struct graph* graph);
void graph_serialize(struct graph* graph, FILE* rsp);
bool graph_parse_sub_domain(struct graph* graph, FILE* rsp, struct token property, char* message);

View file

@ -1,124 +0,0 @@
#include "group.h"
struct group* group_create() {
struct group* group = malloc(sizeof(struct group));
memset(group, 0, sizeof(struct group));
return group;
}
void group_init(struct group* group) {
group->num_members = 0;
group->members = NULL;
}
bool group_is_item_member(struct group* group, struct bar_item* item) {
for (uint32_t i = 0; i < group->num_members; i++) {
if (group->members[i] == item) return true;
}
return false;
}
void group_add_member(struct group* group, struct bar_item* item) {
if (group_is_item_member(group, item)) return;
if (item->group && item->group->members && item->group->members[0] == item) {
for (int i = 1; i < item->group->num_members; i++) {
group_add_member(group, item->group->members[i]);
}
} else {
group->num_members++;
group->members = realloc(group->members, sizeof(struct bar_item*)*group->num_members);
group->members[group->num_members - 1] = item;
item->group = group;
}
}
bool group_is_first_member(struct group* group, struct bar_item* item) {
if (!group_is_item_member(group, item)) return false;
if (group->num_members > 1) {return group->members[1] == item; }
return false;
}
uint32_t group_get_length(struct group* group) {
uint32_t length = 0;
for (int i = 1; i < group->num_members; i++) {
if (group->members[i]->drawing) {
if (group->members[i]->position == POSITION_RIGHT) {
if (i > 1 && !group->members[i]->has_const_width)
length += group->members[i]->background.padding_right;
if (i < group->num_members - 1 && !group->members[i]->has_const_width)
length += group->members[i]->background.padding_left;
}
else {
if (i > 1 && !group->members[i]->has_const_width)
length += group->members[i]->background.padding_left;
if (i < group->num_members - 1 && !group->members[i]->has_const_width)
length += group->members[i]->background.padding_right;
}
length += bar_item_get_length(group->members[i], false);
}
}
return length;
}
uint32_t group_count_members_drawn(struct group* group) {
int count = 0;
for (int i = 1; i < group->num_members; i++) {
if (group->members[i]->drawing) {
count++;
}
}
return count;
}
void group_remove_member(struct group* group, struct bar_item* bar_item) {
if (group->num_members <= 0) return;
struct bar_item* tmp[group->num_members - 1];
int count = 0;
for (int i = 0; i < group->num_members; i++) {
if (group->members[i] == bar_item) continue;
tmp[count++] = group->members[i];
}
group->num_members--;
group->members = realloc(group->members, sizeof(struct bar_item*)*group->num_members);
memcpy(group->members, tmp, sizeof(struct bar_item*)*group->num_members);
}
void group_destroy(struct group* group) {
for (int i = 0; i < group->num_members; i++) {
group->members[i]->group = NULL;
}
if (group->members) free(group->members);
free(group);
}
void group_calculate_bounds(struct group* group, uint32_t x, uint32_t y, bool rtl) {
background_calculate_bounds(&group->members[0]->background, x, y);
group->members[0]->background.bounds.size.width = group_get_length(group)
+ (rtl
? 0
: group_count_members_drawn(group));
group->members[0]->background.bounds.origin.x = x;
group->members[0]->background.bounds.origin.y = y - group->members[0]->background.bounds.size.height / 2
+ group->members[0]->y_offset;
}
void group_draw(struct group* group, CGContextRef context) {
background_draw(&group->members[0]->background, context);
}
void group_serialize(struct group* group, FILE* rsp) {
fprintf(rsp, ",\n"
"\t\"bracket\": [\n");
int counter = 0;
for (int i = 1; i < group->num_members; i++) {
if (!group->members[i]) continue;
if (counter++ > 0) fprintf(rsp, ",\n");
fprintf(rsp, "\t\t\"%s\"",
group->members[i]->name);
}
fprintf(rsp, "\n\t]");
}

View file

@ -1,23 +0,0 @@
#pragma once
#include "bar_item.h"
struct group {
CGRect bounds;
uint32_t num_members;
struct bar_item** members;
};
struct group* group_create();
void group_init(struct group* group);
void group_set_name(struct group* group, char* _name);
void group_add_member(struct group* group, struct bar_item* item);
void group_remove_member(struct group* group, struct bar_item* bar_item);
uint32_t group_get_length(struct group* group);
bool group_is_first_member(struct group* group, struct bar_item* item);
uint32_t group_count_members_drawn(struct group* group);
void group_calculate_bounds(struct group* group, uint32_t x, uint32_t y, bool rtl);
void group_draw(struct group* group, CGContextRef context);
void group_destroy(struct group* group);
void group_serialize(struct group* group, FILE* rsp);

View file

@ -1,158 +0,0 @@
#include "image.h"
#include "misc/helpers.h"
#include "shadow.h"
void image_init(struct image* image) {
image->enabled = false;
image->image_ref = NULL;
image->data_ref = NULL;
image->bounds = CGRectNull;
image->size = CGSizeZero;
image->scale = 1.0;
shadow_init(&image->shadow);
}
bool image_set_enabled(struct image* image, bool enabled) {
if (image->enabled == enabled) return false;
image->enabled = enabled;
return true;
}
bool image_load(struct image* image, char* path, FILE* rsp) {
char* res_path = resolve_path(path);
if (!file_exists(res_path)) {
printf("File %s not found!\n", res_path);
fprintf(rsp, "File %s not found!\n", res_path);
free(res_path);
return false;
}
CGDataProviderRef data_provider = CGDataProviderCreateWithFilename(res_path);
CGImageRef new_image_ref = NULL;
if (strlen(res_path) > 3 && string_equals(&res_path[strlen(res_path) - 4], ".png"))
new_image_ref = CGImageCreateWithPNGDataProvider(data_provider,
NULL,
false,
kCGRenderingIntentDefault);
else {
new_image_ref = CGImageCreateWithJPEGDataProvider(data_provider,
NULL,
false,
kCGRenderingIntentDefault);
}
if (data_provider && new_image_ref)
image_set_image(image,
new_image_ref,
(CGRect){{0,0},
{CGImageGetWidth(new_image_ref),
CGImageGetHeight(new_image_ref)}},
true );
else {
printf("Could not open image file at: %s!\n", res_path);
fprintf(rsp, "Could not open image file at: %s!\n", res_path);
}
CGDataProviderRelease(data_provider);
free(res_path);
return true;
}
bool image_data_equals(struct image* image, CFDataRef new_data_ref) {
bool equals = false;
if (image->image_ref && image->data_ref) {
uint32_t old_len = CFDataGetLength(image->data_ref);
uint32_t new_len = CFDataGetLength(new_data_ref);
if (old_len == new_len)
equals = memcmp(CFDataGetBytePtr(image->data_ref),
CFDataGetBytePtr(new_data_ref),
old_len )
== 0;
}
return equals;
}
void image_copy(struct image* image, CGImageRef source) {
if (source) image->image_ref = CGImageCreateCopy(source);
}
bool image_set_image(struct image* image, CGImageRef new_image_ref, CGRect bounds, bool forced) {
CFDataRef new_data_ref = CGDataProviderCopyData(CGImageGetDataProvider(new_image_ref));
if (!forced && image_data_equals(image, new_data_ref)) {
CFRelease(new_data_ref);
CGImageRelease(new_image_ref);
return false;
}
if (image->image_ref) CGImageRelease(image->image_ref);
if (image->data_ref) CFRelease(image->data_ref);
image->size = bounds.size;
image->bounds = (CGRect){{bounds.origin.x, bounds.origin.y},
{bounds.size.width * image->scale,
bounds.size.height * image->scale}};
image->image_ref = new_image_ref;
image->data_ref = new_data_ref;
image->enabled = true;
return true;
}
bool image_set_scale(struct image* image, float scale) {
if (scale == image->scale) return false;
image->scale = scale;
image->bounds = (CGRect){{image->bounds.origin.x, image->bounds.origin.y},
{image->size.width * image->scale,
image->size.height * image->scale}};
return true;
}
void image_calculate_bounds(struct image* image, uint32_t x, uint32_t y) {
image->bounds.origin.x = x;
image->bounds.origin.y = y - image->bounds.size.height / 2;
}
void image_draw(struct image* image, CGContextRef context) {
if (!image->image_ref) return;
// if (image->shadow.enabled) {
// CGContextSaveGState(context);
// CGRect sbounds = shadow_get_bounds(&image->shadow, image->bounds);
// CGContextDrawImage(context, sbounds, image->image_ref);
// CGContextClipToMask(context, sbounds, image->image_ref);
// CGContextSetRGBFillColor(context, image->shadow.color.r, image->shadow.color.g, image->shadow.color.b, image->shadow.color.a);
// CGContextFillRect(context, sbounds);
// CGContextRestoreGState(context);
// }
CGContextDrawImage(context, image->bounds, image->image_ref);
}
void image_clear_pointers(struct image* image) {
image->image_ref = NULL;
image->data_ref = NULL;
}
void image_destroy(struct image* image) {
CGImageRelease(image->image_ref);
if (image->data_ref) CFRelease(image->data_ref);
image_clear_pointers(image);
}
bool image_parse_sub_domain(struct image* image, FILE* rsp, struct token property, char* message) {
if (token_equals(property, PROPERTY_DRAWING))
return image_set_enabled(image,
evaluate_boolean_state(get_token(&message),
image->enabled) );
else if (token_equals(property, PROPERTY_SCALE))
return image_set_scale(image, token_to_float(get_token(&message)));
else {
fprintf(rsp, "Unknown property: %s \n", property.text);
printf("Unknown property: %s \n", property.text);
}
return false;
}

View file

@ -1,30 +0,0 @@
#pragma once
#include "shadow.h"
#include "misc/defines.h"
struct image {
bool enabled;
float scale;
CGSize size;
CGRect bounds;
CGImageRef image_ref;
CFDataRef data_ref;
struct shadow shadow;
};
void image_init(struct image* image);
bool image_set_enabled(struct image* image, bool enabled);
bool image_data_equals(struct image* image, CFDataRef new_data_ref);
void image_copy(struct image* image, CGImageRef source);
bool image_set_image(struct image* image, CGImageRef new_image_ref, CGRect bounds, bool forced);
bool image_load(struct image* image, char* path, FILE* rsp);
void image_calculate_bounds(struct image* image, uint32_t x, uint32_t y);
void image_draw(struct image* image, CGContextRef context);
void image_clear_pointers(struct image* image);
void image_destroy(struct image* image);
bool image_parse_sub_domain(struct image* image, FILE* rsp, struct token property, char* message);

View file

@ -1,164 +0,0 @@
#include "mach.h"
#include <mach/message.h>
#include <stdint.h>
mach_port_t mach_get_bs_port() {
mach_port_name_t task = mach_task_self();
mach_port_t bs_port;
if (task_get_special_port(task,
TASK_BOOTSTRAP_PORT,
&bs_port ) != KERN_SUCCESS) {
return 0;
}
mach_port_t port;
if (bootstrap_look_up(bs_port,
"git.felix.sketchybar",
&port ) != KERN_SUCCESS) {
return 0;
}
return port;
}
void mach_receive_message(mach_port_t port, struct mach_buffer* buffer, bool timeout) {
*buffer = (struct mach_buffer) { 0 };
mach_msg_return_t msg_return;
if (timeout)
msg_return = mach_msg(&buffer->message.header,
MACH_RCV_MSG | MACH_RCV_TIMEOUT,
0,
sizeof(struct mach_buffer),
port,
10,
MACH_PORT_NULL );
else
msg_return = mach_msg(&buffer->message.header,
MACH_RCV_MSG,
0,
sizeof(struct mach_buffer),
port,
MACH_MSG_TIMEOUT_NONE,
MACH_PORT_NULL );
if (msg_return != MACH_MSG_SUCCESS) {
buffer->message.descriptor.address = NULL;
}
}
bool mach_send_message(mach_port_t port, char* message, uint32_t len, bool await_response) {
if (!message || !port) {
if (message) free(message);
return false;
}
mach_port_t response_port;
if (await_response) {
mach_port_name_t task = mach_task_self();
if (mach_port_allocate(task, MACH_PORT_RIGHT_RECEIVE,
&response_port ) != KERN_SUCCESS) {
return false;
}
if (mach_port_insert_right(task, response_port,
response_port,
MACH_MSG_TYPE_MAKE_SEND)!= KERN_SUCCESS) {
return false;
}
}
struct mach_message msg = { 0 };
msg.header.msgh_remote_port = port;
if (await_response) {
msg.header.msgh_local_port = response_port;
msg.header.msgh_id = response_port;
msg.header.msgh_bits = MACH_MSGH_BITS_SET(MACH_MSG_TYPE_COPY_SEND,
MACH_MSG_TYPE_MAKE_SEND_ONCE,
0,
MACH_MSGH_BITS_COMPLEX );
} else {
msg.header.msgh_bits = MACH_MSGH_BITS_SET(MACH_MSG_TYPE_MOVE_SEND_ONCE
& MACH_MSGH_BITS_REMOTE_MASK,
0,
0,
MACH_MSGH_BITS_COMPLEX );
}
msg.header.msgh_size = sizeof(struct mach_message);
msg.msgh_descriptor_count = 1;
msg.descriptor.address = message;
msg.descriptor.size = len * sizeof(char);
msg.descriptor.copy = MACH_MSG_VIRTUAL_COPY;
msg.descriptor.deallocate = await_response;
msg.descriptor.type = MACH_MSG_OOL_DESCRIPTOR;
mach_msg_return_t msg_return = mach_msg(&msg.header,
MACH_SEND_MSG,
sizeof(struct mach_message),
0,
MACH_PORT_NULL,
MACH_MSG_TIMEOUT_NONE,
MACH_PORT_NULL );
if (await_response) {
struct mach_buffer buffer = { 0 };
mach_receive_message(response_port, &buffer, true);
if (buffer.message.descriptor.address)
printf("%s", (char*)buffer.message.descriptor.address);
mach_msg_destroy(&buffer.message.header);
}
return msg_return == MACH_MSG_SUCCESS;
}
static void* mach_connection_handler(void *context) {
struct mach_server* server = context;
while (server->is_running) {
struct mach_buffer* buffer = malloc(sizeof(struct mach_buffer));
mach_receive_message(server->port, buffer, false);
server->handler(buffer);
}
return NULL;
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
bool mach_server_begin(struct mach_server* mach_server, mach_handler handler) {
mach_server->task = mach_task_self();
if (mach_port_allocate(mach_server->task,
MACH_PORT_RIGHT_RECEIVE,
&mach_server->port ) != KERN_SUCCESS) {
return false;
}
if (mach_port_insert_right(mach_server->task,
mach_server->port,
mach_server->port,
MACH_MSG_TYPE_MAKE_SEND) != KERN_SUCCESS) {
return false;
}
if (task_get_special_port(mach_server->task,
TASK_BOOTSTRAP_PORT,
&mach_server->bs_port) != KERN_SUCCESS) {
return false;
}
if (bootstrap_register(mach_server->bs_port,
"git.felix.sketchybar",
mach_server->port ) != KERN_SUCCESS) {
return false;
}
mach_server->handler = handler;
mach_server->is_running = true;
pthread_create(&mach_server->thread, NULL, &mach_connection_handler,
mach_server );
return true;
}
#pragma clang diagnostic pop

View file

@ -1,38 +0,0 @@
#pragma once
#include <bootstrap.h>
#include <mach/mach.h>
#include <mach/message.h>
#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
struct mach_message {
mach_msg_header_t header;
mach_msg_size_t msgh_descriptor_count;
mach_msg_ool_descriptor_t descriptor;
};
struct mach_buffer {
struct mach_message message;
mach_msg_trailer_t trailer;
};
#define MACH_HANDLER(name) void name(struct mach_buffer* message)
typedef MACH_HANDLER(mach_handler);
struct mach_server {
bool is_running;
mach_port_name_t task;
mach_port_t port;
mach_port_t bs_port;
pthread_t thread;
mach_handler* handler;
};
struct mach_server g_mach_server;
bool mach_server_begin(struct mach_server* mach_server, mach_handler handler);
bool mach_send_message(mach_port_t port, char* message, uint32_t len,
bool await_response);
mach_port_t mach_get_bs_port();

View file

@ -1,630 +0,0 @@
#include "message.h"
#include "misc/defines.h"
extern struct event_loop g_event_loop;
extern struct bar_manager g_bar_manager;
extern bool g_verbose;
// Syntax: sketchybar -m --subscribe <name> <event>
static void handle_domain_subscribe(FILE* rsp, struct token domain, char* message) {
struct token name = get_token(&message);
int item_index_for_name = bar_manager_get_item_index_for_name(&g_bar_manager,
name.text );
if (item_index_for_name < 0) return;
struct bar_item* bar_item = g_bar_manager.bar_items[item_index_for_name];
bar_item_parse_subscribe_message(bar_item, message);
}
// Syntax: sketchybar -m --trigger <event>
static void handle_domain_trigger(FILE* rsp, struct token domain, char* message) {
struct token event = get_token(&message);
struct env_vars env_vars;
env_vars_init(&env_vars);
struct token token = get_token(&message);
while (token.text && token.length > 0) {
struct key_value_pair key_value_pair = get_key_value_pair(token.text, '=');
if (key_value_pair.key && key_value_pair.value) {
env_vars_set(&env_vars,
string_copy(key_value_pair.key),
string_copy(key_value_pair.value));
}
token = get_token(&message);
}
bar_manager_custom_events_trigger(&g_bar_manager, event.text, &env_vars);
env_vars_destroy(&env_vars);
}
// Syntax: sketchybar -m --push <name> <y>
static void handle_domain_push(FILE* rsp, struct token domain, char* message) {
struct token name = get_token(&message);
struct token y = get_token(&message);
int item_index_for_name = bar_manager_get_item_index_for_name(&g_bar_manager,
name.text );
if (item_index_for_name < 0) return;
struct bar_item* bar_item = g_bar_manager.bar_items[item_index_for_name];
graph_push_back(&bar_item->graph, token_to_float(y));
bar_item_needs_update(bar_item);
}
// Syntax sketchybar -m --rename <old name> <new name>
static void handle_domain_rename(FILE* rsp, struct token domain, char* message) {
struct token old_name = get_token(&message);
struct token new_name = get_token(&message);
int item_index_for_old_name = bar_manager_get_item_index_for_name(&g_bar_manager,
old_name.text);
int item_index_for_new_name = bar_manager_get_item_index_for_name(&g_bar_manager,
new_name.text);
if (item_index_for_old_name < 0 || item_index_for_new_name >= 0) {
fprintf(rsp, "Could not rename item: %s -> %s \n", old_name.text,
new_name.text);
printf("Could not rename item: %s -> %s \n", old_name.text,
new_name.text);
return;
}
bar_item_set_name(g_bar_manager.bar_items[item_index_for_old_name],
token_to_string(new_name) );
}
// Syntax: sketchybar -m --clone <name> <parent name>
static void handle_domain_clone(FILE* rsp, struct token domain, char* message) {
struct token name = get_token(&message);
struct token parent = get_token(&message);
struct token modifier = get_token(&message);
struct bar_item* parent_item = NULL;
int parent_index = bar_manager_get_item_index_for_name(&g_bar_manager,
parent.text );
if (parent_index >= 0)
parent_item = g_bar_manager.bar_items[parent_index];
else {
printf("Parent Item: %s does not exist \n", parent.text);
fprintf(rsp, "Parent Item: %s does not exist \n", parent.text);
return;
}
if (bar_manager_get_item_index_for_name(&g_bar_manager, name.text) >= 0) {
fprintf(rsp, "Item %s already exists \n", name.text);
return;
}
struct bar_item* bar_item = bar_manager_create_item(&g_bar_manager);
bar_item_inherit_from_item(bar_item, parent_item);
bar_item_set_name(bar_item, token_to_string(name));
if (token_equals(modifier, ARGUMENT_COMMON_VAL_BEFORE))
bar_manager_move_item(&g_bar_manager, bar_item, parent_item, true);
else if (token_equals(modifier, ARGUMENT_COMMON_VAL_AFTER))
bar_manager_move_item(&g_bar_manager, bar_item, parent_item, false);
bar_item_needs_update(bar_item);
}
// Syntax: sketchybar -m --add <item|component identifer> <name>[:parent] [<position>]
static void handle_domain_add(FILE* rsp, struct token domain, char* message) {
struct token command = get_token(&message);
if (token_equals(command, COMMAND_ADD_EVENT)) {
struct token event = get_token(&message);
if (strlen(message) > 0)
custom_events_append(&g_bar_manager.custom_events,
token_to_string(event),
token_to_string(get_token(&message)));
else custom_events_append(&g_bar_manager.custom_events,
token_to_string(event),
NULL );
return;
}
struct token name = get_token(&message);
struct token position = get_token(&message);
if (bar_manager_get_item_index_for_name(&g_bar_manager, name.text) >= 0) {
fprintf(rsp, "Item %s already exists \n", name.text);
return;
}
struct bar_item* bar_item = bar_manager_create_item(&g_bar_manager);
bar_item_set_type(bar_item, command.text[0]);
bar_item_set_position(bar_item, position.text[0]);
if (position.text[0] == POSITION_POPUP) {
char* pair = string_copy(position.text);
struct key_value_pair key_value_pair = get_key_value_pair(pair, '.');
if (key_value_pair.key && key_value_pair.value) {
int item_index_for_name = bar_manager_get_item_index_for_name(&g_bar_manager,
key_value_pair.value);
if (item_index_for_name < 0) {
fprintf(rsp, "Name: %s not found in bar items \n", key_value_pair.value);
printf("Name: %s not found in bar items \n", key_value_pair.value);
free(pair);
return;
}
struct bar_item* target_item = g_bar_manager.bar_items[item_index_for_name];
popup_add_item(&target_item->popup, bar_item);
}
free(pair);
}
bar_item_set_name(bar_item, token_to_string(name));
if (token_equals(command, COMMAND_ADD_ITEM)) {
} else if (command.length > 0) {
if (bar_item->type == BAR_COMPONENT_GRAPH) {
struct token width = get_token(&message);
graph_setup(&bar_item->graph, token_to_uint32t(width));
}
else if (bar_item->type == BAR_COMPONENT_ALIAS) {
char* tmp_name = string_copy(name.text);
struct key_value_pair key_value_pair = get_key_value_pair(tmp_name, ',');
if (!key_value_pair.key || !key_value_pair.value)
alias_setup(&bar_item->alias, token_to_string(name), NULL);
else
alias_setup(&bar_item->alias,
string_copy(key_value_pair.key),
string_copy(key_value_pair.value));
free(tmp_name);
}
else if (bar_item->type == BAR_COMPONENT_GROUP) {
struct token member = position;
while (member.text && member.length > 0) {
int index = bar_manager_get_item_index_for_name(&g_bar_manager,
member.text );
if (index >= 0)
group_add_member(bar_item->group, g_bar_manager.bar_items[index]);
else {
printf("Item %s not found! \n", member.text);
fprintf(rsp, "Item %s not found! \n", member.text);
}
member = get_token(&message);
}
}
} else {
printf("Command: %s not found \n", command.text);
fprintf(rsp, "Command: %s not found \n", command.text);
return;
}
bar_item_needs_update(bar_item);
}
// Syntax: sketchybar -m --set <name> <property>=<value> ... <property>=<value>
// Syntax: sketchybar -m --default <property>=<value> ... <property>=<value>
static void handle_domain_default(FILE* rsp, struct token domain, char* message) {
bar_item_parse_set_message(&g_bar_manager.default_item, message, rsp);
}
// Syntax: sketchybar -m --bar <property>=<value> ... <property>=<value>
static bool handle_domain_bar(FILE *rsp, struct token domain, char *message) {
struct token command = get_token(&message);
bool needs_refresh = false;
if (token_equals(command, PROPERTY_MARGIN)) {
struct token token = get_token(&message);
g_bar_manager.margin = token_to_int(token);
needs_refresh = true;
} else if (token_equals(command, PROPERTY_YOFFSET)) {
struct token token = get_token(&message);
g_bar_manager.y_offset = token_to_int(token);
needs_refresh = true;
} else if (token_equals(command, PROPERTY_BLUR_RADIUS)) {
struct token token = get_token(&message);
needs_refresh = bar_manager_set_background_blur(&g_bar_manager,
token_to_uint32t(token));
} else if (token_equals(command, PROPERTY_FONT_SMOOTHING)) {
struct token state = get_token(&message);
needs_refresh = bar_manager_set_font_smoothing(&g_bar_manager,
evaluate_boolean_state(state,
g_bar_manager.font_smoothing));
} else if (token_equals(command, PROPERTY_SHADOW)) {
struct token state = get_token(&message);
needs_refresh = bar_manager_set_shadow(&g_bar_manager,
evaluate_boolean_state(state,
g_bar_manager.shadow));
} else if (token_equals(command, PROPERTY_NOTCH_WIDTH)) {
struct token token = get_token(&message);
needs_refresh = bar_manager_set_notch_width(&g_bar_manager,
token_to_uint32t(token));
} else if (token_equals(command, PROPERTY_HIDDEN)) {
struct token state = get_token(&message);
uint32_t adid = 0;
if (token_equals(state, "current")) {
adid = display_arrangement(display_active_display_id());
if (adid > 0 && adid <= g_bar_manager.bar_count)
needs_refresh = bar_manager_set_hidden(&g_bar_manager,
adid,
!g_bar_manager.bars[adid - 1]->hidden);
else
printf("No bar on display %u \n", adid);
} else needs_refresh = bar_manager_set_hidden(&g_bar_manager,
adid,
evaluate_boolean_state(state,
g_bar_manager.any_bar_hidden));
} else if (token_equals(command, PROPERTY_TOPMOST)) {
struct token token = get_token(&message);
needs_refresh = bar_manager_set_topmost(&g_bar_manager,
evaluate_boolean_state(token,
g_bar_manager.topmost));
} else if (token_equals(command, PROPERTY_DISPLAY)) {
struct token position = get_token(&message);
if (position.length > 0)
needs_refresh = bar_manager_set_display(&g_bar_manager,
position.text[0]);
else {
printf("value for %s must be either 'main' or 'all'.\n", command.text);
fprintf(rsp, "value for %s must be either 'main' or 'all'.\n", command.text);
}
} else if (token_equals(command, PROPERTY_POSITION)) {
struct token position = get_token(&message);
if (position.length > 0)
needs_refresh = bar_manager_set_position(&g_bar_manager, position.text[0]);
else {
printf("value for %s must be either 'top' or 'bottom'.\n", command.text);
fprintf(rsp, "value for %s must be either 'top' or 'bottom'.\n", command.text);
}
}
else
needs_refresh = background_parse_sub_domain(&g_bar_manager.background, rsp, command, message);
return needs_refresh;
}
static char* reformat_batch_key_value_pair(struct token token) {
struct key_value_pair key_value_pair = get_key_value_pair(token.text, '=');
if (!key_value_pair.key) return NULL;
char* rbr_msg = malloc((strlen(key_value_pair.key) + (key_value_pair.value
? strlen(key_value_pair.value)
: 0)
+ 3) * sizeof(char) );
pack_key_value_pair(rbr_msg, &key_value_pair);
return rbr_msg;
}
static char* get_batch_line(char** message) {
char* cursor = *message;
bool end_of_batch = false;
while (true) {
if (*cursor == '\0' && *(cursor + 1) == '\0') {
end_of_batch = true;
break;
}
if (*cursor == '\0' && *(cursor + 1) == '-')
break;
cursor++;
}
char* rbr_msg = malloc(sizeof(char) * (cursor - *message + 2));
memcpy(rbr_msg, *message, sizeof(char) * (cursor - *message + 1));
*(rbr_msg + (cursor - *message + 1)) = '\0';
if (end_of_batch) *message = cursor;
else *message = cursor + 1;
return rbr_msg;
}
// Syntax: sketchybar -m --query bar
// Syntax: sketchybar -m --query item <name>
// Syntax: sketchybar -m --query defaults
// Syntax: sketchybar -m --query events
static void handle_domain_query(FILE* rsp, struct token domain, char* message) {
struct token token = get_token(&message);
if (token_equals(token, COMMAND_QUERY_DEFAULT_ITEMS)) {
print_all_menu_items(rsp);
} else if (token_equals(token, COMMAND_QUERY_ITEM)) {
struct token name = get_token(&message);
int item_index_for_name = bar_manager_get_item_index_for_name(&g_bar_manager,
name.text );
if (item_index_for_name < 0) {
fprintf(rsp, "Name: %s not found in bar items \n", name.text);
printf("Name: %s not found in bar items \n", name.text);
return;
}
bar_item_serialize(g_bar_manager.bar_items[item_index_for_name], rsp);
} else if (token_equals(token, COMMAND_QUERY_BAR)) {
bar_manager_serialize(&g_bar_manager, rsp);
} else if (token_equals(token, COMMAND_QUERY_DEFAULTS)) {
bar_item_serialize(&g_bar_manager.default_item, rsp);
} else if (token_equals(token, COMMAND_QUERY_EVENTS)) {
custom_events_serialize(&g_bar_manager.custom_events, rsp);
} else {
struct token name = token;
int item_index_for_name = bar_manager_get_item_index_for_name(&g_bar_manager,
name.text );
if (item_index_for_name < 0) {
fprintf(rsp, "Not a valid query, or item: %s not found \n", name.text);
printf("Not a valid query, or item: %s not found \n", name.text);
return;
}
bar_item_serialize(g_bar_manager.bar_items[item_index_for_name], rsp);
}
}
// Syntax: sketchybar -m --remove <name>
static void handle_domain_remove(FILE* rsp, struct token domain, char* message) {
struct token name = get_token(&message);
uint32_t count = 0;
struct bar_item** bar_items = NULL;
if (name.length > 1 && name.text[0] == REGEX_DELIMITER
&& name.text[name.length - 1] == REGEX_DELIMITER ) {
char* regstring = malloc(sizeof(char)*(name.length - 1));
memcpy(regstring, &name.text[1], name.length - 2);
regstring[name.length - 2] = '\0';
regex_t regex;
int reti;
reti = regcomp(&regex, regstring, 0);
free(regstring);
if (reti) {
fprintf(rsp, "Could not compile regex: %s \n", name.text);
printf("Could not compile regex: %s \n", name.text);
return;
}
for (int i = 0; i < g_bar_manager.bar_item_count; i++) {
struct bar_item* bar_item = g_bar_manager.bar_items[i];
reti = regexec(&regex, bar_item->name, 0, NULL, 0);
if (!reti) {
count++;
bar_items = realloc(bar_items, sizeof(struct bar_item*)*count);
bar_items[count - 1] = bar_item;
}
else if (reti != REG_NOMATCH) {
char buf[100];
regerror(reti, &regex, buf, sizeof(buf));
fprintf(rsp, "Regex match failed: %s\n", buf);
printf("Regex match failed: %s\n", buf);
return;
}
}
regfree(&regex);
}
else {
int item_index_for_name = bar_manager_get_item_index_for_name(&g_bar_manager,
name.text );
if (item_index_for_name < 0) {
fprintf(rsp, "Name: %s not found in bar items \n", name.text);
printf("Name: %s not found in bar items \n", name.text);
return;
}
bar_items = realloc(bar_items, sizeof(struct bar_item*));
bar_items[0] = g_bar_manager.bar_items[item_index_for_name];
count = 1;
}
if (!bar_items || count == 0) return;
for (int i = 0; i < count; i++) {
bar_manager_remove_item(&g_bar_manager, bar_items[i]);
}
if (bar_items) free(bar_items);
}
// Syntax: sketchybar -m --move <name> </> <reference>
static void handle_domain_move(FILE* rsp, struct token domain, char* message) {
struct token name = get_token(&message);
struct token direction = get_token(&message);
struct token reference = get_token(&message);
int item_index = bar_manager_get_item_index_for_name(&g_bar_manager, name.text);
int reference_item_index = bar_manager_get_item_index_for_name(&g_bar_manager, reference.text);
if (item_index < 0 || reference_item_index < 0) {
fprintf(rsp, "Name: %s or %s not found in bar items \n", name.text, reference.text);
printf("Name: %s or %s not found in bar items \n", name.text, reference.text);
return;
}
bar_manager_move_item(&g_bar_manager,
g_bar_manager.bar_items[item_index],
g_bar_manager.bar_items[reference_item_index],
token_equals(direction, ARGUMENT_COMMON_VAL_BEFORE));
bar_item_needs_update(g_bar_manager.bar_items[item_index]);
}
static void handle_domain_order(FILE* rsp, struct token domain, char* message) {
struct bar_item* ordering[g_bar_manager.bar_item_count];
memset(ordering, 0, sizeof(struct bar_item*)*g_bar_manager.bar_item_count);
uint32_t count = 0;
struct token name = get_token(&message);
while (name.text && name.length > 0) {
int index = bar_manager_get_item_index_for_name(&g_bar_manager, name.text);
if (index < 0) {
fprintf(rsp, "Item: %s does not exist in bar items.\n", name.text);
printf("Item: %s does not exist in bar items.\n", name.text);
name = get_token(&message);
continue;
}
ordering[count] = g_bar_manager.bar_items[index];
count++;
name = get_token(&message);
}
bar_manager_sort(&g_bar_manager, ordering, count);
bar_manager_refresh(&g_bar_manager, false);
}
void handle_message_mach(struct mach_buffer* buffer) {
if (!buffer->message.descriptor.address) return;
char* message = buffer->message.descriptor.address;
char* response = NULL;
size_t length = 0;
FILE* rsp = open_memstream(&response, &length);
fprintf(rsp, "");
bar_manager_freeze(&g_bar_manager);
struct token command = get_token(&message);
bool bar_needs_refresh = false;
while (command.text && command.length > 0) {
if (token_equals(command, DOMAIN_SET)) {
struct token name = get_token(&message);
uint32_t count = 0;
struct bar_item** bar_items = NULL;
if (name.length > 1 && name.text[0] == REGEX_DELIMITER
&& name.text[name.length - 1] == REGEX_DELIMITER ) {
char* regstring = malloc(sizeof(char)*(name.length - 1));
memcpy(regstring, &name.text[1], name.length - 2);
regstring[name.length - 2] = '\0';
regex_t regex;
int reti;
reti = regcomp(&regex, regstring, 0);
free(regstring);
if (reti) {
fprintf(rsp, "Could not compile regex: %s \n", name.text);
printf("Could not compile regex: %s \n", name.text);
break;
}
for (int i = 0; i < g_bar_manager.bar_item_count; i++) {
struct bar_item* bar_item = g_bar_manager.bar_items[i];
reti = regexec(&regex, bar_item->name, 0, NULL, 0);
if (!reti) {
count++;
bar_items = realloc(bar_items, sizeof(struct bar_item*)*count);
bar_items[count - 1] = bar_item;
}
else if (reti != REG_NOMATCH) {
char buf[100];
regerror(reti, &regex, buf, sizeof(buf));
fprintf(rsp, "Regex match failed: %s\n", buf);
printf("Regex match failed: %s\n", buf);
break;
}
}
regfree(&regex);
}
else {
int item_index_for_name = bar_manager_get_item_index_for_name(&g_bar_manager, name.text);
if (item_index_for_name < 0) {
fprintf(rsp, "Name: %s not found in bar items \n", name.text);
printf("Name: %s not found in bar items \n", name.text);
break;
}
bar_items = realloc(bar_items, sizeof(struct bar_item*));
bar_items[0] = g_bar_manager.bar_items[item_index_for_name];
count = 1;
}
if (!bar_items || count == 0) return;
struct token token = get_token(&message);
while (token.text && token.length > 0) {
for (int i = 0; i < count; i++) {
struct token tmp = {string_copy(token.text), token.length};
char* rbr_msg = reformat_batch_key_value_pair(tmp);
free(tmp.text);
if (!rbr_msg) break;
bar_item_parse_set_message(bar_items[i], rbr_msg, rsp);
free(rbr_msg);
}
if (message && message[0] == '-') break;
token = get_token(&message);
}
free(bar_items);
}
else if (token_equals(command, DOMAIN_DEFAULT)) {
struct token token = get_token(&message);
while (token.text && token.length > 0) {
char* rbr_msg = reformat_batch_key_value_pair(token);
if (!rbr_msg) break;
handle_domain_default(rsp, command, rbr_msg);
free(rbr_msg);
if (message && message[0] == '-') break;
token = get_token(&message);
}
} else if (token_equals(command, DOMAIN_BAR)) {
struct token token = get_token(&message);
while (token.text && token.length > 0) {
char* rbr_msg = reformat_batch_key_value_pair(token);
if (!rbr_msg) break;
bar_needs_refresh |= handle_domain_bar(rsp, command, rbr_msg);
free(rbr_msg);
if (message && message[0] == '-') break;
token = get_token(&message);
}
} else if (token_equals(command, DOMAIN_ADD)) {
char* rbr_msg = get_batch_line(&message);
handle_domain_add(rsp, command, rbr_msg);
free(rbr_msg);
} else if (token_equals(command, DOMAIN_CLONE)) {
char* rbr_msg = get_batch_line(&message);
handle_domain_clone(rsp, command, rbr_msg);
free(rbr_msg);
} else if (token_equals(command, DOMAIN_SUBSCRIBE)) {
char* rbr_msg = get_batch_line(&message);
handle_domain_subscribe(rsp, command, rbr_msg);
free(rbr_msg);
} else if (token_equals(command, DOMAIN_PUSH)) {
char* rbr_msg = get_batch_line(&message);
handle_domain_push(rsp, command, rbr_msg);
free(rbr_msg);
} else if (token_equals(command, DOMAIN_UPDATE)) {
bar_manager_update_space_components(&g_bar_manager, true);
bar_manager_update(&g_bar_manager, true);
bar_needs_refresh = true;
} else if (token_equals(command, DOMAIN_TRIGGER)) {
char* rbr_msg = get_batch_line(&message);
handle_domain_trigger(rsp, command, rbr_msg);
free(rbr_msg);
} else if (token_equals(command, DOMAIN_QUERY)) {
char* rbr_msg = get_batch_line(&message);
handle_domain_query(rsp, command, rbr_msg);
free(rbr_msg);
} else if (token_equals(command, DOMAIN_REORDER)) {
char* rbr_msg = get_batch_line(&message);
handle_domain_order(rsp, command, rbr_msg);
free(rbr_msg);
} else if (token_equals(command, DOMAIN_MOVE)) {
char* rbr_msg = get_batch_line(&message);
handle_domain_move(rsp, command, rbr_msg);
free(rbr_msg);
} else if (token_equals(command, DOMAIN_REMOVE)) {
char* rbr_msg = get_batch_line(&message);
handle_domain_remove(rsp, command, rbr_msg);
bar_needs_refresh = true;
free(rbr_msg);
} else if (token_equals(command, DOMAIN_RENAME)) {
char* rbr_msg = get_batch_line(&message);
handle_domain_rename(rsp, command, rbr_msg);
free(rbr_msg);
} else if (token_equals(command, DOMAIN_EXIT)) {
bar_manager_destroy(&g_bar_manager);
exit(0);
} else {
char* rbr_msg = get_batch_line(&message);
fprintf(rsp, "unknown domain %s\n", command.text);
printf("unknown domain %s\n", command.text);
free(rbr_msg);
}
command = get_token(&message);
}
bar_manager_unfreeze(&g_bar_manager);
if (bar_needs_refresh) {
bar_manager_resize(&g_bar_manager);
bar_manager_refresh(&g_bar_manager, true);
}
else {
bar_manager_refresh(&g_bar_manager, false);
}
if (rsp) fclose(rsp);
mach_send_message(buffer->message.header.msgh_remote_port, response,
length,
false );
if (response) free(response);
}
MACH_HANDLER(mach_message_handler) {
struct event *event = event_create(&g_event_loop, MACH_MESSAGE, message);
event_loop_post(&g_event_loop, event);
}

View file

@ -1,18 +0,0 @@
#pragma once
#include <regex.h>
#include "alias.h"
#include "background.h"
#include "bar_item.h"
#include "bar_manager.h"
#include "display.h"
#include "group.h"
#include "mach.h"
#include "event.h"
#include "event_loop.h"
#include "misc/helpers.h"
#include "misc/defines.h"
MACH_HANDLER(mach_message_handler);
void handle_message_mach(struct mach_buffer* buffer);

View file

@ -1,137 +0,0 @@
#pragma once
#define DOMAIN_ADD "--add"
#define COMMAND_ADD_ITEM "item"
#define COMMAND_ADD_COMPONENT "component"
#define COMMAND_ADD_EVENT "event"
#define DOMAIN_UPDATE "--update"
#define DOMAIN_PUSH "--push"
#define DOMAIN_TRIGGER "--trigger"
#define DOMAIN_DEFAULT "--default"
#define COMMAND_DEFAULT_RESET "reset"
#define DOMAIN_CLONE "--clone"
#define DOMAIN_RENAME "--rename"
#define DOMAIN_REORDER "--reorder"
#define DOMAIN_REMOVE "--remove"
#define DOMAIN_MOVE "--move"
#define DOMAIN_SET "--set"
#define DOMAIN_EXIT "--exit"
#define SUB_DOMAIN_ICON "icon"
#define SUB_DOMAIN_LABEL "label"
#define SUB_DOMAIN_BACKGROUND "background"
#define SUB_DOMAIN_GRAPH "graph"
#define SUB_DOMAIN_ALIAS "alias"
#define SUB_DOMAIN_POPUP "popup"
#define SUB_DOMAIN_SHADOW "shadow"
#define SUB_DOMAIN_IMAGE "image"
#define PROPERTY_FONT "font"
#define PROPERTY_COLOR "color"
#define PROPERTY_HIGHLIGHT "highlight"
#define PROPERTY_HIGHLIGHT_COLOR "highlight_color"
#define PROPERTY_PADDING_LEFT "padding_left"
#define PROPERTY_PADDING_RIGHT "padding_right"
#define PROPERTY_HEIGHT "height"
#define PROPERTY_BORDER_COLOR "border_color"
#define PROPERTY_BORDER_WIDTH "border_width"
#define PROPERTY_CORNER_RADIUS "corner_radius"
#define PROPERTY_FILL_COLOR "fill_color"
#define PROPERTY_LINE_WIDTH "line_width"
#define PROPERTY_BLUR_RADIUS "blur_radius"
#define PROPERTY_DRAWING "drawing"
#define PROPERTY_DISTANCE "distance"
#define PROPERTY_ANGLE "angle"
#define PROPERTY_SCALE "scale"
#define PROPERTY_UPDATES "updates"
#define PROPERTY_POSITION "position"
#define PROPERTY_ASSOCIATED_DISPLAY "associated_display"
#define PROPERTY_ASSOCIATED_SPACE "associated_space"
#define PROPERTY_UPDATE_FREQ "update_freq"
#define PROPERTY_SCRIPT "script"
#define PROPERTY_CLICK_SCRIPT "click_script"
#define PROPERTY_ICON "icon"
#define PROPERTY_YOFFSET "y_offset"
#define PROPERTY_WIDTH "width"
#define PROPERTY_LABEL "label"
#define PROPERTY_CACHE_SCRIPTS "cache_scripts"
#define PROPERTY_LAZY "lazy"
#define PROPERTY_IGNORE_ASSOCIATION "ignore_association"
#define DOMAIN_BAR "--bar"
#define PROPERTY_POSITION "position"
#define PROPERTY_MARGIN "margin"
#define PROPERTY_DISPLAY "display"
#define PROPERTY_TOPMOST "topmost"
#define PROPERTY_HIDDEN "hidden"
#define PROPERTY_FONT_SMOOTHING "font_smoothing"
#define PROPERTY_SHADOW "shadow"
#define PROPERTY_ALIGN "align"
#define PROPERTY_NOTCH_WIDTH "notch_width"
#define PROPERTY_HORIZONTAL "horizontal"
#define DOMAIN_SUBSCRIBE "--subscribe"
#define COMMAND_SUBSCRIBE_FRONT_APP_SWITCHED "front_app_switched"
#define COMMAND_SUBSCRIBE_SPACE_CHANGE "space_change"
#define COMMAND_SUBSCRIBE_DISPLAY_CHANGE "display_change"
#define COMMAND_SUBSCRIBE_SYSTEM_WOKE "system_woke"
#define COMMAND_SUBSCRIBE_SYSTEM_WILL_SLEEP "system_will_sleep"
#define COMMAND_SUBSCRIBE_MOUSE_ENTERED "mouse.entered"
#define COMMAND_SUBSCRIBE_MOUSE_EXITED "mouse.exited"
#define COMMAND_SUBSCRIBE_MOUSE_CLICKED "mouse.clicked"
#define DOMAIN_QUERY "--query"
#define COMMAND_QUERY_DEFAULT_ITEMS "default_menu_items"
#define COMMAND_QUERY_ITEM "item"
#define COMMAND_QUERY_DEFAULTS "defaults"
#define COMMAND_QUERY_BAR "bar"
#define COMMAND_QUERY_EVENTS "events"
#define ARGUMENT_COMMON_VAL_ON "on"
#define ARGUMENT_COMMON_VAL_TRUE "true"
#define ARGUMENT_COMMON_VAL_ONE "1"
#define ARGUMENT_COMMON_VAL_YES "yes"
#define ARGUMENT_COMMON_VAL_OFF "off"
#define ARGUMENT_COMMON_VAL_FALSE "false"
#define ARGUMENT_COMMON_VAL_ZERO "0"
#define ARGUMENT_COMMON_VAL_NO "no"
#define ARGUMENT_COMMON_VAL_TOGGLE "toggle"
#define ARGUMENT_COMMON_VAL_BEFORE "before"
#define ARGUMENT_COMMON_VAL_AFTER "after"
#define ARGUMENT_UPDATES_WHEN_SHOWN "when_shown"
#define ARGUMENT_DYNAMIC "dynamic"
#define POSITION_TOP 't'
#define POSITION_BOTTOM 'b'
#define POSITION_LEFT 'l'
#define POSITION_RIGHT 'r'
#define POSITION_CENTER 'c'
#define POSITION_POPUP 'p'
#define POSITION_CENTER_LEFT 'q'
#define POSITION_CENTER_RIGHT 'e'
#define DISPLAY_MAIN 'm'
#define DISPLAY_ALL 'a'
#define BAR_ITEM 'i'
#define BAR_COMPONENT_GRAPH 'g'
#define BAR_COMPONENT_SPACE 's'
#define BAR_COMPONENT_ALIAS 'a'
#define BAR_COMPONENT_GROUP 'b'
#define BAR_PLUGIN 'p'
#define REGEX_DELIMITER '/'

View file

@ -1,71 +0,0 @@
#pragma once
struct key_value_pair {
char* key;
char* value;
};
struct env_vars {
uint32_t count;
struct key_value_pair** vars;
};
static inline void env_vars_init(struct env_vars* env_vars) {
env_vars->vars = NULL;
env_vars->count = 0;
}
static inline void env_vars_unset(struct env_vars* env_vars, char* key) {
struct key_value_pair* key_value_pair = NULL;
for (int i = 0; i < env_vars->count; i++) {
if (strcmp(env_vars->vars[i]->key, key) == 0) key_value_pair = env_vars->vars[i];
}
if (key_value_pair == NULL) return;
if (env_vars->count == 1) {
free(env_vars->vars);
env_vars->vars = NULL;
env_vars->count = 0;
} else {
struct key_value_pair* tmp[env_vars->count - 1];
int count = 0;
for (int i = 0; i < env_vars->count; i++) {
if (env_vars->vars[i] == key_value_pair) continue;
tmp[count++] = env_vars->vars[i];
}
env_vars->count--;
env_vars->vars = realloc(env_vars->vars, sizeof(struct key_value_pair*)*env_vars->count);
memcpy(env_vars->vars, tmp, sizeof(struct key_value_pair*)*env_vars->count);
}
if (key_value_pair->key) free(key_value_pair->key);
if (key_value_pair->value) free(key_value_pair->value);
free(key_value_pair);
}
static inline void env_vars_set(struct env_vars* env_vars, char* key, char* value) {
env_vars_unset(env_vars, key);
env_vars->count++;
env_vars->vars = realloc(env_vars->vars, env_vars->count * sizeof(struct key_value_pair*));
env_vars->vars[env_vars->count - 1] = malloc(sizeof(struct key_value_pair));
env_vars->vars[env_vars->count - 1]->key = key;
env_vars->vars[env_vars->count - 1]->value = value;
}
static inline char* env_vars_get_value_for_key(struct env_vars* env_vars, char* key) {
for (int i = 0; i < env_vars->count; i++) {
if (strcmp(env_vars->vars[i]->key, key) == 0) return env_vars->vars[i]->value;
}
return NULL;
}
static inline void env_vars_destroy(struct env_vars* env_vars) {
for (int i = 0; i < env_vars->count; i++) {
if (env_vars->vars[i]->key) free(env_vars->vars[i]->key);
if (env_vars->vars[i]->value) free(env_vars->vars[i]->value);
free(env_vars->vars[i]);
}
free(env_vars->vars);
}

View file

@ -1,387 +0,0 @@
#pragma once
#include <CoreFoundation/CoreFoundation.h>
#include <CoreGraphics/CoreGraphics.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include "env_vars.h"
#include "defines.h"
#define array_count(a) (sizeof((a)) / sizeof(*(a)))
#define MAXLEN 512
#define FORK_TIMEOUT 60
extern CFArrayRef SLSCopyManagedDisplaySpaces(int cid);
extern uint32_t SLSGetActiveSpace(int cid);
extern int g_connection;
struct signal_args {
struct env_vars env_vars;
void *entity;
void *param1;
};
struct rgba_color {
float r;
float g;
float b;
float a;
};
struct token {
char *text;
unsigned int length;
};
struct notification {
char* name;
char* info;
};
static inline struct notification* notification_create() {
struct notification* notification = malloc(sizeof(struct notification));
memset(notification, 0, sizeof(struct notification));
return notification;
}
static inline void notification_destroy(struct notification* notification) {
if (notification->name) free(notification->name);
if (notification->info) free(notification->info);
free(notification);
}
static inline uint32_t hex_from_rgba_color(struct rgba_color rgba_color) {
uint32_t result = 0;
result += ((uint32_t)(rgba_color.a * 255.0)) << 24;
result += ((uint32_t)(rgba_color.r * 255.0)) << 16;
result += ((uint32_t)(rgba_color.g * 255.0)) << 8;
result += ((uint32_t)(rgba_color.b * 255.0)) << 0;
return result;
}
static inline struct rgba_color rgba_color_from_hex(uint32_t color) {
struct rgba_color result;
result.r = ((color >> 16) & 0xff) / 255.0;
result.g = ((color >> 8) & 0xff) / 255.0;
result.b = ((color >> 0) & 0xff) / 255.0;
result.a = ((color >> 24) & 0xff) / 255.0;
return result;
}
static inline struct key_value_pair get_key_value_pair(char *token, char split) {
struct key_value_pair key_value_pair;
key_value_pair.key = token;
while (*token) {
if (token[0] == split) break;
++token;
}
if (*token != split) {
key_value_pair.key = NULL;
key_value_pair.value = NULL;
} else if (token[1]) {
*token = '\0';
key_value_pair.value = token + 1;
} else {
*token = '\0';
key_value_pair.value = NULL;
}
return key_value_pair;
}
static inline void pack_key_value_pair(char* cursor, struct key_value_pair* key_value_pair) {
uint32_t key_len = strlen(key_value_pair->key);
uint32_t val_len = key_value_pair->value ? strlen(key_value_pair->value) : 0;
memcpy(cursor, key_value_pair->key, key_len);
cursor += key_len;
*cursor++ = '\0';
memcpy(cursor, key_value_pair->value, val_len);
cursor += val_len;
*cursor++ = '\0';
*cursor++ = '\0';
}
static inline bool is_root(void) {
return getuid() == 0 || geteuid() == 0;
}
static inline bool string_equals(const char *a, const char *b) {
return a && b && strcmp(a, b) == 0;
}
static inline char* get_type_description(uint32_t type) {
switch (type) {
case kCGEventLeftMouseUp:
return "left";
case kCGEventRightMouseUp:
return "right";
default:
return "other";
}
}
static inline char* get_modifier_description(uint32_t modifier) {
if (modifier & kCGEventFlagMaskShift)
return "shift";
else if (modifier & kCGEventFlagMaskControl)
return "ctrl";
else if (modifier & kCGEventFlagMaskAlternate)
return "alt";
else if (modifier & kCGEventFlagMaskCommand)
return "cmd";
else
return "none";
}
static inline bool token_equals(struct token token, char *match) {
char *at = match;
for (int i = 0; i < token.length; ++i, ++at) {
if ((*at == 0) || (token.text[i] != *at)) {
return false;
}
}
return *at == 0;
}
static inline char *token_to_string(struct token token) {
char *result = malloc(token.length + 1);
if (!result) return NULL;
memcpy(result, token.text, token.length);
result[token.length] = '\0';
return result;
}
static inline uint32_t token_to_uint32t(struct token token) {
char buffer[token.length + 1];
memcpy(buffer, token.text, token.length);
buffer[token.length] = '\0';
return strtoul(buffer, NULL, 0);
}
static inline int token_to_int(struct token token) {
char buffer[token.length + 1];
memcpy(buffer, token.text, token.length);
buffer[token.length] = '\0';
return (int) strtol(buffer, NULL, 0);
}
static inline float token_to_float(struct token token) {
char buffer[token.length + 1];
memcpy(buffer, token.text, token.length);
buffer[token.length] = '\0';
return strtof(buffer, NULL);
}
static inline struct token get_token(char **message) {
struct token token;
token.text = *message;
while (**message) {
++(*message);
}
token.length = *message - token.text;
if ((*message)[0] == '\0' && (*message)[1] != '\0') {
++(*message);
} else {
// NOTE(koekeishiya): don't go past the null-terminator
}
return token;
}
static inline bool evaluate_boolean_state(struct token state, bool previous_state) {
if (token_equals(state, ARGUMENT_COMMON_VAL_ON) || token_equals(state, ARGUMENT_COMMON_VAL_YES) || token_equals(state, ARGUMENT_COMMON_VAL_TRUE) || token_equals(state, ARGUMENT_COMMON_VAL_ONE)) return true;
else if (token_equals(state, ARGUMENT_COMMON_VAL_TOGGLE)) return !previous_state;
else return false;
}
static inline uint32_t get_set_bit_position(uint32_t mask) {
if (mask == 0) return UINT32_MAX;
uint32_t pos = 0;
while (!(mask & 1)) {
mask >>= 1;
pos++;
}
return pos;
}
static inline void draw_rect(CGContextRef context, CGRect region, struct rgba_color* fill_color, uint32_t corner_radius, uint32_t line_width, struct rgba_color* stroke_color, bool clear) {
CGContextSetLineWidth(context, line_width);
if (stroke_color) CGContextSetRGBStrokeColor(context, stroke_color->r, stroke_color->g, stroke_color->b, stroke_color->a);
CGContextSetRGBFillColor(context, fill_color->r, fill_color->g, fill_color->b, fill_color->a);
if (clear) CGContextClearRect(context, region);
CGMutablePathRef path = CGPathCreateMutable();
CGRect inset_region = CGRectInset(region, (float)(line_width) / 2.f, (float)(line_width) / 2.f);
if (corner_radius > inset_region.size.height / 2.f || corner_radius > inset_region.size.width / 2.f)
corner_radius = inset_region.size.height > inset_region.size.width ? inset_region.size.width / 2.f : inset_region.size.height / 2.f;
CGPathAddRoundedRect(path, NULL, inset_region, corner_radius, corner_radius);
CGContextAddPath(context, path);
CGContextDrawPath(context, kCGPathFillStroke);
CFRelease(path);
}
static inline CGRect cgrect_mirror_y(CGRect rect, float y) {
CGRect mirrored_rect = rect;
mirrored_rect.origin.y = 2*y - rect.origin.y;
return mirrored_rect;
}
static inline bool cgrect_contains_point(CGRect* r, CGPoint* p) {
return p->x >= r->origin.x && p->x <= r->origin.x + r->size.width &&
p->y >= r->origin.y && p->y <= r->origin.y + r->size.height;
}
static inline char *string_escape_quote(char *s) {
if (!s) return NULL;
char *cursor = s;
int num_quotes = 0;
while (*cursor) {
if (*cursor == '"') ++num_quotes;
++cursor;
}
if (!num_quotes) return NULL;
int size_in_bytes = (int)(cursor - s) + num_quotes;
char *result = malloc(sizeof(char) * (size_in_bytes+1));
result[size_in_bytes] = '\0';
for (char *dst = result, *cursor = s; *cursor; ++cursor) {
if (*cursor == '"') *dst++ = '\\';
*dst++ = *cursor;
}
return result;
}
static inline char *cfstring_copy(CFStringRef string) {
CFIndex num_bytes = CFStringGetMaximumSizeForEncoding(CFStringGetLength(string), kCFStringEncodingUTF8);
char *result = malloc(num_bytes + 1);
if (!result) return NULL;
if (!CFStringGetCString(string, result, num_bytes + 1, kCFStringEncodingUTF8)) {
free(result);
result = NULL;
}
return result;
}
static inline char *string_copy(char *s) {
int length = strlen(s);
char *result = malloc(length + 1);
if (!result) return NULL;
memcpy(result, s, length);
result[length] = '\0';
return result;
}
static inline char* read_file(char* path) {
int fd = open(path, O_RDONLY);
int len = lseek(fd, 0, SEEK_END);
char* file = mmap(0, len, PROT_READ, MAP_PRIVATE, fd, 0);
close(fd);
free(path);
return string_copy(file);
}
static inline char* resolve_path(char* path) {
if (path[0] == '~') {
char* home = getenv("HOME");
char buf[512];
snprintf(buf, sizeof(buf), "%s%s", home, &path[1]);
free(path);
return string_copy(buf);
}
return path;
}
static inline bool file_exists(char *filename) {
struct stat buffer;
if (stat(filename, &buffer) != 0) {
return false;
}
if (buffer.st_mode & S_IFDIR) {
return false;
}
return true;
}
static inline bool ensure_executable_permission(char *filename) {
struct stat buffer;
if (stat(filename, &buffer) != 0) {
return false;
}
bool is_executable = buffer.st_mode & S_IXUSR;
if (!is_executable && chmod(filename, S_IXUSR | buffer.st_mode) != 0) {
return false;
}
return true;
}
static inline bool sync_exec(char *command, struct env_vars *env_vars) {
if (env_vars) {
for (int i = 0; i < env_vars->count; i++) {
setenv(env_vars->vars[i]->key, env_vars->vars[i]->value, 1);
}
}
char *exec[] = { "/usr/bin/env", "sh", "-c", command, NULL};
return execvp(exec[0], exec);
}
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
static inline bool fork_exec(char *command, struct env_vars* env_vars) {
int pid = vfork();
if (pid == -1) return false;
if (pid != 0) return true;
alarm(FORK_TIMEOUT);
exit(sync_exec(command, env_vars));
}
#pragma clang diagnostic pop
static inline int mission_control_index(uint64_t sid) {
uint64_t result = 0;
int desktop_cnt = 1;
CFArrayRef display_spaces_ref = SLSCopyManagedDisplaySpaces(g_connection);
int display_spaces_count = CFArrayGetCount(display_spaces_ref);
for (int i = 0; i < display_spaces_count; ++i) {
CFDictionaryRef display_ref = CFArrayGetValueAtIndex(display_spaces_ref, i);
CFArrayRef spaces_ref = CFDictionaryGetValue(display_ref, CFSTR("Spaces"));
int spaces_count = CFArrayGetCount(spaces_ref);
for (int j = 0; j < spaces_count; ++j) {
CFDictionaryRef space_ref = CFArrayGetValueAtIndex(spaces_ref, j);
CFNumberRef sid_ref = CFDictionaryGetValue(space_ref, CFSTR("id64"));
CFNumberGetValue(sid_ref, CFNumberGetType(sid_ref), &result);
if (sid == result) goto out;
++desktop_cnt;
}
}
desktop_cnt = 0;
out:
CFRelease(display_spaces_ref);
return desktop_cnt;
}
static inline uint32_t current_space(void) {
return mission_control_index(SLSGetActiveSpace(g_connection));
}

View file

@ -1,30 +0,0 @@
#ifndef LOG_H
#define LOG_H
extern bool g_verbose;
static inline void debug(const char *format, ...) {
if (!g_verbose) return;
va_list args;
va_start(args, format);
vfprintf(stdout, format, args);
va_end(args);
}
static inline void warn(const char *format, ...) {
va_list args;
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
}
static inline void error(const char *format, ...) {
va_list args;
va_start(args, format);
vfprintf(stderr, format, args);
va_end(args);
exit(EXIT_FAILURE);
}
#endif

View file

@ -1,39 +0,0 @@
#pragma once
#include <stdlib.h>
#include <stdbool.h>
#include <sys/mman.h>
#define KILOBYTES(value) ((value) * 1024ULL)
#define MEGABYTES(value) (KILOBYTES(value) * 1024ULL)
#define GIGABYTES(value) (MEGABYTES(value) * 1024ULL)
struct memory_pool {
void *memory;
uint64_t size;
volatile uint64_t used;
};
static inline bool memory_pool_init(struct memory_pool *pool, uint64_t size) {
pool->used = 0;
pool->size = size;
pool->memory = mmap(0, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
return pool->memory != NULL;
}
#define memory_pool_push(p, t) memory_pool_push_size(p, sizeof(t))
static inline void *memory_pool_push_size(struct memory_pool *pool, uint64_t size) {
for (;;) {
uint64_t used = pool->used;
uint64_t new_used = used + size;
if (new_used < pool->size) {
if (__sync_bool_compare_and_swap(&pool->used, used, new_used)) {
return pool->memory + used;
}
} else {
if (__sync_bool_compare_and_swap(&pool->used, used, size)) {
return pool->memory;
}
}
}
}

View file

@ -1,42 +0,0 @@
#include "mouse.h"
extern struct event_loop g_event_loop;
static pascal OSStatus mouse_handler(EventHandlerCallRef next, EventRef e, void *data) {
switch (GetEventKind(e)) {
case kEventMouseUp: {
struct event *event = event_create(&g_event_loop,
MOUSE_UP,
(void *) CFRetain(CopyEventCGEvent(e)));
event_loop_post(&g_event_loop, event);
break;
}
case kEventMouseEntered: {
struct event *event = event_create(&g_event_loop,
MOUSE_ENTERED,
(void *) CFRetain(CopyEventCGEvent(e)));
event_loop_post(&g_event_loop, event);
break;
}
case kEventMouseExited: {
struct event *event = event_create(&g_event_loop,
MOUSE_EXITED,
(void *) CFRetain(CopyEventCGEvent(e)));
event_loop_post(&g_event_loop, event);
break;
}
default:
break;
}
return CallNextEventHandler(next, e);
}
void mouse_begin(void) {
InstallEventHandler(GetEventDispatcherTarget(),
NewEventHandlerUPP(mouse_handler),
GetEventTypeCount(mouse_events),
mouse_events, 0, 0);
}

View file

@ -1,12 +0,0 @@
#pragma once
#include <Carbon/Carbon.h>
#include "event_loop.h"
#include "event.h"
static const EventTypeSpec mouse_events [] = {
{ kEventClassMouse, kEventMouseDown },
{ kEventClassMouse, kEventMouseUp },
{ kEventClassMouse, kEventMouseEntered },
{ kEventClassMouse, kEventMouseExited }
};
void mouse_begin(void);

View file

@ -1,222 +0,0 @@
#include "popup.h"
#include "bar_item.h"
#include "bar_manager.h"
void popup_init(struct popup* popup) {
popup->drawing = false;
popup->horizontal = false;
popup->overrides_cell_size = false;
popup->anchor = (CGPoint){0, 0};
popup->y_offset = 0;
popup->adid = 0;
popup->align = POSITION_LEFT;
popup->num_items = 0;
popup->cell_size = 30;
popup->items = NULL;
background_init(&popup->background);
popup->background.border_color = rgba_color_from_hex(0xffff0000);
popup->background.color = rgba_color_from_hex(0x44000000);
}
void popup_calculate_bounds(struct popup* popup) {
uint32_t y = popup->background.border_width;
uint32_t x = 0;
uint32_t width = 0;
uint32_t height = 0;
for (int j = 0; j < popup->num_items; j++) {
struct bar_item* bar_item = NULL;
if (popup->horizontal) bar_item = popup->items[j];
else bar_item = popup->items[popup->num_items - 1 - j];
if (!bar_item->drawing) continue;
uint32_t cell_height = bar_item_get_height(bar_item) > popup->cell_size
? bar_item_get_height(bar_item)
: popup->cell_size;
uint32_t item_width = bar_item->background.padding_right
+ bar_item->background.padding_left
+ bar_item_calculate_bounds(bar_item,
cell_height,
x,
y + cell_height / 2);
if (item_width > width && !popup->horizontal) width = item_width;
if (cell_height > height && popup->horizontal) height = cell_height;
if (popup->horizontal) x += item_width;
else y += cell_height;
}
if (popup->horizontal) {
width = x;
y += height;
}
y += popup->background.border_width;
popup->background.bounds.size.width = width;// + popup->background.border_width/2;
popup->background.bounds.size.height = y;
}
void popup_create_window(struct popup* popup) {
window_create(&popup->window, (CGRect){{popup->anchor.x, popup->anchor.y},
{popup->background.bounds.size.width,
popup->background.bounds.size.height}});
if (!popup->background.shadow.enabled)
window_disable_shadow(&popup->window);
window_set_level(&popup->window, kCGScreenSaverWindowLevelKey);
CGContextSetInterpolationQuality(popup->window.context, kCGInterpolationNone);
context_set_font_smoothing(popup->window.context, g_bar_manager.font_smoothing);
popup->drawing = true;
}
void popup_close_window(struct popup* popup) {
window_close(&popup->window);
popup->drawing = false;
}
void popup_add_item(struct popup* popup, struct bar_item* bar_item) {
popup->num_items++;
popup->items = realloc(popup->items,
sizeof(struct bar_item*)*popup->num_items);
popup->items[popup->num_items - 1] = bar_item;
}
bool popup_contains_item(struct popup* popup, struct bar_item* bar_item) {
for (int i = 0; i < popup->num_items; i++) {
if (popup->items[i] == bar_item) return true;
}
return false;
}
void popup_remove_item(struct popup* popup, struct bar_item* bar_item) {
if (popup->num_items == 0 || !popup_contains_item(popup, bar_item))
return;
else if (popup->num_items == 1) {
free(popup->items);
popup->items = NULL;
popup->num_items = 0;
return;
}
struct bar_item* tmp[popup->num_items - 1];
int count = 0;
for (int i = 0; i < popup->num_items; i++) {
if (popup->items[i] == bar_item) continue;
tmp[count++] = popup->items[i];
}
popup->num_items--;
popup->items = realloc(popup->items,
sizeof(struct bar_item*)*popup->num_items);
memcpy(popup->items, tmp, sizeof(struct bar_item*)*popup->num_items);
}
void popup_set_anchor(struct popup* popup, CGPoint anchor, uint32_t adid) {
if (popup->anchor.x != anchor.x
|| popup->anchor.y != anchor.y + popup->y_offset) {
popup->anchor = anchor;
popup->anchor.y += popup->y_offset;
SLSMoveWindow(g_connection, popup->window.id, &popup->anchor);
}
popup->adid = adid;
}
void popup_set_drawing(struct popup* popup, bool drawing) {
if (!drawing && popup->drawing) popup_close_window(popup);
else if (drawing && !popup->drawing) popup_create_window(popup);
}
void popup_draw(struct popup* popup) {
if (!popup->drawing) return;
SLSOrderWindow(g_connection, popup->window.id, -1, 0);
window_resize(&popup->window, (CGRect){{popup->anchor.x, popup->anchor.y},
{popup->background.bounds.size.width,
popup->background.bounds.size.height}});
draw_rect(popup->window.context,
popup->background.bounds,
&popup->background.color,
popup->background.corner_radius,
popup->background.border_width,
&popup->background.border_color,
true );
for (int i = 0; i < popup->num_items; i++) {
struct bar_item* bar_item = popup->items[i];
if (!bar_item->drawing) continue;
if (bar_item->update_mask & UPDATE_MOUSE_ENTERED
|| bar_item->update_mask & UPDATE_MOUSE_EXITED) {
CGRect tracking_rect = cgrect_mirror_y(bar_item_construct_bounding_rect(bar_item),
popup->background.bounds.size.height / 2. );
tracking_rect.origin.y -= tracking_rect.size.height;
SLSAddTrackingRect(g_connection, popup->window.id, tracking_rect);
}
bar_item_set_bounding_rect_for_display(bar_item,
popup->adid,
popup->anchor,
popup->background.bounds.size.height);
bool state = bar_item->popup.drawing;
bar_item->popup.drawing = false;
bar_item_draw(bar_item, popup->window.context);
bar_item->popup.drawing = state;
}
CGContextFlush(popup->window.context);
SLSOrderWindow(g_connection, popup->window.id, 1, popup->window.id);
}
void popup_destroy(struct popup* popup) {
for (int i = 0; i < popup->num_items; i++) {
bar_manager_remove_item(&g_bar_manager, popup->items[i]);
}
if (popup->items) free(popup->items);
popup_close_window(popup);
}
bool popup_parse_sub_domain(struct popup* popup, FILE* rsp, struct token property, char* message) {
if (token_equals(property, PROPERTY_YOFFSET)) {
popup->y_offset = token_to_int(get_token(&message));
return true;
} else if (token_equals(property, PROPERTY_DRAWING)) {
popup_set_drawing(popup,
evaluate_boolean_state(get_token(&message),
popup->drawing) );
return true;
} else if (token_equals(property, PROPERTY_HORIZONTAL)) {
popup->horizontal = evaluate_boolean_state(get_token(&message),
popup->horizontal );
return true;
} else if (token_equals(property, PROPERTY_ALIGN)) {
popup->align = get_token(&message).text[0];
return true;
} else if (token_equals(property, PROPERTY_HEIGHT)) {
popup->cell_size = token_to_int(get_token(&message));
popup->overrides_cell_size = true;
return true;
}
else {
struct key_value_pair key_value_pair = get_key_value_pair(property.text,
'.' );
if (key_value_pair.key && key_value_pair.value) {
struct token subdom = { key_value_pair.key, strlen(key_value_pair.key) };
struct token entry = {key_value_pair.value,strlen(key_value_pair.value)};
if (token_equals(subdom, SUB_DOMAIN_BACKGROUND))
return background_parse_sub_domain(&popup->background,
rsp,
entry,
message );
else {
fprintf(rsp, "Invalid subdomain: %s \n", subdom.text);
printf("Invalid subdomain: %s \n", subdom.text);
}
}
else {
fprintf(rsp, "Unknown property: %s \n", property.text);
printf("Unknown property: %s \n", property.text);
}
}
return false;
}

View file

@ -1,39 +0,0 @@
#pragma once
#include "background.h"
#include "misc/helpers.h"
#include "window.h"
struct bar_item;
struct popup {
bool drawing;
bool horizontal;
bool overrides_cell_size;
char align;
uint32_t adid;
uint32_t cell_size;
int y_offset;
CGPoint anchor;
struct window window;
struct bar_item** items;
uint32_t num_items;
struct background background;
};
void popup_init(struct popup* popup);
void popup_set_anchor(struct popup* popup, CGPoint anchor, uint32_t adid);
void popup_add_item(struct popup* popup, struct bar_item* item);
void popup_set_drawing(struct popup* popup, bool drawing);
void popup_remove_item(struct popup* popup, struct bar_item* bar_item);
void popup_calculate_bounds(struct popup* popup);
void popup_draw(struct popup* popup);
void popup_destroy(struct popup* popup);
bool popup_parse_sub_domain(struct popup* popup, FILE* rsp, struct token property, char* message);

View file

@ -1,67 +0,0 @@
#include "shadow.h"
void shadow_init(struct shadow* shadow) {
shadow->enabled = false;
shadow->angle = 30;
shadow->distance = 5;
shadow->color = rgba_color_from_hex(0xff000000);
}
bool shadow_set_enabled(struct shadow* shadow, bool enabled) {
if (shadow->enabled == enabled) return false;
shadow->enabled = enabled;
return true;
}
bool shadow_set_angle(struct shadow* shadow, float angle) {
if (shadow->angle == angle) return false;
shadow->angle = angle;
return true;
}
bool shadow_set_distance(struct shadow* shadow, float distance) {
if (shadow->distance == distance) return false;
shadow->distance = distance;
return true;
}
bool shadow_set_color(struct shadow* shadow, uint32_t color) {
struct rgba_color target_color = rgba_color_from_hex(color);
if (shadow->color.r == target_color.r
&& shadow->color.g == target_color.g
&& shadow->color.b == target_color.b
&& shadow->color.a == target_color.a) return false;
shadow->color = target_color;
shadow_set_enabled(shadow, true);
return true;
}
CGRect shadow_get_bounds(struct shadow* shadow, CGRect reference_bounds) {
return (CGRect){{reference_bounds.origin.x
+ shadow->distance*cos(((double)shadow->angle)/360.
* 2.* M_PI ),
reference_bounds.origin.y
- shadow->distance* sin(((double)shadow->angle)/360.
* 2.* M_PI )},
reference_bounds.size };
}
bool shadow_parse_sub_domain(struct shadow* shadow, FILE* rsp, struct token property, char* message) {
if (token_equals(property, PROPERTY_DRAWING))
return shadow_set_enabled(shadow,
evaluate_boolean_state(get_token(&message),
shadow->enabled ));
else if (token_equals(property, PROPERTY_DISTANCE))
return shadow_set_distance(shadow, token_to_uint32t(get_token(&message)));
else if (token_equals(property, PROPERTY_ANGLE))
return shadow_set_angle(shadow, token_to_uint32t(get_token(&message)));
else if (token_equals(property, PROPERTY_COLOR))
return shadow_set_color(shadow, token_to_uint32t(get_token(&message)));
else {
fprintf(rsp, "Unknown property: %s \n", property.text);
printf("Unknown property: %s \n", property.text);
}
return false;
}

View file

@ -1,20 +0,0 @@
#pragma once
#include "misc/helpers.h"
struct shadow {
bool enabled;
uint32_t angle;
uint32_t distance;
struct rgba_color color;
};
void shadow_init(struct shadow* shadow);
bool shadow_set_enabled(struct shadow* shadow, bool enabled);
bool shadow_set_angle(struct shadow* shadow, float angle);
bool shadow_set_distance(struct shadow* shadow, float distance);
bool shadow_set_color(struct shadow* shadow, uint32_t color);
CGRect shadow_get_bounds(struct shadow* shadow, CGRect reference_bounds);
bool shadow_parse_sub_domain(struct shadow* shadow, FILE* rsp, struct token property, char* message);

Some files were not shown because too many files have changed in this diff Show more