Initial commit: TopManager macOS system monitor

A native SwiftUI app for monitoring macOS system resources:
- Processes tab with sorting, filtering, and process control
- Apps tab for running applications
- Performance tab with CPU, memory, and network charts
- Power & Storage tab with system info, GPU, storage, and network

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
hariel1985
2026-01-30 23:56:51 +01:00
commit 41010541a7
48 fájl változott, egészen pontosan 5251 új sor hozzáadva és 0 régi sor törölve

40
.gitignore vendored Normal file
Fájl megtekintése

@@ -0,0 +1,40 @@
# Xcode
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/
*.xccheckout
*.moved-aside
DerivedData/
*.hmap
*.ipa
*.xcuserstate
*.xcscmblueprint
# Swift Package Manager
.build/
Packages/
Package.resolved
*.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/
# CocoaPods
Pods/
# Carthage
Carthage/Build/
# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots/**/*.png
fastlane/test_output
# Code Injection
iOSInjectionProject/

674
LICENSE Normal file
Fájl megtekintése

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

63
README.md Normal file
Fájl megtekintése

@@ -0,0 +1,63 @@
# TopManager
A native macOS system monitor application built with SwiftUI. TopManager provides real-time monitoring of system resources including processes, applications, CPU, memory, GPU, storage, and network.
![macOS](https://img.shields.io/badge/macOS-13.0+-blue)
![Swift](https://img.shields.io/badge/Swift-5.9-orange)
![License](https://img.shields.io/badge/License-GPL--3.0-green)
## Features
### Processes Tab
- View all running processes with CPU, memory, and thread information
- Sort by any column (name, PID, CPU%, memory, threads, user, state)
- Process states: Running, Sleeping, Stopped, Zombie
- Context menu to terminate, force kill, suspend, or resume processes
- Search processes by name or PID
### Apps Tab
- View running user-facing applications
- Shows app icons, CPU/memory usage, and bundle identifiers
- Quick actions: Activate, Hide, Quit, Force Quit
- Copy bundle ID to clipboard
### Performance Tab
- Real-time CPU usage graphs (global and per-core)
- Memory usage visualization with donut chart
- Network throughput monitoring
- Support for Apple Silicon P-cores and E-cores
### Power & Storage Tab
- System status: macOS version, uptime, thermal state
- CPU and GPU core counts
- GPU memory/VRAM usage
- Storage volumes with usage bars
- Network interface statistics
## Requirements
- macOS 13.0 or later
- Xcode 15.0 or later (for building)
## Building
1. Clone the repository:
```bash
git clone https://github.com/yourusername/TopManager.git
```
2. Open `TopManager.xcodeproj` in Xcode
3. Build and run (⌘R)
## License
This project is licensed under the GNU General Public License v3.0 - see the [LICENSE](LICENSE) file for details.
## Acknowledgments
Built with SwiftUI and native macOS APIs including:
- `libproc` for process information
- `IOKit` for GPU and hardware monitoring
- `Metal` for GPU detection
- `SystemConfiguration` for network monitoring

Fájl megtekintése

@@ -0,0 +1,495 @@
// !$*UTF8*$!
{
archiveVersion = 1;
classes = {
};
objectVersion = 77;
objects = {
/* Begin PBXBuildFile section */
00EC5A90B7B8C6C5015D90D1 /* PerformanceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F80A817DCDA254349DEA6F06 /* PerformanceView.swift */; };
2B3C4D5E6F7A8B9C0D1E2F3A /* AppsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1A2B3C4D5E6F7A8B9C0D1E2F /* AppsView.swift */; };
0AA7D351AEB05078FA9B4B93 /* ProcessView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B6F97E6EF65AA17A469F037 /* ProcessView.swift */; };
136DAD1FE90FD682DF666667 /* TopManager_icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 8E4A6E8E2305CEDC119AC6BC /* TopManager_icon.png */; };
1F212CE158B7D14B29077B18 /* CPUInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44281079654C7E1C9E16806C /* CPUInfo.swift */; };
1F25A84B560709AE71C27D23 /* GPUInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = F481045B4FC6017F50849FF1 /* GPUInfo.swift */; };
266B888ADE2FDDBCEC8D28A5 /* MemoryLineChart.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7326AE4B2D75476BDCFE3FFB /* MemoryLineChart.swift */; };
341C12CED58388D32ED6C5BB /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4F1ACD0492CAB741595DEAA /* ContentView.swift */; };
35852165B2DA76AB7F073723 /* MenuBarView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9D71CC63FC2FEF52A069372E /* MenuBarView.swift */; };
4427B8406B25B8FEDF27CDBA /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 334573CEB47D60570A40B55D /* Assets.xcassets */; };
501C13D57386C179C0B3B14B /* PowerStorageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6038CCDF3BDF0F8BC93C9D4 /* PowerStorageView.swift */; };
744F52D036D1F3E081923382 /* ProcessInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4CF69D4888FDBB3669619A1A /* ProcessInfo.swift */; };
7A1144E43159D96564C13164 /* MemoryInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD3EDCDEDF4A0CE1921A3B25 /* MemoryInfo.swift */; };
833976FD8DC4CCC45078CF9A /* DiskMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 162FC58F6C44EC1DD7022A86 /* DiskMonitor.swift */; };
8F9ED99AB6D8D90AE79B5179 /* DiskUsageView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95B3F62455B01B2E9C0D76A9 /* DiskUsageView.swift */; };
9146403BC02D18A234444DF6 /* ProcessMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 295232B4C746511757DCF8FE /* ProcessMonitor.swift */; };
A0649565A902BA48DB10F592 /* CPUMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 19ED582C412C63A0A2E2103E /* CPUMonitor.swift */; };
B62B18DF32A8734D5908B16B /* DiskInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 352CA1BE2A3B43643A9DBD72 /* DiskInfo.swift */; };
C077A279E20A90FD6038CCB0 /* ProcessDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 110A314A63AE355A9E04990D /* ProcessDetailView.swift */; };
CB7F422FBF9F6D152FC4F41B /* NetworkChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBFADE83965AA863B775A910 /* NetworkChartView.swift */; };
D6FC8D1EACCB4DED5DF39372 /* TopManagerApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A404EBD588B7ACD36079A95D /* TopManagerApp.swift */; };
DB3603F30B6F559BE66E4349 /* SystemMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 279B972C08A878053821285D /* SystemMonitor.swift */; };
DE50ECC69FCE60B10364802C /* ByteFormatters.swift in Sources */ = {isa = PBXBuildFile; fileRef = 78C9B469F6A45F3CC21A7594 /* ByteFormatters.swift */; };
E379C349DC9617D6C505B74B /* GPUMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE3BB62AE0DC43777AD00658 /* GPUMonitor.swift */; };
E40A4E80ED4092A3D3A9C219 /* MemoryDonutView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8F402CE13EF67DE550786B79 /* MemoryDonutView.swift */; };
E4AF7F7CA1E1FE8638CA5A77 /* NetworkInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3010F605712E09175D9D8878 /* NetworkInfo.swift */; };
EB0D84848F42134927F9C9B1 /* NetworkMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 347E47F825E496F40FD8ED11 /* NetworkMonitor.swift */; };
F5722D2B18EF7ABF43847EE4 /* MemoryMonitor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 27FDD19B8DBB7D955A5ECB5B /* MemoryMonitor.swift */; };
FA252F9182ADDA26AD1E54DE /* CPUChartView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94D5A13CC5B9CF1B90CC2214 /* CPUChartView.swift */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
110A314A63AE355A9E04990D /* ProcessDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProcessDetailView.swift; sourceTree = "<group>"; };
1A2B3C4D5E6F7A8B9C0D1E2F /* AppsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppsView.swift; sourceTree = "<group>"; };
162FC58F6C44EC1DD7022A86 /* DiskMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiskMonitor.swift; sourceTree = "<group>"; };
19ED582C412C63A0A2E2103E /* CPUMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CPUMonitor.swift; sourceTree = "<group>"; };
279B972C08A878053821285D /* SystemMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SystemMonitor.swift; sourceTree = "<group>"; };
27FDD19B8DBB7D955A5ECB5B /* MemoryMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MemoryMonitor.swift; sourceTree = "<group>"; };
295232B4C746511757DCF8FE /* ProcessMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProcessMonitor.swift; sourceTree = "<group>"; };
3010F605712E09175D9D8878 /* NetworkInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkInfo.swift; sourceTree = "<group>"; };
334573CEB47D60570A40B55D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
33BCE156CB39EDADFFC938F9 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
347E47F825E496F40FD8ED11 /* NetworkMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkMonitor.swift; sourceTree = "<group>"; };
352CA1BE2A3B43643A9DBD72 /* DiskInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiskInfo.swift; sourceTree = "<group>"; };
44281079654C7E1C9E16806C /* CPUInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CPUInfo.swift; sourceTree = "<group>"; };
4CF69D4888FDBB3669619A1A /* ProcessInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProcessInfo.swift; sourceTree = "<group>"; };
5E1D2EA8E1AD11B42FF225EB /* TopManager.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = TopManager.entitlements; sourceTree = "<group>"; };
7326AE4B2D75476BDCFE3FFB /* MemoryLineChart.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MemoryLineChart.swift; sourceTree = "<group>"; };
78C9B469F6A45F3CC21A7594 /* ByteFormatters.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ByteFormatters.swift; sourceTree = "<group>"; };
7B6F97E6EF65AA17A469F037 /* ProcessView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProcessView.swift; sourceTree = "<group>"; };
8E4A6E8E2305CEDC119AC6BC /* TopManager_icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = TopManager_icon.png; sourceTree = "<group>"; };
8F402CE13EF67DE550786B79 /* MemoryDonutView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MemoryDonutView.swift; sourceTree = "<group>"; };
94D5A13CC5B9CF1B90CC2214 /* CPUChartView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CPUChartView.swift; sourceTree = "<group>"; };
95B3F62455B01B2E9C0D76A9 /* DiskUsageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiskUsageView.swift; sourceTree = "<group>"; };
9D71CC63FC2FEF52A069372E /* MenuBarView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MenuBarView.swift; sourceTree = "<group>"; };
A3A3D0B1EB522C9975F71DA8 /* TopManager.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TopManager.app; sourceTree = BUILT_PRODUCTS_DIR; };
A404EBD588B7ACD36079A95D /* TopManagerApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TopManagerApp.swift; sourceTree = "<group>"; };
B6038CCDF3BDF0F8BC93C9D4 /* PowerStorageView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PowerStorageView.swift; sourceTree = "<group>"; };
BBFADE83965AA863B775A910 /* NetworkChartView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkChartView.swift; sourceTree = "<group>"; };
BD3EDCDEDF4A0CE1921A3B25 /* MemoryInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MemoryInfo.swift; sourceTree = "<group>"; };
BE3BB62AE0DC43777AD00658 /* GPUMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GPUMonitor.swift; sourceTree = "<group>"; };
C4F1ACD0492CAB741595DEAA /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
F481045B4FC6017F50849FF1 /* GPUInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = GPUInfo.swift; sourceTree = "<group>"; };
F80A817DCDA254349DEA6F06 /* PerformanceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PerformanceView.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXGroup section */
3C4D5E6F7A8B9C0D1E2F3A4B /* Apps */ = {
isa = PBXGroup;
children = (
1A2B3C4D5E6F7A8B9C0D1E2F /* AppsView.swift */,
);
path = Apps;
sourceTree = "<group>";
};
06D63CC4D5468CEC1E31137A /* Services */ = {
isa = PBXGroup;
children = (
19ED582C412C63A0A2E2103E /* CPUMonitor.swift */,
162FC58F6C44EC1DD7022A86 /* DiskMonitor.swift */,
BE3BB62AE0DC43777AD00658 /* GPUMonitor.swift */,
27FDD19B8DBB7D955A5ECB5B /* MemoryMonitor.swift */,
347E47F825E496F40FD8ED11 /* NetworkMonitor.swift */,
295232B4C746511757DCF8FE /* ProcessMonitor.swift */,
279B972C08A878053821285D /* SystemMonitor.swift */,
);
path = Services;
sourceTree = "<group>";
};
19147E0E8DFE80E34D0F23D7 = {
isa = PBXGroup;
children = (
36BB5A20B1330E54F2DCF357 /* TopManager */,
E6438D9AF8EDEFEDCB087B38 /* Products */,
);
sourceTree = "<group>";
};
32ADF00BA31F63CAE52B2D0A /* Models */ = {
isa = PBXGroup;
children = (
44281079654C7E1C9E16806C /* CPUInfo.swift */,
352CA1BE2A3B43643A9DBD72 /* DiskInfo.swift */,
F481045B4FC6017F50849FF1 /* GPUInfo.swift */,
BD3EDCDEDF4A0CE1921A3B25 /* MemoryInfo.swift */,
3010F605712E09175D9D8878 /* NetworkInfo.swift */,
4CF69D4888FDBB3669619A1A /* ProcessInfo.swift */,
);
path = Models;
sourceTree = "<group>";
};
36BB5A20B1330E54F2DCF357 /* TopManager */ = {
isa = PBXGroup;
children = (
33BCE156CB39EDADFFC938F9 /* Info.plist */,
8E4A6E8E2305CEDC119AC6BC /* TopManager_icon.png */,
5E1D2EA8E1AD11B42FF225EB /* TopManager.entitlements */,
A404EBD588B7ACD36079A95D /* TopManagerApp.swift */,
32ADF00BA31F63CAE52B2D0A /* Models */,
5C510700418C1704216D424E /* Resources */,
06D63CC4D5468CEC1E31137A /* Services */,
9C38088C52BDE6A2BA1CEF73 /* Utilities */,
C0EC67468EF5F8D83745F3E1 /* Views */,
);
path = TopManager;
sourceTree = "<group>";
};
4935484C55FD4C912A30D623 /* Performance */ = {
isa = PBXGroup;
children = (
94D5A13CC5B9CF1B90CC2214 /* CPUChartView.swift */,
8F402CE13EF67DE550786B79 /* MemoryDonutView.swift */,
7326AE4B2D75476BDCFE3FFB /* MemoryLineChart.swift */,
BBFADE83965AA863B775A910 /* NetworkChartView.swift */,
F80A817DCDA254349DEA6F06 /* PerformanceView.swift */,
);
path = Performance;
sourceTree = "<group>";
};
5C510700418C1704216D424E /* Resources */ = {
isa = PBXGroup;
children = (
334573CEB47D60570A40B55D /* Assets.xcassets */,
);
path = Resources;
sourceTree = "<group>";
};
9C38088C52BDE6A2BA1CEF73 /* Utilities */ = {
isa = PBXGroup;
children = (
78C9B469F6A45F3CC21A7594 /* ByteFormatters.swift */,
);
path = Utilities;
sourceTree = "<group>";
};
C0EC67468EF5F8D83745F3E1 /* Views */ = {
isa = PBXGroup;
children = (
C4F1ACD0492CAB741595DEAA /* ContentView.swift */,
9D71CC63FC2FEF52A069372E /* MenuBarView.swift */,
3C4D5E6F7A8B9C0D1E2F3A4B /* Apps */,
4935484C55FD4C912A30D623 /* Performance */,
CC52DA4C64987575E4D96A00 /* PowerStorage */,
F2616FC0A232C728E792C2E8 /* Processes */,
);
path = Views;
sourceTree = "<group>";
};
CC52DA4C64987575E4D96A00 /* PowerStorage */ = {
isa = PBXGroup;
children = (
95B3F62455B01B2E9C0D76A9 /* DiskUsageView.swift */,
B6038CCDF3BDF0F8BC93C9D4 /* PowerStorageView.swift */,
);
path = PowerStorage;
sourceTree = "<group>";
};
E6438D9AF8EDEFEDCB087B38 /* Products */ = {
isa = PBXGroup;
children = (
A3A3D0B1EB522C9975F71DA8 /* TopManager.app */,
);
name = Products;
sourceTree = "<group>";
};
F2616FC0A232C728E792C2E8 /* Processes */ = {
isa = PBXGroup;
children = (
110A314A63AE355A9E04990D /* ProcessDetailView.swift */,
7B6F97E6EF65AA17A469F037 /* ProcessView.swift */,
);
path = Processes;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
F86DD5615146D759EB0D44EB /* TopManager */ = {
isa = PBXNativeTarget;
buildConfigurationList = 56829675F6738AEDCFCDEE52 /* Build configuration list for PBXNativeTarget "TopManager" */;
buildPhases = (
CF5286324D09B9417D3070C3 /* Sources */,
DB2502B4805DC2F183DF015E /* Resources */,
);
buildRules = (
);
dependencies = (
);
name = TopManager;
packageProductDependencies = (
);
productName = TopManager;
productReference = A3A3D0B1EB522C9975F71DA8 /* TopManager.app */;
productType = "com.apple.product-type.application";
};
/* End PBXNativeTarget section */
/* Begin PBXProject section */
4BAFF5CBBA9A1302C6CCDCD2 /* Project object */ = {
isa = PBXProject;
attributes = {
BuildIndependentTargetsInParallel = YES;
LastUpgradeCheck = 1500;
TargetAttributes = {
F86DD5615146D759EB0D44EB = {
DevelopmentTeam = "";
ProvisioningStyle = Automatic;
};
};
};
buildConfigurationList = A70528C1B1F0BAB178B0B048 /* Build configuration list for PBXProject "TopManager" */;
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
Base,
en,
);
mainGroup = 19147E0E8DFE80E34D0F23D7;
minimizedProjectReferenceProxies = 1;
preferredProjectObjectVersion = 77;
projectDirPath = "";
projectRoot = "";
targets = (
F86DD5615146D759EB0D44EB /* TopManager */,
);
};
/* End PBXProject section */
/* Begin PBXResourcesBuildPhase section */
DB2502B4805DC2F183DF015E /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
4427B8406B25B8FEDF27CDBA /* Assets.xcassets in Resources */,
136DAD1FE90FD682DF666667 /* TopManager_icon.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
CF5286324D09B9417D3070C3 /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
2B3C4D5E6F7A8B9C0D1E2F3A /* AppsView.swift in Sources */,
DE50ECC69FCE60B10364802C /* ByteFormatters.swift in Sources */,
FA252F9182ADDA26AD1E54DE /* CPUChartView.swift in Sources */,
1F212CE158B7D14B29077B18 /* CPUInfo.swift in Sources */,
A0649565A902BA48DB10F592 /* CPUMonitor.swift in Sources */,
341C12CED58388D32ED6C5BB /* ContentView.swift in Sources */,
B62B18DF32A8734D5908B16B /* DiskInfo.swift in Sources */,
833976FD8DC4CCC45078CF9A /* DiskMonitor.swift in Sources */,
8F9ED99AB6D8D90AE79B5179 /* DiskUsageView.swift in Sources */,
1F25A84B560709AE71C27D23 /* GPUInfo.swift in Sources */,
E379C349DC9617D6C505B74B /* GPUMonitor.swift in Sources */,
E40A4E80ED4092A3D3A9C219 /* MemoryDonutView.swift in Sources */,
7A1144E43159D96564C13164 /* MemoryInfo.swift in Sources */,
266B888ADE2FDDBCEC8D28A5 /* MemoryLineChart.swift in Sources */,
F5722D2B18EF7ABF43847EE4 /* MemoryMonitor.swift in Sources */,
35852165B2DA76AB7F073723 /* MenuBarView.swift in Sources */,
CB7F422FBF9F6D152FC4F41B /* NetworkChartView.swift in Sources */,
E4AF7F7CA1E1FE8638CA5A77 /* NetworkInfo.swift in Sources */,
EB0D84848F42134927F9C9B1 /* NetworkMonitor.swift in Sources */,
00EC5A90B7B8C6C5015D90D1 /* PerformanceView.swift in Sources */,
501C13D57386C179C0B3B14B /* PowerStorageView.swift in Sources */,
C077A279E20A90FD6038CCB0 /* ProcessDetailView.swift in Sources */,
744F52D036D1F3E081923382 /* ProcessInfo.swift in Sources */,
9146403BC02D18A234444DF6 /* ProcessMonitor.swift in Sources */,
0AA7D351AEB05078FA9B4B93 /* ProcessView.swift in Sources */,
DB3603F30B6F559BE66E4349 /* SystemMonitor.swift in Sources */,
D6FC8D1EACCB4DED5DF39372 /* TopManagerApp.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */
/* Begin XCBuildConfiguration section */
00F8AAE6BB8D4ED66312B6CB /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = TopManager/TopManager.entitlements;
COMBINE_HIDPI_IMAGES = YES;
GENERATE_INFOPLIST_FILE = NO;
INFOPLIST_FILE = TopManager/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.topmanager.app;
PRODUCT_NAME = TopManager;
SDKROOT = macosx;
SWIFT_EMIT_LOC_STRINGS = YES;
};
name = Release;
};
A8E20AFB3898C4F0324DC8BA /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_DYNAMIC_NO_PIC = NO;
GCC_NO_COMMON_BLOCKS = YES;
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PREPROCESSOR_DEFINITIONS = (
"$(inherited)",
"DEBUG=1",
);
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 5.9;
};
name = Debug;
};
C4D5AD1B7274BBED9D423AC0 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = TopManager/TopManager.entitlements;
COMBINE_HIDPI_IMAGES = YES;
GENERATE_INFOPLIST_FILE = NO;
INFOPLIST_FILE = TopManager/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
PRODUCT_BUNDLE_IDENTIFIER = com.topmanager.app;
PRODUCT_NAME = TopManager;
SDKROOT = macosx;
SWIFT_EMIT_LOC_STRINGS = YES;
};
name = Debug;
};
E46229D98EBEA8F9C3D6CBDE /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_ENABLE_OBJC_WEAK = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
GCC_NO_COMMON_BLOCKS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
GCC_WARN_UNDECLARED_SELECTOR = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 5.9;
};
name = Release;
};
/* End XCBuildConfiguration section */
/* Begin XCConfigurationList section */
56829675F6738AEDCFCDEE52 /* Build configuration list for PBXNativeTarget "TopManager" */ = {
isa = XCConfigurationList;
buildConfigurations = (
C4D5AD1B7274BBED9D423AC0 /* Debug */,
00F8AAE6BB8D4ED66312B6CB /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
};
A70528C1B1F0BAB178B0B048 /* Build configuration list for PBXProject "TopManager" */ = {
isa = XCConfigurationList;
buildConfigurations = (
A8E20AFB3898C4F0324DC8BA /* Debug */,
E46229D98EBEA8F9C3D6CBDE /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Debug;
};
/* End XCConfigurationList section */
};
rootObject = 4BAFF5CBBA9A1302C6CCDCD2 /* Project object */;
}

Fájl megtekintése

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>

22
TopManager/Info.plist Normal file
Fájl megtekintése

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>

Fájl megtekintése

@@ -0,0 +1,64 @@
import Foundation
struct CPUInfo {
let globalUsage: Double
let userUsage: Double
let systemUsage: Double
let idleUsage: Double
let coreUsages: [CoreUsage]
let pCoreUsages: [CoreUsage]
let eCoreUsages: [CoreUsage]
let timestamp: Date
init(
globalUsage: Double,
userUsage: Double,
systemUsage: Double,
idleUsage: Double,
coreUsages: [CoreUsage],
pCoreUsages: [CoreUsage] = [],
eCoreUsages: [CoreUsage] = [],
timestamp: Date = Date()
) {
self.globalUsage = globalUsage
self.userUsage = userUsage
self.systemUsage = systemUsage
self.idleUsage = idleUsage
self.coreUsages = coreUsages
self.pCoreUsages = pCoreUsages
self.eCoreUsages = eCoreUsages
self.timestamp = timestamp
}
}
struct CoreUsage: Identifiable {
let id: Int
let usage: Double
let coreType: CoreType
enum CoreType: String {
case performance = "P"
case efficiency = "E"
case unknown = ""
}
init(id: Int, usage: Double, coreType: CoreType = .unknown) {
self.id = id
self.usage = usage
self.coreType = coreType
}
}
struct CPUHistoryPoint: Identifiable {
let id = UUID()
let timestamp: Date
let usage: Double
let userUsage: Double
let systemUsage: Double
}
struct CoreHistoryPoint: Identifiable {
let id = UUID()
let timestamp: Date
let usage: Double
}

Fájl megtekintése

@@ -0,0 +1,57 @@
import Foundation
struct DiskInfo {
let volumes: [VolumeInfo]
let timestamp: Date
init(volumes: [VolumeInfo], timestamp: Date = Date()) {
self.volumes = volumes
self.timestamp = timestamp
}
}
struct VolumeInfo: Identifiable {
let id: String
let name: String
let mountPoint: String
let totalSpace: UInt64
let freeSpace: UInt64
let usedSpace: UInt64
let fileSystem: String
let isRemovable: Bool
let isInternal: Bool
var usagePercentage: Double {
guard totalSpace > 0 else { return 0 }
return Double(usedSpace) / Double(totalSpace) * 100
}
init(
name: String,
mountPoint: String,
totalSpace: UInt64,
freeSpace: UInt64,
fileSystem: String,
isRemovable: Bool,
isInternal: Bool
) {
self.id = mountPoint
self.name = name
self.mountPoint = mountPoint
self.totalSpace = totalSpace
self.freeSpace = freeSpace
self.usedSpace = totalSpace > freeSpace ? totalSpace - freeSpace : 0
self.fileSystem = fileSystem
self.isRemovable = isRemovable
self.isInternal = isInternal
}
}
struct DiskIOStats: Identifiable {
let id = UUID()
let timestamp: Date
let readBytes: UInt64
let writeBytes: UInt64
let readRate: Double
let writeRate: Double
}

Fájl megtekintése

@@ -0,0 +1,45 @@
import Foundation
struct GPUInfo {
let name: String
let vramUsed: UInt64
let vramTotal: UInt64?
let utilizationPercent: Double?
let isUnifiedMemory: Bool
let coreCount: Int?
let timestamp: Date
var vramUsagePercentage: Double? {
guard let total = vramTotal, total > 0 else { return nil }
return Double(vramUsed) / Double(total) * 100
}
var memoryLabel: String {
isUnifiedMemory ? "GPU Memory" : "VRAM"
}
init(
name: String,
vramUsed: UInt64,
vramTotal: UInt64?,
utilizationPercent: Double?,
isUnifiedMemory: Bool = false,
coreCount: Int? = nil,
timestamp: Date = Date()
) {
self.name = name
self.vramUsed = vramUsed
self.vramTotal = vramTotal
self.utilizationPercent = utilizationPercent
self.isUnifiedMemory = isUnifiedMemory
self.coreCount = coreCount
self.timestamp = timestamp
}
}
struct GPUHistoryPoint: Identifiable {
let id = UUID()
let timestamp: Date
let vramUsed: UInt64
let utilizationPercent: Double?
}

Fájl megtekintése

@@ -0,0 +1,81 @@
import Foundation
struct MemoryInfo {
let totalMemory: UInt64
let usedMemory: UInt64
let freeMemory: UInt64
let activeMemory: UInt64
let inactiveMemory: UInt64
let wiredMemory: UInt64
let compressedMemory: UInt64
let cachedMemory: UInt64
let swapUsed: UInt64
let swapTotal: UInt64
let memoryPressure: MemoryPressure
let timestamp: Date
var usagePercentage: Double {
guard totalMemory > 0 else { return 0 }
return Double(usedMemory) / Double(totalMemory) * 100
}
var appMemory: UInt64 {
activeMemory + inactiveMemory
}
init(
totalMemory: UInt64,
usedMemory: UInt64,
freeMemory: UInt64,
activeMemory: UInt64,
inactiveMemory: UInt64,
wiredMemory: UInt64,
compressedMemory: UInt64,
cachedMemory: UInt64,
swapUsed: UInt64,
swapTotal: UInt64,
memoryPressure: MemoryPressure,
timestamp: Date = Date()
) {
self.totalMemory = totalMemory
self.usedMemory = usedMemory
self.freeMemory = freeMemory
self.activeMemory = activeMemory
self.inactiveMemory = inactiveMemory
self.wiredMemory = wiredMemory
self.compressedMemory = compressedMemory
self.cachedMemory = cachedMemory
self.swapUsed = swapUsed
self.swapTotal = swapTotal
self.memoryPressure = memoryPressure
self.timestamp = timestamp
}
}
enum MemoryPressure: String {
case nominal = "Normal"
case warning = "Warning"
case critical = "Critical"
case unknown = "Unknown"
var color: String {
switch self {
case .nominal: return "green"
case .warning: return "yellow"
case .critical: return "red"
case .unknown: return "gray"
}
}
}
struct MemoryHistoryPoint: Identifiable {
let id = UUID()
let timestamp: Date
let usedMemory: UInt64
let totalMemory: UInt64
var usagePercentage: Double {
guard totalMemory > 0 else { return 0 }
return Double(usedMemory) / Double(totalMemory) * 100
}
}

Fájl megtekintése

@@ -0,0 +1,63 @@
import Foundation
struct NetworkInfo {
let interfaces: [NetworkInterface]
let totalDownloadRate: Double
let totalUploadRate: Double
let totalDownloadBytes: UInt64
let totalUploadBytes: UInt64
let timestamp: Date
init(
interfaces: [NetworkInterface],
totalDownloadRate: Double,
totalUploadRate: Double,
totalDownloadBytes: UInt64,
totalUploadBytes: UInt64,
timestamp: Date = Date()
) {
self.interfaces = interfaces
self.totalDownloadRate = totalDownloadRate
self.totalUploadRate = totalUploadRate
self.totalDownloadBytes = totalDownloadBytes
self.totalUploadBytes = totalUploadBytes
self.timestamp = timestamp
}
}
struct NetworkInterface: Identifiable {
let id: String
let name: String
let displayName: String
let downloadBytes: UInt64
let uploadBytes: UInt64
let downloadRate: Double
let uploadRate: Double
let isActive: Bool
init(
name: String,
displayName: String,
downloadBytes: UInt64,
uploadBytes: UInt64,
downloadRate: Double,
uploadRate: Double,
isActive: Bool
) {
self.id = name
self.name = name
self.displayName = displayName
self.downloadBytes = downloadBytes
self.uploadBytes = uploadBytes
self.downloadRate = downloadRate
self.uploadRate = uploadRate
self.isActive = isActive
}
}
struct NetworkHistoryPoint: Identifiable {
let id = UUID()
let timestamp: Date
let downloadRate: Double
let uploadRate: Double
}

Fájl megtekintése

@@ -0,0 +1,73 @@
import Foundation
import AppKit
struct ProcessItem: Identifiable, Hashable {
let id: pid_t
let pid: pid_t
let name: String
let user: String
let cpuUsage: Double
let memoryUsage: Int64
let threadCount: Int32
let state: ProcessState
let icon: NSImage?
let parentPid: pid_t
let startTime: Date?
var iconPlaceholder: String { "" }
init(
pid: pid_t,
name: String,
user: String,
cpuUsage: Double,
memoryUsage: Int64,
threadCount: Int32,
state: ProcessState,
icon: NSImage?,
parentPid: pid_t,
startTime: Date?
) {
self.id = pid
self.pid = pid
self.name = name
self.user = user
self.cpuUsage = cpuUsage
self.memoryUsage = memoryUsage
self.threadCount = threadCount
self.state = state
self.icon = icon
self.parentPid = parentPid
self.startTime = startTime
}
func hash(into hasher: inout Hasher) {
hasher.combine(pid)
}
static func == (lhs: ProcessItem, rhs: ProcessItem) -> Bool {
lhs.pid == rhs.pid &&
lhs.cpuUsage == rhs.cpuUsage &&
lhs.memoryUsage == rhs.memoryUsage &&
lhs.threadCount == rhs.threadCount &&
lhs.state == rhs.state
}
}
enum ProcessState: String {
case running = "Running"
case sleeping = "Sleeping"
case stopped = "Stopped"
case zombie = "Zombie"
case unknown = "Unknown"
var symbol: String {
switch self {
case .running: return "play.circle.fill"
case .sleeping: return "moon.fill"
case .stopped: return "pause.circle.fill"
case .zombie: return "exclamationmark.triangle.fill"
case .unknown: return "questionmark.circle"
}
}
}

Fájl megtekintése

@@ -0,0 +1,68 @@
{
"images" : [
{
"filename" : "icon_16x16.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "16x16"
},
{
"filename" : "icon_16x16@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "16x16"
},
{
"filename" : "icon_32x32.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "32x32"
},
{
"filename" : "icon_32x32@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "32x32"
},
{
"filename" : "icon_128x128.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "128x128"
},
{
"filename" : "icon_128x128@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "128x128"
},
{
"filename" : "icon_256x256.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "256x256"
},
{
"filename" : "icon_256x256@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "256x256"
},
{
"filename" : "icon_512x512.png",
"idiom" : "mac",
"scale" : "1x",
"size" : "512x512"
},
{
"filename" : "icon_512x512@2x.png",
"idiom" : "mac",
"scale" : "2x",
"size" : "512x512"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Méret: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Méret: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Méret: 969 B

Binary file not shown.

After

Width:  |  Height:  |  Méret: 969 B

Binary file not shown.

After

Width:  |  Height:  |  Méret: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Méret: 99 KiB

Binary file not shown.

After

Width:  |  Height:  |  Méret: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Méret: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Méret: 385 KiB

Binary file not shown.

After

Width:  |  Height:  |  Méret: 337 KiB

Fájl megtekintése

@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

Fájl megtekintése

@@ -0,0 +1,180 @@
import Foundation
import Darwin
final class CPUMonitor {
private var previousCpuInfo: [processor_cpu_load_info]?
private var previousGlobalInfo: host_cpu_load_info?
private var pCoreCount: Int = 0
private var eCoreCount: Int = 0
private var isAppleSiliconCPU: Bool = false
init() {
detectCPUArchitecture()
}
private func detectCPUArchitecture() {
var sysinfo = utsname()
uname(&sysinfo)
let machine = withUnsafePointer(to: &sysinfo.machine) {
$0.withMemoryRebound(to: CChar.self, capacity: 1) {
String(cString: $0)
}
}
isAppleSiliconCPU = machine.hasPrefix("arm64")
if isAppleSiliconCPU {
detectPerfLevelCounts()
}
}
private func detectPerfLevelCounts() {
var pCores: Int32 = 0
var eCores: Int32 = 0
var size = MemoryLayout<Int32>.size
if sysctlbyname("hw.perflevel1.logicalcpu", &pCores, &size, nil, 0) == 0,
sysctlbyname("hw.perflevel0.logicalcpu", &eCores, &size, nil, 0) == 0 {
self.pCoreCount = Int(pCores)
self.eCoreCount = Int(eCores)
}
}
func fetchCPUInfo() -> CPUInfo? {
guard let perCoreUsages = fetchPerCoreUsages(),
let globalUsage = fetchGlobalUsage() else {
return nil
}
var pCoreUsages: [CoreUsage] = []
var eCoreUsages: [CoreUsage] = []
if isAppleSiliconCPU && pCoreCount > 0 && eCoreCount > 0 {
for core in perCoreUsages {
if core.id < pCoreCount {
pCoreUsages.append(CoreUsage(id: core.id, usage: core.usage, coreType: .performance))
} else {
eCoreUsages.append(CoreUsage(id: core.id, usage: core.usage, coreType: .efficiency))
}
}
}
return CPUInfo(
globalUsage: globalUsage.usage,
userUsage: globalUsage.user,
systemUsage: globalUsage.system,
idleUsage: globalUsage.idle,
coreUsages: perCoreUsages,
pCoreUsages: pCoreUsages,
eCoreUsages: eCoreUsages
)
}
private func fetchPerCoreUsages() -> [CoreUsage]? {
var numCPUs: natural_t = 0
var cpuInfo: processor_info_array_t?
var numCpuInfo: mach_msg_type_number_t = 0
let result = host_processor_info(
mach_host_self(),
PROCESSOR_CPU_LOAD_INFO,
&numCPUs,
&cpuInfo,
&numCpuInfo
)
guard result == KERN_SUCCESS, let cpuInfo = cpuInfo else {
return nil
}
defer {
vm_deallocate(
mach_task_self_,
vm_address_t(bitPattern: cpuInfo),
vm_size_t(Int(numCpuInfo) * MemoryLayout<integer_t>.size)
)
}
var coreUsages: [CoreUsage] = []
let cpuLoadInfo = cpuInfo.withMemoryRebound(to: processor_cpu_load_info.self, capacity: Int(numCPUs)) { ptr in
Array(UnsafeBufferPointer(start: ptr, count: Int(numCPUs)))
}
for (index, currentInfo) in cpuLoadInfo.enumerated() {
var usage = 0.0
if let previous = previousCpuInfo, index < previous.count {
let prevInfo = previous[index]
let userDelta = Int64(currentInfo.cpu_ticks.0) - Int64(prevInfo.cpu_ticks.0)
let systemDelta = Int64(currentInfo.cpu_ticks.1) - Int64(prevInfo.cpu_ticks.1)
let idleDelta = Int64(currentInfo.cpu_ticks.2) - Int64(prevInfo.cpu_ticks.2)
let niceDelta = Int64(currentInfo.cpu_ticks.3) - Int64(prevInfo.cpu_ticks.3)
let totalDelta = userDelta + systemDelta + idleDelta + niceDelta
if totalDelta > 0 {
usage = Double(userDelta + systemDelta) / Double(totalDelta) * 100
}
}
let coreType: CoreUsage.CoreType
if isAppleSiliconCPU && pCoreCount > 0 {
coreType = index < pCoreCount ? .performance : .efficiency
} else {
coreType = .unknown
}
coreUsages.append(CoreUsage(id: index, usage: usage, coreType: coreType))
}
previousCpuInfo = cpuLoadInfo
return coreUsages
}
private func fetchGlobalUsage() -> (usage: Double, user: Double, system: Double, idle: Double)? {
var size = mach_msg_type_number_t(MemoryLayout<host_cpu_load_info_data_t>.size / MemoryLayout<integer_t>.size)
var cpuLoadInfo = host_cpu_load_info_data_t()
let result = withUnsafeMutablePointer(to: &cpuLoadInfo) { ptr in
ptr.withMemoryRebound(to: integer_t.self, capacity: Int(size)) { intPtr in
host_statistics(mach_host_self(), HOST_CPU_LOAD_INFO, intPtr, &size)
}
}
guard result == KERN_SUCCESS else { return nil }
var usage = 0.0
var userPct = 0.0
var systemPct = 0.0
var idlePct = 0.0
if let previous = previousGlobalInfo {
let userDelta = Int64(cpuLoadInfo.cpu_ticks.0) - Int64(previous.cpu_ticks.0)
let systemDelta = Int64(cpuLoadInfo.cpu_ticks.1) - Int64(previous.cpu_ticks.1)
let idleDelta = Int64(cpuLoadInfo.cpu_ticks.2) - Int64(previous.cpu_ticks.2)
let niceDelta = Int64(cpuLoadInfo.cpu_ticks.3) - Int64(previous.cpu_ticks.3)
let totalDelta = userDelta + systemDelta + idleDelta + niceDelta
if totalDelta > 0 {
userPct = Double(userDelta + niceDelta) / Double(totalDelta) * 100
systemPct = Double(systemDelta) / Double(totalDelta) * 100
idlePct = Double(idleDelta) / Double(totalDelta) * 100
usage = userPct + systemPct
}
}
previousGlobalInfo = cpuLoadInfo
return (usage, userPct, systemPct, idlePct)
}
var isAppleSilicon: Bool {
isAppleSiliconCPU
}
var performanceCoreCount: Int {
pCoreCount
}
var efficiencyCoreCount: Int {
eCoreCount
}
}

Fájl megtekintése

@@ -0,0 +1,80 @@
import Foundation
final class DiskMonitor {
func fetchDiskInfo() -> DiskInfo {
let volumes = fetchVolumes()
return DiskInfo(volumes: volumes)
}
private func fetchVolumes() -> [VolumeInfo] {
var volumes: [VolumeInfo] = []
let fileManager = FileManager.default
guard let mountedVolumeURLs = fileManager.mountedVolumeURLs(
includingResourceValuesForKeys: [
.volumeNameKey,
.volumeTotalCapacityKey,
.volumeAvailableCapacityKey,
.volumeIsRemovableKey,
.volumeIsInternalKey,
.volumeLocalizedFormatDescriptionKey
],
options: [.skipHiddenVolumes]
) else {
return []
}
for volumeURL in mountedVolumeURLs {
do {
let resourceValues = try volumeURL.resourceValues(forKeys: [
.volumeNameKey,
.volumeTotalCapacityKey,
.volumeAvailableCapacityKey,
.volumeIsRemovableKey,
.volumeIsInternalKey,
.volumeLocalizedFormatDescriptionKey
])
let name = resourceValues.volumeName ?? volumeURL.lastPathComponent
let totalSpace = UInt64(resourceValues.volumeTotalCapacity ?? 0)
let freeSpace = UInt64(resourceValues.volumeAvailableCapacity ?? 0)
let isRemovable = resourceValues.volumeIsRemovable ?? false
let isInternal = resourceValues.volumeIsInternal ?? true
let fileSystem = resourceValues.volumeLocalizedFormatDescription ?? "Unknown"
let mountPoint = volumeURL.path
// Skip system volumes
guard shouldIncludeVolume(mountPoint: mountPoint) else {
continue
}
volumes.append(VolumeInfo(
name: name,
mountPoint: mountPoint,
totalSpace: totalSpace,
freeSpace: freeSpace,
fileSystem: fileSystem,
isRemovable: isRemovable,
isInternal: isInternal
))
} catch {
continue
}
}
return volumes.sorted { $0.mountPoint < $1.mountPoint }
}
private func shouldIncludeVolume(mountPoint: String) -> Bool {
let excludedPaths = [
"/System/Volumes/VM",
"/System/Volumes/Preboot",
"/System/Volumes/Update",
"/System/Volumes/xarts",
"/System/Volumes/iSCPreboot",
"/System/Volumes/Hardware"
]
return !excludedPaths.contains(where: { mountPoint.hasPrefix($0) })
}
}

Fájl megtekintése

@@ -0,0 +1,253 @@
import Foundation
import IOKit
import Metal
final class GPUMonitor {
private let isAppleSilicon: Bool
private let chipName: String
private let gpuCoreCount: Int?
init() {
var sysinfo = utsname()
uname(&sysinfo)
let machine = withUnsafePointer(to: &sysinfo.machine) {
$0.withMemoryRebound(to: CChar.self, capacity: 1) {
String(cString: $0)
}
}
isAppleSilicon = machine.hasPrefix("arm64")
chipName = GPUMonitor.getChipName()
gpuCoreCount = GPUMonitor.getGPUCoreCount()
}
private static func getGPUCoreCount() -> Int? {
// Try to get GPU core count from Metal
guard let device = MTLCreateSystemDefaultDevice() else { return nil }
// For Apple Silicon, we can infer from the chip name or use Metal properties
// Metal doesn't directly expose core count, but we can check recommended working set size
// as a proxy or use the chip name to look up known values
// Try IOKit for more detailed info
let matchingDict = IOServiceMatching("AGXAccelerator")
var iterator: io_iterator_t = 0
if IOServiceGetMatchingServices(kIOMainPortDefault, matchingDict, &iterator) == KERN_SUCCESS {
defer { IOObjectRelease(iterator) }
let service = IOIteratorNext(iterator)
if service != 0 {
defer { IOObjectRelease(service) }
if let props = IORegistryEntryCreateCFProperty(
service,
"gpu-core-count" as CFString,
kCFAllocatorDefault,
0
)?.takeRetainedValue() as? Int {
return props
}
}
}
// Fallback: infer from device name
let name = device.name.lowercased()
if name.contains("m3 max") { return 40 }
if name.contains("m3 pro") { return 18 }
if name.contains("m3") { return 10 }
if name.contains("m2 ultra") { return 76 }
if name.contains("m2 max") { return 38 }
if name.contains("m2 pro") { return 19 }
if name.contains("m2") { return 10 }
if name.contains("m1 ultra") { return 64 }
if name.contains("m1 max") { return 32 }
if name.contains("m1 pro") { return 16 }
if name.contains("m1") { return 8 }
return nil
}
private static func getChipName() -> String {
var size: size_t = 0
sysctlbyname("machdep.cpu.brand_string", nil, &size, nil, 0)
var brand = [CChar](repeating: 0, count: size)
sysctlbyname("machdep.cpu.brand_string", &brand, &size, nil, 0)
let brandString = String(cString: brand)
// For Apple Silicon, this returns "Apple M1", "Apple M2", etc.
if brandString.hasPrefix("Apple") {
return brandString
}
// Fallback: try to get chip from IOKit
return getAppleSiliconChipName() ?? "Apple GPU"
}
private static func getAppleSiliconChipName() -> String? {
let matchingDict = IOServiceMatching("IOPlatformExpertDevice")
var service: io_service_t = 0
guard IOServiceGetMatchingServices(kIOMainPortDefault, matchingDict, &service) == KERN_SUCCESS else {
return nil
}
let platformExpert = IOServiceGetMatchingService(kIOMainPortDefault, IOServiceMatching("IOPlatformExpertDevice"))
defer { IOObjectRelease(platformExpert) }
if let modelData = IORegistryEntryCreateCFProperty(
platformExpert,
"model" as CFString,
kCFAllocatorDefault,
0
)?.takeRetainedValue() as? Data {
let model = String(data: modelData, encoding: .utf8)?.trimmingCharacters(in: .controlCharacters) ?? ""
// Map model identifiers to chip names
if model.contains("Mac14") || model.contains("Mac15") {
return "Apple M2/M3"
} else if model.contains("Mac13") {
return "Apple M2"
} else if model.contains("Mac12") || model.contains("MacBookAir10") || model.contains("MacBookPro17") || model.contains("MacBookPro18") || model.contains("Macmini9") || model.contains("iMac21") {
return "Apple M1"
}
}
return nil
}
func fetchGPUInfo() -> GPUInfo? {
if isAppleSilicon {
return fetchAppleSiliconGPUInfo()
} else {
return fetchDiscreteGPUInfo()
}
}
private func fetchAppleSiliconGPUInfo() -> GPUInfo? {
// Apple Silicon uses unified memory - get memory pressure instead
let totalMemory = ProcessInfo.processInfo.physicalMemory
// Try to get GPU utilization from IOKit
var utilizationPercent: Double? = nil
var inUseSystemMemory: UInt64 = 0
let matchingDict = IOServiceMatching("IOAccelerator")
var iterator: io_iterator_t = 0
if IOServiceGetMatchingServices(kIOMainPortDefault, matchingDict, &iterator) == KERN_SUCCESS {
defer { IOObjectRelease(iterator) }
var service = IOIteratorNext(iterator)
while service != 0 {
defer {
IOObjectRelease(service)
service = IOIteratorNext(iterator)
}
if let props = IORegistryEntryCreateCFProperty(
service,
"PerformanceStatistics" as CFString,
kCFAllocatorDefault,
0
)?.takeRetainedValue() as? [String: Any] {
// Try various keys for GPU memory on Apple Silicon
if let inUse = props["In use system memory"] as? UInt64 {
inUseSystemMemory = inUse
} else if let inUse = props["Alloc system memory"] as? UInt64 {
inUseSystemMemory = inUse
} else if let inUse = props["inUseSystemMemory"] as? UInt64 {
inUseSystemMemory = inUse
}
// GPU utilization
if let util = props["Device Utilization %"] as? Int {
utilizationPercent = Double(util)
} else if let util = props["GPU Activity(%)"] as? Int {
utilizationPercent = Double(util)
}
break
}
}
}
// For Apple Silicon, show unified memory usage
return GPUInfo(
name: chipName + " GPU",
vramUsed: inUseSystemMemory,
vramTotal: inUseSystemMemory > 0 ? totalMemory : nil,
utilizationPercent: utilizationPercent,
isUnifiedMemory: true,
coreCount: gpuCoreCount
)
}
private func fetchDiscreteGPUInfo() -> GPUInfo? {
let matchingDict = IOServiceMatching("IOAccelerator")
var iterator: io_iterator_t = 0
guard IOServiceGetMatchingServices(kIOMainPortDefault, matchingDict, &iterator) == KERN_SUCCESS else {
return nil
}
defer { IOObjectRelease(iterator) }
var service = IOIteratorNext(iterator)
while service != 0 {
defer {
IOObjectRelease(service)
service = IOIteratorNext(iterator)
}
var name = "GPU"
if let modelData = IORegistryEntryCreateCFProperty(
service,
"model" as CFString,
kCFAllocatorDefault,
0
)?.takeRetainedValue() as? Data {
name = String(data: modelData, encoding: .utf8)?
.trimmingCharacters(in: .controlCharacters) ?? "GPU"
}
if let props = IORegistryEntryCreateCFProperty(
service,
"PerformanceStatistics" as CFString,
kCFAllocatorDefault,
0
)?.takeRetainedValue() as? [String: Any] {
let vramUsed = (props["vramUsedBytes"] as? UInt64)
?? (props["VRAM,totalMB"] as? UInt64).map { $0 * 1024 * 1024 }
?? (props["inUseVidMemoryBytes"] as? UInt64)
?? 0
let vramFree = props["vramFreeBytes"] as? UInt64
let vramTotal: UInt64?
if let free = vramFree {
vramTotal = vramUsed + free
} else if let totalMB = props["VRAM,totalMB"] as? UInt64 {
vramTotal = totalMB * 1024 * 1024
} else {
vramTotal = nil
}
let utilization = props["Device Utilization %"] as? Double
?? props["GPU Core Utilization"] as? Double
return GPUInfo(
name: name,
vramUsed: vramUsed,
vramTotal: vramTotal,
utilizationPercent: utilization,
isUnifiedMemory: false
)
}
}
return nil
}
}

Fájl megtekintése

@@ -0,0 +1,97 @@
import Foundation
import Darwin
final class MemoryMonitor {
private let pageSize: UInt64
init() {
var pageSizeValue: vm_size_t = 0
host_page_size(mach_host_self(), &pageSizeValue)
pageSize = UInt64(pageSizeValue)
}
func fetchMemoryInfo() -> MemoryInfo? {
guard let vmStats = fetchVMStatistics() else { return nil }
let totalMemory = ProcessInfo.processInfo.physicalMemory
let freeMemory = vmStats.freePages * pageSize
let activeMemory = vmStats.activePages * pageSize
let inactiveMemory = vmStats.inactivePages * pageSize
let wiredMemory = vmStats.wiredPages * pageSize
let compressedMemory = vmStats.compressedPages * pageSize
let cachedMemory = vmStats.cachedPages * pageSize
let usedMemory = activeMemory + wiredMemory + compressedMemory
let swapInfo = fetchSwapInfo()
let memoryPressure = fetchMemoryPressure()
return MemoryInfo(
totalMemory: totalMemory,
usedMemory: usedMemory,
freeMemory: freeMemory,
activeMemory: activeMemory,
inactiveMemory: inactiveMemory,
wiredMemory: wiredMemory,
compressedMemory: compressedMemory,
cachedMemory: cachedMemory,
swapUsed: swapInfo.used,
swapTotal: swapInfo.total,
memoryPressure: memoryPressure
)
}
private func fetchVMStatistics() -> (
freePages: UInt64,
activePages: UInt64,
inactivePages: UInt64,
wiredPages: UInt64,
compressedPages: UInt64,
cachedPages: UInt64
)? {
var stats = vm_statistics64_data_t()
var count = mach_msg_type_number_t(MemoryLayout<vm_statistics64_data_t>.size / MemoryLayout<integer_t>.size)
let result = withUnsafeMutablePointer(to: &stats) { ptr in
ptr.withMemoryRebound(to: integer_t.self, capacity: Int(count)) { intPtr in
host_statistics64(mach_host_self(), HOST_VM_INFO64, intPtr, &count)
}
}
guard result == KERN_SUCCESS else { return nil }
return (
freePages: UInt64(stats.free_count),
activePages: UInt64(stats.active_count),
inactivePages: UInt64(stats.inactive_count),
wiredPages: UInt64(stats.wire_count),
compressedPages: UInt64(stats.compressor_page_count),
cachedPages: UInt64(stats.external_page_count)
)
}
private func fetchSwapInfo() -> (used: UInt64, total: UInt64) {
var swapUsage = xsw_usage()
var size = MemoryLayout<xsw_usage>.size
if sysctlbyname("vm.swapusage", &swapUsage, &size, nil, 0) == 0 {
return (UInt64(swapUsage.xsu_used), UInt64(swapUsage.xsu_total))
}
return (0, 0)
}
private func fetchMemoryPressure() -> MemoryPressure {
var pressure: Int32 = 0
var size = MemoryLayout<Int32>.size
if sysctlbyname("kern.memorystatus_vm_pressure_level", &pressure, &size, nil, 0) == 0 {
switch pressure {
case 1: return .nominal
case 2: return .warning
case 4: return .critical
default: return .nominal
}
}
return .unknown
}
}

Fájl megtekintése

@@ -0,0 +1,124 @@
import Foundation
import Darwin
final class NetworkMonitor {
private var previousStats: [String: (download: UInt64, upload: UInt64, timestamp: Date)] = [:]
func fetchNetworkInfo() -> NetworkInfo {
let interfaces = fetchInterfaces()
let totalDownload = interfaces.reduce(0.0) { $0 + $1.downloadRate }
let totalUpload = interfaces.reduce(0.0) { $0 + $1.uploadRate }
let totalDownloadBytes = interfaces.reduce(UInt64(0)) { $0 + $1.downloadBytes }
let totalUploadBytes = interfaces.reduce(UInt64(0)) { $0 + $1.uploadBytes }
return NetworkInfo(
interfaces: interfaces,
totalDownloadRate: totalDownload,
totalUploadRate: totalUpload,
totalDownloadBytes: totalDownloadBytes,
totalUploadBytes: totalUploadBytes
)
}
private func fetchInterfaces() -> [NetworkInterface] {
var ifaddr: UnsafeMutablePointer<ifaddrs>?
guard getifaddrs(&ifaddr) == 0, let firstAddr = ifaddr else {
return []
}
defer { freeifaddrs(ifaddr) }
var interfaceStats: [String: (download: UInt64, upload: UInt64)] = [:]
var currentAddr: UnsafeMutablePointer<ifaddrs>? = firstAddr
while let addr = currentAddr {
let interface = addr.pointee
if interface.ifa_addr.pointee.sa_family == UInt8(AF_LINK) {
let name = String(cString: interface.ifa_name)
if shouldIncludeInterface(name: name),
let data = interface.ifa_data {
let networkData = data.assumingMemoryBound(to: if_data.self).pointee
let download = UInt64(networkData.ifi_ibytes)
let upload = UInt64(networkData.ifi_obytes)
if let existing = interfaceStats[name] {
interfaceStats[name] = (
download: existing.download + download,
upload: existing.upload + upload
)
} else {
interfaceStats[name] = (download: download, upload: upload)
}
}
}
currentAddr = interface.ifa_next
}
let now = Date()
var interfaces: [NetworkInterface] = []
for (name, stats) in interfaceStats {
var downloadRate: Double = 0
var uploadRate: Double = 0
if let previous = previousStats[name] {
let timeDelta = now.timeIntervalSince(previous.timestamp)
if timeDelta > 0 {
// Handle counter reset/overflow: only compute rate if current >= previous
if stats.download >= previous.download {
downloadRate = Double(stats.download - previous.download) / timeDelta
}
if stats.upload >= previous.upload {
uploadRate = Double(stats.upload - previous.upload) / timeDelta
}
}
}
previousStats[name] = (stats.download, stats.upload, now)
let isActive = downloadRate > 0 || uploadRate > 0 || stats.download > 0 || stats.upload > 0
interfaces.append(NetworkInterface(
name: name,
displayName: displayName(for: name),
downloadBytes: stats.download,
uploadBytes: stats.upload,
downloadRate: downloadRate,
uploadRate: uploadRate,
isActive: isActive
))
}
return interfaces.sorted { $0.name < $1.name }
}
private func shouldIncludeInterface(name: String) -> Bool {
// Include common physical interfaces
let includedPrefixes = ["en", "bridge", "awdl", "llw", "utun"]
return includedPrefixes.contains { name.hasPrefix($0) }
}
private func displayName(for interface: String) -> String {
if interface.hasPrefix("en") {
if interface == "en0" {
return "Wi-Fi / Ethernet"
}
return "Ethernet \(interface)"
} else if interface.hasPrefix("bridge") {
return "Bridge"
} else if interface.hasPrefix("awdl") {
return "AirDrop"
} else if interface.hasPrefix("llw") {
return "Low Latency WLAN"
} else if interface.hasPrefix("utun") {
return "VPN Tunnel"
}
return interface
}
}

Fájl megtekintése

@@ -0,0 +1,296 @@
import Foundation
import Darwin
import AppKit
final class ProcessMonitor {
private var previousCPUTimes: [pid_t: (user: UInt64, system: UInt64, timestamp: Date)] = [:]
private let iconCache = NSCache<NSNumber, NSImage>()
private var nameCache: [pid_t: String] = [:]
private var userCache: [uid_t: String] = [:]
private let timebaseInfo: mach_timebase_info_data_t
init() {
var info = mach_timebase_info_data_t()
mach_timebase_info(&info)
self.timebaseInfo = info
}
func fetchProcesses() -> [ProcessItem] {
var pids = [pid_t](repeating: 0, count: 2048)
let bytesUsed = proc_listpids(UInt32(PROC_ALL_PIDS), 0, &pids, Int32(pids.count * MemoryLayout<pid_t>.size))
guard bytesUsed > 0 else { return [] }
let pidCount = Int(bytesUsed) / MemoryLayout<pid_t>.size
var processes: [ProcessItem] = []
var currentPids = Set<pid_t>()
for i in 0..<pidCount {
let pid = pids[i]
guard pid > 0 else { continue }
currentPids.insert(pid)
if let process = fetchProcessInfo(pid: pid) {
processes.append(process)
}
}
// Clean up caches for terminated processes
let stalePids = Set(nameCache.keys).subtracting(currentPids)
for pid in stalePids {
nameCache.removeValue(forKey: pid)
iconCache.removeObject(forKey: NSNumber(value: pid))
previousCPUTimes.removeValue(forKey: pid)
}
return processes
}
private func fetchProcessInfo(pid: pid_t) -> ProcessItem? {
var bsdInfo = proc_bsdinfo()
let bsdInfoSize = Int32(MemoryLayout<proc_bsdinfo>.size)
let bsdResult = proc_pidinfo(pid, PROC_PIDTBSDINFO, 0, &bsdInfo, bsdInfoSize)
// If proc_pidinfo fails, use sysctl to get basic info (works for processes we don't own)
if bsdResult != bsdInfoSize {
return fetchBasicProcessInfo(pid: pid)
}
var taskInfo = proc_taskinfo()
let taskInfoSize = Int32(MemoryLayout<proc_taskinfo>.size)
let taskResult = proc_pidinfo(pid, PROC_PIDTASKINFO, 0, &taskInfo, taskInfoSize)
let hasTaskInfo = taskResult == taskInfoSize
let name = fetchProcessName(pid: pid, bsdInfo: bsdInfo)
let user = fetchUsername(uid: bsdInfo.pbi_uid)
let parentPid = pid_t(bsdInfo.pbi_ppid)
let startTime = Date(timeIntervalSince1970: TimeInterval(bsdInfo.pbi_start_tvsec))
// For processes without task info, use defaults
let memoryUsage: Int64
let threadCount: Int32
let cpuUsage: Double
if hasTaskInfo {
let rusageData = fetchRusageData(pid: pid)
memoryUsage = rusageData.memory
threadCount = taskInfo.pti_threadnum
cpuUsage = calculateCPUUsage(
pid: pid,
userTime: rusageData.userTime,
systemTime: rusageData.systemTime
)
} else {
memoryUsage = 0
threadCount = 0
cpuUsage = 0
}
let state = determineProcessState(status: bsdInfo.pbi_status, cpuUsage: cpuUsage)
let icon = fetchIcon(pid: pid)
return ProcessItem(
pid: pid,
name: name,
user: user,
cpuUsage: cpuUsage,
memoryUsage: memoryUsage,
threadCount: threadCount,
state: state,
icon: icon,
parentPid: parentPid,
startTime: startTime
)
}
private func fetchProcessName(pid: pid_t, bsdInfo: proc_bsdinfo) -> String {
// Check cache first
if let cached = nameCache[pid] {
return cached
}
// PROC_PIDPATHINFO_MAXSIZE is 4 * MAXPATHLEN = 4096
var pathBuffer = [CChar](repeating: 0, count: 4096)
let pathLength = proc_pidpath(pid, &pathBuffer, UInt32(pathBuffer.count))
let name: String
if pathLength > 0 {
let path = String(cString: pathBuffer)
name = (path as NSString).lastPathComponent
} else {
let bsdName = withUnsafePointer(to: bsdInfo.pbi_name) { ptr -> String in
ptr.withMemoryRebound(to: CChar.self, capacity: Int(MAXCOMLEN)) {
String(cString: $0)
}
}
name = bsdName.isEmpty ? "(Unknown)" : bsdName
}
nameCache[pid] = name
return name
}
private func fetchUsername(uid: uid_t) -> String {
if let cached = userCache[uid] {
return cached
}
let name: String
if let pw = getpwuid(uid) {
name = String(cString: pw.pointee.pw_name)
} else {
name = String(uid)
}
userCache[uid] = name
return name
}
private func fetchRusageData(pid: pid_t) -> (memory: Int64, userTime: UInt64, systemTime: UInt64) {
var rusage = rusage_info_v4()
let result = withUnsafeMutablePointer(to: &rusage) { ptr -> Int32 in
ptr.withMemoryRebound(to: rusage_info_t?.self, capacity: 1) { rusagePtr in
proc_pid_rusage(pid, RUSAGE_INFO_V4, rusagePtr)
}
}
if result == 0 {
return (
memory: Int64(rusage.ri_phys_footprint),
userTime: rusage.ri_user_time,
systemTime: rusage.ri_system_time
)
}
// Fallback to proc_taskinfo if rusage fails
var taskInfo = proc_taskinfo()
let taskInfoSize = Int32(MemoryLayout<proc_taskinfo>.size)
if proc_pidinfo(pid, PROC_PIDTASKINFO, 0, &taskInfo, taskInfoSize) == taskInfoSize {
return (
memory: Int64(taskInfo.pti_resident_size),
userTime: taskInfo.pti_total_user,
systemTime: taskInfo.pti_total_system
)
}
return (memory: 0, userTime: 0, systemTime: 0)
}
private func fetchBasicProcessInfo(pid: pid_t) -> ProcessItem? {
var mib: [Int32] = [CTL_KERN, KERN_PROC, KERN_PROC_PID, pid]
var info = kinfo_proc()
var size = MemoryLayout<kinfo_proc>.size
let result = sysctl(&mib, UInt32(mib.count), &info, &size, nil, 0)
guard result == 0, size > 0 else { return nil }
// Extract name from kp_proc.p_comm
var name = withUnsafePointer(to: info.kp_proc.p_comm) { ptr -> String in
ptr.withMemoryRebound(to: CChar.self, capacity: 16) {
String(cString: $0)
}
}
if name.isEmpty {
name = "(Unknown)"
}
// Check cache for full name
if let cachedName = nameCache[pid] {
name = cachedName
} else {
nameCache[pid] = name
}
let user = fetchUsername(uid: info.kp_eproc.e_ucred.cr_uid)
let parentPid = info.kp_eproc.e_ppid
// Determine state from p_stat
let state: ProcessState
switch info.kp_proc.p_stat {
case 5: state = .zombie
case 4: state = .stopped
case 1: state = .unknown
default: state = .sleeping // Can't determine CPU usage, assume sleeping
}
return ProcessItem(
pid: pid,
name: name,
user: user,
cpuUsage: 0,
memoryUsage: 0,
threadCount: 0,
state: state,
icon: nil,
parentPid: parentPid,
startTime: nil
)
}
private func determineProcessState(status: UInt32, cpuUsage: Double) -> ProcessState {
// Status values: SIDL=1, SRUN=2, SSLEEP=3, SSTOP=4, SZOMB=5
switch status {
case 5: return .zombie
case 4: return .stopped
case 1: return .unknown
default:
// For runnable processes (stat == 2 or 3), use CPU usage to determine display state
return cpuUsage > 1.0 ? .running : .sleeping
}
}
private func calculateCPUUsage(pid: pid_t, userTime: UInt64, systemTime: UInt64) -> Double {
let now = Date()
let totalTime = userTime + systemTime
defer {
previousCPUTimes[pid] = (userTime, systemTime, now)
}
guard let previous = previousCPUTimes[pid] else {
return 0
}
let timeDelta = now.timeIntervalSince(previous.timestamp)
guard timeDelta > 0 else { return 0 }
let previousTotal = previous.user + previous.system
// Handle case where times might wrap or process restarted
guard totalTime >= previousTotal else { return 0 }
let cpuDelta = totalTime - previousTotal
// Convert Mach absolute time to nanoseconds
let nanoseconds = cpuDelta * UInt64(timebaseInfo.numer) / UInt64(timebaseInfo.denom)
// Convert nanoseconds to seconds
let cpuSeconds = Double(nanoseconds) / 1_000_000_000
// Calculate percentage: (CPU time / wall time) * 100
let cpuUsage = (cpuSeconds / timeDelta) * 100
return min(cpuUsage, 100 * Double(ProcessInfo.processInfo.processorCount))
}
private func fetchIcon(pid: pid_t) -> NSImage? {
let cacheKey = NSNumber(value: pid)
if let cached = iconCache.object(forKey: cacheKey) {
return cached
}
if let app = NSRunningApplication(processIdentifier: pid),
let icon = app.icon {
iconCache.setObject(icon, forKey: cacheKey)
return icon
}
return nil
}
func clearCPUHistory() {
previousCPUTimes.removeAll()
}
}

Fájl megtekintése

@@ -0,0 +1,183 @@
import Foundation
import Combine
@MainActor
final class SystemMonitor: ObservableObject {
static let shared = SystemMonitor()
// Published properties
@Published var cpuInfo: CPUInfo?
@Published var memoryInfo: MemoryInfo?
@Published var processes: [ProcessItem] = []
@Published var diskInfo: DiskInfo?
@Published var networkInfo: NetworkInfo?
@Published var gpuInfo: GPUInfo?
@Published var lastError: String?
// History for charts
@Published var cpuHistory: [CPUHistoryPoint] = []
@Published var coreHistories: [Int: [CoreHistoryPoint]] = [:]
@Published var memoryHistory: [MemoryHistoryPoint] = []
@Published var networkHistory: [NetworkHistoryPoint] = []
// Sub-monitors
private let cpuMonitor = CPUMonitor()
private let memoryMonitor = MemoryMonitor()
private let processMonitor = ProcessMonitor()
private let diskMonitor = DiskMonitor()
private let networkMonitor = NetworkMonitor()
private let gpuMonitor = GPUMonitor()
// Timer
private var timer: Timer?
private let historyLimit = 60
private var refreshCount = 0
var isAppleSilicon: Bool {
cpuMonitor.isAppleSilicon
}
var thermalState: ProcessInfo.ThermalState {
ProcessInfo.processInfo.thermalState
}
private init() {}
func startMonitoring() {
// Initial fetch
Task {
await refreshAll()
}
// Start periodic refresh (2 second interval to reduce CPU usage)
timer = Timer.scheduledTimer(withTimeInterval: 2.0, repeats: true) { [weak self] _ in
Task { @MainActor in
await self?.refreshAll()
}
}
}
func stopMonitoring() {
timer?.invalidate()
timer = nil
}
private func refreshAll() async {
refreshCount += 1
await withTaskGroup(of: Void.self) { group in
group.addTask { await self.refreshCPU() }
group.addTask { await self.refreshMemory() }
group.addTask { await self.refreshNetwork() }
// Refresh processes every other cycle = 4 seconds (expensive operation)
if self.refreshCount % 2 == 0 {
group.addTask { await self.refreshProcesses() }
}
// Refresh disk and GPU every 3 cycles = 6 seconds (less volatile)
if self.refreshCount % 3 == 0 {
group.addTask { await self.refreshDisk() }
group.addTask { await self.refreshGPU() }
}
}
}
private func refreshCPU() async {
if let info = cpuMonitor.fetchCPUInfo() {
cpuInfo = info
// Global CPU history
let historyPoint = CPUHistoryPoint(
timestamp: info.timestamp,
usage: info.globalUsage,
userUsage: info.userUsage,
systemUsage: info.systemUsage
)
cpuHistory.append(historyPoint)
if cpuHistory.count > historyLimit {
cpuHistory.removeFirst()
}
// Per-core history
for core in info.coreUsages {
let corePoint = CoreHistoryPoint(
timestamp: info.timestamp,
usage: core.usage
)
if coreHistories[core.id] == nil {
coreHistories[core.id] = []
}
coreHistories[core.id]?.append(corePoint)
if coreHistories[core.id]?.count ?? 0 > historyLimit {
coreHistories[core.id]?.removeFirst()
}
}
}
}
private func refreshMemory() async {
if let info = memoryMonitor.fetchMemoryInfo() {
memoryInfo = info
let historyPoint = MemoryHistoryPoint(
timestamp: info.timestamp,
usedMemory: info.usedMemory,
totalMemory: info.totalMemory
)
memoryHistory.append(historyPoint)
if memoryHistory.count > historyLimit {
memoryHistory.removeFirst()
}
}
}
private func refreshProcesses() async {
processes = processMonitor.fetchProcesses()
}
private func refreshDisk() async {
diskInfo = diskMonitor.fetchDiskInfo()
}
private func refreshNetwork() async {
if let info = networkMonitor.fetchNetworkInfo() as NetworkInfo? {
networkInfo = info
let historyPoint = NetworkHistoryPoint(
timestamp: info.timestamp,
downloadRate: info.totalDownloadRate,
uploadRate: info.totalUploadRate
)
networkHistory.append(historyPoint)
if networkHistory.count > historyLimit {
networkHistory.removeFirst()
}
}
}
private func refreshGPU() async {
gpuInfo = gpuMonitor.fetchGPUInfo()
}
// Process control methods
@discardableResult
func terminateProcess(_ pid: pid_t) -> Bool {
kill(pid, SIGTERM) == 0
}
@discardableResult
func forceKillProcess(_ pid: pid_t) -> Bool {
kill(pid, SIGKILL) == 0
}
@discardableResult
func suspendProcess(_ pid: pid_t) -> Bool {
kill(pid, SIGSTOP) == 0
}
@discardableResult
func resumeProcess(_ pid: pid_t) -> Bool {
kill(pid, SIGCONT) == 0
}
}

Fájl megtekintése

@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.app-sandbox</key>
<false/>
</dict>
</plist>

Fájl megtekintése

@@ -0,0 +1,35 @@
import SwiftUI
@main
struct TopManagerApp: App {
@StateObject private var monitor = SystemMonitor.shared
var body: some Scene {
WindowGroup {
ContentView()
.environmentObject(monitor)
.onAppear {
monitor.startMonitoring()
}
}
.windowStyle(.automatic)
.defaultSize(width: 1000, height: 700)
.commands {
CommandGroup(replacing: .newItem) { }
}
// Menu Bar Extra showing CPU %
MenuBarExtra {
MenuBarView()
.environmentObject(monitor)
} label: {
if let cpu = monitor.cpuInfo {
Text(String(format: "%.0f%%", cpu.globalUsage))
.monospacedDigit()
} else {
Image(systemName: "cpu")
}
}
.menuBarExtraStyle(.window)
}
}

BINáris
TopManager/TopManager_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Méret: 337 KiB

Fájl megtekintése

@@ -0,0 +1,66 @@
import Foundation
func formatBytes(_ bytes: UInt64) -> String {
let formatter = ByteCountFormatter()
formatter.countStyle = .binary
formatter.allowedUnits = [.useBytes, .useKB, .useMB, .useGB, .useTB]
return formatter.string(fromByteCount: Int64(bytes))
}
func formatBytes(_ bytes: Int64) -> String {
let formatter = ByteCountFormatter()
formatter.countStyle = .binary
formatter.allowedUnits = [.useBytes, .useKB, .useMB, .useGB, .useTB]
return formatter.string(fromByteCount: bytes)
}
func formatBytes(_ bytes: Double) -> String {
formatBytes(UInt64(max(0, bytes)))
}
func formatBytesPerSecond(_ bytesPerSecond: Double) -> String {
let absValue = abs(bytesPerSecond)
if absValue < 1 {
return "0 B/s"
}
let formatter = ByteCountFormatter()
formatter.countStyle = .binary
formatter.allowedUnits = [.useBytes, .useKB, .useMB, .useGB]
return formatter.string(fromByteCount: Int64(absValue)) + "/s"
}
func formatBytesCompact(_ bytes: Double) -> String {
let absValue = abs(bytes)
if absValue < 1 {
return "0"
} else if absValue < 1024 {
return String(format: "%.0f B", absValue)
} else if absValue < 1024 * 1024 {
return String(format: "%.1f KB", absValue / 1024)
} else if absValue < 1024 * 1024 * 1024 {
return String(format: "%.1f MB", absValue / (1024 * 1024))
} else {
return String(format: "%.2f GB", absValue / (1024 * 1024 * 1024))
}
}
func formatPercentage(_ value: Double, decimals: Int = 1) -> String {
String(format: "%.\(decimals)f%%", value)
}
func formatUptime(_ interval: TimeInterval) -> String {
let days = Int(interval) / 86400
let hours = (Int(interval) % 86400) / 3600
let minutes = (Int(interval) % 3600) / 60
if days > 0 {
return "\(days)d \(hours)h \(minutes)m"
} else if hours > 0 {
return "\(hours)h \(minutes)m"
} else {
return "\(minutes)m"
}
}

Fájl megtekintése

@@ -0,0 +1,233 @@
import SwiftUI
import AppKit
struct RunningApp: Identifiable {
let id: pid_t
let pid: pid_t
let name: String
let bundleIdentifier: String?
let icon: NSImage?
let isActive: Bool
let isHidden: Bool
let launchDate: Date?
var cpuUsage: Double
var memoryUsage: Int64
}
struct AppsView: View {
@EnvironmentObject var monitor: SystemMonitor
@State private var runningApps: [RunningApp] = []
@State private var selectedApp: Set<pid_t> = []
@State private var sortOrder: [KeyPathComparator<RunningApp>] = [
.init(\.name, order: .forward)
]
@State private var searchText = ""
var filteredApps: [RunningApp] {
let filtered = runningApps.filter {
searchText.isEmpty ||
$0.name.localizedCaseInsensitiveContains(searchText) ||
($0.bundleIdentifier?.localizedCaseInsensitiveContains(searchText) ?? false)
}
return filtered.sorted(using: sortOrder)
}
var body: some View {
VStack(spacing: 0) {
// Summary bar
HStack {
Text("\(runningApps.count) apps")
.foregroundColor(.secondary)
Spacer()
if let activeApp = runningApps.first(where: { $0.isActive }) {
HStack(spacing: 4) {
Text("Active:")
.foregroundColor(.secondary)
if let icon = activeApp.icon {
Image(nsImage: icon)
.resizable()
.frame(width: 14, height: 14)
}
Text(activeApp.name)
.fontWeight(.medium)
}
}
TextField("Search...", text: $searchText)
.textFieldStyle(.roundedBorder)
.frame(width: 150)
}
.padding(.horizontal)
.padding(.vertical, 8)
.background(Color(nsColor: .windowBackgroundColor))
Divider()
// Apps table
Table(filteredApps, selection: $selectedApp, sortOrder: $sortOrder) {
TableColumn("") { app in
if let icon = app.icon {
Image(nsImage: icon)
.resizable()
.frame(width: 20, height: 20)
} else {
Image(systemName: "app.dashed")
.frame(width: 20, height: 20)
}
}
.width(28)
TableColumn("Name", value: \.name) { app in
HStack(spacing: 6) {
Text(app.name)
.lineLimit(1)
if app.isActive {
Circle()
.fill(Color.green)
.frame(width: 6, height: 6)
}
if app.isHidden {
Image(systemName: "eye.slash")
.font(.caption)
.foregroundColor(.secondary)
}
}
}
.width(min: 150, ideal: 200)
TableColumn("PID", value: \.pid) { app in
Text("\(app.pid)")
.monospacedDigit()
}
.width(60)
TableColumn("CPU %", value: \.cpuUsage) { app in
Text(String(format: "%.1f%%", app.cpuUsage))
.monospacedDigit()
.foregroundColor(cpuColor(app.cpuUsage))
}
.width(70)
TableColumn("Memory", value: \.memoryUsage) { app in
Text(formatBytes(app.memoryUsage))
.monospacedDigit()
}
.width(90)
TableColumn("Bundle ID") { app in
Text(app.bundleIdentifier ?? "-")
.font(.caption)
.foregroundColor(.secondary)
.lineLimit(1)
}
.width(min: 150, ideal: 200)
}
.contextMenu(forSelectionType: pid_t.self) { selection in
if let pid = selection.first, let app = runningApps.first(where: { $0.pid == pid }) {
Button("Activate") {
activateApp(pid: pid)
}
Button("Hide") {
hideApp(pid: pid)
}
Divider()
Button("Quit") {
quitApp(pid: pid)
}
Button("Force Quit") {
forceQuitApp(pid: pid)
}
Divider()
Button("Copy Bundle ID") {
if let bundleId = app.bundleIdentifier {
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(bundleId, forType: .string)
}
}
.disabled(app.bundleIdentifier == nil)
}
} primaryAction: { selection in
if let pid = selection.first {
activateApp(pid: pid)
}
}
}
.onAppear {
refreshApps()
}
.onChange(of: monitor.processes) { _ in
refreshApps()
}
}
private func refreshApps() {
let workspace = NSWorkspace.shared
let apps = workspace.runningApplications
// Build a map of PID to process info for CPU/memory data
let processMap = Dictionary(uniqueKeysWithValues: monitor.processes.map { ($0.pid, $0) })
runningApps = apps.compactMap { app -> RunningApp? in
// Only include regular apps (not background agents)
guard app.activationPolicy == .regular else { return nil }
let pid = app.processIdentifier
let processInfo = processMap[pid]
return RunningApp(
id: pid,
pid: pid,
name: app.localizedName ?? app.bundleIdentifier ?? "Unknown",
bundleIdentifier: app.bundleIdentifier,
icon: app.icon,
isActive: app.isActive,
isHidden: app.isHidden,
launchDate: app.launchDate,
cpuUsage: processInfo?.cpuUsage ?? 0,
memoryUsage: processInfo?.memoryUsage ?? 0
)
}
}
private func activateApp(pid: pid_t) {
if let app = NSRunningApplication(processIdentifier: pid) {
app.activate(options: [.activateIgnoringOtherApps])
}
}
private func hideApp(pid: pid_t) {
if let app = NSRunningApplication(processIdentifier: pid) {
app.hide()
}
}
private func quitApp(pid: pid_t) {
if let app = NSRunningApplication(processIdentifier: pid) {
app.terminate()
}
}
private func forceQuitApp(pid: pid_t) {
if let app = NSRunningApplication(processIdentifier: pid) {
app.forceTerminate()
}
}
private func cpuColor(_ usage: Double) -> Color {
if usage > 80 {
return .red
} else if usage > 50 {
return .orange
} else if usage > 20 {
return .yellow
}
return .primary
}
}
#Preview {
AppsView()
.environmentObject(SystemMonitor.shared)
}

Fájl megtekintése

@@ -0,0 +1,35 @@
import SwiftUI
struct ContentView: View {
@EnvironmentObject var monitor: SystemMonitor
var body: some View {
TabView {
ProcessView()
.tabItem {
Label("Processes", systemImage: "list.bullet.rectangle")
}
AppsView()
.tabItem {
Label("Apps", systemImage: "square.grid.2x2")
}
PerformanceView()
.tabItem {
Label("Performance", systemImage: "chart.line.uptrend.xyaxis")
}
PowerStorageView()
.tabItem {
Label("Power & Storage", systemImage: "battery.100.bolt")
}
}
.frame(minWidth: 800, minHeight: 500)
}
}
#Preview {
ContentView()
.environmentObject(SystemMonitor.shared)
}

Fájl megtekintése

@@ -0,0 +1,83 @@
import SwiftUI
struct MenuBarView: View {
@EnvironmentObject var monitor: SystemMonitor
var body: some View {
VStack(alignment: .leading, spacing: 8) {
if let cpu = monitor.cpuInfo {
HStack {
Image(systemName: "cpu")
.frame(width: 16)
Text("CPU:")
Spacer()
Text(String(format: "%.1f%%", cpu.globalUsage))
.monospacedDigit()
}
}
if let mem = monitor.memoryInfo {
HStack {
Image(systemName: "memorychip")
.frame(width: 16)
Text("Memory:")
Spacer()
Text(String(format: "%.1f%%", mem.usagePercentage))
.monospacedDigit()
}
}
if let net = monitor.networkInfo {
HStack {
Image(systemName: "arrow.down.circle")
.frame(width: 16)
Text("Download:")
Spacer()
Text(formatBytesPerSecond(net.totalDownloadRate))
.monospacedDigit()
}
HStack {
Image(systemName: "arrow.up.circle")
.frame(width: 16)
Text("Upload:")
Spacer()
Text(formatBytesPerSecond(net.totalUploadRate))
.monospacedDigit()
}
}
if let gpu = monitor.gpuInfo {
HStack {
Image(systemName: "gpu")
.frame(width: 16)
Text("GPU VRAM:")
Spacer()
Text(formatBytes(gpu.vramUsed))
.monospacedDigit()
}
}
Divider()
Button("Open TopManager") {
NSApp.activate(ignoringOtherApps: true)
if let window = NSApp.windows.first(where: { $0.canBecomeMain }) {
window.makeKeyAndOrderFront(nil)
}
}
Button("Quit") {
NSApplication.shared.terminate(nil)
}
.keyboardShortcut("q")
}
.padding(12)
.frame(width: 220)
}
}
#Preview {
MenuBarView()
.environmentObject(SystemMonitor.shared)
}

Fájl megtekintése

@@ -0,0 +1,87 @@
import SwiftUI
import Charts
struct CPULineChart: View {
let history: [CPUHistoryPoint]
var body: some View {
Chart {
ForEach(history) { point in
// User usage line
LineMark(
x: .value("Time", point.timestamp),
y: .value("User", point.userUsage),
series: .value("Type", "User")
)
.foregroundStyle(.blue)
.lineStyle(StrokeStyle(lineWidth: 1.5))
// System usage line
LineMark(
x: .value("Time", point.timestamp),
y: .value("System", point.systemUsage),
series: .value("Type", "System")
)
.foregroundStyle(.red)
.lineStyle(StrokeStyle(lineWidth: 1.5))
// Total usage line
LineMark(
x: .value("Time", point.timestamp),
y: .value("Total", point.usage),
series: .value("Type", "Total")
)
.foregroundStyle(.gray)
.lineStyle(StrokeStyle(lineWidth: 2))
}
}
.chartYScale(domain: -5...105)
.chartYAxis {
AxisMarks(position: .leading, values: [0, 25, 50, 75, 100]) { value in
AxisGridLine()
AxisValueLabel {
if let intValue = value.as(Int.self) {
Text("\(intValue)%")
.font(.caption2)
}
}
}
}
.padding(.vertical, 8)
.chartXAxis {
AxisMarks(values: .automatic(desiredCount: 5)) { _ in
AxisGridLine()
}
}
.chartLegend(position: .bottom, spacing: 10) {
HStack(spacing: 16) {
ChartLegendItem(color: .blue, label: "User")
ChartLegendItem(color: .red, label: "System")
ChartLegendItem(color: .gray, label: "Total")
}
}
.drawingGroup()
}
}
struct ChartLegendItem: View {
let color: Color
let label: String
var body: some View {
HStack(spacing: 4) {
RoundedRectangle(cornerRadius: 2)
.fill(color)
.frame(width: 12, height: 3)
Text(label)
.font(.caption)
.foregroundColor(.secondary)
}
}
}
#Preview {
CPULineChart(history: [])
.frame(height: 200)
.padding()
}

Fájl megtekintése

@@ -0,0 +1,112 @@
import SwiftUI
struct MemoryDonutView: View {
@EnvironmentObject var monitor: SystemMonitor
var memorySegments: [MemorySegment] {
guard let mem = monitor.memoryInfo else { return [] }
return [
MemorySegment(name: "App", value: Double(mem.appMemory), color: .blue),
MemorySegment(name: "Wired", value: Double(mem.wiredMemory), color: .orange),
MemorySegment(name: "Compressed", value: Double(mem.compressedMemory), color: .yellow),
MemorySegment(name: "Free", value: Double(mem.freeMemory + mem.cachedMemory), color: .green.opacity(0.5))
]
}
var body: some View {
ZStack {
// Donut chart
DonutChart(segments: memorySegments)
// Center text
if let mem = monitor.memoryInfo {
VStack {
Text(formatBytes(mem.usedMemory))
.font(.title3)
.fontWeight(.semibold)
.monospacedDigit()
Text("of \(formatBytes(mem.totalMemory))")
.font(.caption)
.foregroundColor(.secondary)
}
}
}
}
}
struct DonutChart: View {
let segments: [MemorySegment]
let lineWidth: CGFloat = 30
var total: Double {
segments.reduce(0) { $0 + $1.value }
}
var body: some View {
GeometryReader { geometry in
let size = min(geometry.size.width, geometry.size.height)
ZStack {
ForEach(Array(segments.enumerated()), id: \.element.id) { index, segment in
DonutSegment(
startAngle: startAngle(for: index),
endAngle: endAngle(for: index),
lineWidth: lineWidth
)
.fill(segment.color)
}
}
.frame(width: size, height: size)
.position(x: geometry.size.width / 2, y: geometry.size.height / 2)
}
}
private func startAngle(for index: Int) -> Angle {
guard total > 0 else { return .degrees(-90) }
let precedingSum = segments.prefix(index).reduce(0) { $0 + $1.value }
return .degrees((precedingSum / total) * 360 - 90)
}
private func endAngle(for index: Int) -> Angle {
guard total > 0 else { return .degrees(-90) }
let sum = segments.prefix(index + 1).reduce(0) { $0 + $1.value }
return .degrees((sum / total) * 360 - 90)
}
}
struct DonutSegment: Shape {
let startAngle: Angle
let endAngle: Angle
let lineWidth: CGFloat
func path(in rect: CGRect) -> Path {
var path = Path()
let center = CGPoint(x: rect.midX, y: rect.midY)
let radius = min(rect.width, rect.height) / 2 - lineWidth / 2
path.addArc(
center: center,
radius: radius,
startAngle: startAngle,
endAngle: endAngle,
clockwise: false
)
return path.strokedPath(StrokeStyle(lineWidth: lineWidth, lineCap: .butt))
}
}
struct MemorySegment: Identifiable {
let id = UUID()
let name: String
let value: Double
let color: Color
}
#Preview {
MemoryDonutView()
.environmentObject(SystemMonitor.shared)
.frame(width: 250, height: 250)
.padding()
}

Fájl megtekintése

@@ -0,0 +1,44 @@
import SwiftUI
import Charts
struct MemoryLineChart: View {
let history: [MemoryHistoryPoint]
var body: some View {
Chart {
ForEach(history) { point in
LineMark(
x: .value("Time", point.timestamp),
y: .value("Usage", point.usagePercentage)
)
.foregroundStyle(.blue)
.lineStyle(StrokeStyle(lineWidth: 2))
}
}
.chartYScale(domain: -5...105)
.chartYAxis {
AxisMarks(position: .leading, values: [0, 25, 50, 75, 100]) { value in
AxisGridLine()
AxisValueLabel {
if let intValue = value.as(Int.self) {
Text("\(intValue)%")
.font(.caption2)
}
}
}
}
.padding(.vertical, 8)
.chartXAxis {
AxisMarks(values: .automatic(desiredCount: 5)) { _ in
AxisGridLine()
}
}
.drawingGroup()
}
}
#Preview {
MemoryLineChart(history: [])
.frame(height: 200)
.padding()
}

Fájl megtekintése

@@ -0,0 +1,100 @@
import SwiftUI
import Charts
struct DownloadLineChart: View {
let history: [NetworkHistoryPoint]
var maxRate: Double {
max(history.map(\.downloadRate).max() ?? 0, 1024)
}
var yScaleMax: Double {
maxRate * 1.1 // 10% margin at top
}
var body: some View {
Chart {
ForEach(history) { point in
LineMark(
x: .value("Time", point.timestamp),
y: .value("Download", point.downloadRate)
)
.foregroundStyle(.blue)
.lineStyle(StrokeStyle(lineWidth: 2))
}
}
.chartYScale(domain: 0...yScaleMax)
.chartYAxis {
AxisMarks(position: .leading) { value in
AxisGridLine()
AxisValueLabel {
if let rate = value.as(Double.self) {
Text(formatBytesPerSecond(rate))
.font(.caption2)
}
}
}
}
.chartXAxis {
AxisMarks(values: .automatic(desiredCount: 5)) { _ in
AxisGridLine()
}
}
.padding(.vertical, 8)
.drawingGroup()
}
}
struct UploadLineChart: View {
let history: [NetworkHistoryPoint]
var maxRate: Double {
max(history.map(\.uploadRate).max() ?? 0, 1024)
}
var yScaleMax: Double {
maxRate * 1.1 // 10% margin at top
}
var body: some View {
Chart {
ForEach(history) { point in
LineMark(
x: .value("Time", point.timestamp),
y: .value("Upload", point.uploadRate)
)
.foregroundStyle(.green)
.lineStyle(StrokeStyle(lineWidth: 2))
}
}
.chartYScale(domain: 0...yScaleMax)
.chartYAxis {
AxisMarks(position: .leading) { value in
AxisGridLine()
AxisValueLabel {
if let rate = value.as(Double.self) {
Text(formatBytesPerSecond(rate))
.font(.caption2)
}
}
}
}
.chartXAxis {
AxisMarks(values: .automatic(desiredCount: 5)) { _ in
AxisGridLine()
}
}
.padding(.vertical, 8)
.drawingGroup()
}
}
#Preview {
VStack {
DownloadLineChart(history: [])
.frame(height: 150)
UploadLineChart(history: [])
.frame(height: 150)
}
.padding()
}

Fájl megtekintése

@@ -0,0 +1,541 @@
import SwiftUI
import Charts
struct PerformanceView: View {
@State private var selectedTab = 0
var body: some View {
TabView(selection: $selectedTab) {
CPUTabView()
.tabItem {
Label("CPU", systemImage: "cpu")
}
.tag(0)
MemoryTabView()
.tabItem {
Label("Memory", systemImage: "memorychip")
}
.tag(1)
NetworkTabView()
.tabItem {
Label("Network", systemImage: "network")
}
.tag(2)
}
}
}
// MARK: - CPU Tab
struct CPUTabView: View {
@EnvironmentObject var monitor: SystemMonitor
private let coreColumns = [
GridItem(.flexible()),
GridItem(.flexible()),
GridItem(.flexible()),
GridItem(.flexible())
]
var body: some View {
ScrollView {
VStack(spacing: 16) {
// Overall CPU
GroupBox {
VStack(alignment: .leading, spacing: 12) {
HStack {
Text("Total CPU Usage")
.font(.headline)
Spacer()
if let cpu = monitor.cpuInfo {
Text(String(format: "%.1f%%", cpu.globalUsage))
.font(.title2)
.fontWeight(.semibold)
.monospacedDigit()
}
}
CPULineChart(history: monitor.cpuHistory)
.frame(height: 120)
// Legend
HStack(spacing: 20) {
ChartLegendItem(color: .blue, label: "User")
ChartLegendItem(color: .red, label: "System")
ChartLegendItem(color: .gray, label: "Total")
}
.frame(maxWidth: .infinity)
}
.padding(.vertical, 8)
}
// Per-core charts
if let cpu = monitor.cpuInfo {
// P-Cores
if !cpu.pCoreUsages.isEmpty {
GroupBox {
VStack(alignment: .leading, spacing: 12) {
Text("Performance Cores")
.font(.headline)
LazyVGrid(columns: coreColumns, spacing: 12) {
ForEach(cpu.pCoreUsages) { core in
CoreLineChartView(
coreId: core.id,
coreType: "P",
usage: core.usage,
history: monitor.coreHistories[core.id] ?? [],
color: .orange
)
}
}
}
.padding(.vertical, 8)
}
}
// E-Cores
if !cpu.eCoreUsages.isEmpty {
GroupBox {
VStack(alignment: .leading, spacing: 12) {
Text("Efficiency Cores")
.font(.headline)
LazyVGrid(columns: coreColumns, spacing: 12) {
ForEach(cpu.eCoreUsages) { core in
CoreLineChartView(
coreId: core.id,
coreType: "E",
usage: core.usage,
history: monitor.coreHistories[core.id] ?? [],
color: .blue
)
}
}
}
.padding(.vertical, 8)
}
}
// All cores (for non-Apple Silicon)
if cpu.pCoreUsages.isEmpty && cpu.eCoreUsages.isEmpty {
GroupBox {
VStack(alignment: .leading, spacing: 12) {
Text("CPU Cores")
.font(.headline)
LazyVGrid(columns: coreColumns, spacing: 12) {
ForEach(cpu.coreUsages) { core in
CoreLineChartView(
coreId: core.id,
coreType: "",
usage: core.usage,
history: monitor.coreHistories[core.id] ?? [],
color: .blue
)
}
}
}
.padding(.vertical, 8)
}
}
}
}
.padding()
}
}
}
struct CoreLineChartView: View {
let coreId: Int
let coreType: String
let usage: Double
let history: [CoreHistoryPoint]
let color: Color
var body: some View {
VStack(alignment: .leading, spacing: 4) {
HStack {
Text(coreType.isEmpty ? "Core \(coreId)" : "\(coreType)\(coreId)")
.font(.caption)
.fontWeight(.medium)
Spacer()
Text(String(format: "%.0f%%", usage))
.font(.caption)
.monospacedDigit()
.foregroundColor(usageColor(usage))
}
// Line chart for this core
Chart {
ForEach(history) { point in
LineMark(
x: .value("Time", point.timestamp),
y: .value("Usage", point.usage)
)
.foregroundStyle(color)
.lineStyle(StrokeStyle(lineWidth: 1.5))
}
}
.chartYScale(domain: -5...105)
.chartXAxis(.hidden)
.chartYAxis(.hidden)
.frame(height: 50)
.drawingGroup()
}
.padding(8)
.background(Color(nsColor: .controlBackgroundColor))
.cornerRadius(6)
}
private func usageColor(_ usage: Double) -> Color {
if usage > 80 { return .red }
if usage > 50 { return .orange }
return .primary
}
}
// MARK: - Memory Tab
struct MemoryTabView: View {
@EnvironmentObject var monitor: SystemMonitor
var body: some View {
ScrollView {
VStack(spacing: 16) {
HStack(alignment: .top, spacing: 16) {
// Left column: Donut chart
GroupBox {
VStack(alignment: .leading, spacing: 12) {
Text("Memory Composition")
.font(.headline)
MemoryDonutView()
.frame(height: 200)
if let mem = monitor.memoryInfo {
MemoryLegendView(memory: mem)
}
}
.padding(.vertical, 8)
}
// Right column: Chart + Details
VStack(spacing: 16) {
// Memory history chart
GroupBox {
VStack(alignment: .leading, spacing: 12) {
HStack {
Text("Memory Usage Over Time")
.font(.headline)
Spacer()
if let mem = monitor.memoryInfo {
Text(String(format: "%.1f%%", mem.usagePercentage))
.font(.title2)
.fontWeight(.semibold)
.monospacedDigit()
}
}
MemoryLineChart(history: monitor.memoryHistory)
.frame(height: 150)
if let mem = monitor.memoryInfo {
HStack {
Text("Used: \(formatBytes(mem.usedMemory))")
Spacer()
Text("Free: \(formatBytes(mem.freeMemory))")
Spacer()
Text("Total: \(formatBytes(mem.totalMemory))")
}
.font(.caption)
.foregroundColor(.secondary)
}
}
.padding(.vertical, 8)
}
// Memory details
if let mem = monitor.memoryInfo {
GroupBox {
VStack(alignment: .leading, spacing: 12) {
Text("Memory Details")
.font(.headline)
HStack(spacing: 20) {
MemoryStatItem(label: "Swap Used", value: formatBytes(mem.swapUsed))
MemoryStatItem(label: "Swap Total", value: formatBytes(mem.swapTotal))
MemoryStatItem(label: "Pressure", value: mem.memoryPressure.rawValue, color: pressureColor(mem.memoryPressure))
Spacer()
}
}
.padding(.vertical, 8)
.frame(maxWidth: .infinity)
}
.frame(maxWidth: .infinity)
}
}
}
// GPU Memory
if let gpu = monitor.gpuInfo {
GroupBox {
VStack(alignment: .leading, spacing: 12) {
HStack {
Label("GPU", systemImage: "gpu")
.font(.headline)
Text(gpu.name)
.foregroundColor(.secondary)
Spacer()
}
HStack {
Text(gpu.memoryLabel + ":")
.foregroundColor(.secondary)
if gpu.vramUsed > 0 {
Text(formatBytes(gpu.vramUsed))
.monospacedDigit()
if let total = gpu.vramTotal {
Text("/ \(formatBytes(total))")
.foregroundColor(.secondary)
}
} else if gpu.isUnifiedMemory {
Text("Unified Memory Architecture")
.foregroundColor(.secondary)
}
Spacer()
if let util = gpu.utilizationPercent {
Text("GPU: \(String(format: "%.0f%%", util))")
.monospacedDigit()
}
}
if gpu.vramUsed > 0, let total = gpu.vramTotal {
ProgressView(value: Double(gpu.vramUsed), total: Double(total))
.tint(.purple)
}
}
.padding(.vertical, 8)
}
}
}
.padding()
}
}
private func pressureColor(_ pressure: MemoryPressure) -> Color {
switch pressure {
case .nominal: return .green
case .warning: return .yellow
case .critical: return .red
case .unknown: return .secondary
}
}
}
struct MemoryLegendView: View {
let memory: MemoryInfo
var body: some View {
VStack(spacing: 4) {
LegendRow(color: .blue, label: "App Memory", value: formatBytes(memory.appMemory))
LegendRow(color: .orange, label: "Wired", value: formatBytes(memory.wiredMemory))
LegendRow(color: .yellow, label: "Compressed", value: formatBytes(memory.compressedMemory))
LegendRow(color: .green.opacity(0.5), label: "Cached/Free", value: formatBytes(memory.cachedMemory + memory.freeMemory))
}
}
}
struct LegendRow: View {
let color: Color
let label: String
let value: String
var body: some View {
HStack {
Circle()
.fill(color)
.frame(width: 8, height: 8)
Text(label)
.font(.caption)
.foregroundColor(.secondary)
Spacer()
Text(value)
.font(.caption)
.monospacedDigit()
}
}
}
struct MemoryStatItem: View {
let label: String
let value: String
var color: Color = .primary
var body: some View {
VStack(alignment: .leading, spacing: 2) {
Text(label)
.font(.caption)
.foregroundColor(.secondary)
Text(value)
.font(.body)
.foregroundColor(color)
.monospacedDigit()
}
}
}
// MARK: - Network Tab
struct NetworkTabView: View {
@EnvironmentObject var monitor: SystemMonitor
var body: some View {
ScrollView {
VStack(spacing: 16) {
// Download chart
GroupBox {
VStack(alignment: .leading, spacing: 12) {
HStack {
Label("Download", systemImage: "arrow.down.circle")
.font(.headline)
.foregroundColor(.blue)
Spacer()
if let net = monitor.networkInfo {
Text(formatBytesPerSecond(net.totalDownloadRate))
.font(.title2)
.fontWeight(.semibold)
.monospacedDigit()
}
}
DownloadLineChart(history: monitor.networkHistory)
.frame(height: 150)
}
.padding(.vertical, 8)
}
// Upload chart
GroupBox {
VStack(alignment: .leading, spacing: 12) {
HStack {
Label("Upload", systemImage: "arrow.up.circle")
.font(.headline)
.foregroundColor(.green)
Spacer()
if let net = monitor.networkInfo {
Text(formatBytesPerSecond(net.totalUploadRate))
.font(.title2)
.fontWeight(.semibold)
.monospacedDigit()
}
}
UploadLineChart(history: monitor.networkHistory)
.frame(height: 150)
}
.padding(.vertical, 8)
}
// Network interfaces
GroupBox {
VStack(alignment: .leading, spacing: 12) {
Text("Network Interfaces")
.font(.headline)
if let net = monitor.networkInfo {
ForEach(net.interfaces.filter { $0.isActive }) { iface in
NetworkInterfaceRowView(interface: iface)
}
if net.interfaces.filter({ $0.isActive }).isEmpty {
Text("No active interfaces")
.foregroundColor(.secondary)
}
}
}
.padding(.vertical, 8)
}
// Totals
if let net = monitor.networkInfo {
GroupBox {
VStack(alignment: .leading, spacing: 8) {
Text("Session Totals")
.font(.headline)
HStack(spacing: 40) {
VStack(alignment: .leading) {
Text("Downloaded")
.font(.caption)
.foregroundColor(.secondary)
Text(formatBytes(net.totalDownloadBytes))
.monospacedDigit()
}
VStack(alignment: .leading) {
Text("Uploaded")
.font(.caption)
.foregroundColor(.secondary)
Text(formatBytes(net.totalUploadBytes))
.monospacedDigit()
}
}
}
.padding(.vertical, 8)
}
}
}
.padding()
}
}
}
struct NetworkInterfaceRowView: View {
let interface: NetworkInterface
var body: some View {
VStack(alignment: .leading, spacing: 4) {
HStack {
Text(interface.displayName)
.fontWeight(.medium)
Spacer()
Text(interface.name)
.font(.caption)
.foregroundColor(.secondary)
}
HStack {
HStack(spacing: 4) {
Image(systemName: "arrow.down")
.foregroundColor(.blue)
Text(formatBytesPerSecond(interface.downloadRate))
.monospacedDigit()
}
Spacer()
HStack(spacing: 4) {
Image(systemName: "arrow.up")
.foregroundColor(.green)
Text(formatBytesPerSecond(interface.uploadRate))
.monospacedDigit()
}
}
.font(.caption)
Divider()
}
}
}
#Preview {
PerformanceView()
.environmentObject(SystemMonitor.shared)
.frame(width: 900, height: 700)
}

Fájl megtekintése

@@ -0,0 +1,91 @@
import SwiftUI
struct DiskUsageView: View {
let volume: VolumeInfo
var body: some View {
VStack(alignment: .leading, spacing: 8) {
HStack {
Image(systemName: volumeIcon)
.foregroundColor(.secondary)
Text(volume.name)
.fontWeight(.medium)
Spacer()
Text(volume.mountPoint)
.font(.caption)
.foregroundColor(.secondary)
}
ProgressView(value: volume.usagePercentage, total: 100)
.tint(usageColor)
HStack {
Text("\(formatBytes(volume.usedSpace)) used")
.font(.caption)
.foregroundColor(.secondary)
Spacer()
Text("\(formatBytes(volume.freeSpace)) free")
.font(.caption)
.foregroundColor(.secondary)
Spacer()
Text("\(formatBytes(volume.totalSpace)) total")
.font(.caption)
.foregroundColor(.secondary)
}
Divider()
}
}
private var volumeIcon: String {
if volume.isRemovable {
return "externaldrive"
} else if volume.mountPoint == "/" {
return "internaldrive.fill"
} else {
return "internaldrive"
}
}
private var usageColor: Color {
if volume.usagePercentage > 90 {
return .red
} else if volume.usagePercentage > 75 {
return .orange
} else {
return .blue
}
}
}
#Preview {
VStack {
DiskUsageView(volume: VolumeInfo(
name: "Macintosh HD",
mountPoint: "/",
totalSpace: 500 * 1024 * 1024 * 1024,
freeSpace: 150 * 1024 * 1024 * 1024,
fileSystem: "apfs",
isRemovable: false,
isInternal: true
))
DiskUsageView(volume: VolumeInfo(
name: "External Drive",
mountPoint: "/Volumes/External",
totalSpace: 1024 * 1024 * 1024 * 1024,
freeSpace: 800 * 1024 * 1024 * 1024,
fileSystem: "apfs",
isRemovable: true,
isInternal: false
))
}
.padding()
}

Fájl megtekintése

@@ -0,0 +1,272 @@
import SwiftUI
struct PowerStorageView: View {
@EnvironmentObject var monitor: SystemMonitor
var body: some View {
ScrollView {
VStack(spacing: 20) {
// System Status and GPU side by side
HStack(alignment: .top, spacing: 20) {
// System Status (left column)
GroupBox {
VStack(alignment: .leading, spacing: 10) {
Label("System Status", systemImage: "thermometer.medium")
.font(.headline)
HStack {
Text("macOS:")
Spacer()
Text(ProcessInfo.processInfo.operatingSystemVersionString)
.foregroundColor(.secondary)
}
HStack {
Text("Uptime:")
Spacer()
Text(formatUptime(ProcessInfo.processInfo.systemUptime))
.monospacedDigit()
}
HStack {
Text("Thermal State:")
Spacer()
ThermalStateView(state: monitor.thermalState)
}
if let cpu = monitor.cpuInfo {
HStack {
Text("CPU Usage:")
Spacer()
Text(String(format: "%.1f%%", cpu.globalUsage))
.monospacedDigit()
}
HStack {
Text("CPU Cores:")
Spacer()
Text("\(cpu.coreUsages.count)")
.monospacedDigit()
}
}
if let mem = monitor.memoryInfo {
HStack {
Text("Memory:")
Spacer()
Text("\(formatBytes(mem.usedMemory)) / \(formatBytes(mem.totalMemory))")
.monospacedDigit()
}
}
if monitor.isAppleSilicon {
HStack {
Text("Architecture:")
Spacer()
Text("Apple Silicon")
}
}
}
.padding(.vertical, 8)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
// GPU Info (right column)
GroupBox {
VStack(alignment: .leading, spacing: 10) {
if let gpu = monitor.gpuInfo {
HStack {
Label("GPU", systemImage: "cpu.fill")
.font(.headline)
Spacer()
}
HStack {
Text("Name:")
Spacer()
Text(gpu.name)
.foregroundColor(.secondary)
}
if let cores = gpu.coreCount {
HStack {
Text("GPU Cores:")
Spacer()
Text("\(cores)")
.monospacedDigit()
}
}
HStack {
Text("VRAM Used:")
Spacer()
Text(formatBytes(gpu.vramUsed))
.monospacedDigit()
}
if let total = gpu.vramTotal {
HStack {
Text("VRAM Total:")
Spacer()
Text(formatBytes(total))
.monospacedDigit()
}
ProgressView(value: Double(gpu.vramUsed), total: Double(total))
.tint(.purple)
}
if let utilization = gpu.utilizationPercent {
HStack {
Text("Utilization:")
Spacer()
Text(String(format: "%.1f%%", utilization))
.monospacedDigit()
}
}
} else {
Label("GPU", systemImage: "cpu.fill")
.font(.headline)
Text("Loading GPU info...")
.foregroundColor(.secondary)
}
Spacer(minLength: 0)
}
.padding(.vertical, 8)
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
}
.frame(maxWidth: .infinity, maxHeight: .infinity)
}
.fixedSize(horizontal: false, vertical: true)
// Storage
GroupBox {
VStack(alignment: .leading, spacing: 12) {
Label("Storage", systemImage: "internaldrive")
.font(.headline)
if let diskInfo = monitor.diskInfo {
ForEach(diskInfo.volumes) { volume in
DiskUsageView(volume: volume)
}
} else {
Text("Loading storage information...")
.foregroundColor(.secondary)
}
}
.padding(.vertical, 8)
}
// Network Interfaces
GroupBox {
VStack(alignment: .leading, spacing: 12) {
Label("Network Interfaces", systemImage: "network")
.font(.headline)
if let networkInfo = monitor.networkInfo {
ForEach(networkInfo.interfaces.filter { $0.isActive }) { iface in
NetworkInterfaceRow(interface: iface)
}
if networkInfo.interfaces.filter({ $0.isActive }).isEmpty {
Text("No active interfaces")
.foregroundColor(.secondary)
}
}
}
.padding(.vertical, 8)
}
}
.padding()
}
}
}
struct ThermalStateView: View {
let state: ProcessInfo.ThermalState
var body: some View {
HStack(spacing: 4) {
Image(systemName: stateIcon)
.foregroundColor(stateColor)
Text(stateText)
.foregroundColor(stateColor)
}
}
private var stateIcon: String {
switch state {
case .nominal: return "checkmark.circle.fill"
case .fair: return "exclamationmark.circle.fill"
case .serious: return "exclamationmark.triangle.fill"
case .critical: return "xmark.octagon.fill"
@unknown default: return "questionmark.circle"
}
}
private var stateColor: Color {
switch state {
case .nominal: return .green
case .fair: return .yellow
case .serious: return .orange
case .critical: return .red
@unknown default: return .secondary
}
}
private var stateText: String {
switch state {
case .nominal: return "Normal"
case .fair: return "Fair"
case .serious: return "Serious"
case .critical: return "Critical"
@unknown default: return "Unknown"
}
}
}
struct NetworkInterfaceRow: View {
let interface: NetworkInterface
var body: some View {
VStack(alignment: .leading, spacing: 4) {
HStack {
Text(interface.displayName)
.fontWeight(.medium)
Spacer()
Text(interface.name)
.font(.caption)
.foregroundColor(.secondary)
}
HStack {
HStack(spacing: 4) {
Image(systemName: "arrow.down")
.foregroundColor(.blue)
Text(formatBytesPerSecond(interface.downloadRate))
.monospacedDigit()
}
Spacer()
HStack(spacing: 4) {
Image(systemName: "arrow.up")
.foregroundColor(.green)
Text(formatBytesPerSecond(interface.uploadRate))
.monospacedDigit()
}
}
.font(.caption)
Divider()
}
}
}
#Preview {
PowerStorageView()
.environmentObject(SystemMonitor.shared)
.frame(width: 600, height: 700)
}

Fájl megtekintése

@@ -0,0 +1,110 @@
import SwiftUI
struct ProcessDetailView: View {
let process: ProcessItem
var body: some View {
VStack(alignment: .leading, spacing: 16) {
// Header
HStack(spacing: 12) {
if let icon = process.icon {
Image(nsImage: icon)
.resizable()
.frame(width: 48, height: 48)
} else {
Image(systemName: "app.dashed")
.font(.system(size: 48))
}
VStack(alignment: .leading) {
Text(process.name)
.font(.title2)
.fontWeight(.semibold)
Text("PID: \(process.pid)")
.foregroundColor(.secondary)
}
Spacer()
VStack(alignment: .trailing) {
HStack {
Image(systemName: process.state.symbol)
Text(process.state.rawValue)
}
.foregroundColor(stateColor(process.state))
}
}
Divider()
// Details grid
LazyVGrid(columns: [
GridItem(.flexible()),
GridItem(.flexible())
], alignment: .leading, spacing: 12) {
DetailRow(label: "CPU Usage", value: String(format: "%.1f%%", process.cpuUsage))
DetailRow(label: "Memory", value: formatBytes(process.memoryUsage))
DetailRow(label: "Threads", value: "\(process.threadCount)")
DetailRow(label: "User", value: process.user)
DetailRow(label: "Parent PID", value: "\(process.parentPid)")
if let startTime = process.startTime {
DetailRow(label: "Started", value: formatDate(startTime))
}
}
Spacer()
}
.padding()
.frame(minWidth: 300)
}
private func stateColor(_ state: ProcessState) -> Color {
switch state {
case .running: return .green
case .sleeping: return .secondary
case .stopped: return .orange
case .zombie: return .red
case .unknown: return .secondary
}
}
private func formatDate(_ date: Date) -> String {
let formatter = DateFormatter()
formatter.dateStyle = .short
formatter.timeStyle = .medium
return formatter.string(from: date)
}
}
struct DetailRow: View {
let label: String
let value: String
var body: some View {
VStack(alignment: .leading, spacing: 2) {
Text(label)
.font(.caption)
.foregroundColor(.secondary)
Text(value)
.font(.body)
.monospacedDigit()
}
}
}
#Preview {
ProcessDetailView(process: ProcessItem(
pid: 1234,
name: "Safari",
user: "ariel",
cpuUsage: 12.5,
memoryUsage: 512 * 1024 * 1024,
threadCount: 42,
state: .running,
icon: nil,
parentPid: 1,
startTime: Date()
))
}

Fájl megtekintése

@@ -0,0 +1,426 @@
import SwiftUI
enum ProcessSortColumn: String {
case name, pid, cpu, memory, threads, user, state
}
struct ProcessView: View {
@EnvironmentObject var monitor: SystemMonitor
@State private var searchText = ""
@State private var selectedProcess: Set<ProcessItem.ID> = []
@State private var sortColumn: ProcessSortColumn = .cpu
@State private var sortAscending: Bool = false
@State private var displayedProcesses: [ProcessItem] = []
// Keep sortOrder for Table binding compatibility
@State private var sortOrder: [KeyPathComparator<ProcessItem>] = [
.init(\.cpuUsage, order: .reverse)
]
// Confirmation dialogs
@State private var showTerminateConfirm = false
@State private var showForceKillConfirm = false
@State private var processToKill: ProcessItem?
// "Don't ask again" preferences
@AppStorage("skipTerminateConfirm") private var skipTerminateConfirm = false
@AppStorage("skipForceKillConfirm") private var skipForceKillConfirm = false
private func updateDisplayedProcesses() {
let filtered = monitor.processes.filter {
searchText.isEmpty ||
$0.name.localizedCaseInsensitiveContains(searchText) ||
String($0.pid).contains(searchText)
}
displayedProcesses = filtered.sorted { lhs, rhs in
let comparison: ComparisonResult
switch sortColumn {
case .name:
comparison = lhs.name.localizedCaseInsensitiveCompare(rhs.name)
case .pid:
comparison = lhs.pid < rhs.pid ? .orderedAscending : (lhs.pid > rhs.pid ? .orderedDescending : .orderedSame)
case .cpu:
comparison = lhs.cpuUsage < rhs.cpuUsage ? .orderedAscending : (lhs.cpuUsage > rhs.cpuUsage ? .orderedDescending : .orderedSame)
case .memory:
comparison = lhs.memoryUsage < rhs.memoryUsage ? .orderedAscending : (lhs.memoryUsage > rhs.memoryUsage ? .orderedDescending : .orderedSame)
case .threads:
comparison = lhs.threadCount < rhs.threadCount ? .orderedAscending : (lhs.threadCount > rhs.threadCount ? .orderedDescending : .orderedSame)
case .user:
comparison = lhs.user.localizedCaseInsensitiveCompare(rhs.user)
case .state:
comparison = lhs.state.rawValue.compare(rhs.state.rawValue)
}
// Primary sort
if comparison != .orderedSame {
return sortAscending ? comparison == .orderedAscending : comparison == .orderedDescending
}
// Tiebreaker: sort by PID for stability
return lhs.pid < rhs.pid
}
}
var selectedProcessItem: ProcessItem? {
guard let pid = selectedProcess.first else { return nil }
return monitor.processes.first { $0.pid == pid }
}
var body: some View {
VStack(spacing: 0) {
// Summary bar - separate view to avoid re-rendering table
ProcessSummaryBar(processCount: displayedProcesses.count, searchText: $searchText)
Divider()
// Process table
Table(displayedProcesses, selection: $selectedProcess, sortOrder: $sortOrder) {
TableColumn("") { process in
if let icon = process.icon {
Image(nsImage: icon)
.resizable()
.frame(width: 16, height: 16)
} else {
Image(systemName: "app.dashed")
.frame(width: 16, height: 16)
}
}
.width(24)
TableColumn("Name", value: \.name) { process in
Text(process.name)
.lineLimit(1)
}
.width(min: 150, ideal: 200)
TableColumn("PID", value: \.pid) { process in
Text("\(process.pid)")
.monospacedDigit()
}
.width(60)
TableColumn("CPU %", value: \.cpuUsage) { process in
Text(String(format: "%.1f%%", process.cpuUsage))
.monospacedDigit()
.foregroundColor(cpuColor(process.cpuUsage))
}
.width(70)
TableColumn("Memory", value: \.memoryUsage) { process in
Text(formatBytes(process.memoryUsage))
.monospacedDigit()
}
.width(80)
TableColumn("Threads", value: \.threadCount) { process in
Text("\(process.threadCount)")
.monospacedDigit()
}
.width(60)
TableColumn("User", value: \.user) { process in
Text(process.user)
.lineLimit(1)
}
.width(80)
TableColumn("State", value: \.state.rawValue) { process in
HStack(spacing: 4) {
Image(systemName: process.state.symbol)
.foregroundColor(stateColor(process.state))
Text(process.state.rawValue)
}
}
.width(90)
}
.contextMenu(forSelectionType: ProcessItem.ID.self) { selection in
if let pid = selection.first {
Button("Terminate (⌫)") {
initiateTerminate()
}
Button("Force Kill (⌘⌫)") {
initiateForceKill()
}
Divider()
Button("Suspend") {
monitor.suspendProcess(pid)
}
Button("Resume") {
monitor.resumeProcess(pid)
}
Divider()
Button("Copy PID") {
NSPasteboard.general.clearContents()
NSPasteboard.general.setString("\(pid)", forType: .string)
}
}
} primaryAction: { selection in
// Double-click action
}
.onDeleteCommand {
initiateTerminate()
}
}
.onAppear {
updateDisplayedProcesses()
}
.onChange(of: monitor.processes) { _ in
updateDisplayedProcesses()
}
.onChange(of: searchText) { _ in
updateDisplayedProcesses()
}
.onChange(of: sortColumn) { _ in
updateDisplayedProcesses()
}
.onChange(of: sortAscending) { _ in
updateDisplayedProcesses()
}
.onChange(of: sortOrder) { newOrder in
guard let comparator = newOrder.first else { return }
// Detect which column and direction from the KeyPathComparator
let ascending = comparator.order == .forward
// Use string representation of keypath to determine column
let keyPathString = String(describing: comparator)
if keyPathString.contains("cpuUsage") {
sortColumn = .cpu
} else if keyPathString.contains("memoryUsage") {
sortColumn = .memory
} else if keyPathString.contains("name") {
sortColumn = .name
} else if keyPathString.contains("pid") {
sortColumn = .pid
} else if keyPathString.contains("threadCount") {
sortColumn = .threads
} else if keyPathString.contains("user") {
sortColumn = .user
} else if keyPathString.contains("state") {
sortColumn = .state
}
sortAscending = ascending
}
.background(
KeyboardShortcutHandler(
onCommandBackspace: { initiateForceKill() }
)
)
.sheet(isPresented: $showTerminateConfirm) {
if let process = processToKill {
ConfirmationSheet(
title: "Terminate Process",
message: "Are you sure you want to terminate \"\(process.name)\" (PID: \(process.pid))?",
actionTitle: "Terminate",
isDestructive: true,
skipPreferenceKey: "skipTerminateConfirm",
onConfirm: {
monitor.terminateProcess(process.pid)
},
onCancel: {}
)
}
}
.sheet(isPresented: $showForceKillConfirm) {
if let process = processToKill {
ConfirmationSheet(
title: "Force Kill Process",
message: "Are you sure you want to force kill \"\(process.name)\" (PID: \(process.pid))?\n\nThis will immediately terminate the process without allowing it to save data.",
actionTitle: "Force Kill",
isDestructive: true,
skipPreferenceKey: "skipForceKillConfirm",
onConfirm: {
monitor.forceKillProcess(process.pid)
},
onCancel: {}
)
}
}
}
private func initiateTerminate() {
guard let process = selectedProcessItem else { return }
processToKill = process
if skipTerminateConfirm {
monitor.terminateProcess(process.pid)
} else {
showTerminateConfirm = true
}
}
private func initiateForceKill() {
guard let process = selectedProcessItem else { return }
processToKill = process
if skipForceKillConfirm {
monitor.forceKillProcess(process.pid)
} else {
showForceKillConfirm = true
}
}
private func cpuColor(_ usage: Double) -> Color {
if usage > 80 {
return .red
} else if usage > 50 {
return .orange
} else if usage > 20 {
return .yellow
}
return .primary
}
private func stateColor(_ state: ProcessState) -> Color {
switch state {
case .running: return .green
case .sleeping: return .secondary
case .stopped: return .orange
case .zombie: return .red
case .unknown: return .secondary
}
}
}
struct ConfirmationSheet: View {
let title: String
let message: String
let actionTitle: String
let isDestructive: Bool
let skipPreferenceKey: String
let onConfirm: () -> Void
let onCancel: () -> Void
@Environment(\.dismiss) private var dismiss
@State private var dontAskAgain = false
@AppStorage private var skipConfirm: Bool
init(
title: String,
message: String,
actionTitle: String,
isDestructive: Bool,
skipPreferenceKey: String,
onConfirm: @escaping () -> Void,
onCancel: @escaping () -> Void
) {
self.title = title
self.message = message
self.actionTitle = actionTitle
self.isDestructive = isDestructive
self.skipPreferenceKey = skipPreferenceKey
self.onConfirm = onConfirm
self.onCancel = onCancel
self._skipConfirm = AppStorage(wrappedValue: false, skipPreferenceKey)
}
var body: some View {
VStack(spacing: 20) {
Image(systemName: isDestructive ? "exclamationmark.triangle.fill" : "questionmark.circle.fill")
.font(.system(size: 48))
.foregroundColor(isDestructive ? .orange : .blue)
Text(title)
.font(.headline)
Text(message)
.font(.body)
.foregroundColor(.secondary)
.multilineTextAlignment(.center)
.fixedSize(horizontal: false, vertical: true)
Toggle("Don't ask again", isOn: $dontAskAgain)
.toggleStyle(.checkbox)
HStack(spacing: 12) {
Button("Cancel") {
onCancel()
dismiss()
}
.keyboardShortcut(.cancelAction)
Button(actionTitle) {
if dontAskAgain {
skipConfirm = true
}
onConfirm()
dismiss()
}
.keyboardShortcut(.defaultAction)
.buttonStyle(.borderedProminent)
.tint(isDestructive ? .red : .accentColor)
}
}
.padding(24)
.frame(width: 350)
}
}
struct KeyboardShortcutHandler: NSViewRepresentable {
let onCommandBackspace: () -> Void
func makeNSView(context: Context) -> NSView {
let view = KeyCaptureView()
view.onCommandBackspace = onCommandBackspace
return view
}
func updateNSView(_ nsView: NSView, context: Context) {
if let view = nsView as? KeyCaptureView {
view.onCommandBackspace = onCommandBackspace
}
}
class KeyCaptureView: NSView {
var onCommandBackspace: (() -> Void)?
override func performKeyEquivalent(with event: NSEvent) -> Bool {
// Backspace = keyCode 51
if event.keyCode == 51 && event.modifierFlags.contains(.command) {
onCommandBackspace?()
return true
}
return super.performKeyEquivalent(with: event)
}
}
}
struct ProcessSummaryBar: View {
@EnvironmentObject var monitor: SystemMonitor
let processCount: Int
@Binding var searchText: String
var body: some View {
HStack {
Text("\(processCount) processes")
.foregroundColor(.secondary)
Spacer()
if let cpu = monitor.cpuInfo {
Text("CPU: \(String(format: "%.1f%%", cpu.globalUsage))")
.monospacedDigit()
}
if let mem = monitor.memoryInfo {
Text("Memory: \(formatBytes(mem.usedMemory)) / \(formatBytes(mem.totalMemory))")
.monospacedDigit()
}
TextField("Search...", text: $searchText)
.textFieldStyle(.roundedBorder)
.frame(width: 150)
}
.padding(.horizontal)
.padding(.vertical, 8)
.background(Color(nsColor: .windowBackgroundColor))
}
}
#Preview {
ProcessView()
.environmentObject(SystemMonitor.shared)
}

37
project.yml Normal file
Fájl megtekintése

@@ -0,0 +1,37 @@
name: TopManager
options:
bundleIdPrefix: com.topmanager
deploymentTarget:
macOS: "13.0"
xcodeVersion: "15.0"
createIntermediateGroups: true
settings:
base:
MACOSX_DEPLOYMENT_TARGET: "13.0"
SWIFT_VERSION: "5.9"
CODE_SIGN_STYLE: Automatic
ENABLE_HARDENED_RUNTIME: YES
DEVELOPMENT_TEAM: ""
targets:
TopManager:
type: application
platform: macOS
sources:
- path: TopManager
excludes:
- "**/.DS_Store"
settings:
base:
PRODUCT_BUNDLE_IDENTIFIER: com.topmanager.app
INFOPLIST_FILE: TopManager/Info.plist
CODE_SIGN_ENTITLEMENTS: TopManager/TopManager.entitlements
PRODUCT_NAME: TopManager
GENERATE_INFOPLIST_FILE: NO
SWIFT_EMIT_LOC_STRINGS: YES
ASSETCATALOG_COMPILER_APPICON_NAME: AppIcon
info:
path: TopManager/Info.plist
entitlements:
path: TopManager/TopManager.entitlements