Add base gnome extensions

This commit is contained in:
2024-01-17 15:38:16 -05:00
parent 78ab940cae
commit 6d45aaa042
330 changed files with 47886 additions and 0 deletions

View File

@ -0,0 +1,34 @@
// Bing Wallpaper GNOME extension
// Copyright (C) 2017-2023 Michael Carroll
// This extension is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// See the GNU General Public License, version 3 or later for details.
import St from 'gi://St';
import Gio from 'gi://Gio';
const CLIPBOARD_TYPE = St.ClipboardType.CLIPBOARD;
export default class BWClipboard {
constructor() {
this.clipboard = St.Clipboard.get_default();
}
setImage(filename) {
try {
let file = Gio.File.new_for_path(filename);
let [success, image_data] = file.load_contents(null);
//log('error: '+success);
if (success)
this.clipboard.set_content(CLIPBOARD_TYPE, 'image/jpeg', image_data);
} catch (err) {
log('unable to set clipboard to data in '+filename);
}
}
setText(text) {
this.clipboard.set_text(CLIPBOARD_TYPE, text);
}
};

View File

@ -0,0 +1,675 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://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 <http://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:
{project} Copyright (C) {year} {fullname}
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
<http://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
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -0,0 +1,99 @@
# GNOME Shell extension - Bing Wallpaper
Bring some color to your GNOME desktop by syncing your desktop and lockscreen wallpapers with today's Microsoft Bing image of the day (the image you see when you visit Bing.com) with this extension. The intention of this extension is to just do what it needs to do and stay out of your way, with a few optional features to improve quality-of-life.
[![Get it on GNOME extensions](/screenshot/get_it_on_gnome_extensions.png)](https://extensions.gnome.org/extension/1262/bing-wallpaper-changer/) [![<3 Sponsor this project on GitHub <3](/screenshot/sponsor.png)](https://github.com/sponsors/neffo)
![Screenshot](/screenshot/notification.png)
As featured on [OMG! Ubuntu](https://www.omgubuntu.co.uk/2017/07/bing-wallpaper-changer-gnome-extension).
Also, check out my related [Google Earth View wallpaper extension](https://github.com/neffo/earth-view-wallpaper-gnome-extension) and the partially-derived [Bing Desktop Wallpaper for Cinnamon](https://cinnamon-spices.linuxmint.com/applets/view/320) applet by Starcross.
## Features
* Automatically sets the Bing [Image of the Day](https://www.microsoft.com/en-us/bing/bing-wallpaper) as both lock screen and desktop wallpapers
* Only attempts to download wallpapers when they have been updated - doesn't poll continuously
* Shuffle/randomise wallpapers at adjustable intervals (including from your stored Bing images)
* Image gallery to view, select and curate stored images
* Optionally delete old images after a week, or you can keep (and curate) them forever
* Override the lockscreen blur (NEW: lockscreen blur is now dynamic!)
* Language support: English (en), German (de), Dutch (nl), Italian (it), Polish (pl), Chinese (zh_CN, zh_TW), French (fr_FR), Portuguese (pt, pt_BR), Ukrainian (uk), Russian (ru_RU), Spanish (es), Korean (ko), Indonesian (id), Catalan (ca), Norwegian Bokmål (nb) & Nynorsk (nn), Swedish (sv), Arabic (ar), Hungarian (hu), Japanese (ja), Czech (cs_CZ), Finnish (fi_FI) and Turkish (tr) - a HUGE thanks to the translators
* Image preview in menus & ability to manually set wallpapers individually or copy image to clipboard
* A selection of different theme-aware indicator (tray) icons to choose (or hide it completely)
## TODO
* add more languages (#14) - [please help if you can](https://github.com/neffo/bing-wallpaper-gnome-extension/issues/14)
* add user features requests - [lots have already been implemented](https://github.com/neffo/bing-wallpaper-gnome-extension/issues?q=is%3Aissue+label%3Aenhancement+is%3Aclosed)
## Known Issues
* In China, users are limited to 'Chinese China', 'English - International' markets (this is the way Bing handles the Chinese market/locale, not an extension 'bug' - sorry!)
* Bing may detect your location incorrectly (and force a locale as above) - if you see this, please let me know what Bing.com itself does
* GNOME Shell themes can break some GNOME popup menu elements (toggle switches for example). This impacts GNOME more generally, not just this extension. Double check you are running latest versions of your themes (or disable them).
## Requirements
GNOME 3.36+ or 40+ (Ubuntu 20.04 LTS or later, older versions of the extension work with 3.18+, but are no longer supported).
## Install
[Install from extensions.gnome.org](https://extensions.gnome.org/extension/1262/bing-wallpaper-changer/)
or install directly to your GNOME extensions directory (useful if you want to hack on it)
```
mkdir ~/Desktop/source
cd ~/Desktop/source
git clone https://github.com/neffo/bing-wallpaper-gnome-extension.git
cd bing-wallpaper-gnome-extension
sh install.sh
```
## Enable debug logging
Enable debug logging through the exptension preferences 'Debug options' tab or if unable to open preferences you can enable debugging using dconf-editor with this command:
```
GSETTINGS_SCHEMA_DIR=$HOME/.local/share/gnome-shell/extensions/BingWallpaper@ineffable-gmail.com/schemas dconf-editor /org/gnome/shell/extensions/bingwallpaper/
```
Please include logs from your journal when submitting bug notices (make sure nothing sensitive is included in the text!).
## Screenshots
### Image gallery
![Settings](/screenshot/settings5.png)
### Preferences
![Settings](/screenshot/settings.png)
![Settings](/screenshot/settings2.png)
![Settings](/screenshot/settings3.png)
![Settings](/screenshot/settings4.png)
### Lockscreen blur control
From left to right:
* no blur/no dimming
* slight blur/default dimming
* default blur/default dimming
![Blur example](/screenshot/blurexample.jpg)
## Toss a coin to your coder
Do you like this extension and want to show that you appreciate the work that goes into adding new features and keeping it maintained? Please consider buying me a coffee on [GitHub Sponsors](https://github.com/sponsors/neffo) or on [Flattr](https://flattr.com/@neffo).
## Disclaimer
This extension is unofficial and not affiliated with Bing or Microsoft in any way. Images are protected by copyright, and are licensed only for use as wallpapers.
## Special Thanks
This extension is based on the NASA APOD extension by [Elinvention](https://github.com/Elinvention)
and inspired by Bing Desktop WallpaperChanger by [Utkarsh Gupta](https://github.com/UtkarshGpta). Lockscreen blur code is based on [Pratap-Kumar's extension](https://github.com/PRATAP-KUMAR/Control_Blur_Effect_On_Lock_Screen). I'd like to give a special shout out to those who have [contributed code and translations](https://github.com/neffo/bing-wallpaper-gnome-extension/graphs/contributors) as well as everyone who has reported bugs or provided feedback and suggestions for improvements. Also, thanks to Microsoft for this great API and wallpaper collection.
## License
This extension is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

View File

@ -0,0 +1,159 @@
// Bing Wallpaper GNOME extension
// Copyright (C) 2017-2023 Michael Carroll
// This extension is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// See the GNU General Public License, version 3 or later for details.
// Based on GNOME shell extension NASA APOD by Elia Argentieri https://github.com/Elinvention/gnome-shell-extension-nasa-apod
// This code based on https://github.com/PRATAP-KUMAR/Control_Blur_Effect_On_Lock_Screen
// and https://github.com/sunwxg/gnome-shell-extension-unlockDialogBackground
import St from 'gi://St';
import * as UnlockDialog from 'resource:///org/gnome/shell/ui/unlockDialog.js';
import * as Config from 'resource:///org/gnome/shell/misc/config.js';
var _updateBackgroundEffects = UnlockDialog.UnlockDialog.prototype._updateBackgroundEffects;
var _showClock = UnlockDialog.UnlockDialog.prototype._showClock;
var _showPrompt = UnlockDialog.UnlockDialog.prototype._showPrompt;
var shellVersionMajor = parseInt(Config.PACKAGE_VERSION.split('.')[0]);
var shellVersionMinor = parseInt(Config.PACKAGE_VERSION.split('.')[1]);
var shellVersionPoint = parseInt(Config.PACKAGE_VERSION.split('.')[2]);
// default BWP mild blur
var BWP_BLUR_SIGMA = 2;
var BWP_BLUR_BRIGHTNESS = 55;
// GNOME defaults
var BLUR_BRIGHTNESS = 0.55;
var BLUR_SIGMA = 60;
var debug = false;
var promptActive = false; // default GNOME method of testing this relies on state of a transisiton
// so we are being explicit here (do not want any races, thanks)
function log(msg) {
if (debug) // set 'debug' above to false to keep the noise down in journal
console.log("BingWallpaper extension/Blur: " + msg);
}
// we patch UnlockDialog._updateBackgroundEffects()
function _updateBackgroundEffects_BWP(monitorIndex) {
// GNOME shell 3.36.4 and above
log("_updateBackgroundEffects_BWP() called for shell >= 3.36.4");
const themeContext = St.ThemeContext.get_for_stage(global.stage);
for (const widget of this._backgroundGroup.get_children()) {
// set blur effects, we have two modes in lockscreen: login prompt or clock
// blur on when clock is visible is adjustable
const effect = widget.get_effect('blur');
if (promptActive) {
log('default blur active');
if (effect) {
effect.set({ // GNOME defaults when login prompt is visible
brightness: BLUR_BRIGHTNESS,
sigma: BLUR_SIGMA * themeContext.scale_factor,
});
}
}
else {
log('adjustable blur active');
if (effect) {
effect.set({ // adjustable blur when clock is visible
brightness: BWP_BLUR_BRIGHTNESS * 0.01, // we use 0-100 rather than 0-1, so divide by 100
sigma: BWP_BLUR_SIGMA * themeContext.scale_factor,
});
}
}
}
}
// we patch both UnlockDialog._showClock() and UnlockDialog._showPrompt() to let us
// adjustable blur in a Windows-like way (this ensures login prompt is readable)
function _showClock_BWP() {
promptActive = false;
this._showClock_GNOME(); // pass to default GNOME function
this._updateBackgroundEffects();
}
function _showPrompt_BWP() {
promptActive = true;
this._showPrompt_GNOME(); // pass to default GNOME function
this._updateBackgroundEffects();
}
export default class Blur {
constructor() {
this.enabled = false;
log('Bing Wallpaper adjustable blur is '+supportedVersion()?'available':'not available');
}
set_blur_strength(value) {
BWP_BLUR_SIGMA = this._clampValue(value);
log("lockscreen blur strength set to "+BWP_BLUR_SIGMA);
}
set_blur_brightness(value) {
BWP_BLUR_BRIGHTNESS = this._clampValue(value);
log("lockscreen brightness set to " + BWP_BLUR_BRIGHTNESS);
}
// valid values are 0 to 100
_clampValue(value) {
if (value > 100)
value = 100;
if (value < 0 )
value = 0;
return value;
}
_switch(enabled) {
if (enabled && !this.enabled) {
this._enable();
}
else {
this._disable();
}
}
_enable() {
if (supportedVersion()) {
log("Blur._enable() called on GNOME "+Config.PACKAGE_VERSION);
UnlockDialog.UnlockDialog.prototype._updateBackgroundEffects = _updateBackgroundEffects_BWP;
// we override _showClock and _showPrompt to patch in updates to blur effect before calling the GNOME functions
UnlockDialog.UnlockDialog.prototype._showClock = _showClock_BWP;
UnlockDialog.UnlockDialog.prototype._showPrompt = _showPrompt_BWP;
// this are the original functions which we call into from our versions above
UnlockDialog.UnlockDialog.prototype._showClock_GNOME = _showClock;
UnlockDialog.UnlockDialog.prototype._showPrompt_GNOME = _showPrompt;
}
this.enabled = true;
}
_disable() {
if (!this.enabled)
return;
log("_lockscreen_blur_disable() called");
if (supportedVersion()) {
// restore default functions
UnlockDialog.UnlockDialog.prototype._updateBackgroundEffects = _updateBackgroundEffects;
UnlockDialog.UnlockDialog.prototype._showClock = _showClock;
UnlockDialog.UnlockDialog.prototype._showPrompt = _showPrompt;
// clean up unused functions we created
UnlockDialog.UnlockDialog.prototype._showClock_GNOME = null;
delete UnlockDialog.UnlockDialog.prototype._showClock_GNOME;
UnlockDialog.UnlockDialog.prototype._showPrompt_GNOME = null;
delete UnlockDialog.UnlockDialog.prototype._showPrompt_GNOME;
}
this.enabled = false;
}
};
function supportedVersion() { // when current lockscren blur implementation was first shipped (we ignore earlier weird version)
if (shellVersionMajor >= 40 ||
(shellVersionMajor == 3 && shellVersionMinor == 36 && shellVersionPoint >= 4)) {
return true;
}
return false;
}

View File

@ -0,0 +1,228 @@
// Bing Wallpaper GNOME extension
// Copyright (C) 2017-2023 Michael Carroll
// This extension is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// See the GNU General Public License, version 3 or later for details.
// Based on GNOME shell extension NASA APOD by Elia Argentieri https://github.com/Elinvention/gnome-shell-extension-nasa-apod
import Gtk from 'gi://Gtk';
import GdkPixbuf from 'gi://GdkPixbuf';
import Gio from 'gi://Gio';
import * as Utils from './utils.js';
import {gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
const default_dimensions = [30, 30, 1650, 800]; // TODO: pull from and save dimensions to settings, but perhaps verify that dimensions are ok
const GALLERY_THUMB_WIDTH = 320;
const GALLERY_THUMB_HEIGHT = 180;
export default class Carousel {
constructor(settings, button = null, callbackfunc = null, prefs_flowbox = null, extensionPath = null) {
//create_gallery(widget, settings);
this.settings = settings;
this.button = button;
this.callbackfunc = callbackfunc;
this.flowBox = null;
this.window = null;
this.imageList = Utils.imageListSortByDate(Utils.getImageList(this.settings)).reverse(); // get images and reverse order
this.searchEntry = null;
this.extensionPath = extensionPath
this.log('create carousel...');
this.flowBox = prefs_flowbox;
this.flowBox.insert(this._create_placeholder_item(), -1);
}
_enable_button() {
if (this.button) {
this.button.set_sensitive(state);
}
}
_create_gallery() {
Utils.randomIntervals.forEach((x) => {
let item = this._create_random_item(x.value, _(x.title));
this.flowBox.insert(item, -1);
});
this.imageList.forEach((image) => {
let item = this._create_gallery_item(image);
this.flowBox.insert(item, -1);
});
}
_create_gallery_item(image) {
let buildable = new Gtk.Builder();
// grab appropriate object from UI file
buildable.add_objects_from_file(this.extensionPath + '/ui/carousel4.ui', ["flowBoxChild"]);
// assign variables to the UI objects we've just loaded
let galleryImage = buildable.get_object('galleryImage');
let filename = Utils.imageToFilename(this.settings, image);
let viewButton = buildable.get_object('viewButton');
let applyButton = buildable.get_object('applyButton');
let infoButton = buildable.get_object('infoButton');
let deleteButton = buildable.get_object('deleteButton');
let favButton = buildable.get_object('favButton');
let unfavButton = buildable.get_object('unfavButton');
if (Utils.isFavourite(image)) {
favButton.set_visible(false);
this.log('image is favourited');
}
else {
unfavButton.set_visible(false);
}
try {
this._load_image(galleryImage, filename);
}
catch (e) {
galleryImage.set_from_icon_name('image-missing');
galleryImage.set_icon_size = 2; // Gtk.GTK_ICON_SIZE_LARGE;
this.log('create_gallery_image: '+e);
}
galleryImage.set_tooltip_text(image.copyright);
// set up actions for when a image button is clicked
viewButton.connect('clicked', () => {
Utils.openInSystemViewer(filename);
});
applyButton.connect('clicked', () => {
this.settings.set_string('selected-image', Utils.getImageUrlBase(image));
this.log('gallery selected '+Utils.getImageUrlBase(image));
});
infoButton.connect('clicked', () => {
Utils.openInSystemViewer(image.copyrightlink, false);
this.log('info page link opened '+image.copyrightlink);
});
deleteButton.connect('clicked', (widget) => {
this.log('Delete requested for '+filename);
Utils.deleteImage(filename);
//Utils.cleanupImageList(this.settings); // hide image instead
Utils.hideImage(this.settings, [image]);
widget.get_parent().get_parent().set_visible(false); // bit of a hack
if (this.callbackfunc)
this.callbackfunc();
});
// button is unchecked, so we want to make the checked one visible
favButton.connect('clicked', (widget) => {
this.log('favourited '+Utils.getImageUrlBase(image));
widget.set_visible(false);
unfavButton.set_visible(true);
Utils.setImageFavouriteStatus(this.settings, image.urlbase, true);
});
// button is checked, so we want to make the unchecked one visible
unfavButton.connect('clicked', (widget) => {
this.log('unfavourited '+Utils.getImageUrlBase(image));
widget.set_visible(false);
favButton.set_visible(true);
Utils.setImageFavouriteStatus(this.settings, image.urlbase, false);
});
let item = buildable.get_object('flowBoxChild');
return item;
}
_create_random_item(interval, title) {
let buildable = new Gtk.Builder();
// grab appropriate object from UI file
buildable.add_objects_from_file(this.extensionPath + '/ui/carousel4.ui', ["flowBoxRandom"]);
let randomLabel = buildable.get_object('randomLabel');
randomLabel.set_text(title);
let filename = 'random';
let applyButton = buildable.get_object('randomButton');
applyButton.connect('clicked', (widget) => {
this.settings.set_string('random-interval-mode', interval);
this.settings.set_boolean('random-mode-enabled', true);
this.log('gallery selected random with interval '+interval+' ('+title+')');
});
let item = buildable.get_object('flowBoxRandom');
return item;
}
_create_placeholder_item() {
let buildable = new Gtk.Builder();
this.flowBox.set_max_children_per_line(1);
// grab appropriate object from UI file
buildable.add_objects_from_file(this.extensionPath + '/ui/carousel4.ui', ["flowBoxPlaceholder"]);
let loadButton = buildable.get_object('loadButton');
loadButton.connect('clicked', (widget) => {
widget.set_label(_("Loading...")); // does this work???
this.flowBox.remove(widget.get_parent());
this.flowBox.set_max_children_per_line(2);
this._create_gallery();
});
let item = buildable.get_object('flowBoxPlaceholder');
return item;
}
_load_image(galleryImage, filename) {
let thumb_path = Utils.getWallpaperDir(this.settings)+'.thumbs/';
let thumb_dir = Gio.file_new_for_path(thumb_path);
let save_thumbs = !this.settings.get_boolean('delete-previous') && this.settings.get_boolean('create-thumbs'); // create thumbs only if not deleting previous and thumbs are enabled
if (!thumb_dir.query_exists(null)) {
thumb_dir.make_directory_with_parents(null);
}
let image_file = Gio.file_new_for_path(filename);
// load gallery image or create new thumbnail if it doesn't
if (!image_file.query_exists(null)){
this._set_blank_image(galleryImage);
}
else {
let image_thumb_path = thumb_path + image_file.get_basename();
let image_thumb = Gio.file_new_for_path(image_thumb_path);
try {
let pixbuf;
// use thumbnail if available
if (image_thumb.query_exists(null)) {
pixbuf = GdkPixbuf.Pixbuf.new_from_file(image_thumb_path);
}
else { // save changed thumbnail significantly speeds up gallery loading, but costs some addtional disk space
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(filename, GALLERY_THUMB_WIDTH, GALLERY_THUMB_HEIGHT);
if (save_thumbs)
pixbuf.savev(image_thumb_path,'jpeg',['quality'], ['90']);
}
galleryImage.set_pixbuf(pixbuf);
}
catch (e) {
this._set_blank_image(galleryImage);
this.log('create_gallery_image: '+e);
}
}
}
_set_blank_image(galleryImage) {
//galleryImage.set_from_icon_name('image-missing');
//galleryImage.set_icon_size = 2; // Gtk.GTK_ICON_SIZE_LARGE;
}
log(msg) {
if (this.settings.get_boolean('debug-logging'))
console.log("BingWallpaper extension: " + msg); // disable to keep the noise down in journal
}
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,81 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="128"
height="128"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="bing.svg"
inkscape:export-filename="/home/giulio/Scaricati/bing.svg.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.28574218"
inkscape:cx="360.85355"
inkscape:cy="487.41923"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
fit-margin-left="0"
fit-margin-bottom="0"
fit-margin-top="0"
fit-margin-right="0"
inkscape:window-width="1307"
inkscape:window-height="704"
inkscape:window-x="59"
inkscape:window-y="27"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid2996"
empspacing="5"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true"
originx="226.45871"
originy="5.9950575"
spacingx="1.0666667"
spacingy="1.0666667" />
</sodipodi:namedview>
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(226.45871,-1000.5147)">
<path
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.06666672"
d="m -207.22508,1000.5147 25.56889,8.995 0,90.0025 36.01496,-20.7906 -17.65737,-8.2848 -11.13975,-27.7264 56.74602,19.9359 0,28.9836 -63.94928,36.8848 -25.58347,-14.2309 z"
id="path2998"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Capa_1"
x="0px"
y="0px"
viewBox="0 0 128.00033 120.875"
xml:space="preserve"
sodipodi:docname="brick2.svg"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
width="128.00034"
height="120.875"><metadata
id="metadata39"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs37" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="2202"
inkscape:window-height="1449"
id="namedview35"
showgrid="false"
inkscape:zoom="1.0050722"
inkscape:cx="-133.99539"
inkscape:cy="3.4704905"
inkscape:window-x="238"
inkscape:window-y="59"
inkscape:window-maximized="0"
inkscape:current-layer="Capa_1" />
<rect
x="-53.404499"
y="-53.404499"
width="128.00034"
height="120.875"
style="fill:#000000;fill-opacity:0;stroke:none;stroke-width:0.97177076"
id="rect5" />
<path
d="M 4.08844,23.702082 C 1.834347,23.702082 0,21.75341 0,19.35754 V 4.344542 C 0,1.948672 1.834347,0 4.08844,0 h 51.734577 c 2.25409,0 4.08844,1.948672 4.08844,4.344542 V 19.35754 c 0,2.39587 -1.83435,4.344542 -4.08844,4.344542 z m 119.82346,0 c 2.25409,0 4.08844,-1.948672 4.08844,-4.344542 V 4.344542 C 128.00034,1.948672 126.16599,0 123.9119,0 H 72.177317 c -2.25409,0 -4.08844,1.948672 -4.08844,4.344542 V 19.35754 c 0,2.39587 1.83435,4.344542 4.08844,4.344542 z M 89.867177,56.09267 c 2.2541,0 4.08844,-1.94925 4.08844,-4.34454 V 36.735707 c 0,-2.395869 -1.83434,-4.344541 -4.08844,-4.344541 h -51.73457 c -2.254093,0 -4.08844,1.948672 -4.08844,4.344541 V 51.74871 c 0,2.39529 1.834347,4.34454 4.08844,4.34454 h 51.73457 z m -68.088329,0 c 2.254638,0 4.088439,-1.94867 4.088439,-4.34454 V 36.735707 c 0,-2.395869 -1.833801,-4.344541 -4.088439,-4.344541 H 4.387169 c -2.254638,0 -4.08844,1.948672 -4.08844,4.344541 V 51.74871 c 0,2.39587 1.833802,4.34454 4.08844,4.34454 h 17.391679 z m 101.834322,0 c 2.25464,0 4.08844,-1.94867 4.08844,-4.34454 V 36.735707 c 0,-2.395869 -1.8338,-4.344541 -4.08844,-4.344541 h -17.39168 c -2.25464,0 -4.08844,1.948672 -4.08844,4.344541 V 51.74871 c 0,2.39587 1.8338,4.34454 4.08844,4.34454 h 17.39168 z M 55.823017,88.48383 c 2.25409,0 4.08844,-1.94867 4.08844,-4.34454 v -15.013 c 0,-2.39529 -1.83435,-4.34454 -4.08844,-4.34454 H 4.08844 C 1.834347,64.78175 0,66.731 0,69.12629 v 15.013 c 0,2.39587 1.834347,4.34454 4.08844,4.34454 z m 68.088883,0 c 2.25409,0 4.08844,-1.94867 4.08844,-4.34454 v -15.013 c 0,-2.39529 -1.83435,-4.34454 -4.08844,-4.34454 H 72.177317 c -2.25409,0 -4.08844,1.94925 -4.08844,4.34454 v 15.013 c 0,2.39587 1.83435,4.34454 4.08844,4.34454 z M 89.867177,120.875 c 2.2541,0 4.08844,-1.94867 4.08844,-4.34454 v -15.013 c 0,-2.39587 -1.83434,-4.34454 -4.08844,-4.34454 h -51.73457 c -2.254093,0 -4.08844,1.94867 -4.08844,4.34454 v 15.013 c 0,2.39587 1.834347,4.34454 4.08844,4.34454 z m -68.088329,0 c 2.254638,0 4.088439,-1.94867 4.088439,-4.34454 v -15.013 c 0,-2.39587 -1.833801,-4.34454 -4.088439,-4.34454 H 4.387169 c -2.254638,0 -4.08844,1.94867 -4.08844,4.34454 v 15.013 c 0,2.39587 1.833802,4.34454 4.08844,4.34454 z m 101.834322,0 c 2.25464,0 4.08844,-1.94867 4.08844,-4.34454 v -15.013 c 0,-2.39587 -1.8338,-4.34454 -4.08844,-4.34454 h -17.39168 c -2.25464,0 -4.08844,1.94867 -4.08844,4.34454 v 15.013 c 0,2.39587 1.8338,4.34454 4.08844,4.34454 z"
id="path2"
style="fill:#cccccc;fill-opacity:1;stroke-width:0.56193948"
inkscape:connector-curvature="0" />
<g
id="g4"
transform="translate(-53.404333,-56.967)">
</g>
<g
id="g6"
transform="translate(-53.404333,-56.967)">
</g>
<g
id="g8"
transform="translate(-53.404333,-56.967)">
</g>
<g
id="g10"
transform="translate(-53.404333,-56.967)">
</g>
<g
id="g12"
transform="translate(-53.404333,-56.967)">
</g>
<g
id="g14"
transform="translate(-53.404333,-56.967)">
</g>
<g
id="g16"
transform="translate(-53.404333,-56.967)">
</g>
<g
id="g18"
transform="translate(-53.404333,-56.967)">
</g>
<g
id="g20"
transform="translate(-53.404333,-56.967)">
</g>
<g
id="g22"
transform="translate(-53.404333,-56.967)">
</g>
<g
id="g24"
transform="translate(-53.404333,-56.967)">
</g>
<g
id="g26"
transform="translate(-53.404333,-56.967)">
</g>
<g
id="g28"
transform="translate(-53.404333,-56.967)">
</g>
<g
id="g30"
transform="translate(-53.404333,-56.967)">
</g>
<g
id="g32"
transform="translate(-53.404333,-56.967)">
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="48" width="48"><path d="M20.95 31.95 35.4 17.5l-2.15-2.15-12.3 12.3L15 21.7l-2.15 2.15ZM9 42q-1.2 0-2.1-.9Q6 40.2 6 39V9q0-1.2.9-2.1Q7.8 6 9 6h30q1.2 0 2.1.9.9.9.9 2.1v30q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h30V9H9v30ZM9 9v30V9Z"/></svg>

After

Width:  |  Height:  |  Size: 277 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="48" width="48"><path d="m24 41.95-2.05-1.85q-5.3-4.85-8.75-8.375-3.45-3.525-5.5-6.3T4.825 20.4Q4 18.15 4 15.85q0-4.5 3.025-7.525Q10.05 5.3 14.5 5.3q2.85 0 5.275 1.35Q22.2 8 24 10.55q2.1-2.7 4.45-3.975T33.5 5.3q4.45 0 7.475 3.025Q44 11.35 44 15.85q0 2.3-.825 4.55T40.3 25.425q-2.05 2.775-5.5 6.3T26.05 40.1Z"/></svg>

After

Width:  |  Height:  |  Size: 363 B

View File

@ -0,0 +1,11 @@
<svg viewBox="0 0 128 128" xmlns="http://www.w3.org/2000/svg">
<g>
<path d="M26.49,55.55c1.8,5.02,1.26,10.22-2.59,11.6c-3.85,1.38-8.46-2.05-10.23-6.96c-1.81-5.02-1.36-10.23,2.59-11.6 C20.13,47.26,24.69,50.53,26.49,55.55z"/>
<path d="M50.1,111.9c-3.74,1.64-8.81-1.77-10.92-6.55c-2.15-4.88-1.83-10.23,1.91-11.87c3.75-1.64,8.59,1.24,10.73,6.12 S53.84,110.26,50.1,111.9z"/>
<ellipse cx="64.29" cy="29.27" rx="13.81" ry="9.93"/>
<path d="M87.6,106.06c-2.85,4.66-8.18,6.82-11.39,4.86c-3.21-1.96-3.65-7.63-0.73-12.24c3.28-5.19,8.25-6.57,11.46-4.61 S90.45,101.4,87.6,106.06z"/>
<path d="M100.58,83.5c-2.82,4.83-8.22,7.14-11.54,5.2c-3.31-1.94-3.83-7.58-1.01-12.42c2.82-4.82,8.33-6.97,11.65-5.03 S103.4,78.68,100.58,83.5z"/>
<path d="M113.2,61.77c-2.71,4.74-7.97,7.05-11.24,5.19c-3.27-1.86-3.63-7.23-0.92-11.97c2.71-4.75,7.88-7.05,11.15-5.19 C115.45,51.67,115.91,57.02,113.2,61.77z"/>
<path d="M120.63,49.77v-0.12c0.03-2.18,0.03-4.15-0.04-5.46c-0.19-3.62-0.93-6.51-2.83-10.16c-0.12-0.23-0.24-0.45-0.37-0.68 c-0.24-0.43-0.5-0.86-0.77-1.28c-0.01-0.02-0.03-0.05-0.04-0.07c-0.23-0.35-0.46-0.7-0.7-1.05c-0.36-0.52-0.73-1.02-1.11-1.5 c-0.15-0.2-0.31-0.4-0.47-0.59c-0.16-0.19-0.31-0.38-0.47-0.57c-0.55-0.65-1.09-1.25-1.6-1.77c-0.14-0.15-0.28-0.28-0.41-0.41 c-0.27-0.26-0.52-0.5-0.76-0.71c0-0.01-0.01-0.02-0.01-0.02c-0.35-0.38-0.76-0.75-1.22-1.1C103.99,19.91,77.88,7.8,72.34,5.76 c-1.79-0.66-5.35-1.55-9.16-1.55c-2.21,0-4.5,0.3-6.6,1.11c-4.52,1.75-33.19,15.02-35.96,16.77c-0.35,0.22-0.7,0.46-1.04,0.71 c-0.01,0.01-0.02,0.01-0.03,0.02c-0.01,0-0.01,0.01-0.02,0.01c-0.24,0.15-0.47,0.29-0.64,0.42c-3.29,2.38-7.29,5.41-9.41,9.46 c-2.03,3.87-2.84,6.83-2.99,11.79v0.41c-0.01,0.06-0.01,0.12-0.01,0.18C6.33,50.26,6.64,81.82,6.71,86.1 c0.07,4.72,1.23,9.97,4.37,12.66c3.14,2.69,28.57,18.82,34.29,21.29c0.47,0.2,0.93,0.38,1.4,0.53c0.03,0.01,0.06,0.02,0.09,0.03 c0.53,0.22,1.09,0.45,1.66,0.66c0.69,0.26,1.4,0.52,2.14,0.76c0.36,0.12,0.73,0.24,1.11,0.35c0.23,0.07,0.47,0.14,0.72,0.21 c0.22,0.07,0.44,0.13,0.67,0.19c2.3,0.62,4.83,1.1,7.55,1.3c0.42,0.03,0.85,0.06,1.29,0.07c0.47,0.02,0.95,0.03,1.43,0.03 c0.23,0,0.46-0.01,0.69-0.01c8.02-0.15,13.29-2.62,16.36-4.08l0.01-0.01c0.01,0,0.01-0.01,0.02-0.01c0.03-0.01,0.06-0.02,0.09-0.03 c0.39-0.17,0.79-0.33,1.19-0.51c0.35-0.16,0.7-0.32,1.05-0.48c0.12-0.06,0.25-0.12,0.38-0.18c0.37-0.18,0.75-0.37,1.14-0.57 c0.04-0.02,0.08-0.04,0.13-0.07c0.88-0.45,1.78-0.93,2.68-1.43c0.09-0.05,0.18-0.1,0.27-0.15c0.52-0.29,1.03-0.59,1.55-0.89 c0.26-0.15,0.51-0.3,0.77-0.46c0.52-0.3,1.03-0.61,1.54-0.92c3.58-2.18,7.03-4.45,9.97-6.21c6.72-4.03,11.96-7.45,14.3-9.37 c3-2.45,5.03-8.38,5.14-13.42C120.8,81.15,120.71,57.83,120.63,49.77z M61.73,111.09c-0.25,3.9-1.98,6.81-4.54,8.5 c-2.85-0.52-5.76-1.41-8.8-2.67l-0.13-0.06l-0.13-0.04l-0.09-0.03l-0.03-0.01l-0.02-0.01c-0.3-0.1-0.64-0.22-1.03-0.39 c-3.09-1.34-12.67-7.15-20.8-12.31c-6.04-3.85-11.29-7.33-12.48-8.35c-1.77-1.51-2.9-5.22-2.97-9.69 c-0.01-0.59-0.02-1.66-0.04-3.08c-0.1-9.15-0.31-32.95-0.2-37.62l0.02-0.09v-0.68c0.09-2.82,0.38-4.8,1.11-6.82 c2.14-0.56,4.57-0.16,6.53,0.96c3.18,1.83,34.18,19.61,38.1,22.3c3.92,2.69,5.72,7.97,5.72,11.55S62.29,102.46,61.73,111.09z M27.55,40.33c-6.91-3.51-10.79-5.67-11.82-9.33c1.61-1.64,3.57-3.11,5.5-4.51c0.03-0.02,0.16-0.11,0.38-0.24l0.17-0.1l0.16-0.12 c0.22-0.17,0.49-0.35,0.82-0.56c1.9-1.2,20.88-10.1,30.49-14.37c2.18-0.97,3.87-1.7,4.78-2.05c1.43-0.56,3.17-0.84,5.15-0.84 c3.34,0,6.46,0.82,7.78,1.3c0.61,0.23,1.44,0.56,2.46,0.99c0,0,0.01,0.01,0.02,0.01C81.7,14,101.78,23.5,107.07,27.22l1.35,1.18 c0.82,0.73,2.08,2.05,3.33,3.67c-0.64,1.06-1.63,2.05-2.94,2.9c-4.53,2.93-35.89,21.99-44.35,21.7 C56,56.38,35.58,44.41,27.55,40.33z M116.71,85.29c-0.1,4.52-1.98,9.03-3.68,10.42c-2.14,1.75-7.18,5.05-13.82,9.03 c-1.54,0.93-3.19,1.97-4.94,3.07c-2.42,1.53-5,3.16-7.57,4.66c-2.64,1.53-5.28,2.92-7.71,3.9l-0.76,0.32l-0.09,0.08 c-1.83,0.86-4.34,1.96-7.69,2.67c-2.86-2.34-4.52-6.19-4.59-8.13c-0.11-3.25,0.11-35.19,0.11-39.33c0-4.14,1.35-7.98,4.71-10.64 c4.82-3.81,35.07-21.86,41.23-23.2c1.26-0.27,2.36-0.3,3.31-0.11c0,0.01,0,0.01,0,0.01c0.86,2.07,1.25,3.96,1.38,6.36 c0.05,1.07,0.06,2.76,0.03,5.2v0.09c0.04,3.7,0.08,10.75,0.1,17.66C116.75,75.28,116.76,83.02,116.71,85.29z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.1 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 6.8 KiB

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="96pt"
height="76.800003pt"
viewBox="0 0 96 76.800003"
version="1.1"
id="svg7"
sodipodi:docname="low-frame2.svg"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
<metadata
id="metadata13">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs11" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1466"
inkscape:window-height="1148"
id="namedview9"
showgrid="false"
inkscape:zoom="0.921875"
inkscape:cx="-150.77966"
inkscape:cy="51.2"
inkscape:window-x="60"
inkscape:window-y="30"
inkscape:window-maximized="0"
inkscape:current-layer="surface1296651" />
<g
id="surface1296651"
transform="translate(-48,-57.6)">
<rect
x="0"
y="0"
width="192"
height="192"
style="fill:#000000;fill-opacity:0.0044053;stroke:none"
id="rect2" />
<path
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.60000002"
d="M 134.4,57.6 H 57.6 c -5.303906,0 -9.6,4.296094 -9.6,9.6 v 57.6 c 0,5.30391 4.296094,9.6 9.6,9.6 h 76.8 c 5.30391,0 9.6,-4.29609 9.6,-9.6 V 67.2 c 0,-5.303906 -4.29609,-9.6 -9.6,-9.6 z m -68.985937,58.52578 11.953124,-15.36797 c 0.939844,-1.211716 2.758594,-1.239841 3.738282,-0.0586 L 91.2,112.84687 106.07109,93.686719 c 0.96797,-1.253906 2.86407,-1.232813 3.81563,0.03281 l 16.83281,22.441411 C 127.90547,117.74297 126.77813,120 124.8,120 H 67.305469 c -1.996875,0 -3.119532,-2.29922 -1.891406,-3.87422 z m 0,0"
id="path4"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="96pt"
height="96pt"
viewBox="0 0 96 96"
version="1.1"
id="svg7"
sodipodi:docname="mid-frame2.svg"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)">
<metadata
id="metadata13">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<defs
id="defs11" />
<sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="977"
inkscape:window-height="803"
id="namedview9"
showgrid="false"
inkscape:zoom="1.3828125"
inkscape:cx="63.999998"
inkscape:cy="64.000002"
inkscape:window-x="526"
inkscape:window-y="574"
inkscape:window-maximized="0"
inkscape:current-layer="svg7" />
<g
id="surface1295461"
transform="scale(0.74999998)">
<rect
x="0"
y="0"
width="128"
height="128"
style="fill:#000000;fill-opacity:0;stroke:none"
id="rect2" />
<path
style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 8,20 v 88 H 120 V 20 Z m 8,8 h 96 V 83.625 L 90.875,62.375 88,59.5 69.875,77.625 46.875,54.375 44,51.5 16,79.5 Z m 80,8 c -4.421875,0 -8,3.578125 -8,8 0,4.421875 3.578125,8 8,8 4.42188,0 8,-3.578125 8,-8 0,-4.421875 -3.57812,-8 -8,-8 z M 44,62.875 80.75,100 H 16 v -9.125 z m 44,8 24,24 V 100 H 92.125 L 75.5,83.25 Z m 0,0"
id="path4"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 25.2.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg version="1.1" id="Layer_4" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
viewBox="0 0 128 128" style="enable-background:new 0 0 128 128;" xml:space="preserve">
<g>
<ellipse style="fill:#000000;" cx="63.94" cy="104.89" rx="35" ry="13.61"/>
<path style="fill:#000000;" d="M108.51,32.83l-2.26,12.33l-6.61-6.61l3.44-3.44l-9.75,2.84l0.6,0.6l-8.09,8.09l-6.54-6.54
l-9.63,0.82l-5.72,5.72l-6.2-6.2l-8.96-0.52l-6.72,6.72l-8.09-8.09l0.83-0.83l-9.36-1.98l2.81,2.81l-6.39,6.39L19.63,32.6
l-4.56-2.58l14.51,80.37C30.7,118.02,45.29,124,64.05,124s33.08-5.98,34.51-13.61l14.6-80.45L108.51,32.83z M84.06,110.53
l-6.32-6.32l8.09-8.09l8.09,8.09l0,0l-4.72,4.72C87.58,109.51,85.86,110.04,84.06,110.53z M39.21,109.46l-5.25-5.25l0,0l8.09-8.09
l8.09,8.09l-6.51,6.51C42.09,110.34,40.61,109.91,39.21,109.46z M72.03,104.22l-8.09,8.09l-8.09-8.09l8.09-8.09L72.03,104.22z
M66.8,93.27l8.09-8.09l8.09,8.09l-8.09,8.09L66.8,93.27z M52.99,101.36l-8.09-8.09l8.09-8.09l8.09,8.09L52.99,101.36z
M52.99,107.07l6.13,6.13c-3.65-0.25-7.33-0.75-10.84-1.43L52.99,107.07z M68.76,113.2l6.13-6.13l4.58,4.58
C75.99,112.39,72.36,112.94,68.76,113.2z M96.07,100.65l-7.38-7.38l8.09-8.09l1.8,1.8L96.07,100.65z M100.67,75.57l-3.89,3.89
l-8.09-8.09l8.09-8.09l5.19,5.19L100.67,75.57z M93.92,82.32l-8.09,8.09l-8.09-8.09l8.09-8.09L93.92,82.32z M74.88,79.47
l-8.09-8.09l8.09-8.09l8.09,8.09L74.88,79.47z M72.03,82.32l-8.09,8.09l-8.09-8.09l8.09-8.09L72.03,82.32z M52.99,79.47l-8.09-8.09
l8.09-8.09l8.09,8.09L52.99,79.47z M50.13,82.32l-8.09,8.09l-8.09-8.09l8.09-8.09L50.13,82.32z M31.1,79.47l-3.72-3.72l-1.33-7.4
l5.05-5.05l8.09,8.09L31.1,79.47z M31.1,85.18l8.09,8.09l-7.35,7.35L29.38,86.9L31.1,85.18z M102.85,63.65l-3.22-3.22l4.67-4.67
L102.85,63.65z M96.78,41.4l8.09,8.09l-8.09,8.09l-8.09-8.09L96.78,41.4z M85.83,52.34l8.09,8.09l-8.09,8.09l-8.09-8.09
L85.83,52.34z M74.88,41.4l8.09,8.09l-8.09,8.09l-8.09-8.09L74.88,41.4z M72.03,60.43l-8.09,8.09l-8.09-8.09l8.09-8.09L72.03,60.43
z M52.99,41.4l8.09,8.09l-8.09,8.09l-8.09-8.09L52.99,41.4z M50.13,60.43l-8.09,8.09l-8.09-8.09l8.09-8.09L50.13,60.43z M31.1,41.4
l8.09,8.09l-8.09,8.09l-8.09-8.09L31.1,41.4z M28.24,60.43l-3.06,3.06l-1.34-7.47L28.24,60.43z"/>
<path style="fill:#000000;" d="M64,4C34.17,4,9.99,9.9,9.99,22.74c0,10.24,24.18,18.74,54.01,18.74c29.83,0,54.01-8.5,54.01-18.74
C118.01,11.29,93.83,4,64,4z M64,34.36c-24.01,0-43.47-5.98-43.47-13.35c0-7.37,19.46-11.69,43.47-11.69
c24.01,0,43.47,4.32,43.47,11.69C107.47,28.38,88.01,34.36,64,34.36z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,62 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 25.2.3, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
version="1.1"
id="Layer_4"
x="0px"
y="0px"
viewBox="0 0 128 128"
xml:space="preserve"
sodipodi:docname="trashcan-symbolic.svg"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns="http://www.w3.org/2000/svg"
xmlns:svg="http://www.w3.org/2000/svg">
<g
id="surface1295461"
transform="translate(-7.5935033,-12.2479)"><g
id="g2016"
transform="matrix(0.1102846,-0.73545299,0.80952843,0.0919598,17.044863,109.0104)"
inkscape:label="g2016"><path
style="fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:none"
d="m 8,20 v 88 H 120 V 20 Z m 8,8 h 96 V 83.625 L 90.875,62.375 88,59.5 69.875,77.625 46.875,54.375 44,51.5 16,79.5 Z m 80,8 c -4.421875,0 -8,3.578125 -8,8 0,4.421875 3.578125,8 8,8 4.42188,0 8,-3.578125 8,-8 0,-4.421875 -3.57812,-8 -8,-8 z M 44,62.875 80.75,100 H 16 v -9.125 z m 44,8 24,24 V 100 H 92.125 L 75.5,83.25 Z m 0,0"
id="path4"
inkscape:connector-curvature="0"
sodipodi:insensitive="true" /></g></g><g
id="g86">
<ellipse
style="fill:#000000"
cx="63.939999"
cy="104.89"
rx="35"
ry="13.61"
id="ellipse67" />
<linearGradient
id="SVGID_1_"
gradientUnits="userSpaceOnUse"
x1="64.110703"
y1="89.9664"
x2="64.110703"
y2="147.6283">
<stop
offset="0"
style="stop-color:#82AFC1"
id="stop71" />
<stop
offset="1"
style="stop-color:#2F7889"
id="stop73" />
</linearGradient>
<path
style="fill:#000000"
d="m 108.51,32.83 -2.26,12.33 -6.61,-6.61 3.44,-3.44 -9.75,2.84 0.6,0.6 -8.09,8.09 -6.54,-6.54 -9.63,0.82 -5.72,5.72 -6.2,-6.2 -8.96,-0.52 -6.72,6.72 -8.09,-8.09 0.83,-0.83 -9.36,-1.98 2.81,2.81 -6.39,6.39 -2.24,-12.34 -4.56,-2.58 14.51,80.37 c 1.12,7.63 15.71,13.61 34.47,13.61 18.76,0 33.08,-5.98 34.51,-13.61 l 14.6,-80.45 z m -24.45,77.7 -6.32,-6.32 8.09,-8.09 8.09,8.09 v 0 l -4.72,4.72 c -1.62,0.58 -3.34,1.11 -5.14,1.6 z m -44.85,-1.07 -5.25,-5.25 v 0 l 8.09,-8.09 8.09,8.09 -6.51,6.51 c -1.54,-0.38 -3.02,-0.81 -4.42,-1.26 z m 32.82,-5.24 -8.09,8.09 -8.09,-8.09 8.09,-8.09 z m -5.23,-10.95 8.09,-8.09 8.09,8.09 -8.09,8.09 z m -13.81,8.09 -8.09,-8.09 8.09,-8.09 8.09,8.09 z m 0,5.71 6.13,6.13 c -3.65,-0.25 -7.33,-0.75 -10.84,-1.43 z m 15.77,6.13 6.13,-6.13 4.58,4.58 c -3.48,0.74 -7.11,1.29 -10.71,1.55 z m 27.31,-12.55 -7.38,-7.38 8.09,-8.09 1.8,1.8 z m 4.6,-25.08 -3.89,3.89 -8.09,-8.09 8.09,-8.09 5.19,5.19 z m -6.75,6.75 -8.09,8.09 -8.09,-8.09 8.09,-8.09 z m -19.04,-2.85 -8.09,-8.09 8.09,-8.09 8.09,8.09 z m -2.85,2.85 -8.09,8.09 -8.09,-8.09 8.09,-8.09 z m -19.04,-2.85 -8.09,-8.09 8.09,-8.09 8.09,8.09 z m -2.86,2.85 -8.09,8.09 -8.09,-8.09 8.09,-8.09 z m -19.03,-2.85 -3.72,-3.72 -1.33,-7.4 5.05,-5.05 8.09,8.09 z m 0,5.71 8.09,8.09 -7.35,7.35 -2.46,-13.72 z m 71.75,-21.53 -3.22,-3.22 4.67,-4.67 z m -6.07,-22.25 8.09,8.09 -8.09,8.09 -8.09,-8.09 z m -10.95,10.94 8.09,8.09 -8.09,8.09 -8.09,-8.09 z M 74.88,41.4 l 8.09,8.09 -8.09,8.09 -8.09,-8.09 z m -2.85,19.03 -8.09,8.09 -8.09,-8.09 8.09,-8.09 z M 52.99,41.4 l 8.09,8.09 -8.09,8.09 -8.09,-8.09 z m -2.86,19.03 -8.09,8.09 -8.09,-8.09 8.09,-8.09 z M 31.1,41.4 l 8.09,8.09 -8.09,8.09 -8.09,-8.09 z m -2.86,19.03 -3.06,3.06 -1.34,-7.47 z"
id="path76" />
<path
style="fill:#000000"
d="M 64,4 C 34.17,4 9.99,9.9 9.99,22.74 c 0,10.24 24.18,18.74 54.01,18.74 29.83,0 54.01,-8.5 54.01,-18.74 C 118.01,11.29 93.83,4 64,4 Z m 0,30.36 C 39.99,34.36 20.53,28.38 20.53,21.01 20.53,13.64 39.99,9.32 64,9.32 c 24.01,0 43.47,4.32 43.47,11.69 0,7.37 -19.46,13.35 -43.47,13.35 z"
id="path78" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="48" width="48"><path d="M9 42q-1.2 0-2.1-.9Q6 40.2 6 39V9q0-1.2.9-2.1Q7.8 6 9 6h30q1.2 0 2.1.9.9.9.9 2.1v30q0 1.2-.9 2.1-.9.9-2.1.9Zm0-3h30V9H9v30Z"/></svg>

After

Width:  |  Height:  |  Size: 204 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" height="48" width="48"><path d="m24 41.95-2.05-1.85q-5.3-4.85-8.75-8.375-3.45-3.525-5.5-6.3T4.825 20.4Q4 18.15 4 15.85q0-4.5 3.025-7.525Q10.05 5.3 14.5 5.3q2.85 0 5.275 1.35Q22.2 8 24 10.55q2.1-2.7 4.45-3.975T33.5 5.3q4.45 0 7.475 3.025Q44 11.35 44 15.85q0 2.3-.825 4.55T40.3 25.425q-2.05 2.775-5.5 6.3T26.05 40.1ZM24 38q5.05-4.65 8.325-7.975 3.275-3.325 5.2-5.825 1.925-2.5 2.7-4.45.775-1.95.775-3.9 0-3.3-2.1-5.425T33.5 8.3q-2.55 0-4.75 1.575T25.2 14.3h-2.45q-1.3-2.8-3.5-4.4-2.2-1.6-4.75-1.6-3.3 0-5.4 2.125Q7 12.55 7 15.85q0 1.95.775 3.925.775 1.975 2.7 4.5Q12.4 26.8 15.7 30.1 19 33.4 24 38Zm0-14.85Z"/></svg>

After

Width:  |  Height:  |  Size: 654 B

View File

@ -0,0 +1,13 @@
{
"_generated": "Generated by SweetTooth, do not edit",
"description": "Sync your wallpaper to today's Microsoft Bing image of the day (the image you see when you visit Bing.com).\n\n *Disclaimer*: this extension is unofficial and not affiliated with Bing or Microsoft in any way. Images are protected by copyright and are licensed only for use as wallpapers.\n\nFeatures:\n* UHD resolution wallpapers\n* Automatically fetches current Bing wallpaper of the day and sets as both lock screen and desktop wallpaper (user selectable on GNOME versions that support it)\n* Doesn't poll continuously - only once per day and on startup (schedules a refresh when Bing is due to update)\n * random mode (from previously downloaded wallpapers)\n *NEW: select/cycle wallpaper through previously downloaded images\n* Language support: English (en), German (de), Dutch (nl), Italian (it), Polish (pl), Chinese (zh_CN, zh_TW), French (fr), Portuguese (pt), Ukrainian (uk), Russian (ru_RU), Spanish (es), Korean (ko), Indonesian (id), Catalan (ca), Norwegian Bokm\u00e5l (nb) & Nynorsk (ni), Swedish (sv), Arabic (ar), Hungarian (hu) and Japanese (ja) - a HUGE thanks to the translators\n\nThis extension was forked from the NASA APOD extension by Elinvention (https://github.com/Elinvention) and inspired by Bing Desktop Wallpaper Changer by Utkarsh Gupta (https://github.com/UtkarshGpta).\n\nAlways restart GNOME after manually updating extensions. Please report bugs to the GitHub page below:",
"gettext-domain": "BingWallpaper",
"name": "Bing Wallpaper",
"settings-schema": "org.gnome.shell.extensions.bingwallpaper",
"shell-version": [
"45"
],
"url": "https://github.com/neffo/bing-wallpaper-gnome-extension",
"uuid": "BingWallpaper@ineffable-gmail.com",
"version": 48
}

View File

@ -0,0 +1,247 @@
// Bing Wallpaper GNOME extension
// Copyright (C) 2017-2023 Michael Carroll
// This extension is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// See the GNU General Public License, version 3 or later for details.
// Based on GNOME shell extension NASA APOD by Elia Argentieri https://github.com/Elinvention/gnome-shell-extension-nasa-apod
import Gtk from 'gi://Gtk';
import Gdk from 'gi://Gdk';
import Gio from 'gi://Gio';
import Soup from 'gi://Soup';
import Adw from 'gi://Adw';
import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
import * as Config from 'resource:///org/gnome/Shell/Extensions/js/misc/config.js';
import * as Utils from './utils.js';
import Carousel from './carousel.js';
const BingImageURL = Utils.BingImageURL;
var DESKTOP_SCHEMA = 'org.gnome.desktop.background';
var PREFS_DEFAULT_WIDTH = 950;
var PREFS_DEFAULT_HEIGHT = 950;
export default class BingWallpaperExtensionPreferences extends ExtensionPreferences {
fillPreferencesWindow(window) {
// formally globals
let settings = this.getSettings(Utils.BING_SCHEMA);
let desktop_settings = this.getSettings(Utils.DESKTOP_SCHEMA);
window.set_default_size(PREFS_DEFAULT_WIDTH, PREFS_DEFAULT_HEIGHT);
let icon_image = null;
let provider = new Gtk.CssProvider();
let carousel = null;
let httpSession = null;
let log = (msg) => { // avoids need for globals
if (settings.get_boolean('debug-logging'))
console.log("BingWallpaper extension: " + msg); // disable to keep the noise down in journal
}
// Prepare labels and controls
let buildable = new Gtk.Builder();
// GTK4 removes some properties, and builder breaks when it sees them
buildable.add_from_file( this.dir.get_path() + '/ui/Settings4.ui' );
provider.load_from_path(this.dir.get_path() + '/ui/prefs.css');
Gtk.StyleContext.add_provider_for_display(
Gdk.Display.get_default(),
provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
let box = buildable.get_object('prefs_widget');
// fix size of prefs window in GNOME shell 40+ (but super racy, so is unreliable)
buildable.get_object('extension_version').set_text(this.metadata.version.toString());
buildable.get_object('extension_name').set_text(this.metadata.name.toString());
// assign variables to UI objects we've loaded
let hideSwitch = buildable.get_object('hide');
let iconEntry = buildable.get_object('icon');
let notifySwitch = buildable.get_object('notify');
let bgSwitch = buildable.get_object('background');
let styleEntry = buildable.get_object('background_style');
let fileChooserBtn = buildable.get_object('download_folder');
let fileChooser = buildable.get_object('file_chooser'); // this should only exist on Gtk4
let folderOpenBtn = buildable.get_object('button_open_download_folder');
let marketEntry = buildable.get_object('market');
let resolutionEntry = buildable.get_object('resolution');
let historyEntry = buildable.get_object('history');
icon_image = buildable.get_object('icon_image');
let overrideSwitch = buildable.get_object('lockscreen_override');
let strengthEntry = buildable.get_object('entry_strength');
let brightnessEntry = buildable.get_object('entry_brightness');
let debugSwitch = buildable.get_object('debug_switch');
let revertSwitch = buildable.get_object('revert_switch');
let unsafeSwitch = buildable.get_object('unsafe_switch');
let randomIntervalEntry = buildable.get_object('entry_random_interval');
let change_log = buildable.get_object('change_log');
let buttonGDMdefault = buildable.get_object('button_default_gnome');
let buttonnoblur = buildable.get_object('button_no_blur');
let buttonslightblur = buildable.get_object('button_slight_blur');
let buttonImportData = buildable.get_object('button_json_import');
let buttonExportData = buildable.get_object('button_json_export');
let switchAlwaysExport = buildable.get_object('always_export_switch');
let switchEnableShuffle = buildable.get_object('shuffle_enabled_switch');
let entryShuffleMode = buildable.get_object('shuffle_mode_combo');
let carouselFlowBox = (Gtk.get_major_version() == 4) ? buildable.get_object('carouselFlowBox'): null;
try {
httpSession = new Soup.Session();
httpSession.user_agent = 'User-Agent: Mozilla/5.0 (X11; GNOME Shell/' + Config.PACKAGE_VERSION + '; Linux x86_64; +https://github.com/neffo/bing-wallpaper-gnome-extension ) BingWallpaper Gnome Extension/' + this.metadata.version;
}
catch (e) {
log("Error creating httpSession: " + e);
}
// check that these are valid (can be edited through dconf-editor)
Utils.validate_resolution(settings);
Utils.validate_icon(settings, this.path, icon_image);
// Indicator & notifications
settings.bind('hide', hideSwitch, 'active', Gio.SettingsBindFlags.DEFAULT);
settings.bind('notify', notifySwitch, 'active', Gio.SettingsBindFlags.DEFAULT);
// add markets to dropdown list (aka a GtkComboText)
Utils.icon_list.forEach((iconname, index) => {
iconEntry.append(iconname, iconname);
});
// user selectable indicator icons
settings.bind('icon-name', iconEntry, 'active_id', Gio.SettingsBindFlags.DEFAULT);
settings.connect('changed::icon-name', () => {
Utils.validate_icon(settings, this.path, icon_image);
});
iconEntry.set_active_id(settings.get_string('icon-name'));
// connect switches to settings changes
settings.bind('set-background', bgSwitch, 'active', Gio.SettingsBindFlags.DEFAULT);
settings.bind('debug-logging', debugSwitch, 'active', Gio.SettingsBindFlags.DEFAULT);
settings.bind('revert-to-current-image', revertSwitch, 'active', Gio.SettingsBindFlags.DEFAULT);
settings.bind('override-unsafe-wayland', unsafeSwitch, 'active', Gio.SettingsBindFlags.DEFAULT);
settings.bind('random-interval', randomIntervalEntry, 'value', Gio.SettingsBindFlags.DEFAULT);
settings.bind('always-export-bing-json', switchAlwaysExport, 'active', Gio.SettingsBindFlags.DEFAULT);
// button opens Nautilus at our image folder
folderOpenBtn.connect('clicked', (widget) => {
Utils.openImageFolder(settings);
});
// we populate the tab (gtk4+, gnome 40+), this was previously a button to open a new window in gtk3
carousel = new Carousel(settings, null, null, carouselFlowBox, this.dir.get_path()); // auto load carousel
// this is intended for migrating image folders between computers (or even sharing) or backups
// we export the Bing JSON data to the image directory, so this folder becomes portable
buttonImportData.connect('clicked', () => {
Utils.importBingJSON(settings);
});
buttonExportData.connect('clicked', () => {
Utils.exportBingJSON(settings);
});
//download folder
fileChooserBtn.set_label(Utils.getWallpaperDir(settings));
fileChooserBtn.connect('clicked', (widget) => {
let parent = widget.get_root();
let curWallpaperDir = Gio.File.new_for_path(Utils.getWallpaperDir(settings));
fileChooser.set_current_folder(curWallpaperDir.get_parent());
fileChooser.set_action(Gtk.FileChooserAction.SELECT_FOLDER);
fileChooser.set_transient_for(parent);
fileChooser.set_accept_label(_('Select folder'));
fileChooser.show();
});
fileChooser.connect('response', (widget, response) => {
if (response !== Gtk.ResponseType.ACCEPT) {
return;
}
let fileURI = fileChooser.get_file().get_path().replace('file://', '');
fileChooserBtn.set_label(fileURI);
Utils.moveImagesToNewFolder(settings, Utils.getWallpaperDir(settings), fileURI);
Utils.setWallpaperDir(settings, fileURI);
});
// in Gtk 4 instead we use a DropDown, but we need to treat it a bit special
let market_grid = buildable.get_object('market_grid');
marketEntry = Gtk.DropDown.new_from_strings(Utils.marketName);
marketEntry.set_selected(Utils.markets.indexOf(settings.get_string('market')));
market_grid.attach(marketEntry, 1, 0, 1, 2);
marketEntry.connect('notify::selected-item', () => {
let id = marketEntry.get_selected();
settings.set_string('market', Utils.markets[id]);
});
settings.connect('changed::market', () => {
marketEntry.set_selected(Utils.markets.indexOf(settings.get_string('market')));
});
settings.connect('changed::download-folder', () => {
fileChooserBtn.set_label(Utils.getWallpaperDir(settings));
});
// Resolution
Utils.resolutions.forEach((res) => { // add res to dropdown list (aka a GtkComboText)
resolutionEntry.append(res, res);
});
settings.bind('resolution', resolutionEntry, 'active_id', Gio.SettingsBindFlags.DEFAULT);
settings.connect('changed::resolution', () => {
Utils.validate_resolution(settings);
});
// shuffle modes
settings.bind('random-mode-enabled', switchEnableShuffle, 'active', Gio.SettingsBindFlags.DEFAULT);
Utils.randomIntervals.forEach((x) => {
entryShuffleMode.append(x.value, _(x.title));
});
settings.bind('random-interval-mode', entryShuffleMode, 'active_id', Gio.SettingsBindFlags.DEFAULT);
// selected image can no longer be changed through a dropdown (didn't scale)
settings.bind('selected-image', historyEntry, 'label', Gio.SettingsBindFlags.DEFAULT);
settings.connect('changed::selected-image', () => {
Utils.validate_imagename(settings);
});
// background styles (e.g. zoom or span)
Utils.backgroundStyle.forEach((style) => {
styleEntry.append(style, style);
});
desktop_settings.bind('picture-options', styleEntry, 'active_id', Gio.SettingsBindFlags.DEFAULT);
// GDM3 lockscreen blur override
settings.bind('override-lockscreen-blur', overrideSwitch, 'active', Gio.SettingsBindFlags.DEFAULT);
settings.bind('lockscreen-blur-strength', strengthEntry, 'value', Gio.SettingsBindFlags.DEFAULT);
settings.bind('lockscreen-blur-brightness', brightnessEntry, 'value', Gio.SettingsBindFlags.DEFAULT);
// add a couple of preset buttons
buttonGDMdefault.connect('clicked', (widget) => {
Utils.set_blur_preset(settings, Utils.PRESET_GNOME_DEFAULT);
});
buttonnoblur.connect('clicked', (widget) => {
Utils.set_blur_preset(settings, Utils.PRESET_NO_BLUR);
});
buttonslightblur.connect('clicked', (widget) => {
Utils.set_blur_preset(settings, Utils.PRESET_SLIGHT_BLUR);
});
// fetch
if (httpSession)
Utils.fetch_change_log(this.metadata.version.toString(), change_log, httpSession);
const page = new Adw.PreferencesPage();
const group = new Adw.PreferencesGroup();
group.add(box);
page.add(group);
window.add(page);
}
}

View File

@ -0,0 +1,249 @@
<schemalist gettext-domain="gnome-shell-extensions">
<schema id="org.gnome.shell.extensions.bingwallpaper"
path="/org/gnome/shell/extensions/bingwallpaper/">
<key name="hide" type="b">
<default>false</default>
<summary>Hide indicator</summary>
<description>Hide indicator icon from status area</description>
</key>
<key name="notify" type="b">
<default>false</default>
<summary>Send a notifications</summary>
<description>Send a notification with explanation when a new image is available</description>
</key>
<key name="notify-only-latest" type="b">
<default>true</default>
<summary>Send a notifications only on most recent image</summary>
<description>Notify only the most recent image, in combination with 'notify' setting</description>
</key>
<key name="transient" type="b">
<default>true</default>
<summary>Use transient notifications (auto dismiss)</summary>
<description></description>
</key>
<key name="set-background" type="b">
<default>true</default>
<summary>Set background</summary>
<description>Set background to Bing's background</description>
</key>
<key name="set-lock-screen" type="b">
<default>false</default>
<summary>Set lock screen</summary>
<description>Set lock screen to Bing's background</description>
</key>
<key name="download-folder" type="s">
<default>""</default>
<summary>Where to download pictures.</summary>
<description></description>
</key>
<key name="market" type="s">
<default>"auto"</default>
<summary>Default Market for Bing</summary>
<description></description>
</key>
<key name="resolution" type="s">
<default>"auto"</default>
<summary>Screen Size</summary>
<description>Valid sizes are '800x600', '1024x768', '1280x720', '1280x768', '1366x768', '1920x1080', '1920x1200' and 'UHD'</description>
</key>
<key name="debug-logging" type="b">
<default>false</default>
<summary>Log messages to systemd journal</summary>
<description>Unlikely to be useful for ordinary users, but helpful for debugging</description>
</key>
<key name="delete-previous" type="b">
<default>false</default>
<summary>Delete previous wallpapers</summary>
<description>Save disk space</description>
</key>
<key name="previous-days" type="i">
<default>8</default>
<summary>Number of days to keep wallpapers</summary>
<description>Delete wallpapers after this number of days</description>
</key>
<key name="replace-watermark" type="s">
<default>""</default>
<summary>Replace or remove Bing watermark on high-res images</summary>
<description>Set to "none", "Gnome" or "Ubuntu"</description>
</key>
<key name="icon-name" type="s">
<default>"bing-symbolic"</default>
<summary>Icon Name</summary>
<description>Icon filename to use for extension applet</description>
</key>
<key name="override-wp-flag" type="b">
<default>false</default>
<summary>Ignore Bing permitted for use as wallpaper flag</summary>
<description>Used when wallpaper is animated, or not licensed for wallpaper use</description>
</key>
<key name="override-lockscreen-blur" type="b">
<default>false</default>
<summary>Override GNOME lockscreen (gdm3) wallpaper blur</summary>
<description>Applies to GNOME 3.36 and above only</description>
</key>
<key name="lockscreen-blur-strength" type="i">
<range min="0" max="100" />
<default>2</default>
<summary>GNOME lockscreen (gdm3) wallpaper blur strength</summary>
<description>Degree of fuzziness</description>
</key>
<key name="lockscreen-blur-brightness" type="i">
<range min="0" max="100" />
<default>50</default>
<summary>GNOME lockscreen (gdm3) wallpaper blur Brightness</summary>
<description>Used to darken the wallpaper to improve visibility</description>
</key>
<key name="selected-image" type="s">
<default>"current"</default>
<summary>Use older Bing image, select by filename</summary>
<description></description>
</key>
<key name="revert-to-current-image" type="b">
<default>true</default>
<summary>Revert to showing the current image when a new one arrives</summary>
<description>This setting may best reflect what users want from selectable or random images</description>
</key>
<key name="state" type="s">
<default>"[]"</default>
<summary>Store state in JSON format so we can restore details immediately on boot</summary>
<description></description>
</key>
<key name="bing-json" type="s">
<default>"[]"</default>
<summary>Store Bing image details for rollback</summary>
<description></description>
</key>
<key name="random-interval-mode" type="s">
<default>"daily"</default>
<summary>Set to either 'daily', 'hourly', 'weekly', 'custom'</summary>
<description>Daily is midnight, hourly is on the hour, weekly is midnight on Sunday, or custom as defined by the 'random-interval'</description>
</key>
<key name="random-interval" type="i">
<range min="300" max="86400" />
<default>3600</default>
<summary>How frequently to change the wallpaper when on random mode</summary>
<description></description>
</key>
<key name="random-mode-include-only-favourites" type="b">
<default>false</default>
<summary>Only pick from favourites in random mode</summary>
<description></description>
</key>
<key name="random-mode-enabled" type="b">
<default>false</default>
<summary>Pick a random image at random-interval</summary>
<description></description>
</key>
<key name="random-mode-include-only-uhd" type="b">
<default>false</default>
<summary>Only pick from UHD in random mode</summary>
<description></description>
</key>
<key name="random-mode-include-only-unhidden" type="b">
<default>true</default>
<summary>Only pick from unhidden in random mode</summary>
<description></description>
</key>
<key name="override-unsafe-wayland" type="b">
<default>true</default>
<summary>Override safe defaults for Wayland desktop</summary>
<description>Enables features which may or may not be unstable or untested in all cases</description>
</key>
<key name="create-thumbs" type="b">
<default>true</default>
<summary>Create thumbnails to speed up image gallery loading</summary>
<description>Speeds up subsequent loads, but requires some additional disk space</description>
</key>
<key name="min-uhd-height" type="i">
<range min="1080" max="3000" />
<default>2160</default>
<summary>Minimum image height to be considered UHD</summary>
<description></description>
</key>
<key name="always-export-bing-json" type="b">
<default>false</default>
<summary>Save backup copy of Bing JSON to wallpaper directory</summary>
<description>Enables migration to new install or restoration from back up</description>
</key>
<key name="show-count-in-image-title" type="b">
<default>false</default>
<summary>Include current index and total image count in image title</summary>
</key>
<key name="controls-icon-size" type="i">
<range min="16" max="48" />
<default>32</default>
<summary>Size of icons for controls in popup menu</summary>
</key>
<key name="trash-deletes-images" type="b">
<default>false</default>
<summary>Trash deletes images or just marks as bad</summary>
</key>
<!-- not currently used
<key name="gallery-width" type="i">
<range min="1000" max="9600" />
<default>1600</default>
<summary>Gallery window width</summary>
<description></description>
</key>
<key name="gallery-height" type="i">
<range min="700" max="9600" />
<default>800</default>
<summary>Gallery window height</summary>
<description></description>
</key>
<key name="gallery-top" type="i">
<range min="0" max="9600" />
<default>30</default>
<summary>Gallery window x-pos</summary>
<description></description>
</key>
<key name="gallery-left" type="i">
<range min="0" max="9600" />
<default>30</default>
<summary>Gallery window y-pos</summary>
<description></description>
</key>
-->
</schema>
</schemalist>

View File

@ -0,0 +1,2 @@
.wp-thumbnail-image:focus, .wp-thumbnail-image:hover {
background-color: rgba(247, 247, 247, 0.1) !important; }

View File

@ -0,0 +1,29 @@
// Bing Wallpaper GNOME extension
// Copyright (C) 2017-2023 Michael Carroll
// This extension is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// See the GNU General Public License, version 3 or later for details.
import Gio from 'gi://Gio';
import GdkPixbuf from 'gi://GdkPixbuf';
const THUMBNAIL_WIDTH = 480;
const THUMBNAIL_HEIGHT = 270;
export default class Thumbnail {
constructor(filePath, scale = 1.0) {
if (!filePath) {
throw new Error(`need argument ${filePath}`);
}
try {
let w = Math.round(THUMBNAIL_WIDTH * scale);
let h = Math.round(THUMBNAIL_HEIGHT * scale);
this.pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(filePath, w, h);
this.srcFile = Gio.File.new_for_path(filePath);
} catch (err) {
log('Unable to create thumbnail for corrupt or incomplete file: ' + filePath + ' err: ' + err);
}
}
};

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,209 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2
Copyright (C) 2017-2021
This file is part of Bing Wallpaper.
Bing Wallpaper 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.
Bing Wallpaper 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 Bing Wallpaper. If not, see <http://www.gnu.org/licenses/>.
Author: Michael Carroll
-->
<interface>
<requires lib="gtk" version="4.0"/>
<object class="GtkScrolledWindow" id="carouselScrollable">
<property name="hscrollbar-policy">never</property>
<property name="child">
<object class="GtkViewport" id="carouselViewPort">
<property name="can-focus">0</property>
<property name="vexpand">0</property>
<property name="height-request">500</property>
<property name="child">
<object class="GtkFlowBox" id="carouselFlowBox">
<property name="can-focus">0</property>
<property name="halign">center</property>
<property name="homogeneous">1</property>
<!-- <property name="max-children-per-line">5</property> -->
<property name="min-children-per-line">2</property>
<property name="row-spacing">10</property>
<property name="column-spacing">4</property>
</object>
</property>
</object>
</property>
</object>
<object class="GtkFlowBoxChild" id="flowBoxChild">
<property name="can-focus">0</property>
<property name="child">
<object class="GtkBox" id="imageGrid">
<property name="can-focus">0</property>
<property name="homogeneous">0</property>
<property name="spacing">5</property>
<!-- <property name="orientation">vertical</property> -->
<child>
<object class="GtkPicture" id="galleryImage">
<property name="width-request">320</property>
<property name="height-request">180</property>
<property name="can-focus">0</property>
<property name="hexpand">1</property>
<property name="vexpand">1</property>
</object>
</child>
<child>
<object class="GtkBox" id="buttonBar">
<property name="can-focus">0</property>
<property name="orientation">vertical</property>
<property name="vexpand">1</property>
<property name="valign">center</property>
<child>
<object class="GtkButton" id="favButton">
<property name="tooltip-text" translatable="yes">Favorite</property>
<property name='icon-name'>checkbox</property>
<!-- <property name='icon-name'>checkbox-checked</property> -->
<property name="receives-default">1</property>
<property name="hexpand">0</property>
<property name="halign">center</property>
</object>
</child>
<child>
<object class="GtkButton" id="unfavButton">
<property name="tooltip-text" translatable="yes">Favorite</property>
<property name='icon-name'>checkbox-checked</property>
<!-- <property name='icon-name'>checkbox-checked</property> -->
<property name="receives-default">1</property>
<property name="hexpand">0</property>
<property name="halign">center</property>
</object>
</child>
<child>
<object class="GtkButton" id="applyButton">
<property name="tooltip-text" translatable="yes">Apply</property>
<property name='icon-name'>preferences-desktop-wallpaper</property>
<property name="receives-default">1</property>
<property name="hexpand">0</property>
<property name="halign">center</property>
</object>
</child>
<child>
<object class="GtkButton" id="viewButton">
<property name="tooltip-text" translatable="yes">View</property>
<property name='icon-name'>view-reveal</property>
<property name="receives-default">1</property>
<property name="hexpand">0</property>
<property name="halign">center</property>
</object>
</child>
<child>
<object class="GtkButton" id="infoButton">
<property name="tooltip-text" translatable="yes">Info</property>
<property name='icon-name'>preferences-system-details</property>
<property name="receives-default">1</property>
<property name="hexpand">0</property>
<property name="halign">center</property>
</object>
</child>
<child>
<object class="GtkButton" id="deleteButton">
<property name="tooltip-text" translatable="yes">Delete</property>
<property name='icon-name'>edit-delete</property>
<property name="receives-default">1</property>
<property name="hexpand">0</property>
<property name="halign">center</property>
</object>
</child>
</object>
</child>
</object>
</property>
</object>
<object class="GtkFlowBoxChild" id="flowBoxRandom">
<property name="can-focus">0</property>
<property name="child">
<object class="GtkGrid" id="imageGrid">
<property name="can-focus">0</property>
<property name="halign">center</property>
<child>
<object class="GtkImage" id="randomImage">
<property name="width-request">320</property>
<property name="height-request">120</property>
<property name="can-focus">0</property>
<property name="icon-name">media-playlist-shuffle</property>
<property name="icon_size">2</property>
<layout>
<property name="column">0</property>
<property name="row">0</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkLabel" id="randomLabel">
<property name="can-focus">0</property>
<property name="label" translatable="yes">&lt;image name here&gt;</property>
<layout>
<property name="column">0</property>
<property name="row">1</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
<child>
<object class="GtkButton" id="randomButton">
<property name="label" translatable="yes">Set random mode</property>
<property name="receives-default">1</property>
<layout>
<property name="column">0</property>
<property name="row">2</property>
<property name="column-span">2</property>
</layout>
</object>
</child>
</object>
</property>
</object>
<object class="GtkFlowBoxChild" id="flowBoxPlaceholder">
<property name="can-focus">0</property>
<property name="child">
<object class="GtkGrid" id="loadGrid">
<property name="can-focus">0</property>
<property name="halign">center</property>
<child>
<object class="GtkImage" id="loadImage">
<property name="width-request">320</property>
<property name="height-request">120</property>
<property name="can-focus">0</property>
<property name="icon-name">preferences-desktop-wallpaper-symbolic</property>
<property name="icon_size">3</property>
<layout>
<property name="column">0</property>
<property name="row">0</property>
</layout>
</object>
</child>
<child>
<object class="GtkButton" id="loadButton">
<property name="label" translatable="yes">Load image gallery</property>
<property name="receives-default">1</property>
<layout>
<property name="column">0</property>
<property name="row">1</property>
</layout>
</object>
</child>
</object>
</property>
</object>
</interface>

View File

@ -0,0 +1,4 @@
.icon_image_black_bg
{
background-color: rgba(0, 0, 0, 1);
}

View File

@ -0,0 +1,623 @@
// Bing Wallpaper GNOME extension
// Copyright (C) 2017-2023 Michael Carroll
// This extension is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// See the GNU General Public License, version 3 or later for details.
// Based on GNOME shell extension NASA APOD by Elia Argentieri https://github.com/Elinvention/gnome-shell-extension-nasa-apod
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import Soup from 'gi://Soup';
import GdkPixbuf from 'gi://GdkPixbuf';
export var PRESET_GNOME_DEFAULT = { blur: 60, dim: 55 }; // as at GNOME 40
export var PRESET_NO_BLUR = { blur: 0, dim: 60 };
export var PRESET_SLIGHT_BLUR = { blur: 2, dim: 60 };
export var BING_SCHEMA = 'org.gnome.shell.extensions.bingwallpaper';
export var DESKTOP_SCHEMA = 'org.gnome.desktop.background';
var vertical_blur = null;
var horizontal_blur = null;
let gitreleaseurl = 'https://api.github.com/repos/neffo/bing-wallpaper-gnome-extension/releases/tags/';
let debug = false;
export var icon_list = ['bing-symbolic', 'brick-symbolic', 'high-frame-symbolic', 'mid-frame-symbolic', 'low-frame-symbolic'];
export var resolutions = ['auto', 'UHD', '1920x1200', '1920x1080', '1366x768', '1280x720', '1024x768', '800x600'];
export var markets = ['auto', 'ar-XA', 'da-DK', 'de-AT', 'de-CH', 'de-DE', 'en-AU', 'en-CA', 'en-GB',
'en-ID', 'en-IE', 'en-IN', 'en-MY', 'en-NZ', 'en-PH', 'en-SG', 'en-US', 'en-WW', 'en-XA', 'en-ZA', 'es-AR',
'es-CL', 'es-ES', 'es-MX', 'es-US', 'es-XL', 'et-EE', 'fi-FI', 'fr-BE', 'fr-CA', 'fr-CH', 'fr-FR',
'he-IL', 'hr-HR', 'hu-HU', 'it-IT', 'ja-JP', 'ko-KR', 'lt-LT', 'lv-LV', 'nb-NO', 'nl-BE', 'nl-NL',
'pl-PL', 'pt-BR', 'pt-PT', 'ro-RO', 'ru-RU', 'sk-SK', 'sl-SL', 'sv-SE', 'th-TH', 'tr-TR', 'uk-UA',
'zh-CN', 'zh-HK', 'zh-TW'];
export var marketName = [
'auto', '(شبه الجزيرة العربية‎) العربية', 'dansk (Danmark)', 'Deutsch (Österreich)',
'Deutsch (Schweiz)', 'Deutsch (Deutschland)', 'English (Australia)', 'English (Canada)',
'English (United Kingdom)', 'English (Indonesia)', 'English (Ireland)', 'English (India)', 'English (Malaysia)',
'English (New Zealand)', 'English (Philippines)', 'English (Singapore)', 'English (United States)',
'English (International)', 'English (Arabia)', 'English (South Africa)', 'español (Argentina)', 'español (Chile)',
'español (España)', 'español (México)', 'español (Estados Unidos)', 'español (Latinoamérica)', 'eesti (Eesti)',
'suomi (Suomi)', 'français (Belgique)', 'français (Canada)', 'français (Suisse)', 'français (France)',
'(עברית (ישראל', 'hrvatski (Hrvatska)', 'magyar (Magyarország)', 'italiano (Italia)', '日本語 (日本)', '한국어(대한민국)',
'lietuvių (Lietuva)', 'latviešu (Latvija)', 'norsk bokmål (Norge)', 'Nederlands (België)', 'Nederlands (Nederland)',
'polski (Polska)', 'português (Brasil)', 'português (Portugal)', 'română (România)', 'русский (Россия)',
'slovenčina (Slovensko)', 'slovenščina (Slovenija)', 'svenska (Sverige)', 'ไทย (ไทย)', 'Türkçe (Türkiye)',
'українська (Україна)', '中文(中国)', '中文(中國香港特別行政區)', '中文(台灣)'
];
export var backgroundStyle = ['none', 'wallpaper', 'centered', 'scaled', 'stretched', 'zoom', 'spanned']; // this may change in the future
export var randomIntervals = [ {value: 'hourly', title: ('on the hour')},
{value: 'daily', title: ('every day at midnight')},
{value: 'weekly', title: ('every Sunday at midnight')} ];
export var BingImageURL = 'https://www.bing.com/HPImageArchive.aspx';
export var BingParams = { format: 'js', idx: '0' , n: '8' , mbl: '1' , mkt: '' } ;
export function validate_icon(settings, extension_path, icon_image = null) {
BingLog('validate_icon()');
let icon_name = settings.get_string('icon-name');
if (icon_name == '' || icon_list.indexOf(icon_name) == -1) {
settings.reset('icon-name');
icon_name = settings.get_string('icon-name');
}
// if called from prefs
if (icon_image) {
BingLog('set icon to: ' + extension_path + '/icons/' + icon_name + '.svg');
let pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(extension_path + '/icons/' + icon_name + '.svg', 32, 32);
icon_image.set_from_pixbuf(pixbuf);
}
}
export function validate_resolution(settings) {
let resolution = settings.get_string('resolution');
if (resolution == '' || resolutions.indexOf(resolution) == -1) // if not a valid resolution
settings.reset('resolution');
}
// FIXME: needs work
export function validate_imagename(settings) {
let filename = settings.get_string('selected-image');
if (filename != 'current' || filename != 'random') // FIXME: remove this when we move to new shuffle mode
return;
if (!inImageList(getImageList(settings), filename)) {
BingLog('invalid image selected');
//settings.reset('selected-image');
settings.set_string('selected-image', 'current');
}
}
export function get_current_bg(schema) {
let gsettings = new Gio.Settings({ schema: schema });
let cur = gsettings.get_string('picture-uri');
return (cur);
}
export function fetch_change_log(version, label, httpSession) {
const decoder = new TextDecoder();
// create an http message
let url = gitreleaseurl + "v" + version;
let request = Soup.Message.new('GET', url);
request.request_headers.append('Accept', 'application/json');
BingLog("Fetching " + url);
// queue the http request
try {
if (Soup.MAJOR_VERSION >= 3) {
httpSession.send_and_read_async(request, GLib.PRIORITY_DEFAULT, null, (httpSession, message) => {
let data = decoder.decode(httpSession.send_and_read_finish(message).get_data());
let text = JSON.parse(data).body;
label.set_label(text);
});
}
else {
httpSession.queue_message(request, (httpSession, message) => {
let data = message.response_body.data;
let text = JSON.parse(data).body;
label.set_label(text);
});
}
}
catch (error) {
BingLog("Error fetching change log: " + error);
label.set_label(_("Error fetching change log: "+error));
}
}
export function set_blur_preset(settings, preset) {
settings.set_int('lockscreen-blur-strength', preset.blur);
settings.set_int('lockscreen-blur-brightness', preset.dim);
BingLog("Set blur preset to " + preset.blur + " brightness to " + preset.dim);
}
export function imageHasBasename(image_item, i, b) {
//log("imageHasBasename : " + image_item.urlbase + " =? " + this);
if (this && this.search(image_item.urlbase.replace('th?id=OHR.', '')))
return true;
return false;
}
export function dateFromLongDate(longdate, add_seconds) {
if (typeof longdate === 'number')
longdate = longdate.toString();
return GLib.DateTime.new(GLib.TimeZone.new_utc(),
parseInt(longdate.substr(0, 4)), // year
parseInt(longdate.substr(4, 2)), // month
parseInt(longdate.substr(6, 2)), // day
parseInt(longdate.substr(8, 2)), // hour
parseInt(longdate.substr(10, 2)), // mins
0 ).add_seconds(add_seconds); // seconds
}
export function dateFromShortDate(shortdate) {
if (typeof shortdate === 'number')
shortdate = shortdate.toString();
return GLib.DateTime.new(GLib.TimeZone.new_utc(),
parseInt(shortdate.substr(0, 4)), // year
parseInt(shortdate.substr(4, 2)), // month
parseInt(shortdate.substr(6, 2)), // day
0, 0, 0 );
}
export function getImageList(settings, filter = null) {
let image_list = JSON.parse(settings.get_string('bing-json'));
if (!filter) {
return image_list;
}
else {
return image_list.filter((x, i) => {
if (filter.faves && !x.favourite)
return false;
if (filter.min_height && x.height < filter.min_height)
return false;
if (filter.hidden && x.hidden)
return false;
return true;
});
}
}
export function setImageList(settings, imageList) {
settings.set_string('bing-json', JSON.stringify(imageList));
if (settings.get_boolean('always-export-bing-json')) { // save copy of current JSON
exportBingJSON(settings);
}
}
export function setImageHiddenStatus(settings, hide_image_list, hide_status) {
// get current image list
let image_list = getImageList(settings);
image_list.forEach( (x, i) => {
hide_image_list.forEach(u => {
if (u.includes(x.urlbase)) {
// mark as hidden
x.hidden = hide_status;
}
});
});
// export image list back to settings
setImageList(settings, image_list);
}
export function getImageTitle(image_data) {
return image_data.copyright.replace(/\s*\(.*?\)\s*/g, '');
}
export function getImageUrlBase(image_data) {
return image_data.urlbase.replace('/th?id=OHR.', '');
}
export function getMaxLongDate(settings) {
let imageList = getImageList(settings);
return Math.max.apply(Math, imageList.map(function(o) { return o.fullstartdate; }));
}
export function getCurrentImageIndex (imageList) {
if (!imageList)
return -1;
let maxLongDate = Math.max.apply(Math, imageList.map(function(o) { return o.fullstartdate; }));
let index = imageList.map(p => parseInt(p.fullstartdate)).indexOf(maxLongDate);
BingLog('getCurrentImageIndex for ' + maxLongDate + ': ' + index);
return index;
}
export function setImageFavouriteStatus(settings, imageURL, newState) {
BingLog('set favourite status of '+imageURL+' to '+newState);
let imageList = getImageList(settings);
imageList.forEach(function(x, i) {
//log('testing: '+imageURL+' includes '+x.urlbase);
if (imageURL.includes(x.urlbase)) {
BingLog('setting index '+i+' to '+newState?'true':'false');
imageList[i].favourite = newState;
}
});
setImageList(settings, imageList); // save back to settings
}
export function getCurrentImage(imageList) {
if (!imageList || imageList.length == 0)
return null;
let index = getCurrentImageIndex(imageList);
if (index == -1)
return imageList[0]; // give something sensible
return imageList[index];
}
export function inImageList(imageList, urlbase) {
let image = null;
imageList.forEach(function(x, i) {
if (urlbase.replace('/th?id=OHR.', '') == x.urlbase.replace('/th?id=OHR.', ''))
image = x;
});
return image;
}
export function inImageListByTitle(imageList, title) {
let image = null;
imageList.forEach(function(x, i) {
BingLog('inImageListbyTitle(): ' + title + ' == ' + getImageTitle(x));
if (getImageTitle(x) == title)
image = x;
});
return image;
}
export function mergeImageLists(settings, imageList) {
let curList = getImageList(settings);
let newList = []; // list of only new images (for future notifications)
imageList.forEach(function(x, i) {
if (!inImageList(curList, x.urlbase)) {// if not in the list, add it
curList.unshift(x); // use unshift to maintain reverse chronological order
newList.unshift(x);
}
});
setImageList(settings, imageListSortByDate(curList)); // sort then save back to settings
return newList; // return this to caller for notifications
}
export function imageIndex(imageList, urlbase) {
return imageList.map(p => p.urlbase.replace('/th?id=OHR.', '')).indexOf(urlbase.replace('/th?id=OHR.', ''));
}
export function isFavourite(image) {
return (image.favourite && image.favourite === true);
}
export function getImageByIndex(imageList, index) {
if (imageList.length == 0 || index < 0 || index > imageList.length - 1)
return null;
return imageList[index];
}
export function cleanupImageList(settings) {
let curList = imageListSortByDate(getImageList(settings));
let cutOff = GLib.DateTime.new_now_utc().add_days(-8); // 8 days ago
let newList = [];
curList.forEach( function (x, i) {
let filename = imageToFilename(settings, x);
let diff = dateFromLongDate(x.fullstartdate, 0).difference(cutOff);
// image is still downloadable (< 8 days old) or still on disk, so we keep
if (diff > 0 || Gio.file_new_for_path(filename).query_exists(null)) {
newList.push(x);
}
else {
BingLog('Cleaning up: '+filename);
}
});
setImageList(settings, newList);
}
export function populateImageListResolutions(settings) {
let curList = imageListSortByDate(getImageList(settings));
let newList = [];
curList.forEach( function (x, i) {
let filename = imageToFilename(settings, x);
let width, height;
if (!x.width || !x.height) {
[width, height] = getFileDimensions(filename);
x.width = width;
x.height = height;
}
newList.push(x);
});
setImageList(settings, newList);
}
export function getFetchableImageList(settings) {
let imageList = getImageList(settings);
let cutOff = GLib.DateTime.new_now_utc().add_days(-8); // 8 days ago
let dlList = [];
imageList.forEach( function (x, i) {
let diff = dateFromLongDate(x.fullstartdate, 0).difference(cutOff);
let filename = imageToFilename(settings, x);
// image is still downloadable (< 8 days old) but not on disk
if (diff > 0 && !Gio.file_new_for_path(filename).query_exists(null)) {
dlList.push(x);
}
});
return dlList;
}
export function getWallpaperDir(settings) {
let homeDir = GLib.get_home_dir();
let BingWallpaperDir = settings.get_string('download-folder').replace('~', homeDir);
let userPicturesDir = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_PICTURES);
let userDesktopDir = GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DESKTOP); // seems to be a safer default
if (BingWallpaperDir == '') {
BingWallpaperDir = (userPicturesDir?userPicturesDir:userDesktopDir) + '/BingWallpaper/';
BingLog('Using default download folder: ' + BingWallpaperDir);
setWallpaperDir(settings, BingWallpaperDir);
}
else if (!BingWallpaperDir.endsWith('/')) {
BingWallpaperDir += '/';
}
let dir = Gio.file_new_for_path(BingWallpaperDir);
if (!dir.query_exists(null)) {
dir.make_directory_with_parents(null);
}
//FIXME: test if dir is good and writable
return BingWallpaperDir;
}
export function setWallpaperDir(settings, uri) {
let homeDir = GLib.get_home_dir();
let relUri = uri.replace(homeDir, '~');
settings.set_string('download-folder', relUri);
}
export function imageToFilename(settings, image, resolution = null) {
return getWallpaperDir(settings) + image.startdate + '-' +
image.urlbase.replace(/^.*[\\\/]/, '').replace('th?id=OHR.', '') + '_'
+ (resolution ? resolution : getResolution(settings, image)) + '.jpg';
}
export function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
// Utility function
export function dump(object, level = 0) {
let output = '';
for (let property in object) {
output += ' - '.repeat(level)+property + ': ' + object[property]+'\n ';
if ( typeof object[property] === 'object' )
output += dump(object[property], level+1);
}
if (level == 0)
BingLog(output);
return(output);
}
export function friendly_time_diff(time, short = true) {
// short we want to keep ~4-5 characters
let now = GLib.DateTime.new_now_local().to_unix();
let seconds = time.to_unix() - now;
if (seconds <= 0) {
return "now";
}
else if (seconds < 60) {
return "< 1 " + (short ? "m" : _("minutes"));
}
else if (seconds < 3600) {
return Math.round(seconds / 60) + " " + (short ? "m" : _("minutes"));
}
else if (seconds > 86400) {
return Math.round(seconds / 86400) + " " + (short ? "d" : _("days"));
}
else {
return Math.round(seconds / 3600) + " " + (short ? "h" : _("hours"));
}
}
export function seconds_until(until) {
let now = GLib.DateTime.new_now_local();
let end, day;
if (until == 'hourly') {
end = GLib.DateTime.new_local(
now.get_year(),
now.get_month(),
now.get_day_of_month(),
now.get_hour()+1, // should roll over to next day if results in >23
0, 0);
}
else {
if (until == 'weekly') {
day = now.add_days(7 - now.get_day_of_week());
}
else {
day = now.add_days(1);
}
end = GLib.DateTime.new_local(
day.get_year(),
day.get_month(),
day.get_day_of_month(),
0, 0, 0); // midnight
}
BingLog('shuffle timer will be set to '+end.format_iso8601());
return(Math.floor(end.difference(now)/1000000)); // difference in μs -> s
}
export function getResolution(settings, image) {
let resolution = settings.get_string('resolution');
if (resolutions.indexOf(resolution) == -1 || (image ? image.wp == false : true) || // wp == false when background is animated
settings.get_string('resolution') == 'auto' ) {
// resolution invalid, animated background or autoselected
resolution = 'UHD';
}
return resolution;
}
export function openImageFolder(settings) {
//const context = global?global.create_app_launch_context(0, -1):null;
Gio.AppInfo.launch_default_for_uri('file://' + getWallpaperDir(settings), null);
}
export function imageListSortByDate(imageList) {
return imageList.sort(function(a, b) {
var x = parseInt(a.fullstartdate); var y = parseInt(b.fullstartdate);
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
});
}
export function shortenName(string, limit) {
if (string.length > limit) {
string = string.substr(0, limit - 4) + '...';
}
return string;
}
export function moveImagesToNewFolder(settings, oldPath, newPath) {
// possible race condition here, need to think about how to fix it
//let BingWallpaperDir = settings.get_string('download-folder');
let dir = Gio.file_new_for_path(oldPath);
let dirIter = dir.enumerate_children('', Gio.FileQueryInfoFlags.NONE, null );
let newDir = Gio.file_new_for_path(newPath);
if (!newDir.query_exists(null)) {
newDir.make_directory_with_parents(null);
}
let file = null;
while (file = dirIter.next_file(null)) {
let filename = file.get_name(); // we only want to move files that we think we own
if (filename.match(/\d{8}\-.+\.jpg/i)) {
BingLog('file: ' + slash(oldPath) + filename + ' -> ' + slash(newPath) + filename);
let cur = Gio.file_new_for_path(slash(oldPath) + filename);
let dest = Gio.file_new_for_path(slash(newPath) + filename);
cur.move(dest, Gio.FileCopyFlags.OVERWRITE, null, function () { BingLog ('...moved'); });
}
}
// correct filenames for GNOME backgrounds
if (settings.get_boolean('set-background'))
moveBackground(oldPath, newPath, DESKTOP_SCHEMA);
}
export function dirname(path) {
return path.match(/.*\//);
}
export function slash(path) {
if (!path.endsWith('/'))
return path += '/';
return path;
}
export function moveBackground(oldPath, newPath, schema) {
let gsettings = new Gio.Settings({schema: schema});
let uri = gsettings.get_string('picture-uri');
gsettings.set_string('picture-uri', uri.replace(oldPath, newPath));
try {
let dark_uri = gsettings.get_string('picture-uri-dark');
gsettings.set_string('picture-uri-dark', dark_uri.replace(oldPath, newPath));
}
catch (e) {
BingLog('no dark background gsettings key found ('+e+')');
}
Gio.Settings.sync();
gsettings.apply();
}
export function BingLog(msg) {
if (debug)
print("BingWallpaper extension: " + msg); // disable to keep the noise down in journal
}
export function deleteImage(to_delete) {
var file = Gio.file_new_for_path(to_delete);
if (file.query_exists(null)) {
try {
file.delete(null);
BingLog("deleted file: " + to_delete);
}
catch (error) {
BingLog("an error occured deleting " + to_delete + " : " + error);
}
}
}
// add image to persistant list so we can delete it later (in chronological order), delete the oldest image (if user wants this)
export function purgeImages(settings) {
let deletepictures = settings.get_boolean('delete-previous');
if (deletepictures === false)
return;
let imagelist = imageListSortByDate(getImageList(settings));
let maxpictures = settings.get_int('previous-days');
let origlength = imagelist.length;
while (imagelist.length > maxpictures) {
var to_delete = imagelist.shift(); // get the first (oldest item from the list)
if (deletepictures && to_delete != '') {
let imageFilename = imageToFilename(settings, to_delete);
BingLog('deleting '+imageFilename);
deleteImage(imageFilename);
}
}
BingLog('cleaned up image list, count was '+origlength+' now '+imagelist.length);
cleanupImageList(settings);
validate_imagename(settings); // if we deleted our current image, we want to reset it to something valid
}
export function openInSystemViewer(filename, is_file = true) {
let context;
try {
context = global.create_app_launch_context(0, -1);
}
catch (error) {
context = null;
}
if (is_file)
filename = 'file://'+filename;
Gio.AppInfo.launch_default_for_uri(filename, context);
}
export function exportBingJSON(settings) {
let json = settings.get_string('bing-json');
let filepath = getWallpaperDir(settings) + 'bing.json';
let file = Gio.file_new_for_path(filepath);
let [success, error] = file.replace_contents(json, null, false, Gio.FileCreateFlags.REPLACE_DESTINATION, null);
if (!success) {
BingLog('error saving bing-json from '+filepath+': '+error);
}
}
export function importBingJSON(settings) {
const decoder = new TextDecoder();
let filepath = getWallpaperDir(settings) + 'bing.json';
let file = Gio.file_new_for_path(filepath);
if (file.query_exists(null)) {
let [success, contents, etag_out] = file.load_contents(null);
if (!success) {
BingLog('error loading bing-json '+filepath+' - '+etag_out);
}
else {
BingLog('JSON import success');
let parsed = JSON.parse(decoder.decode(contents)); // FIXME: triggers GJS warning without the conversion, need to investigate
// need to implement some checks for validity here
mergeImageLists(settings, parsed);
cleanupImageList(settings); // remove the older missing images
}
}
else {
BingLog('JSON import file not found');
}
}
export function getFileDimensions(filepath) {
let format, width, height;
try {
[format, width, height] = GdkPixbuf.Pixbuf.get_file_info(filepath);
return [width, height];
}
catch (e) {
BingLog('unable to getFileDimensions('+filepath+') '+e);
return [null, null];
}
}
export function toFilename(wallpaperDir, startdate, imageURL, resolution) {
return wallpaperDir + startdate + '-' + imageURL.replace(/^.*[\\\/]/, '').replace('th?id=OHR.', '') + '_' + resolution + '.jpg';
}

View File

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) 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
this service 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 make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. 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.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute 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 and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
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
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the 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 a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, 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.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE 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.
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
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{description}
Copyright (C) {year} {fullname}
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 2 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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision 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, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989
Ty Coon, President of Vice
This 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.

View File

@ -0,0 +1,577 @@
import Clutter from 'gi://Clutter';
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import GObject from 'gi://GObject';
import St from 'gi://St'
import * as PanelMenu from 'resource:///org/gnome/shell/ui/panelMenu.js';
import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import * as Util from 'resource:///org/gnome/shell/misc/util.js';
import * as Sensors from './sensors.js';
import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';
import * as MessageTray from 'resource:///org/gnome/shell/ui/messageTray.js';
import * as Values from './values.js';
import * as Config from 'resource:///org/gnome/shell/misc/config.js';
import * as MenuItem from './menuItem.js';
let vitalsMenu;
var VitalsMenuButton = GObject.registerClass({
GTypeName: 'VitalsMenuButton',
}, class VitalsMenuButton extends PanelMenu.Button {
_init(extensionObject) {
super._init(Clutter.ActorAlign.FILL);
this._extensionObject = extensionObject;
this._settings = extensionObject.getSettings();
this._sensorIcons = {
'temperature' : { 'icon': 'temperature-symbolic.svg' },
'voltage' : { 'icon': 'voltage-symbolic.svg' },
'fan' : { 'icon': 'fan-symbolic.svg' },
'memory' : { 'icon': 'memory-symbolic.svg' },
'processor' : { 'icon': 'cpu-symbolic.svg' },
'system' : { 'icon': 'system-symbolic.svg' },
'network' : { 'icon': 'network-symbolic.svg',
'icon-rx': 'network-download-symbolic.svg',
'icon-tx': 'network-upload-symbolic.svg' },
'storage' : { 'icon': 'storage-symbolic.svg' },
'battery' : { 'icon': 'battery-symbolic.svg' }
}
this._warnings = [];
this._sensorMenuItems = {};
this._hotLabels = {};
this._hotIcons = {};
this._groups = {};
this._widths = {};
this._last_query = new Date().getTime();
this._sensors = new Sensors.Sensors(this._settings, this._sensorIcons);
this._values = new Values.Values(this._settings, this._sensorIcons);
this._menuLayout = new St.BoxLayout({
vertical: false,
clip_to_allocation: true,
x_align: Clutter.ActorAlign.START,
y_align: Clutter.ActorAlign.CENTER,
reactive: true,
x_expand: true,
pack_start: false
});
this._drawMenu();
this.add_actor(this._menuLayout);
this._settingChangedSignals = [];
this._refreshTimeoutId = null;
this._addSettingChangedSignal('update-time', this._updateTimeChanged.bind(this));
this._addSettingChangedSignal('position-in-panel', this._positionInPanelChanged.bind(this));
this._addSettingChangedSignal('menu-centered', this._positionInPanelChanged.bind(this));
let settings = [ 'use-higher-precision', 'alphabetize', 'hide-zeros', 'fixed-widths', 'hide-icons', 'unit', 'memory-measurement', 'include-public-ip', 'network-speed-format', 'storage-measurement', 'include-static-info' ];
for (let setting of Object.values(settings))
this._addSettingChangedSignal(setting, this._redrawMenu.bind(this));
// add signals for show- preference based categories
for (let sensor in this._sensorIcons)
this._addSettingChangedSignal('show-' + sensor, this._showHideSensorsChanged.bind(this));
this._initializeMenu();
// start off with fresh sensors
this._querySensors();
// start monitoring sensors
this._initializeTimer();
}
_initializeMenu() {
// display sensor categories
for (let sensor in this._sensorIcons) {
// groups associated sensors under accordion menu
if (sensor in this._groups) continue;
this._groups[sensor] = new PopupMenu.PopupSubMenuMenuItem(_(this._ucFirst(sensor)), true);
this._groups[sensor].icon.gicon = Gio.icon_new_for_string(this._extensionObject.path + '/icons/' + this._sensorIcons[sensor]['icon']);
// hide menu items that user has requested to not include
if (!this._settings.get_boolean('show-' + sensor))
this._groups[sensor].actor.hide();
if (!this._groups[sensor].status) {
this._groups[sensor].status = this._defaultLabel();
this._groups[sensor].actor.insert_child_at_index(this._groups[sensor].status, 4);
this._groups[sensor].status.text = _('No Data');
}
this.menu.addMenuItem(this._groups[sensor]);
}
// add separator
this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
let item = new PopupMenu.PopupBaseMenuItem({
reactive: false,
style_class: 'vitals-menu-button-container'
});
let customButtonBox = new St.BoxLayout({
style_class: 'vitals-button-box',
vertical: false,
clip_to_allocation: true,
x_align: Clutter.ActorAlign.CENTER,
y_align: Clutter.ActorAlign.CENTER,
reactive: true,
x_expand: true,
pack_start: false
});
// custom round refresh button
let refreshButton = this._createRoundButton('view-refresh-symbolic', _('Refresh'));
refreshButton.connect('clicked', (self) => {
// force refresh by clearing history
this._sensors.resetHistory();
this._values.resetHistory();
// make sure timer fires at next full interval
this._updateTimeChanged();
// refresh sensors now
this._querySensors();
});
customButtonBox.add_actor(refreshButton);
// custom round monitor button
let monitorButton = this._createRoundButton('org.gnome.SystemMonitor-symbolic', _('System Monitor'));
monitorButton.connect('clicked', (self) => {
this.menu._getTopMenu().close();
Util.spawn(this._settings.get_string('monitor-cmd').split(" "));
});
customButtonBox.add_actor(monitorButton);
// custom round preferences button
let prefsButton = this._createRoundButton('preferences-system-symbolic', _('Preferences'));
prefsButton.connect('clicked', (self) => {
this.menu._getTopMenu().close();
this._extensionObject.openPreferences();
});
customButtonBox.add_actor(prefsButton);
// now add the buttons to the top bar
item.actor.add_actor(customButtonBox);
// add buttons
this.menu.addMenuItem(item);
// query sensors on menu open
this._menuStateChangeId = this.menu.connect('open-state-changed', (self, isMenuOpen) => {
if (isMenuOpen) {
// make sure timer fires at next full interval
this._updateTimeChanged();
// refresh sensors now
this._querySensors();
}
});
}
_createRoundButton(iconName) {
let button = new St.Button({
style_class: 'message-list-clear-button button vitals-button-action'
});
button.child = new St.Icon({
icon_name: iconName
});
return button;
}
_removeMissingHotSensors(hotSensors) {
for (let i = hotSensors.length - 1; i >= 0; i--) {
let sensor = hotSensors[i];
// make sure default icon (if any) stays visible
if (sensor == '_default_icon_') continue;
// removes sensors that are no longer available
if (!this._sensorMenuItems[sensor]) {
hotSensors.splice(i, 1);
this._removeHotLabel(sensor);
this._removeHotIcon(sensor);
}
}
return hotSensors;
}
_saveHotSensors(hotSensors) {
// removes any sensors that may not currently be available
hotSensors = this._removeMissingHotSensors(hotSensors);
this._settings.set_strv('hot-sensors', hotSensors.filter(
function(item, pos) {
return hotSensors.indexOf(item) == pos;
}
));
}
_initializeTimer() {
// used to query sensors and update display
let update_time = this._settings.get_int('update-time');
this._refreshTimeoutId = GLib.timeout_add_seconds(
GLib.PRIORITY_DEFAULT,
update_time,
(self) => {
// only update menu if we have hot sensors
if (Object.values(this._hotLabels).length > 0)
this._querySensors();
// keep the timer running
return GLib.SOURCE_CONTINUE;
}
);
}
_createHotItem(key, value) {
let icon = this._defaultIcon(key);
this._hotIcons[key] = icon;
this._menuLayout.add_actor(icon)
// don't add a label when no sensors are in the panel
if (key == '_default_icon_') return;
let label = new St.Label({
style_class: 'vitals-panel-label',
text: (value)?value:'\u2026', // ...
y_expand: true,
y_align: Clutter.ActorAlign.START
});
// attempt to prevent ellipsizes
label.get_clutter_text().ellipsize = 0;
// keep track of label for removal later
this._hotLabels[key] = label;
// prevent "called on the widget" "which is not in the stage" errors by adding before width below
this._menuLayout.add_actor(label);
// support for fixed widths #55, save label (text) width
this._widths[key] = label.width;
}
_showHideSensorsChanged(self, sensor) {
this._sensors.resetHistory();
this._groups[sensor.substr(5)].visible = this._settings.get_boolean(sensor);
}
_positionInPanelChanged() {
this.container.get_parent().remove_actor(this.container);
let position = this._positionInPanel();
// allows easily addressable boxes
let boxes = {
left: Main.panel._leftBox,
center: Main.panel._centerBox,
right: Main.panel._rightBox
};
// update position when changed from preferences
boxes[position[0]].insert_child_at_index(this.container, position[1]);
}
_removeHotLabel(key) {
if (key in this._hotLabels) {
let label = this._hotLabels[key];
delete this._hotLabels[key];
// make sure set_label is not called on non existent actor
label.destroy();
}
}
_removeHotLabels() {
for (let key in this._hotLabels)
this._removeHotLabel(key);
}
_removeHotIcon(key) {
if (key in this._hotIcons) {
this._hotIcons[key].destroy();
delete this._hotIcons[key];
}
}
_removeHotIcons() {
for (let key in this._hotIcons)
this._removeHotIcon(key);
}
_redrawMenu() {
this._removeHotIcons();
this._removeHotLabels();
for (let key in this._sensorMenuItems) {
if (key.includes('-group')) continue;
this._sensorMenuItems[key].destroy();
delete this._sensorMenuItems[key];
}
this._drawMenu();
this._sensors.resetHistory();
this._values.resetHistory();
this._querySensors();
}
_drawMenu() {
// grab list of selected menubar icons
let hotSensors = this._settings.get_strv('hot-sensors');
for (let key of Object.values(hotSensors)) {
// fixes issue #225 which started when _max_ was moved to the end
if (key == '__max_network-download__') key = '__network-rx_max__';
if (key == '__max_network-upload__') key = '__network-tx_max__';
this._createHotItem(key);
}
}
_destroyTimer() {
// invalidate and reinitialize timer
if (this._refreshTimeoutId != null) {
GLib.Source.remove(this._refreshTimeoutId);
this._refreshTimeoutId = null;
}
}
_updateTimeChanged() {
this._destroyTimer();
this._initializeTimer();
}
_addSettingChangedSignal(key, callback) {
this._settingChangedSignals.push(this._settings.connect('changed::' + key, callback));
}
_updateDisplay(label, value, type, key) {
// update sensor value in menubar
if (this._hotLabels[key]) {
this._hotLabels[key].set_text(value);
// support for fixed widths #55
if (this._settings.get_boolean('fixed-widths')) {
// grab text box width and see if new text is wider than old text
let width2 = this._hotLabels[key].get_clutter_text().width;
if (width2 > this._widths[key]) {
this._hotLabels[key].set_width(width2);
this._widths[key] = width2;
}
}
}
// have we added this sensor before?
let item = this._sensorMenuItems[key];
if (item) {
// update sensor value in the group
item.value = value;
} else if (type.includes('-group')) {
// update text next to group header
let group = type.split('-')[0];
if (this._groups[group]) {
this._groups[group].status.text = value;
this._sensorMenuItems[type] = this._groups[group];
}
} else {
// add item to group for the first time
let sensor = { 'label': label, 'value': value, 'type': type }
this._appendMenuItem(sensor, key);
}
}
_appendMenuItem(sensor, key) {
let split = sensor.type.split('-');
let type = split[0];
let icon = (split.length == 2)?'icon-' + split[1]:'icon';
let gicon = Gio.icon_new_for_string(this._extensionObject.path + '/icons/' + this._sensorIcons[type][icon]);
let item = new MenuItem.MenuItem(gicon, key, sensor.label, sensor.value, this._hotLabels[key]);
item.connect('toggle', (self) => {
let hotSensors = this._settings.get_strv('hot-sensors');
if (self.checked) {
// add selected sensor to panel
hotSensors.push(self.key);
this._createHotItem(self.key, self.value);
} else {
// remove selected sensor from panel
hotSensors.splice(hotSensors.indexOf(self.key), 1);
this._removeHotLabel(self.key);
this._removeHotIcon(self.key);
}
if (hotSensors.length <= 0) {
// add generic icon to panel when no sensors are selected
hotSensors.push('_default_icon_');
this._createHotItem('_default_icon_');
} else {
let defIconPos = hotSensors.indexOf('_default_icon_');
if (defIconPos >= 0) {
// remove generic icon from panel when sensors are selected
hotSensors.splice(defIconPos, 1);
this._removeHotIcon('_default_icon_');
}
}
// this code is called asynchronously - make sure to save it for next round
this._saveHotSensors(hotSensors);
});
this._sensorMenuItems[key] = item;
let i = Object.keys(this._sensorMenuItems[key]).length;
// alphabetize the sensors for these categories
if (this._settings.get_boolean('alphabetize')) {
let menuItems = this._groups[type].menu._getMenuItems();
for (i = 0; i < menuItems.length; i++)
// use natural sort order for system load, etc
if (menuItems[i].label.localeCompare(item.label, undefined, { numeric: true, sensitivity: 'base' }) > 0)
break;
}
this._groups[type].menu.addMenuItem(item, i);
}
_defaultLabel() {
return new St.Label({
y_expand: true,
y_align: Clutter.ActorAlign.CENTER
});
}
_defaultIcon(key) {
let split = key.replaceAll('_', ' ').trim().split(' ')[0].split('-');
let type = split[0];
let icon = new St.Icon({
style_class: 'system-status-icon vitals-panel-icon-' + type,
reactive: true
});
// second condition prevents crash due to issue #225, which started when _max_ was moved to the end
if (type == 'default' || !(type in this._sensorIcons)) {
icon.gicon = Gio.icon_new_for_string(this._extensionObject.path + '/icons/' + this._sensorIcons['system']['icon']);
} else if (!this._settings.get_boolean('hide-icons')) { // support for hide icons #80
let iconObj = (split.length == 2)?'icon-' + split[1]:'icon';
icon.gicon = Gio.icon_new_for_string(this._extensionObject.path + '/icons/' + this._sensorIcons[type][iconObj]);
}
return icon;
}
_ucFirst(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
_positionInPanel() {
let alignment = '';
let gravity = 0;
let arrow_pos = 0;
switch (this._settings.get_int('position-in-panel')) {
case 0: // left
alignment = 'left';
gravity = -1;
arrow_pos = 1;
break;
case 1: // center
alignment = 'center';
gravity = -1;
arrow_pos = 0.5;
break;
case 2: // right
alignment = 'right';
gravity = 0;
arrow_pos = 0;
break;
case 3: // far left
alignment = 'left';
gravity = 0;
arrow_pos = 1;
break;
case 4: // far right
alignment = 'right';
gravity = -1;
arrow_pos = 0;
break;
}
let centered = this._settings.get_boolean('menu-centered')
if (centered) arrow_pos = 0.5;
// set arrow position when initializing and moving vitals
this.menu._arrowAlignment = arrow_pos;
return [alignment, gravity];
}
_querySensors() {
// figure out last run time
let now = new Date().getTime();
let dwell = (now - this._last_query) / 1000;
this._last_query = now;
this._sensors.query((label, value, type, format) => {
let key = '_' + type.replace('-group', '') + '_' + label.replace(' ', '_').toLowerCase() + '_';
// if a sensor is disabled, gray it out
if (key in this._sensorMenuItems) {
this._sensorMenuItems[key].setSensitive((value!='disabled'));
// don't continue below, last known value is shown
if (value == 'disabled') return;
}
let items = this._values.returnIfDifferent(dwell, label, value, type, format, key);
for (let item of Object.values(items))
this._updateDisplay(_(item[0]), item[1], item[2], item[3]);
}, dwell);
if (this._warnings.length > 0) {
this._notify('Vitals', this._warnings.join("\n"), 'folder-symbolic');
this._warnings = [];
}
}
_notify(msg, details, icon) {
let source = new MessageTray.Source('MyApp Information', icon);
Main.messageTray.add(source);
let notification = new MessageTray.Notification(source, msg, details);
notification.setTransient(true);
source.notify(notification);
}
destroy() {
this._destroyTimer();
for (let signal of Object.values(this._settingChangedSignals))
this._settings.disconnect(signal);
super.destroy();
}
});
export default class VitalsExtension extends Extension {
enable() {
vitalsMenu = new VitalsMenuButton(this);
let position = vitalsMenu._positionInPanel();
Main.panel.addToStatusArea('vitalsMenu', vitalsMenu, position[1], position[0]);
}
disable() {
vitalsMenu.destroy();
vitalsMenu = null;
}
}

View File

@ -0,0 +1,82 @@
import Gio from 'gi://Gio';
import GLib from 'gi://GLib'
// convert Uint8Array into a literal string
function convertUint8ArrayToString(contents) {
const decoder = new TextDecoder('utf-8');
return decoder.decode(contents).trim();
}
export function File(path) {
if (path.indexOf('https://') == -1)
this.file = Gio.File.new_for_path(path);
else
this.file = Gio.File.new_for_uri(path);
}
File.prototype.read = function(delimiter = '', strip_header = false) {
return new Promise((resolve, reject) => {
try {
this.file.load_contents_async(null, function(file, res) {
try {
// grab contents of file or website
let contents = file.load_contents_finish(res)[1];
// convert contents to string
contents = convertUint8ArrayToString(contents);
// split contents by delimiter if passed in
if (delimiter) contents = contents.split(delimiter);
// optionally strip header when converting to a list
if (strip_header) contents.shift();
// return results
resolve(contents);
} catch (e) {
reject(e.message);
}
});
} catch (e) {
reject(e.message);
}
});
};
File.prototype.list = function() {
return new Promise((resolve, reject) => {
let max_items = 125, results = [];
try {
this.file.enumerate_children_async(Gio.FILE_ATTRIBUTE_STANDARD_NAME, Gio.FileQueryInfoFlags.NONE, GLib.PRIORITY_LOW, null, function(file, res) {
try {
let enumerator = file.enumerate_children_finish(res);
let callback = function(enumerator, res) {
try {
let files = enumerator.next_files_finish(res);
for (let i = 0; i < files.length; i++) {
results.push(files[i].get_attribute_as_string(Gio.FILE_ATTRIBUTE_STANDARD_NAME));
}
if (files.length == 0) {
enumerator.close_async(GLib.PRIORITY_LOW, null, function(){});
resolve(results);
} else {
enumerator.next_files_async(max_items, GLib.PRIORITY_LOW, null, callback);
}
} catch (e) {
reject(e.message);
}
};
enumerator.next_files_async(max_items, GLib.PRIORITY_LOW, null, callback);
} catch (e) {
reject(e.message);
}
});
} catch (e) {
reject(e.message);
}
});
};

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16" height="16.001" xmlns="http://www.w3.org/2000/svg">
<g fill="#474747">
<path d="M5 5v2h6V5z" overflow="visible"/>
<path d="M5.469 0c-.49 0-.797.216-1.032.456C4.202.696 4 1.012 4 1.486V2H2v14h12V2h-2v-.406l-.002-.028a1.616 1.616 0 0 0-.416-1.011c-.236-.28-.62-.585-1.2-.553L10.438 0zm.53 2h4v2h2v10H4V4h2z" color="#bebebe" font-family="sans-serif" font-weight="400" overflow="visible" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none" white-space="normal"/>
<path d="m5 8v2h6v-2zm0 3v2h6v-2z" overflow="visible"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 909 B

View File

@ -0,0 +1 @@
<?xml version="1.0" ?><svg enable-background="new 0 0 52 52" id="Layer_1" version="1.1" viewBox="0 0 52 52" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M38.9799805,2H2v48h48V13.0200195L38.9799805,2z M25.0005493,6.0021362h3v2h-3V6.0021362z M25.0005493,10.0021362h3v2h-3 V10.0021362z M25.0005493,14.0021362h3v2h-3V14.0021362z M19.0005493,6.0021362h3v2h-3V6.0021362z M19.0005493,10.0021362h3v2h-3 V10.0021362z M19.0005493,14.0021362h3v2h-3V14.0021362z M10.0005493,46.0021362h-3v-2h3V46.0021362z M10.0005493,42.0021362h-3v-2 h3V42.0021362z M10.0005493,38.0021362h-3v-2h3V38.0021362z M10.0005493,34.0021362h-3v-2h3V34.0021362z M10.0005493,30.0021362h-3 v-2h3V30.0021362z M10.0005493,25.0021362h-3v-2h3V25.0021362z M10.0005493,21.0021362h-3v-2h3V21.0021362z M10.0005493,16.0021362 h-3v-2h3V16.0021362z M10.0005493,12.0021362h-3v-2h3V12.0021362z M10.0005493,8.0021362h-3v-2h3V8.0021362z M16.0005493,46.0021362 h-3v-2h3V46.0021362z M16.0005493,42.0021362h-3v-2h3V42.0021362z M16.0005493,38.0021362h-3v-2h3V38.0021362z M16.0005493,34.0021362h-3v-2h3V34.0021362z M16.0005493,30.0021362h-3v-2h3V30.0021362z M16.0005493,25.0021362h-3v-2h3 V25.0021362z M16.0005493,21.0021362h-3v-2h3V21.0021362z M16.0005493,16.0021362h-3v-2h3V16.0021362z M16.0005493,12.0021362h-3v-2 h3V12.0021362z M16.0005493,8.0021362h-3v-2h3V8.0021362z M19,19h14v14H19V19z M22.0005493,46.0021362h-3v-2h3V46.0021362z M22.0005493,42.0021362h-3v-2h3V42.0021362z M22.0005493,38.0021362h-3v-2h3V38.0021362z M28.0005493,46.0021362h-3v-2h3 V46.0021362z M28.0005493,42.0021362h-3v-2h3V42.0021362z M28.0005493,38.0021362h-3v-2h3V38.0021362z M34.0005493,46.0021362h-3v-2 h3V46.0021362z M34.0005493,42.0021362h-3v-2h3V42.0021362z M34.0005493,38.0021362h-3v-2h3V38.0021362z M34.0005493,16.0021362h-3 v-2h3V16.0021362z M34.0005493,12.0021362h-3v-2h3V12.0021362z M34.0005493,8.0021362h-3v-2h3V8.0021362z M40.0005493,46.0021362h-3 v-2h3V46.0021362z M40.0005493,42.0021362h-3v-2h3V42.0021362z M40.0005493,38.0021362h-3v-2h3V38.0021362z M40.0005493,34.0021362 h-3v-2h3V34.0021362z M40.0005493,30.0021362h-3v-2h3V30.0021362z M40.0005493,25.0021362h-3v-2h3V25.0021362z M40.0005493,21.0021362h-3v-2h3V21.0021362z M40.0005493,16.0021362h-3v-2h3V16.0021362z M40.0005493,12.0021362h-3v-2h3 V12.0021362z M46.0005493,46.0021362h-3v-2h3V46.0021362z M46.0005493,42.0021362h-3v-2h3V42.0021362z M46.0005493,38.0021362h-3v-2 h3V38.0021362z M46.0005493,34.0021362h-3v-2h3V34.0021362z M46.0005493,30.0021362h-3v-2h3V30.0021362z M46.0005493,25.0021362h-3 v-2h3V25.0021362z M46.0005493,21.0021362h-3v-2h3V21.0021362z M46.0005493,16.0021362h-3v-2h3V16.0021362z"/></svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg7384"
version="1.1"
inkscape:version="0.48.3.1 r9886"
height="16"
sodipodi:docname="fan.svg"
width="16">
<metadata
id="metadata90">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>Gnome Symbolic Icon Theme</dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
inkscape:object-paths="true"
inkscape:cy="7.9523753"
inkscape:current-layer="svg7384"
inkscape:window-width="1680"
pagecolor="#555753"
showborder="false"
showguides="true"
inkscape:snap-nodes="false"
objecttolerance="10"
showgrid="true"
inkscape:object-nodes="true"
inkscape:pageshadow="2"
inkscape:guide-bbox="true"
inkscape:window-x="0"
inkscape:snap-bbox="true"
bordercolor="#666666"
id="namedview88"
inkscape:window-maximized="1"
inkscape:snap-global="false"
inkscape:window-y="27"
gridtolerance="10"
inkscape:zoom="45.254834"
inkscape:window-height="991"
borderopacity="1"
guidetolerance="10"
inkscape:snap-bbox-midpoints="false"
inkscape:cx="6.4701314"
inkscape:bbox-paths="false"
inkscape:snap-grids="true"
inkscape:pageopacity="1"
inkscape:snap-to-guides="true">
<inkscape:grid
visible="true"
spacingx="1px"
type="xygrid"
spacingy="1px"
id="grid4866"
empspacing="2"
enabled="true"
snapvisiblegridlinesonly="true" />
</sodipodi:namedview>
<title
id="title9167">Gnome Symbolic Icon Theme</title>
<defs
id="defs7386" />
<g
transform="translate(-261,-277)"
inkscape:groupmode="layer"
id="layer9"
inkscape:label="status"
style="display:inline" />
<g
transform="translate(-261,-277)"
inkscape:groupmode="layer"
id="layer10"
inkscape:label="devices" />
<g
transform="translate(-261,-277)"
inkscape:groupmode="layer"
id="layer11"
inkscape:label="apps" />
<g
transform="translate(-261,-277)"
inkscape:groupmode="layer"
id="layer12"
inkscape:label="actions" />
<g
transform="translate(-261,-277)"
inkscape:groupmode="layer"
id="layer13"
inkscape:label="places" />
<g
transform="translate(-261,-277)"
inkscape:groupmode="layer"
id="layer14"
inkscape:label="mimetypes" />
<g
transform="translate(-261,-277)"
inkscape:groupmode="layer"
id="layer15"
inkscape:label="emblems"
style="display:inline" />
<g
transform="translate(-261,-277)"
inkscape:groupmode="layer"
id="g4953"
inkscape:label="categories"
style="display:inline" />
<path
style="fill:#bebebe;fill-opacity:1;stroke:none"
d="M 8 0 C 7.7662783 -3.1322393e-17 7.5411335 0.011610998 7.3125 0.03125 C 5.2102943 1.4256475 5.5987411 4.0108346 6.90625 6.34375 C 7.2209706 6.1372503 7.5954602 6 8 6 C 8.0316752 6 8.062435 5.9985435 8.09375 6 C 8.7335699 3.3508722 11.235427 1.3679906 11.96875 1.0625 C 10.798244 0.39154001 9.4458996 -7.7509341e-16 8 0 z M 4 1.09375 C 2.5986515 1.9071018 1.4765974 3.1207274 0.78125 4.59375 C 0.9182133 7.1283275 3.3250439 8.0908827 6 8.125 C 5.9974202 8.0834163 6 8.0422335 6 8 C 6 7.6007368 6.1109237 7.2184502 6.3125 6.90625 C 4.3514736 5.0277432 3.8996391 1.8856213 4 1.09375 z M 13.15625 3.0625 C 11.454675 3.0097524 9.9536158 4.4003424 8.875 6.21875 C 9.2647725 6.4100014 9.5848814 6.7069783 9.78125 7.09375 C 12.408696 6.3344077 15.40554 7.5273725 16 8 C 16 6.3023731 15.464331 4.7324062 14.5625 3.4375 C 14.086383 3.1993071 13.609414 3.0765477 13.15625 3.0625 z M 10 7.875 C 10.00258 7.9165837 10 7.9577665 10 8 C 10 8.3992632 9.8890763 8.7815498 9.6875 9.09375 C 11.648527 10.972257 12.100361 14.114379 12 14.90625 C 13.401349 14.092898 14.523403 12.879273 15.21875 11.40625 C 15.081787 8.8716722 12.674956 7.9091173 10 7.875 z M 0 8 C -4.5501758e-16 9.6976269 0.53566854 11.267594 1.4375 12.5625 C 3.7013779 13.695079 5.7591272 12.083936 7.125 9.78125 C 6.7352275 9.5899986 6.4151186 9.2930217 6.21875 8.90625 C 3.5913037 9.6655923 0.5944604 8.4726275 0 8 z M 9.09375 9.65625 C 8.7790294 9.8627497 8.4045398 10 8 10 C 7.9683248 10 7.937565 10.001457 7.90625 10 C 7.26643 12.649128 4.7645729 14.632009 4.03125 14.9375 C 5.2017564 15.60846 6.5541004 16 8 16 C 8.2337217 16 8.4588665 15.988389 8.6875 15.96875 C 10.789706 14.574352 10.401259 11.989165 9.09375 9.65625 z "
id="path3830" />
<path
sodipodi:type="arc"
style="fill:#bebebe;fill-opacity:1;stroke:none"
id="path3896"
sodipodi:cx="8.0433397"
sodipodi:cy="8.0008545"
sodipodi:rx="0.9722718"
sodipodi:ry="0.95017475"
d="m 9.0156115,8.0008545 a 0.9722718,0.95017475 0 1 1 -1.9445436,0 0.9722718,0.95017475 0 1 1 1.9445436,0 z"
transform="matrix(1.028519,0,0,1.052438,-0.27272757,-0.42040319)" />
</svg>

After

Width:  |  Height:  |  Size: 5.4 KiB

View File

@ -0,0 +1 @@
<?xml version="1.0" ?><svg enable-background="new 0 0 52 52" id="Layer_1" version="1.1" viewBox="0 0 52 52" xml:space="preserve" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M50,41.0999756V11.4000244h-6.9978638V7.7766113C44.164978,7.364502,45,6.2706909,45,4.9799805 C45,3.3400269,43.6600342,2,42,2c-1.6499634,0-3,1.3400269-3,2.9799805c0,1.2908936,0.8413696,2.3848267,2.0021362,2.796814v3.62323 h-8V7.7766113C34.164978,7.364502,35,6.2706909,35,4.9799805C35,3.3400269,33.6600342,2,32,2c-1.6499634,0-3,1.3400269-3,2.9799805 c0,1.2908936,0.8413696,2.3848267,2.0021362,2.796814v3.62323h-8V7.7766113C24.164978,7.364502,25,6.2706909,25,4.9799805 C25,3.3400269,23.6600342,2,22,2c-1.6499634,0-3,1.3400269-3,2.9799805c0,1.2908936,0.8413696,2.3848267,2.0021362,2.796814v3.62323 h-8V7.7766113C14.164978,7.364502,15,6.2706909,15,4.9799805C15,3.3400269,13.6600342,2,12,2c-1.6499634,0-3,1.3400269-3,2.9799805 c0,1.2908936,0.8413696,2.3848267,2.0021362,2.796814v3.62323H2v29.6999512h9.0021362v3.1321411 C9.8413696,44.6417847,9,45.7312622,9,47.0299683C9,48.6699829,10.3500366,50,12,50c1.6600342,0,3-1.3300171,3-2.9700317 c0-1.298584-0.835022-2.3878784-1.9978638-2.7977295v-3.1322632h8v3.1321411C19.8413696,44.6417847,19,45.7312622,19,47.0299683 C19,48.6699829,20.3500366,50,22,50c1.6600342,0,3-1.3300171,3-2.9700317c0-1.298584-0.835022-2.3878784-1.9978638-2.7977295 v-3.1322632h8v3.1321411C29.8413696,44.6417847,29,45.7312622,29,47.0299683C29,48.6699829,30.3500366,50,32,50 c1.6600342,0,3-1.3300171,3-2.9700317c0-1.298584-0.835022-2.3878784-1.9978638-2.7977295v-3.1322632h8v3.1321411 C39.8413696,44.6417847,39,45.7312622,39,47.0299683C39,48.6699829,40.3500366,50,42,50c1.6600342,0,3-1.3300171,3-2.9700317 c0-1.298584-0.835022-2.3878784-1.9978638-2.7977295v-3.1322632H50z M7,16.3500366h38v19.7999878H7V16.3500366z"/></svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1 @@
<?xml version="1.0" ?><svg height="16px" version="1.1" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns" xmlns:xlink="http://www.w3.org/1999/xlink"><title/><defs/><g fill="none" fill-rule="evenodd" id="Icons with numbers" stroke="none" stroke-width="1"><g fill="#000000" id="Group" transform="translate(-672.000000, -288.000000)"><path d="M679,293 L679,296 L677,296 L680,300 L683,296 L681,296 L681,293 Z M672,298 C672,296.651721 672.895887,295.507545 674.127761,295.131093 C674.500314,293.897932 675.645295,293 677,293 C677.174013,293 677.344566,293.014816 677.510466,293.043254 C678.195719,291.823839 679.50165,291 681,291 C683.209139,291 685,292.790861 685,295 C686.668415,295.005076 688,296.346276 688,298 C688,299.653483 686.652611,301 684.990522,301 L675.009478,301 C673.336631,301 672,299.656854 672,298 Z M672,298" id="Rectangle 169 copy 2"/></g></g></svg>

After

Width:  |  Height:  |  Size: 936 B

View File

@ -0,0 +1 @@
<?xml version="1.0" ?><svg height="16px" version="1.1" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns" xmlns:xlink="http://www.w3.org/1999/xlink"><title/><defs/><g fill="none" fill-rule="evenodd" id="Icons with numbers" stroke="none" stroke-width="1"><g fill="#000000" id="Group" transform="translate(-576.000000, -288.000000)"><path d="M576,298 C576,296.651721 576.895887,295.507545 578.127761,295.131093 C578.500314,293.897932 579.645295,293 581,293 C581.174013,293 581.344566,293.014816 581.510466,293.043254 C582.195719,291.823839 583.50165,291 585,291 C587.209139,291 589,292.790861 589,295 C590.668415,295.005076 592,296.346276 592,298 C592,299.653483 590.652611,301 588.990522,301 L579.009478,301 C577.336631,301 576,299.656854 576,298 Z M576,298" id="Rectangle 169"/></g></g></svg>

After

Width:  |  Height:  |  Size: 864 B

View File

@ -0,0 +1 @@
<?xml version="1.0" ?><svg height="16px" version="1.1" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns" xmlns:xlink="http://www.w3.org/1999/xlink"><title/><defs/><g fill="none" fill-rule="evenodd" id="Icons with numbers" stroke="none" stroke-width="1"><g fill="#000000" id="Group" transform="translate(-624.000000, -288.000000)"><path d="M631,297 L631,300 L633,300 L633,297 L635,297 L632,293 L629,297 Z M624,298 C624,296.651721 624.895887,295.507545 626.127761,295.131093 C626.500314,293.897932 627.645295,293 629,293 C629.174013,293 629.344566,293.014816 629.510466,293.043254 C630.195719,291.823839 631.50165,291 633,291 C635.209139,291 637,292.790861 637,295 C638.668415,295.005076 640,296.346276 640,298 C640,299.653483 638.652611,301 636.990522,301 L627.009478,301 C625.336631,301 624,299.656854 624,298 Z M624,298" id="Rectangle 169 copy"/></g></g></svg>

After

Width:  |  Height:  |  Size: 934 B

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" version="1.1">
<path style="fill:#bebebe" d="M 3,1 C 2,1 2,2 2,2 V 14 C 2,14 2,15 3,15 H 13 C 13,15 14,15 14,14 V 2 C 14,2 14,1 13,1 Z M 8,3 C 10.21,3 12,4.79 12,7 12,9.21 10.21,11 8,11 H 4 V 7 C 4,4.79 5.79,3 8,3 Z M 8,5 C 6.9,5 6,5.9 6,7 6,8.1 6.9,9 8,9 9.1,9 10,8.1 10,7 10,5.9 9.1,5 8,5 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 367 B

View File

@ -0,0 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" version="1.1">
<path style="fill:#bebebe" d="M 15,1 C 16,1 16,2 16,2 V 12 C 16,12 16,13 15,13 H 1 C 1,13 0,13 0,12 V 2 C 0,2 0,1 1,1 Z M 14,3 H 2 V 11 H 14 Z M 11,14 V 15 H 5 V 14 C 5,13 6,13 6,13 H 10 C 10,13 11,13 11,14 Z"/>
</svg>

After

Width:  |  Height:  |  Size: 298 B

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
enable-background="new -0.2 0 18 30"
height="30"
version="1.1"
viewBox="-0.2 0 30 30"
width="30"
xml:space="preserve"
id="svg6"
sodipodi:docname="if_Vector-icons_49_1041647.svg"
inkscape:version="0.92.3 (3ce5693, 2018-03-11)"><metadata
id="metadata10"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1070"
inkscape:window-height="638"
id="namedview8"
showgrid="false"
inkscape:zoom="7.8666667"
inkscape:cx="5.2520864"
inkscape:cy="14.6"
inkscape:window-x="330"
inkscape:window-y="226"
inkscape:window-maximized="0"
inkscape:current-layer="svg6" /><defs
id="defs2" /><path
d="M 14.6,29.8 C 9.8,29.8 6,25.9 6,21.2 6,18.1 7.6,15.4 10,13.9 V 4.5 C 10,2 12.1,0 14.5,0 16.9,0 19,2 19,4.5 v 9.2 c 2.5,1.5 4.2,4.3 4.2,7.4 0.1,4.8 -3.8,8.7 -8.6,8.7 z M 17.3,15.4 17.1,5 C 17.1,3.8 15.7,2.9 14.5,2.9 13.3,2.9 12,3.8 12,5 v 10.5 c -2.1,1 -3.6,3.2 -3.6,5.7 0,3.5 2.8,6.3 6.3,6.3 3.5,0 6.3,-2.8 6.3,-6.3 0,-2.6 -1.5,-4.8 -3.7,-5.8 z m -2.7,10.5 c -2.6,0 -4.7,-2.1 -4.7,-4.7 0,-2 1.3,-3.7 3.1,-4.4 V 8 h 3 v 8.8 c 1.9,0.6 3.3,2.3 3.3,4.4 0,2.6 -2.1,4.7 -4.7,4.7 z"
id="path4"
inkscape:connector-curvature="0"
style="clip-rule:evenodd;fill:#0d0d0d;fill-rule:evenodd" /></svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
id="svg7384"
version="1.1"
inkscape:version="0.48.3.1 r9886"
height="16"
sodipodi:docname="voltage.svg"
width="16">
<metadata
id="metadata90">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title>Gnome Symbolic Icon Theme</dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<sodipodi:namedview
inkscape:object-paths="true"
inkscape:cy="8.2822539"
inkscape:current-layer="svg7384"
inkscape:window-width="1680"
pagecolor="#555753"
showborder="false"
showguides="true"
inkscape:snap-nodes="false"
objecttolerance="10"
showgrid="true"
inkscape:object-nodes="true"
inkscape:pageshadow="2"
inkscape:guide-bbox="true"
inkscape:window-x="0"
inkscape:snap-bbox="true"
bordercolor="#666666"
id="namedview88"
inkscape:window-maximized="1"
inkscape:snap-global="false"
inkscape:window-y="27"
gridtolerance="10"
inkscape:zoom="68.593502"
inkscape:window-height="991"
borderopacity="1"
guidetolerance="10"
inkscape:snap-bbox-midpoints="false"
inkscape:cx="6.2925429"
inkscape:bbox-paths="false"
inkscape:snap-grids="true"
inkscape:pageopacity="1"
inkscape:snap-to-guides="true">
<inkscape:grid
visible="true"
spacingx="1px"
type="xygrid"
spacingy="1px"
id="grid4866"
empspacing="2"
enabled="true"
snapvisiblegridlinesonly="true" />
</sodipodi:namedview>
<title
id="title9167">Gnome Symbolic Icon Theme</title>
<defs
id="defs7386" />
<g
transform="translate(-261,-277)"
inkscape:groupmode="layer"
id="layer9"
inkscape:label="status"
style="display:inline" />
<g
transform="translate(-261,-277)"
inkscape:groupmode="layer"
id="layer10"
inkscape:label="devices" />
<g
transform="translate(-261,-277)"
inkscape:groupmode="layer"
id="layer11"
inkscape:label="apps" />
<g
transform="translate(-261,-277)"
inkscape:groupmode="layer"
id="layer12"
inkscape:label="actions" />
<g
transform="translate(-261,-277)"
inkscape:groupmode="layer"
id="layer13"
inkscape:label="places" />
<g
transform="translate(-261,-277)"
inkscape:groupmode="layer"
id="layer14"
inkscape:label="mimetypes" />
<g
transform="translate(-261,-277)"
inkscape:groupmode="layer"
id="layer15"
inkscape:label="emblems"
style="display:inline" />
<g
transform="translate(-261,-277)"
inkscape:groupmode="layer"
id="g4953"
inkscape:label="categories"
style="display:inline" />
<path
style="fill:#bebebe;fill-opacity:1;stroke:none"
d="m 11.40625,1 c -0.455108,0.038189 -0.61564,0.1791748 -1.25,0.625 L 2.84375,7.34375 C 1.9959525,8.0221961 2,8.0144269 2,9 l 0,1 4,0 -3.1875,3.1875 C 1.98932,14.004249 2.00091,13.998722 2,15 l 0,1 1,0.03125 c 0.986227,-0.01956 0.997937,-0.03056 1.84375,-0.625 L 12.15625,9.6875 C 13.004048,9.0090539 13,8.9855731 13,8 L 13,7 9,7 12.1875,3.8125 C 13.01068,2.9957516 12.99909,3.0012778 13,2 l 0,-1 -1,0 c -0.246557,0.00489 -0.442047,-0.0127296 -0.59375,0 z"
id="path3898"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sccsccccccccsccccccs" />
</svg>

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@ -0,0 +1,77 @@
import Clutter from 'gi://Clutter';
import GObject from 'gi://GObject';
import St from 'gi://St'
import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
export const MenuItem = GObject.registerClass({
Signals: {
'toggle': { param_types: [Clutter.Event.$gtype] },
},
}, class MenuItem extends PopupMenu.PopupBaseMenuItem {
_init(icon, key, label, value, checked) {
super._init({ reactive: true });
this._checked = checked;
this._updateOrnament();
this._key = key;
this._gIcon = icon;
// add icon
this.add(new St.Icon({ style_class: 'popup-menu-icon', gicon : this._gIcon }));
// add label
this._labelActor = new St.Label({ text: label });
this.add(this._labelActor);
// add value
this._valueLabel = new St.Label({ text: value });
this._valueLabel.set_x_align(Clutter.ActorAlign.END);
this._valueLabel.set_x_expand(true);
this._valueLabel.set_y_expand(true);
this.add(this._valueLabel);
this.actor._delegate = this;
}
get checked() {
return this._checked;
}
get key() {
return this._key;
}
get gicon() {
return this._gIcon;
}
set value(value) {
this._valueLabel.text = value;
}
get value() {
return this._valueLabel.text;
}
// prevents menu from being closed
activate(event) {
this._checked = !this._checked;
this._updateOrnament();
this.emit('toggle', event);
}
_updateOrnament() {
if (this._checked)
this.setOrnament(PopupMenu.Ornament.CHECK);
else
this.setOrnament(PopupMenu.Ornament.NONE);
}
get label() {
return this._labelActor.text;
}
});

View File

@ -0,0 +1,13 @@
{
"_generated": "Generated by SweetTooth, do not edit",
"description": "A glimpse into your computer's temperature, voltage, fan speed, memory usage, processor load, system resources, network speed and storage stats. This is a one stop shop to monitor all of your vital sensors. Uses asynchronous polling to provide a smooth user experience. Feature requests or bugs? Please use GitHub.",
"gettext-domain": "vitals",
"name": "Vitals",
"settings-schema": "org.gnome.shell.extensions.vitals",
"shell-version": [
"45"
],
"url": "https://github.com/corecoding/Vitals",
"uuid": "Vitals@CoreCoding.com",
"version": 63
}

View File

@ -0,0 +1,137 @@
import Adw from 'gi://Adw';
import Gio from 'gi://Gio';
import GObject from 'gi://GObject';
import Gtk from 'gi://Gtk';
import {ExtensionPreferences, gettext as _} from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js';
/*
if (sensor == 'show-storage' && this._settings.get_boolean(sensor)) {
let val = true;
try {
let GTop = imports.gi.GTop;
} catch (e) {
val = false;
}
let now = new Date().getTime();
this._notify("Vitals", "Please run sudo apt install gir1.2-gtop-2.0", 'folder-symbolic');
}
*/
const Settings = new GObject.Class({
Name: 'Vitals.Settings',
_init: function(extensionObject, params) {
this._extensionObject = extensionObject
this.parent(params);
this._settings = extensionObject.getSettings();
this.builder = new Gtk.Builder();
this.builder.set_translation_domain(this._extensionObject.metadata['gettext-domain']);
this.builder.add_from_file(this._extensionObject.path + '/prefs.ui');
this.widget = this.builder.get_object('prefs-container');
this._bind_settings();
},
// Bind the gtk window to the schema settings
_bind_settings: function() {
let widget;
// process sensor toggles
let sensors = [ 'show-temperature', 'show-voltage', 'show-fan',
'show-memory', 'show-processor', 'show-system',
'show-network', 'show-storage', 'use-higher-precision',
'alphabetize', 'hide-zeros', 'include-public-ip',
'show-battery', 'fixed-widths', 'hide-icons',
'menu-centered', 'include-static-info' ];
for (let key in sensors) {
let sensor = sensors[key];
widget = this.builder.get_object(sensor);
widget.set_active(this._settings.get_boolean(sensor));
widget.connect('state-set', (_, val) => {
this._settings.set_boolean(sensor, val);
});
}
// process individual drop down sensor preferences
sensors = [ 'position-in-panel', 'unit', 'network-speed-format', 'memory-measurement', 'storage-measurement', 'battery-slot' ];
for (let key in sensors) {
let sensor = sensors[key];
widget = this.builder.get_object(sensor);
widget.set_active(this._settings.get_int(sensor));
widget.connect('changed', (widget) => {
this._settings.set_int(sensor, widget.get_active());
});
}
this._settings.bind('update-time', this.builder.get_object('update-time'), 'value', Gio.SettingsBindFlags.DEFAULT);
// process individual text entry sensor preferences
sensors = [ 'storage-path', 'monitor-cmd' ];
for (let key in sensors) {
let sensor = sensors[key];
widget = this.builder.get_object(sensor);
widget.set_text(this._settings.get_string(sensor));
widget.connect('changed', (widget) => {
let text = widget.get_text();
if (!text) text = widget.get_placeholder_text();
this._settings.set_string(sensor, text);
});
}
// makes individual sensor preference boxes appear
sensors = [ 'temperature', 'network', 'storage', 'memory', 'battery', 'system', 'processor' ];
for (let key in sensors) {
let sensor = sensors[key];
// create dialog for intelligent autohide advanced settings
this.builder.get_object(sensor + '-prefs').connect('clicked', () => {
let transientObj = this.widget.get_root();
let title = sensor.charAt(0).toUpperCase() + sensor.slice(1);
let dialog = new Gtk.Dialog({ title: _(title) + ' ' + _('Preferences'),
transient_for: transientObj,
use_header_bar: false,
modal: true });
let box = this.builder.get_object(sensor + '_prefs');
dialog.get_content_area().append(box);
dialog.connect('response', (dialog, id) => {
// remove the settings box so it doesn't get destroyed;
dialog.get_content_area().remove(box);
dialog.destroy();
return;
});
dialog.show();
});
}
}
});
export default class VitalsPrefs extends ExtensionPreferences {
fillPreferencesWindow(window) {
window._settings = this.getSettings();
let settings = new Settings(this);
let widget = settings.widget;
const page = new Adw.PreferencesPage();
const group = new Adw.PreferencesGroup({});
group.add(widget);
page.add(group);
window.add(page);
window.set_default_size(widget.width, widget.height);
widget.show();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,140 @@
<?xml version="1.0" encoding="UTF-8"?>
<schemalist gettext-domain="gnome-shell-extensions">
<schema id="org.gnome.shell.extensions.vitals" path="/org/gnome/shell/extensions/vitals/">
<key name="hot-sensors" type="as">
<default>['_memory_usage_', '_system_load_1m_', '__network-rx_max__']</default>
<summary>Sensors to show in panel</summary>
<description>List of sensors to be shown in the panel</description>
</key>
<key type="i" name="update-time">
<default>5</default>
<summary>Seconds between updates</summary>
<description>Delay between sensor polling</description>
</key>
<key type="i" name="position-in-panel">
<default>2</default>
<summary>Position in panel</summary>
<description>Position in Panel ('left', 'center', 'right')</description>
</key>
<key type="b" name="use-higher-precision">
<default>false</default>
<summary>Use higher precision</summary>
<description>Show one extra digit after decimal</description>
</key>
<key type="b" name="alphabetize">
<default>true</default>
<summary>Alphabetize sensors</summary>
<description>Display sensors in alphabetical order</description>
</key>
<key type="b" name="hide-zeros">
<default>false</default>
<summary>Hide zero values</summary>
<description>Hide data from sensors that are invalid</description>
</key>
<key type="b" name="show-temperature">
<default>true</default>
<summary>Monitor temperature</summary>
<description>Display temperature of various components</description>
</key>
<key type="i" name="unit">
<default>0</default>
<summary>Temperature unit</summary>
<description>The unit ('centigrade' or 'fahrenheit') the extension should display the temperature in</description>
</key>
<key type="b" name="show-voltage">
<default>true</default>
<summary>Monitor voltage</summary>
<description>Display voltage of various components</description>
</key>
<key type="b" name="show-fan">
<default>true</default>
<summary>Monitor fan</summary>
<description>Display fan rotation per minute</description>
</key>
<key type="b" name="show-memory">
<default>true</default>
<summary>Monitor memory</summary>
<description>Display memory information</description>
</key>
<key type="b" name="show-processor">
<default>true</default>
<summary>Monitor processor</summary>
<description>Display processor information</description>
</key>
<key type="b" name="show-system">
<default>true</default>
<summary>Monitor system</summary>
<description>Display system information</description>
</key>
<key type="b" name="show-storage">
<default>true</default>
<summary>Monitor storage</summary>
<description>Display storage information</description>
</key>
<key type="b" name="show-network">
<default>true</default>
<summary>Monitor network</summary>
<description>Display network information</description>
</key>
<key type="b" name="include-public-ip">
<default>true</default>
<summary>Include public IP address</summary>
<description>Display public IP address of internet connection</description>
</key>
<key type="i" name="network-speed-format">
<default>0</default>
<summary>Network speed format</summary>
<description>Should speed display in bits or bytes?</description>
</key>
<key type="s" name="storage-path">
<default>"/"</default>
<summary>Storage path</summary>
<description>Storage path for monitoring</description>
</key>
<key type="b" name="show-battery">
<default>false</default>
<summary>Monitor battery</summary>
<description>Monitor battery health</description>
</key>
<key type="i" name="memory-measurement">
<default>1</default>
<summary>Memory measurement</summary>
<description>Can use gigabyte or gibibyte for memory</description>
</key>
<key type="i" name="storage-measurement">
<default>1</default>
<summary>Storage measurement</summary>
<description>Can use gigabyte or gibibyte for storage</description>
</key>
<key type="i" name="battery-slot">
<default>0</default>
<summary>Battery slot to monitor</summary>
<description>Which numerical battery slot should vitals monitor</description>
</key>
<key type="b" name="fixed-widths">
<default>true</default>
<summary>Use fixed widths in top bar</summary>
<description>Keep sensors in top bar from jumping around</description>
</key>
<key type="b" name="hide-icons">
<default>false</default>
<summary>Hide icons in top bar</summary>
<description>Keep top bar clean by only showing sensor values</description>
</key>
<key type="b" name="menu-centered">
<default>false</default>
<summary>Make the menu centered</summary>
<description>Center the menu to the icon regardless of the position in the panel</description>
</key>
<key type="s" name="monitor-cmd">
<default>"gnome-system-monitor"</default>
<summary>System Monitor command</summary>
<description>The command run when system monitor button is clicked</description>
</key>
<key type="b" name="include-static-info">
<default>false</default>
<summary>Include processor static information</summary>
<description>Display processor static information that doesn't change</description>
</key>
</schema>
</schemalist>

View File

@ -0,0 +1,671 @@
/*
Copyright (c) 2018, Chris Monahan <chris@corecoding.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the GNOME nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import GObject from 'gi://GObject';
import * as FileModule from './helpers/file.js';
import { gettext as _ } from 'resource:///org/gnome/shell/extensions/extension.js';
import NM from 'gi://NM';
let GTop, hasGTop = true;
try {
({default: GTop} = await import('gi://GTop'));
} catch (err) {
log(err);
hasGTop = false;
};
export const Sensors = GObject.registerClass({
GTypeName: 'Sensors',
}, class Sensors extends GObject.Object {
_init(settings, sensorIcons) {
this._settings = settings;
this._sensorIcons = sensorIcons;
this.resetHistory();
this._last_processor = { 'core': {}, 'speed': [] };
if (hasGTop) {
this.storage = new GTop.glibtop_fsusage();
this._storageDevice = '';
this._findStorageDevice();
this._lastRead = 0;
this._lastWrite = 0;
}
}
_refreshIPAddress(callback) {
// check IP address
new FileModule.File('https://corecoding.com/vitals.php').read().then(contents => {
let obj = JSON.parse(contents);
this._returnValue(callback, 'Public IP', obj['IPv4'], 'network', 'string');
}).catch(err => { });
}
_findStorageDevice() {
new FileModule.File('/proc/mounts').read("\n").then(lines => {
for (let line of lines) {
let loadArray = line.trim().split(/\s+/);
if (loadArray[1] == this._settings.get_string('storage-path')) {
this._storageDevice = loadArray[0];
break;
}
}
}).catch(err => { });
}
query(callback, dwell) {
if (!this._hardware_detected) {
// we could set _hardware_detected in discoverHardwareMonitors, but by
// doing it here, we guarantee avoidance of race conditions
this._hardware_detected = true;
this._discoverHardwareMonitors(callback);
}
for (let sensor in this._sensorIcons) {
if (this._settings.get_boolean('show-' + sensor)) {
if (sensor == 'temperature' || sensor == 'voltage' || sensor == 'fan') {
// for temp, volt, fan, we have a shared handler
this._queryTempVoltFan(callback, sensor);
} else {
// directly call queryFunction below
let method = '_query' + sensor[0].toUpperCase() + sensor.slice(1);
this[method](callback, dwell);
}
}
}
}
_queryTempVoltFan(callback, type) {
for (let label in this._tempVoltFanSensors[type]) {
let sensor = this._tempVoltFanSensors[type][label];
new FileModule.File(sensor['path']).read().then(value => {
this._returnValue(callback, label, value, type, sensor['format']);
}).catch(err => {
this._returnValue(callback, label, 'disabled', type, sensor['format']);
});
}
}
_queryMemory(callback) {
// check memory info
new FileModule.File('/proc/meminfo').read().then(lines => {
let values = '', total = 0, avail = 0, swapTotal = 0, swapFree = 0, cached = 0, memFree = 0;
if (values = lines.match(/MemTotal:(\s+)(\d+) kB/)) total = values[2];
if (values = lines.match(/MemAvailable:(\s+)(\d+) kB/)) avail = values[2];
if (values = lines.match(/SwapTotal:(\s+)(\d+) kB/)) swapTotal = values[2];
if (values = lines.match(/SwapFree:(\s+)(\d+) kB/)) swapFree = values[2];
if (values = lines.match(/Cached:(\s+)(\d+) kB/)) cached = values[2];
if (values = lines.match(/MemFree:(\s+)(\d+) kB/)) memFree = values[2];
let used = total - avail
let utilized = used / total;
this._returnValue(callback, 'Usage', utilized, 'memory', 'percent');
this._returnValue(callback, 'memory', utilized, 'memory-group', 'percent');
this._returnValue(callback, 'Physical', total, 'memory', 'memory');
this._returnValue(callback, 'Available', avail, 'memory', 'memory');
this._returnValue(callback, 'Allocated', used, 'memory', 'memory');
this._returnValue(callback, 'Cached', cached, 'memory', 'memory');
this._returnValue(callback, 'Free', memFree, 'memory', 'memory');
this._returnValue(callback, 'Swap', swapTotal - swapFree, 'memory', 'memory');
}).catch(err => { });
}
_queryProcessor(callback, dwell) {
let columns = ['user', 'nice', 'system', 'idle', 'iowait', 'irq', 'softirq', 'steal', 'guest', 'guest_nice'];
// check processor usage
new FileModule.File('/proc/stat').read("\n").then(lines => {
let statistics = {};
for (let line of lines) {
let reverse_data = line.match(/^(cpu\d*\s)(.+)/);
if (reverse_data) {
let cpu = reverse_data[1].trim();
if (!(cpu in statistics))
statistics[cpu] = {};
if (!(cpu in this._last_processor['core']))
this._last_processor['core'][cpu] = 0;
let stats = reverse_data[2].trim().split(' ').reverse();
for (let column of columns)
statistics[cpu][column] = parseInt(stats.pop());
}
}
let cores = Object.keys(statistics).length - 1;
for (let cpu in statistics) {
let total = statistics[cpu]['user'] + statistics[cpu]['nice'] + statistics[cpu]['system'];
// make sure we have data to report
if (this._last_processor['core'][cpu] > 0) {
let delta = (total - this._last_processor['core'][cpu]) / dwell;
// /proc/stat provides overall usage for us under the 'cpu' heading
if (cpu == 'cpu') {
delta = delta / cores;
this._returnValue(callback, 'processor', delta / 100, 'processor-group', 'percent');
this._returnValue(callback, 'Usage', delta / 100, 'processor', 'percent');
} else {
this._returnValue(callback, _('Core %d').format(cpu.substr(3)), delta / 100, 'processor', 'percent');
}
}
this._last_processor['core'][cpu] = total;
}
// if frequency scaling is enabled, gather cpu-freq values
if (!this._processor_uses_cpu_info) {
for (let core = 0; core <= cores; core++) {
new FileModule.File('/sys/devices/system/cpu/cpu' + core + '/cpufreq/scaling_cur_freq').read().then(value => {
this._last_processor['speed'][core] = parseInt(value);
}).catch(err => { });
}
}
}).catch(err => { });
// if frequency scaling is disabled, use cpuinfo for speed
if (this._processor_uses_cpu_info) {
// grab CPU frequency
new FileModule.File('/proc/cpuinfo').read("\n").then(lines => {
let freqs = [];
for (let line of lines) {
// grab megahertz
let value = line.match(/^cpu MHz(\s+): ([+-]?\d+(\.\d+)?)/);
if (value) freqs.push(parseFloat(value[2]));
}
let sum = freqs.reduce((a, b) => a + b);
let hertz = (sum / freqs.length) * 1000 * 1000;
this._returnValue(callback, 'Frequency', hertz, 'processor', 'hertz');
//let max_hertz = Math.getMaxOfArray(freqs) * 1000 * 1000;
//this._returnValue(callback, 'Boost', max_hertz, 'processor', 'hertz');
}).catch(err => { });
// if frequency scaling is enabled, cpu-freq reports
} else if (Object.values(this._last_processor['speed']).length > 0) {
let sum = this._last_processor['speed'].reduce((a, b) => a + b);
let hertz = (sum / this._last_processor['speed'].length) * 1000;
this._returnValue(callback, 'Frequency', hertz, 'processor', 'hertz');
//let max_hertz = Math.getMaxOfArray(this._last_processor['speed']) * 1000;
//this._returnValue(callback, 'Boost', max_hertz, 'processor', 'hertz');
}
}
_querySystem(callback) {
// check load average
new FileModule.File('/proc/sys/fs/file-nr').read("\t").then(loadArray => {
this._returnValue(callback, 'Open Files', loadArray[0], 'system', 'string');
}).catch(err => { });
// check load average
new FileModule.File('/proc/loadavg').read(' ').then(loadArray => {
let proc = loadArray[3].split('/');
this._returnValue(callback, 'Load 1m', loadArray[0], 'system', 'load');
this._returnValue(callback, 'system', loadArray[0], 'system-group', 'load');
this._returnValue(callback, 'Load 5m', loadArray[1], 'system', 'load');
this._returnValue(callback, 'Load 15m', loadArray[2], 'system', 'load');
this._returnValue(callback, 'Threads Active', proc[0], 'system', 'string');
this._returnValue(callback, 'Threads Total', proc[1], 'system', 'string');
}).catch(err => { });
// check uptime
new FileModule.File('/proc/uptime').read(' ').then(upArray => {
this._returnValue(callback, 'Uptime', upArray[0], 'system', 'uptime');
let cores = Object.keys(this._last_processor['core']).length - 1;
if (cores > 0)
this._returnValue(callback, 'Process Time', upArray[0] - upArray[1] / cores, 'processor', 'uptime');
}).catch(err => { });
}
_queryNetwork(callback, dwell) {
// check network speed
let directions = ['tx', 'rx'];
let netbase = '/sys/class/net/';
new FileModule.File(netbase).list().then(interfaces => {
for (let iface of interfaces) {
for (let direction of directions) {
// lo tx and rx are the same
if (iface == 'lo' && direction == 'rx') continue;
new FileModule.File(netbase + iface + '/statistics/' + direction + '_bytes').read().then(value => {
// issue #217 - don't include 'lo' traffic in Maximum calculations in values.js
// by not using network-rx or network-tx
let name = iface + ((iface == 'lo')?'':' ' + direction);
let type = 'network' + ((iface=='lo')?'':'-' + direction);
this._returnValue(callback, name, value, type, 'storage');
}).catch(err => { });
}
}
}).catch(err => { });
// some may not want public ip checking
if (this._settings.get_boolean('include-public-ip')) {
// check the public ip every hour or when waking from sleep
if (this._next_public_ip_check <= 0) {
this._next_public_ip_check = 3600;
this._refreshIPAddress(callback);
}
this._next_public_ip_check -= dwell;
}
// wireless interface statistics
new FileModule.File('/proc/net/wireless').read("\n", true).then(lines => {
// wireless has two headers - first is stripped in helper function
lines.shift();
// if multiple wireless device, we use the last one
for (let line of lines) {
let netArray = line.trim().split(/\s+/);
let quality_pct = netArray[2].substr(0, netArray[2].length-1) / 70;
let signal = netArray[3].substr(0, netArray[3].length-1);
this._returnValue(callback, 'WiFi Link Quality', quality_pct, 'network', 'percent');
this._returnValue(callback, 'WiFi Signal Level', signal, 'network', 'string');
}
}).catch(err => { });
}
_queryStorage(callback, dwell) {
// display zfs arc status, if available
new FileModule.File('/proc/spl/kstat/zfs/arcstats').read().then(lines => {
let values = '', target = 0, maximum = 0, current = 0;
if (values = lines.match(/c(\s+)(\d+)(\s+)(\d+)/)) target = values[4];
if (values = lines.match(/c_max(\s+)(\d+)(\s+)(\d+)/)) maximum = values[4];
if (values = lines.match(/size(\s+)(\d+)(\s+)(\d+)/)) current = values[4];
// ZFS statistics
this._returnValue(callback, 'ARC Target', target, 'storage', 'storage');
this._returnValue(callback, 'ARC Maximum', maximum, 'storage', 'storage');
this._returnValue(callback, 'ARC Current', current, 'storage', 'storage');
}).catch(err => { });
// check disk performance stats
new FileModule.File('/proc/diskstats').read("\n").then(lines => {
for (let line of lines) {
let loadArray = line.trim().split(/\s+/);
if ('/dev/' + loadArray[2] == this._storageDevice) {
var read = (loadArray[5] * 512);
var write = (loadArray[9] * 512);
this._returnValue(callback, 'Read total', read, 'storage', 'storage');
this._returnValue(callback, 'Write total', write, 'storage', 'storage');
this._returnValue(callback, 'Read rate', (read - this._lastRead) / dwell, 'storage', 'storage');
this._returnValue(callback, 'Write rate', (write - this._lastWrite) / dwell, 'storage', 'storage');
this._lastRead = read;
this._lastWrite = write;
break;
}
}
}).catch(err => { });
// skip rest of stats if gtop not available
if (!hasGTop) return;
GTop.glibtop_get_fsusage(this.storage, this._settings.get_string('storage-path'));
let total = this.storage.blocks * this.storage.block_size;
let avail = this.storage.bavail * this.storage.block_size;
let free = this.storage.bfree * this.storage.block_size;
let used = total - free;
let reserved = (total - avail) - used;
this._returnValue(callback, 'Total', total, 'storage', 'storage');
this._returnValue(callback, 'Used', used, 'storage', 'storage');
this._returnValue(callback, 'Reserved', reserved, 'storage', 'storage');
this._returnValue(callback, 'Free', avail, 'storage', 'storage');
this._returnValue(callback, 'storage', avail, 'storage-group', 'storage');
}
_queryBattery(callback) {
let battery_slot = this._settings.get_int('battery-slot');
// addresses issue #161
let battery_key = 'BAT'; // BAT0, BAT1 and BAT2
if (battery_slot == 3) {
battery_key = 'CMB'; // CMB0
battery_slot = 0;
} else if (battery_slot == 4) {
battery_key = 'macsmc-battery'; // supports Asahi linux
battery_slot = '';
}
// uevent has all necessary fields, no need to read individual files
let battery_path = '/sys/class/power_supply/' + battery_key + battery_slot + '/uevent';
new FileModule.File(battery_path).read("\n").then(lines => {
let output = {};
for (let line of lines) {
let split = line.split('=');
output[split[0].replace('POWER_SUPPLY_', '')] = split[1];
}
if ('STATUS' in output) {
this._returnValue(callback, 'State', output['STATUS'], 'battery', '');
}
if ('CYCLE_COUNT' in output) {
this._returnValue(callback, 'Cycles', output['CYCLE_COUNT'], 'battery', '');
}
if ('VOLTAGE_NOW' in output) {
this._returnValue(callback, 'Voltage', output['VOLTAGE_NOW'] / 1000, 'battery', 'in');
}
if ('CAPACITY_LEVEL' in output) {
this._returnValue(callback, 'Level', output['CAPACITY_LEVEL'], 'battery', '');
}
if ('CAPACITY' in output) {
this._returnValue(callback, 'Percentage', output['CAPACITY'] / 100, 'battery', 'percent');
}
if ('VOLTAGE_NOW' in output && 'CURRENT_NOW' in output && (!('POWER_NOW' in output))) {
output['POWER_NOW'] = (output['VOLTAGE_NOW'] * output['CURRENT_NOW']) / 1000000;
}
if ('POWER_NOW' in output) {
this._returnValue(callback, 'Rate', output['POWER_NOW'], 'battery', 'watt');
this._returnValue(callback, 'battery', output['POWER_NOW'], 'battery-group', 'watt');
}
if ('CHARGE_FULL' in output && 'VOLTAGE_MIN_DESIGN' in output && (!('ENERGY_FULL' in output))) {
output['ENERGY_FULL'] = (output['CHARGE_FULL'] * output['VOLTAGE_MIN_DESIGN']) / 1000000;
}
if ('ENERGY_FULL' in output) {
this._returnValue(callback, 'Energy (full)', output['ENERGY_FULL'], 'battery', 'watt-hour');
}
if ('CHARGE_FULL_DESIGN' in output && 'VOLTAGE_MIN_DESIGN' in output && (!('ENERGY_FULL_DESIGN' in output))) {
output['ENERGY_FULL_DESIGN'] = (output['CHARGE_FULL_DESIGN'] * output['VOLTAGE_MIN_DESIGN']) / 1000000;
}
if ('ENERGY_FULL_DESIGN' in output) {
this._returnValue(callback, 'Energy (design)', output['ENERGY_FULL_DESIGN'], 'battery', 'watt-hour');
if ('ENERGY_FULL' in output) {
this._returnValue(callback, 'Capacity', (output['ENERGY_FULL'] / output['ENERGY_FULL_DESIGN']), 'battery', 'percent');
}
}
if ('VOLTAGE_MIN_DESIGN' in output && 'CHARGE_NOW' in output && (!('ENERGY_NOW' in output))) {
output['ENERGY_NOW'] = (output['VOLTAGE_MIN_DESIGN'] * output['CHARGE_NOW']) / 1000000;
}
if ('ENERGY_NOW' in output) {
this._returnValue(callback, 'Energy (now)', output['ENERGY_NOW'], 'battery', 'watt-hour');
}
if ('ENERGY_FULL' in output && 'ENERGY_NOW' in output && 'POWER_NOW' in output && output['POWER_NOW'] > 0 && 'STATUS' in output && (output['STATUS'] == 'Charging' || output['STATUS'] == 'Discharging')) {
let timeLeft = 0;
// two different formulas depending on if we are charging or discharging
if (output['STATUS'] == 'Charging') {
timeLeft = ((output['ENERGY_FULL'] - output['ENERGY_NOW']) / output['POWER_NOW']);
} else {
timeLeft = (output['ENERGY_NOW'] / output['POWER_NOW']);
}
// don't process Infinity values
if (timeLeft !== Infinity) {
if (this._battery_charge_status != output['STATUS']) {
// clears history due to state change
this._battery_time_left_history = [];
// clear time left history when laptop goes in and out of charging
this._battery_charge_status = output['STATUS'];
}
// add latest time left estimate to our history
this._battery_time_left_history.push(parseInt(timeLeft * 3600));
// keep track of last 15 time left estimates by erasing the first
if (this._battery_time_left_history.length > 10)
this._battery_time_left_history.shift();
// sum up and create average of our time left history
let sum = this._battery_time_left_history.reduce((a, b) => a + b);
let avg = sum / this._battery_time_left_history.length;
// use time left history to update screen
this._returnValue(callback, 'Time left', parseInt(avg), 'battery', 'runtime');
}
} else {
this._returnValue(callback, 'Time left', output['STATUS'], 'battery', '');
}
}).catch(err => { });
}
_returnValue(callback, label, value, type, format) {
// don't return if value is not a number - will revisit later
//if (isNaN(value)) return;
callback(label, value, type, format);
}
_discoverHardwareMonitors(callback) {
this._tempVoltFanSensors = { 'temperature': {}, 'voltage': {}, 'fan': {} };
let hwbase = '/sys/class/hwmon/';
// process sensor_types now so it is not called multiple times below
let sensor_types = {};
if (this._settings.get_boolean('show-temperature'))
sensor_types['temp'] = 'temperature';
if (this._settings.get_boolean('show-voltage'))
sensor_types['in'] = 'voltage';
if (this._settings.get_boolean('show-fan'))
sensor_types['fan'] = 'fan';
// a little informal, but this code has zero I/O block
new FileModule.File(hwbase).list().then(files => {
for (let file of files) {
// grab name of sensor
new FileModule.File(hwbase + file + '/name').read().then(name => {
// are we dealing with a CPU?
if (name == 'coretemp') {
// determine which processor (socket) we are dealing with
new FileModule.File(hwbase + file + '/temp1_label').read().then(prefix => {
this._processTempVoltFan(callback, sensor_types, prefix, hwbase + file, file);
}).catch(err => {
// this shouldn't be necessary, but just in case temp1_label doesn't exist
// attempt to fix #266
this._processTempVoltFan(callback, sensor_types, name, hwbase + file, file);
});
} else {
// not a CPU, process all other sensors
this._processTempVoltFan(callback, sensor_types, name, hwbase + file, file);
}
}).catch(err => {
new FileModule.File(hwbase + file + '/device/name').read().then(name => {
this._processTempVoltFan(callback, sensor_types, name, hwbase + file + '/device', file);
}).catch(err => { });
});
}
}).catch(err => { });
// does this system support cpu scaling? if so we will use it to grab Frequency and Boost below
new FileModule.File('/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq').read().then(value => {
this._processor_uses_cpu_info = false;
}).catch(err => { });
// is static CPU information enabled?
if (this._settings.get_boolean('include-static-info')) {
// grab static CPU information
new FileModule.File('/proc/cpuinfo').read("\n").then(lines => {
let vendor_id = '';
let bogomips = '';
let sockets = {};
let cache = '';
for (let line of lines) {
let value = '';
// grab cpu vendor
if (value = line.match(/^vendor_id(\s+): (\w+.*)/)) vendor_id = value[2];
// grab bogomips
if (value = line.match(/^bogomips(\s+): (\d*\.?\d*)$/)) bogomips = value[2];
// grab processor count
if (value = line.match(/^physical id(\s+): (\d+)$/)) sockets[value[2]] = 1;
// grab cache
if (value = line.match(/^cache size(\s+): (\d+) KB$/)) cache = value[2];
}
this._returnValue(callback, 'Vendor', vendor_id, 'processor', 'string');
this._returnValue(callback, 'Bogomips', bogomips, 'processor', 'string');
this._returnValue(callback, 'Sockets', Object.keys(sockets).length, 'processor', 'string');
this._returnValue(callback, 'Cache', cache, 'processor', 'memory');
}).catch(err => { });
// grab static CPU information
new FileModule.File('/proc/version').read(' ').then(kernelArray => {
this._returnValue(callback, 'Kernel', kernelArray[2], 'system', 'string');
}).catch(err => { });
}
}
_processTempVoltFan(callback, sensor_types, name, path, file) {
let sensor_files = [ 'input', 'label' ];
// grab files from directory
new FileModule.File(path).list().then(files2 => {
let trisensors = {};
// loop over files from directory
for (let file2 of Object.values(files2)) {
// simple way of processing input and label (from above)
for (let key of Object.values(sensor_files)) {
// process toggled on sensors from extension preferences
for (let sensor_type in sensor_types) {
if (file2.substr(0, sensor_type.length) == sensor_type && file2.substr(-(key.length+1)) == '_' + key) {
let key2 = file + file2.substr(0, file2.indexOf('_'));
if (!(key2 in trisensors)) {
trisensors[key2] = {
'type': sensor_types[sensor_type],
'format': sensor_type,
'label': path + '/name'
};
}
trisensors[key2][key] = path + '/' + file2;
}
}
}
}
for (let obj of Object.values(trisensors)) {
if (!('input' in obj))
continue;
new FileModule.File(obj['input']).read().then(value => {
let extra = (obj['label'].indexOf('_label')==-1) ? ' ' + obj['input'].substr(obj['input'].lastIndexOf('/')+1).split('_')[0] : '';
if (value > 0 || !this._settings.get_boolean('hide-zeros') || obj['type'] == 'fan') {
new FileModule.File(obj['label']).read().then(label => {
this._addTempVoltFan(callback, obj, name, label, extra, value);
}).catch(err => {
let tmpFile = obj['label'].substr(0, obj['label'].lastIndexOf('/')) + '/name';
new FileModule.File(tmpFile).read().then(label => {
this._addTempVoltFan(callback, obj, name, label, extra, value);
}).catch(err => { });
});
}
}).catch(err => { });
}
}).catch(err => { });
}
_addTempVoltFan(callback, obj, name, label, extra, value) {
// prepend module that provided sensor data
if (name != label) label = name + ' ' + label;
//if (label == 'nvme Composite') label = 'NVMe';
//if (label == 'nouveau') label = 'Nvidia';
label = label + extra;
// in the future we will read /etc/sensors3.conf
if (label == 'acpitz temp1') label = 'ACPI Thermal Zone';
if (label == 'pch_cannonlake temp1') label = 'Platform Controller Hub';
if (label == 'iwlwifi_1 temp1') label = 'Wireless Adapter';
if (label == 'Package id 0') label = 'Processor 0';
if (label == 'Package id 1') label = 'Processor 1';
label = label.replace('Package id', 'CPU');
let types = [ 'temperature', 'voltage', 'fan' ];
for (let type of types) {
// check if this label already exists
if (label in this._tempVoltFanSensors[type]) {
for (let i = 2; i <= 9; i++) {
// append an incremented number to end
let new_label = label + ' ' + i;
// if new label is available, use it
if (!(new_label in this._tempVoltFanSensors[type])) {
label = new_label;
break;
}
}
}
}
// update screen on initial build to prevent delay on update
this._returnValue(callback, label, value, obj['type'], obj['format']);
this._tempVoltFanSensors[obj['type']][label] = {
'format': obj['format'],
'path': obj['input']
};
}
resetHistory() {
this._next_public_ip_check = 0;
this._hardware_detected = false;
this._processor_uses_cpu_info = true;
this._battery_time_left_history = [];
this._battery_charge_status = '';
}
});

View File

@ -0,0 +1,16 @@
.vitals-icon { icon-size: 16px; }
.vitals-menu-button-container {}
.vitals-panel-icon-temperature { margin: 0 1px 0 8px; padding: 0; }
.vitals-panel-icon-voltage { margin: 0 0 0 8px; padding: 0; }
.vitals-panel-icon-fan { margin: 0 4px 0 8px; padding: 0; }
.vitals-panel-icon-memory { margin: 0 2px 0 8px; padding: 0; }
.vitals-panel-icon-processor { margin: 0 3px 0 8px; padding: 0; }
.vitals-panel-icon-system { margin: 0 3px 0 8px; padding: 0; }
.vitals-panel-icon-network { margin: 0 3px 0 8px; padding: 0; }
.vitals-panel-icon-storage { margin: 0 2px 0 8px; padding: 0; }
.vitals-panel-icon-battery { margin: 0 4px 0 8px; padding: 0; }
.vitals-panel-label { margin: 0 3px 0 0; padding: 0; }
.vitals-button-action { -st-icon-style: symbolic; border-radius: 32px; margin: 0px; min-height: 22px; min-width: 22px; padding: 10px; font-size: 100%; border: 1px solid transparent; }
.vitals-button-action:hover, .vitals-button-action:focus { border-color: #777; }
.vitals-button-action > StIcon { icon-size: 16px; }
.vitals-button-box { padding: 0px; spacing: 22px; }

View File

@ -0,0 +1,337 @@
/*
Copyright (c) 2018, Chris Monahan <chris@corecoding.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the GNOME nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
import GObject from 'gi://GObject';
const cbFun = (d, c) => {
let bb = d[1] % c[0],
aa = (d[1] - bb) / c[0];
aa = aa > 0 ? aa + c[1] : '';
return [d[0] + aa, bb];
};
export const Values = GObject.registerClass({
GTypeName: 'Values',
}, class Values extends GObject.Object {
_init(settings, sensorIcons) {
this._settings = settings;
this._sensorIcons = sensorIcons;
this._networkSpeedOffset = {};
this._networkSpeeds = {};
this._history = {};
//this._history2 = {};
this.resetHistory();
}
_legible(value, sensorClass) {
let unit = 1000;
if (value === null) return 'N/A';
let use_higher_precision = this._settings.get_boolean('use-higher-precision');
let memory_measurement = this._settings.get_int('memory-measurement')
let storage_measurement = this._settings.get_int('storage-measurement')
let use_bps = (this._settings.get_int('network-speed-format') == 1);
let format = '';
let ending = '';
let exp = 0;
var decimal = [ 'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB' ];
var binary = [ 'B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB' ];
var hertz = [ 'Hz', 'KHz', 'MHz', 'GHz', 'THz', 'PHz', 'EHz', 'ZHz' ];
switch (sensorClass) {
case 'percent':
format = (use_higher_precision)?'%.1f%s':'%d%s';
value = value * 100;
if (value > 100) value = 100;
ending = '%';
break;
case 'temp':
value = value / 1000;
ending = '°C';
// are we converting to fahrenheit?
if (this._settings.get_int('unit') == 1) {
value = ((9 / 5) * value + 32);
ending = '°F';
}
format = (use_higher_precision)?'%.1f%s':'%d%s';
break;
case 'fan':
format = '%d %s';
ending = 'RPM';
break;
case 'in': // voltage
value = value / 1000;
format = ((value >= 0) ? '+' : '-') + ((use_higher_precision)?'%.2f %s':'%.1f %s');
ending = 'V';
break;
case 'hertz':
if (value > 0) {
exp = Math.floor(Math.log(value) / Math.log(unit));
if (value >= Math.pow(unit, exp) * (unit - 0.05)) exp++;
value = parseFloat((value / Math.pow(unit, exp)));
}
format = (use_higher_precision)?'%.2f %s':'%.1f %s';
ending = hertz[exp];
break;
case 'memory':
unit = (memory_measurement)?1000:1024;
if (value > 0) {
value *= unit;
exp = Math.floor(Math.log(value) / Math.log(unit));
if (value >= Math.pow(unit, exp) * (unit - 0.05)) exp++;
value = parseFloat((value / Math.pow(unit, exp)));
}
format = (use_higher_precision)?'%.2f %s':'%.1f %s';
if (memory_measurement)
ending = decimal[exp];
else
ending = binary[exp];
break;
case 'storage':
unit = (storage_measurement)?1000:1024;
if (value > 0) {
exp = Math.floor(Math.log(value) / Math.log(unit));
if (value >= Math.pow(unit, exp) * (unit - 0.05)) exp++;
value = parseFloat((value / Math.pow(unit, exp)));
}
format = (use_higher_precision)?'%.2f %s':'%.1f %s';
if (storage_measurement)
ending = decimal[exp];
else
ending = binary[exp];
break;
case 'speed':
if (value > 0) {
if (use_bps) value *= 8;
exp = Math.floor(Math.log(value) / Math.log(unit));
if (value >= Math.pow(unit, exp) * (unit - 0.05)) exp++;
value = parseFloat((value / Math.pow(unit, exp)));
}
format = (use_higher_precision)?'%.1f %s':'%.0f %s';
if (use_bps) {
ending = decimal[exp].replace('B', 'bps');
} else {
ending = decimal[exp] + '/s';
}
break;
case 'runtime':
case 'uptime':
let scale = [24, 60, 60];
let units = ['d ', 'h ', 'm '];
// show seconds on higher precision or if value under a minute
if (sensorClass != 'runtime' && (use_higher_precision || value < 60)) {
scale.push(1);
units.push('s ');
}
let rslt = scale.map((d, i, a) => a.slice(i).reduce((d, c) => d * c))
.map((d, i) => ([d, units[i]]))
.reduce(cbFun, ['', value]);
value = rslt[0].trim();
format = '%s';
break;
case 'milliamp':
format = (use_higher_precision)?'%.1f %s':'%d %s';
value = value / 1000;
ending = 'mA';
break;
case 'milliamp-hour':
format = (use_higher_precision)?'%.1f %s':'%d %s';
value = value / 1000;
ending = 'mAh';
break;
case 'watt':
format = (use_higher_precision)?'%.2f %s':'%.1f %s';
value = value / 1000000;
ending = 'W';
break;
case 'watt-hour':
format = (use_higher_precision)?'%.2f %s':'%.1f %s';
value = value / 1000000;
ending = 'Wh';
break;
case 'load':
format = (use_higher_precision)?'%.2f %s':'%.1f %s';
break;
default:
format = '%s';
break;
}
return format.format(value, ending);
}
returnIfDifferent(dwell, label, value, type, format, key) {
let output = [];
// make sure the keys exist
if (!(type in this._history)) this._history[type] = {};
// no sense in continuing when the raw value has not changed
if (type != 'network-rx' && type != 'network-tx' &&
key in this._history[type] && this._history[type][key][1] == value)
return output;
// is the value different from last time?
let legible = this._legible(value, format);
// don't return early when dealing with network traffic
if (type != 'network-rx' && type != 'network-tx') {
// only update when we are coming through for the first time, or if a value has changed
if (key in this._history[type] && this._history[type][key][0] == legible)
return output;
// add label as it was sent from sensors class
output.push([label, legible, type, key]);
}
// save previous values to update screen on changes only
let previousValue = this._history[type][key];
this._history[type][key] = [legible, value];
// process average, min and max values
if (type == 'temperature' || type == 'voltage' || type == 'fan') {
let vals = Object.values(this._history[type]).map(x => parseFloat(x[1]));
// show value in group even if there is one value present
let sum = vals.reduce((a, b) => a + b);
let avg = this._legible(sum / vals.length, format);
output.push([type, avg, type + '-group', '']);
// If only one value is present, don't display avg, min and max
if (vals.length > 1) {
output.push(['Average', avg, type, '__' + type + '_avg__']);
// calculate Minimum value
let min = Math.min(...vals);
min = this._legible(min, format);
output.push(['Minimum', min, type, '__' + type + '_min__']);
// calculate Maximum value
let max = Math.max(...vals);
max = this._legible(max, format);
output.push(['Maximum', max, type, '__' + type + '_max__']);
}
} else if (type == 'network-rx' || type == 'network-tx') {
let direction = type.split('-')[1];
// appends total upload and download for all interfaces for #216
let vals = Object.values(this._history[type]).map(x => parseFloat(x[1]));
let sum = vals.reduce((partialSum, a) => partialSum + a, 0);
output.push(['Boot ' + direction, this._legible(sum, format), type, '__' + type + '_boot__']);
// keeps track of session start point
if (!(key in this._networkSpeedOffset) || this._networkSpeedOffset[key] <= 0)
this._networkSpeedOffset[key] = sum;
// outputs session upload and download for all interfaces for #234
output.push(['Session ' + direction, this._legible(sum - this._networkSpeedOffset[key], format), type, '__' + type + '_ses__']);
// calculate speed for this interface
let speed = (value - previousValue[1]) / dwell;
output.push([label, this._legible(speed, 'speed'), type, key]);
// store speed for Device report
if (!(direction in this._networkSpeeds)) this._networkSpeeds[direction] = {};
if (!(label in this._networkSpeeds[direction])) this._networkSpeeds[direction][label] = 0;
// store value for next go around
if (value > 0 || (value == 0 && !this._settings.get_boolean('hide-zeros')))
this._networkSpeeds[direction][label] = speed;
// calculate total upload and download device speed
for (let direction in this._networkSpeeds) {
let sum = 0;
for (let iface in this._networkSpeeds[direction])
sum += parseFloat(this._networkSpeeds[direction][iface]);
sum = this._legible(sum, 'speed');
output.push(['Device ' + direction, sum, 'network-' + direction, '__network-' + direction + '_max__']);
// append download speed to group itself
if (direction == 'rx') output.push([type, sum, type + '-group', '']);
}
}
/*
global.log('before', JSON.stringify(output));
for (let i = output.length - 1; i >= 0; i--) {
let sensor = output[i];
// sensor[0]=label, sensor[1]=value, sensor[2]=type, sensor[3]=key)
//["CPU Core 5","46°C","temperature","_temperature_hwmon8temp7_"]
// make sure the keys exist
if (!(sensor[2] in this._history2)) this._history2[sensor[2]] = {};
if (sensor[3] in this._history2[sensor[2]]) {
if (this._history2[sensor[2]][sensor[3]] == sensor[1]) {
output.splice(i, 1);
}
}
this._history2[sensor[2]][sensor[3]] = sensor[1];
}
global.log(' after', JSON.stringify(output));
global.log('***************************');
*/
return output;
}
resetHistory() {
// don't call this._history = {}, as we want to keep network-rx and network-tx
// otherwise network history statistics will start over
for (let sensor in this._sensorIcons) {
this._history[sensor] = {};
this._history[sensor + '-group'] = {};
//this._history2[sensor] = {};
//this._history2[sensor + '-group'] = {};
}
}
});

View File

@ -0,0 +1,950 @@
// This file is part of the AppIndicator/KStatusNotifierItem GNOME Shell extension
//
// 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 2
// 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, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import Clutter from 'gi://Clutter';
import GLib from 'gi://GLib';
import GObject from 'gi://GObject';
import GdkPixbuf from 'gi://GdkPixbuf';
import Gio from 'gi://Gio';
import St from 'gi://St';
import * as PopupMenu from 'resource:///org/gnome/shell/ui/popupMenu.js';
import * as Signals from 'resource:///org/gnome/shell/misc/signals.js';
import * as DBusInterfaces from './interfaces.js';
import * as PromiseUtils from './promiseUtils.js';
import * as Util from './util.js';
import {DBusProxy} from './dbusProxy.js';
Gio._promisify(GdkPixbuf.Pixbuf, 'new_from_stream_async');
// ////////////////////////////////////////////////////////////////////////
// PART ONE: "ViewModel" backend implementation.
// Both code and design are inspired by libdbusmenu
// ////////////////////////////////////////////////////////////////////////
/**
* Saves menu property values and handles type checking and defaults
*/
export class PropertyStore {
constructor(initialProperties) {
this._props = new Map();
if (initialProperties) {
for (const [prop, value] of Object.entries(initialProperties))
this.set(prop, value);
}
}
set(name, value) {
if (name in PropertyStore.MandatedTypes && value &&
!value.is_of_type(PropertyStore.MandatedTypes[name]))
Util.Logger.warn(`Cannot set property ${name}: type mismatch!`);
else if (value)
this._props.set(name, value);
else
this._props.delete(name);
}
get(name) {
const prop = this._props.get(name);
if (prop)
return prop;
else if (name in PropertyStore.DefaultValues)
return PropertyStore.DefaultValues[name];
else
return null;
}
}
// we list all the properties we know and use here, so we won' have to deal with unexpected type mismatches
PropertyStore.MandatedTypes = {
'visible': GLib.VariantType.new('b'),
'enabled': GLib.VariantType.new('b'),
'label': GLib.VariantType.new('s'),
'type': GLib.VariantType.new('s'),
'children-display': GLib.VariantType.new('s'),
'icon-name': GLib.VariantType.new('s'),
'icon-data': GLib.VariantType.new('ay'),
'toggle-type': GLib.VariantType.new('s'),
'toggle-state': GLib.VariantType.new('i'),
};
PropertyStore.DefaultValues = {
'visible': GLib.Variant.new_boolean(true),
'enabled': GLib.Variant.new_boolean(true),
'label': GLib.Variant.new_string(''),
'type': GLib.Variant.new_string('standard'),
// elements not in here must return null
};
/**
* Represents a single menu item
*/
export class DbusMenuItem extends Signals.EventEmitter {
// will steal the properties object
constructor(client, id, properties, childrenIds) {
super();
this._client = client;
this._id = id;
this._propStore = new PropertyStore(properties);
this._children_ids = childrenIds;
}
propertyGet(propName) {
const prop = this.propertyGetVariant(propName);
return prop ? prop.get_string()[0] : null;
}
propertyGetVariant(propName) {
return this._propStore.get(propName);
}
propertyGetBool(propName) {
const prop = this.propertyGetVariant(propName);
return prop ? prop.get_boolean() : false;
}
propertyGetInt(propName) {
const prop = this.propertyGetVariant(propName);
return prop ? prop.get_int32() : 0;
}
propertySet(prop, value) {
this._propStore.set(prop, value);
this.emit('property-changed', prop, this.propertyGetVariant(prop));
}
getChildrenIds() {
return this._children_ids.concat(); // clone it!
}
addChild(pos, childId) {
this._children_ids.splice(pos, 0, childId);
this.emit('child-added', this._client.getItem(childId), pos);
}
removeChild(childId) {
// find it
let pos = -1;
for (let i = 0; i < this._children_ids.length; ++i) {
if (this._children_ids[i] === childId) {
pos = i;
break;
}
}
if (pos < 0) {
Util.Logger.critical("Trying to remove child which doesn't exist");
} else {
this._children_ids.splice(pos, 1);
this.emit('child-removed', this._client.getItem(childId));
}
}
moveChild(childId, newPos) {
// find the old position
let oldPos = -1;
for (let i = 0; i < this._children_ids.length; ++i) {
if (this._children_ids[i] === childId) {
oldPos = i;
break;
}
}
if (oldPos < 0) {
Util.Logger.critical("tried to move child which wasn't in the list");
return;
}
if (oldPos !== newPos) {
this._children_ids.splice(oldPos, 1);
this._children_ids.splice(newPos, 0, childId);
this.emit('child-moved', oldPos, newPos, this._client.getItem(childId));
}
}
getChildren() {
return this._children_ids.map(el => this._client.getItem(el));
}
handleEvent(event, data, timestamp) {
if (!data)
data = GLib.Variant.new_int32(0);
this._client.sendEvent(this._id, event, data, timestamp);
}
getId() {
return this._id;
}
sendAboutToShow() {
this._client.sendAboutToShow(this._id);
}
}
/**
* The client does the heavy lifting of actually reading layouts and distributing events
*/
export const DBusClient = GObject.registerClass({
Signals: {'ready-changed': {}},
}, class AppIndicatorsDBusClient extends DBusProxy {
static get interfaceInfo() {
if (!this._interfaceInfo) {
this._interfaceInfo = Gio.DBusInterfaceInfo.new_for_xml(
DBusInterfaces.DBusMenu);
}
return this._interfaceInfo;
}
static get baseItems() {
if (!this._baseItems) {
this._baseItems = {
'children-display': GLib.Variant.new_string('submenu'),
};
}
return this._baseItems;
}
static destroy() {
delete this._interfaceInfo;
}
_init(busName, objectPath) {
const {interfaceInfo} = AppIndicatorsDBusClient;
super._init(busName, objectPath, interfaceInfo,
Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES);
this._items = new Map();
this._items.set(0, new DbusMenuItem(this, 0, DBusClient.baseItems, []));
this._flagItemsUpdateRequired = false;
// will be set to true if a layout update is needed once active
this._flagLayoutUpdateRequired = false;
// property requests are queued
this._propertiesRequestedFor = new Set(/* ids */);
this._layoutUpdated = false;
this._active = false;
}
async initAsync(cancellable) {
await super.initAsync(cancellable);
this._requestLayoutUpdate();
}
_onNameOwnerChanged() {
if (this.isReady)
this._requestLayoutUpdate();
}
get isReady() {
return this._layoutUpdated && !!this.gNameOwner;
}
get cancellable() {
return this._cancellable;
}
getRoot() {
return this._items.get(0);
}
_requestLayoutUpdate() {
const cancellable = new Util.CancellableChild(this._cancellable);
this._beginLayoutUpdate(cancellable);
}
async _requestProperties(propertyId, cancellable) {
this._propertiesRequestedFor.add(propertyId);
if (this._propertiesRequest && this._propertiesRequest.pending())
return;
// if we don't have any requests queued, we'll need to add one
this._propertiesRequest = new PromiseUtils.IdlePromise(
GLib.PRIORITY_DEFAULT_IDLE, cancellable);
await this._propertiesRequest;
const requestedProperties = Array.from(this._propertiesRequestedFor);
this._propertiesRequestedFor.clear();
const [result] = await this.GetGroupPropertiesAsync(requestedProperties,
[], cancellable);
result.forEach(([id, properties]) => {
const item = this._items.get(id);
if (!item)
return;
for (const [prop, value] of Object.entries(properties))
item.propertySet(prop, value);
});
}
// Traverses the list of cached menu items and removes everyone that is not in the list
// so we don't keep alive unused items
_gcItems() {
const tag = new Date().getTime();
const toTraverse = [0];
while (toTraverse.length > 0) {
const item = this.getItem(toTraverse.shift());
item._dbusClientGcTag = tag;
Array.prototype.push.apply(toTraverse, item.getChildrenIds());
}
this._items.forEach((i, id) => {
if (i._dbusClientGcTag !== tag)
this._items.delete(id);
});
}
// the original implementation will only request partial layouts if somehow possible
// we try to save us from multiple kinds of race conditions by always requesting a full layout
_beginLayoutUpdate(cancellable) {
this._layoutUpdateUpdateAsync(cancellable).catch(e => {
if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
logError(e);
});
}
// the original implementation will only request partial layouts if somehow possible
// we try to save us from multiple kinds of race conditions by always requesting a full layout
async _layoutUpdateUpdateAsync(cancellable) {
// we only read the type property, because if the type changes after reading all properties,
// the view would have to replace the item completely which we try to avoid
if (this._layoutUpdateCancellable)
this._layoutUpdateCancellable.cancel();
this._layoutUpdateCancellable = cancellable;
try {
const [revision_, root] = await this.GetLayoutAsync(0, -1,
['type', 'children-display'], cancellable);
this._updateLayoutState(true);
this._doLayoutUpdate(root, cancellable);
this._gcItems();
this._flagLayoutUpdateRequired = false;
this._flagItemsUpdateRequired = false;
} catch (e) {
if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
this._updateLayoutState(false);
throw e;
} finally {
if (this._layoutUpdateCancellable === cancellable)
this._layoutUpdateCancellable = null;
}
}
_updateLayoutState(state) {
const wasReady = this.isReady;
this._layoutUpdated = state;
if (this.isReady !== wasReady)
this.emit('ready-changed');
}
_doLayoutUpdate(item, cancellable) {
const [id, properties, children] = item;
const childrenUnpacked = children.map(c => c.deep_unpack());
const childrenIds = childrenUnpacked.map(([c]) => c);
// make sure all our children exist
childrenUnpacked.forEach(c => this._doLayoutUpdate(c, cancellable));
// make sure we exist
const menuItem = this._items.get(id);
if (menuItem) {
// we do, update our properties if necessary
for (const [prop, value] of Object.entries(properties))
menuItem.propertySet(prop, value);
// make sure our children are all at the right place, and exist
const oldChildrenIds = menuItem.getChildrenIds();
for (let i = 0; i < childrenIds.length; ++i) {
// try to recycle an old child
let oldChild = -1;
for (let j = 0; j < oldChildrenIds.length; ++j) {
if (oldChildrenIds[j] === childrenIds[i]) {
[oldChild] = oldChildrenIds.splice(j, 1);
break;
}
}
if (oldChild < 0) {
// no old child found, so create a new one!
menuItem.addChild(i, childrenIds[i]);
} else {
// old child found, reuse it!
menuItem.moveChild(childrenIds[i], i);
}
}
// remove any old children that weren't reused
oldChildrenIds.forEach(c => menuItem.removeChild(c));
if (!this._flagItemsUpdateRequired)
return id;
}
// we don't, so let's create us
let newMenuItem = menuItem;
if (!newMenuItem) {
newMenuItem = new DbusMenuItem(this, id, properties, childrenIds);
this._items.set(id, newMenuItem);
}
this._requestProperties(id, cancellable).catch(e => {
if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
Util.Logger.warn(`Could not get menu properties menu proxy: ${e}`);
});
return id;
}
async _doPropertiesUpdateAsync(cancellable) {
if (this._propertiesUpdateCancellable)
this._propertiesUpdateCancellable.cancel();
this._propertiesUpdateCancellable = cancellable;
try {
const requests = [];
this._items.forEach((_, id) =>
requests.push(this._requestProperties(id, cancellable)));
await Promise.all(requests);
} finally {
if (this._propertiesUpdateCancellable === cancellable)
this._propertiesUpdateCancellable = null;
}
}
_doPropertiesUpdate() {
const cancellable = new Util.CancellableChild(this._cancellable);
this._doPropertiesUpdateAsync(cancellable).catch(e => {
if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
Util.Logger.warn(`Could not get menu properties menu proxy: ${e}`);
});
}
set active(active) {
const wasActive = this._active;
this._active = active;
if (active && wasActive !== active) {
if (this._flagLayoutUpdateRequired) {
this._requestLayoutUpdate();
} else if (this._flagItemsUpdateRequired) {
this._doPropertiesUpdate();
this._flagItemsUpdateRequired = false;
}
}
}
_onSignal(_sender, signal, params) {
if (signal === 'LayoutUpdated') {
if (!this._active) {
this._flagLayoutUpdateRequired = true;
return;
}
this._requestLayoutUpdate();
} else if (signal === 'ItemsPropertiesUpdated') {
if (!this._active) {
this._flagItemsUpdateRequired = true;
return;
}
this._onPropertiesUpdated(params.deep_unpack());
}
}
getItem(id) {
const item = this._items.get(id);
if (!item)
Util.Logger.warn(`trying to retrieve item for non-existing id ${id} !?`);
return item || null;
}
// we don't need to cache and burst-send that since it will not happen that frequently
async sendAboutToShow(id) {
/* Some indicators (you, dropbox!) don't use the right signature
* and don't return a boolean, so we need to support both cases */
try {
const ret = await this.gConnection.call(this.gName, this.gObjectPath,
this.gInterfaceName, 'AboutToShow', new GLib.Variant('(i)', [id]),
null, Gio.DBusCallFlags.NONE, -1, this._cancellable);
if ((ret.is_of_type(new GLib.VariantType('(b)')) &&
ret.get_child_value(0).get_boolean()) ||
ret.is_of_type(new GLib.VariantType('()')))
this._requestLayoutUpdate();
} catch (e) {
if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
logError(e);
}
}
sendEvent(id, event, params, timestamp) {
if (!this.gNameOwner)
return;
this.EventAsync(id, event, params, timestamp, this._cancellable).catch(e => {
if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
logError(e);
});
}
_onPropertiesUpdated([changed, removed]) {
changed.forEach(([id, props]) => {
const item = this._items.get(id);
if (!item)
return;
for (const [prop, value] of Object.entries(props))
item.propertySet(prop, value);
});
removed.forEach(([id, propNames]) => {
const item = this._items.get(id);
if (!item)
return;
propNames.forEach(propName => item.propertySet(propName, null));
});
}
});
// ////////////////////////////////////////////////////////////////////////
// PART TWO: "View" frontend implementation.
// ////////////////////////////////////////////////////////////////////////
// https://bugzilla.gnome.org/show_bug.cgi?id=731514
// GNOME 3.10 and 3.12 can't open a nested submenu.
// Patches have been written, but it's not clear when (if?) they will be applied.
// We also don't know whether they will be backported to 3.10, so we will work around
// it in the meantime. Offending versions can be clearly identified:
const NEED_NESTED_SUBMENU_FIX = '_setOpenedSubMenu' in PopupMenu.PopupMenu.prototype;
/**
* Creates new wrapper menu items and injects methods for managing them at runtime.
*
* Many functions in this object will be bound to the created item and executed as event
* handlers, so any `this` will refer to a menu item create in createItem
*/
const MenuItemFactory = {
createItem(client, dbusItem) {
// first, decide whether it's a submenu or not
let shellItem;
if (dbusItem.propertyGet('children-display') === 'submenu')
shellItem = new PopupMenu.PopupSubMenuMenuItem('FIXME');
else if (dbusItem.propertyGet('type') === 'separator')
shellItem = new PopupMenu.PopupSeparatorMenuItem('');
else
shellItem = new PopupMenu.PopupMenuItem('FIXME');
shellItem._dbusItem = dbusItem;
shellItem._dbusClient = client;
if (shellItem instanceof PopupMenu.PopupMenuItem) {
shellItem._icon = new St.Icon({
style_class: 'popup-menu-icon',
xAlign: Clutter.ActorAlign.END,
});
shellItem.add_child(shellItem._icon);
shellItem.label.x_expand = true;
}
// initialize our state
MenuItemFactory._updateLabel.call(shellItem);
MenuItemFactory._updateOrnament.call(shellItem);
MenuItemFactory._updateImage.call(shellItem);
MenuItemFactory._updateVisible.call(shellItem);
MenuItemFactory._updateSensitive.call(shellItem);
// initially create children
if (shellItem instanceof PopupMenu.PopupSubMenuMenuItem) {
dbusItem.getChildren().forEach(c =>
shellItem.menu.addMenuItem(MenuItemFactory.createItem(client, c)));
}
// now, connect various events
Util.connectSmart(dbusItem, 'property-changed',
shellItem, MenuItemFactory._onPropertyChanged);
Util.connectSmart(dbusItem, 'child-added',
shellItem, MenuItemFactory._onChildAdded);
Util.connectSmart(dbusItem, 'child-removed',
shellItem, MenuItemFactory._onChildRemoved);
Util.connectSmart(dbusItem, 'child-moved',
shellItem, MenuItemFactory._onChildMoved);
Util.connectSmart(shellItem, 'activate',
shellItem, MenuItemFactory._onActivate);
shellItem.connect('destroy', () => {
shellItem._dbusItem = null;
shellItem._dbusClient = null;
shellItem._icon = null;
});
if (shellItem.menu) {
Util.connectSmart(shellItem.menu, 'open-state-changed',
shellItem, MenuItemFactory._onOpenStateChanged);
}
return shellItem;
},
_onOpenStateChanged(menu, open) {
if (open) {
if (NEED_NESTED_SUBMENU_FIX) {
// close our own submenus
if (menu._openedSubMenu)
menu._openedSubMenu.close(false);
// register ourselves and close sibling submenus
if (menu._parent._openedSubMenu && menu._parent._openedSubMenu !== menu)
menu._parent._openedSubMenu.close(true);
menu._parent._openedSubMenu = menu;
}
this._dbusItem.handleEvent('opened', null, 0);
this._dbusItem.sendAboutToShow();
} else {
if (NEED_NESTED_SUBMENU_FIX) {
// close our own submenus
if (menu._openedSubMenu)
menu._openedSubMenu.close(false);
}
this._dbusItem.handleEvent('closed', null, 0);
}
},
_onActivate(_item, event) {
const timestamp = event.get_time();
if (timestamp && this._dbusClient.indicator)
this._dbusClient.indicator.provideActivationToken(timestamp);
this._dbusItem.handleEvent('clicked', GLib.Variant.new('i', 0),
timestamp);
},
_onPropertyChanged(dbusItem, prop, _value) {
if (prop === 'toggle-type' || prop === 'toggle-state')
MenuItemFactory._updateOrnament.call(this);
else if (prop === 'label')
MenuItemFactory._updateLabel.call(this);
else if (prop === 'enabled')
MenuItemFactory._updateSensitive.call(this);
else if (prop === 'visible')
MenuItemFactory._updateVisible.call(this);
else if (prop === 'icon-name' || prop === 'icon-data')
MenuItemFactory._updateImage.call(this);
else if (prop === 'type' || prop === 'children-display')
MenuItemFactory._replaceSelf.call(this);
else
Util.Logger.debug(`Unhandled property change: ${prop}`);
},
_onChildAdded(dbusItem, child, position) {
if (!(this instanceof PopupMenu.PopupSubMenuMenuItem)) {
Util.Logger.warn('Tried to add a child to non-submenu item. Better recreate it as whole');
MenuItemFactory._replaceSelf.call(this);
} else {
this.menu.addMenuItem(MenuItemFactory.createItem(this._dbusClient, child), position);
}
},
_onChildRemoved(dbusItem, child) {
if (!(this instanceof PopupMenu.PopupSubMenuMenuItem)) {
Util.Logger.warn('Tried to remove a child from non-submenu item. Better recreate it as whole');
MenuItemFactory._replaceSelf.call(this);
} else {
// find it!
this.menu._getMenuItems().forEach(item => {
if (item._dbusItem === child)
item.destroy();
});
}
},
_onChildMoved(dbusItem, child, oldpos, newpos) {
if (!(this instanceof PopupMenu.PopupSubMenuMenuItem)) {
Util.Logger.warn('Tried to move a child in non-submenu item. Better recreate it as whole');
MenuItemFactory._replaceSelf.call(this);
} else {
MenuUtils.moveItemInMenu(this.menu, child, newpos);
}
},
_updateLabel() {
const label = this._dbusItem.propertyGet('label').replace(/_([^_])/, '$1');
if (this.label) // especially on GS3.8, the separator item might not even have a hidden label
this.label.set_text(label);
},
_updateOrnament() {
if (!this.setOrnament)
return; // separators and alike might not have gotten the polyfill
if (this._dbusItem.propertyGet('toggle-type') === 'checkmark' &&
this._dbusItem.propertyGetInt('toggle-state'))
this.setOrnament(PopupMenu.Ornament.CHECK);
else if (this._dbusItem.propertyGet('toggle-type') === 'radio' &&
this._dbusItem.propertyGetInt('toggle-state'))
this.setOrnament(PopupMenu.Ornament.DOT);
else
this.setOrnament(PopupMenu.Ornament.NONE);
},
async _updateImage() {
if (!this._icon)
return; // might be missing on submenus / separators
const iconName = this._dbusItem.propertyGet('icon-name');
const iconData = this._dbusItem.propertyGetVariant('icon-data');
if (iconName) {
this._icon.icon_name = iconName;
} else if (iconData) {
try {
const inputStream = Gio.MemoryInputStream.new_from_bytes(
iconData.get_data_as_bytes());
this._icon.gicon = await GdkPixbuf.Pixbuf.new_from_stream_async(
inputStream, this._dbusClient.cancellable);
} catch (e) {
if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
logError(e);
}
}
},
_updateVisible() {
this.visible = this._dbusItem.propertyGetBool('visible');
},
_updateSensitive() {
this.setSensitive(this._dbusItem.propertyGetBool('enabled'));
},
_replaceSelf(newSelf) {
// create our new self if needed
if (!newSelf)
newSelf = MenuItemFactory.createItem(this._dbusClient, this._dbusItem);
// first, we need to find our old position
let pos = -1;
const family = this._parent._getMenuItems();
for (let i = 0; i < family.length; ++i) {
if (family[i] === this)
pos = i;
}
if (pos < 0)
throw new Error("DBusMenu: can't replace non existing menu item");
// add our new self while we're still alive
this._parent.addMenuItem(newSelf, pos);
// now destroy our old self
this.destroy();
},
};
/**
* Utility functions not necessarily belonging into the item factory
*/
const MenuUtils = {
moveItemInMenu(menu, dbusItem, newpos) {
// HACK: we're really getting into the internals of the PopupMenu implementation
// First, find our wrapper. Children tend to lie. We do not trust the old positioning.
const family = menu._getMenuItems();
for (let i = 0; i < family.length; ++i) {
if (family[i]._dbusItem === dbusItem) {
// now, remove it
menu.box.remove_child(family[i]);
// and add it again somewhere else
if (newpos < family.length && family[newpos] !== family[i])
menu.box.insert_child_below(family[i], family[newpos]);
else
menu.box.add(family[i]);
// skip the rest
return;
}
}
},
};
/**
* Processes DBus events, creates the menu items and handles the actions
*
* Something like a mini-god-object
*/
export class Client extends Signals.EventEmitter {
constructor(busName, path, indicator) {
super();
this._busName = busName;
this._busPath = path;
this._client = new DBusClient(busName, path);
this._rootMenu = null; // the shell menu
this._rootItem = null; // the DbusMenuItem for the root
this.indicator = indicator;
this.cancellable = new Util.CancellableChild(this.indicator.cancellable);
this._client.initAsync(this.cancellable).catch(e => {
if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
logError(e);
});
Util.connectSmart(this._client, 'ready-changed', this,
() => this.emit('ready-changed'));
}
get isReady() {
return this._client.isReady;
}
// this will attach the client to an already existing menu that will be used as the root menu.
// it will also connect the client to be automatically destroyed when the menu dies.
attachToMenu(menu) {
this._rootMenu = menu;
this._rootItem = this._client.getRoot();
this._itemsBeingAdded = new Set();
// cleanup: remove existing children (just in case)
this._rootMenu.removeAll();
if (NEED_NESTED_SUBMENU_FIX)
menu._setOpenedSubMenu = this._setOpenedSubmenu.bind(this);
// connect handlers
Util.connectSmart(menu, 'open-state-changed', this, this._onMenuOpened);
Util.connectSmart(menu, 'destroy', this, this.destroy);
Util.connectSmart(this._rootItem, 'child-added', this, this._onRootChildAdded);
Util.connectSmart(this._rootItem, 'child-removed', this, this._onRootChildRemoved);
Util.connectSmart(this._rootItem, 'child-moved', this, this._onRootChildMoved);
// Dropbox requires us to call AboutToShow(0) first
this._rootItem.sendAboutToShow();
// fill the menu for the first time
const children = this._rootItem.getChildren();
children.forEach(child =>
this._onRootChildAdded(this._rootItem, child));
}
_setOpenedSubmenu(submenu) {
if (!submenu)
return;
if (submenu._parent !== this._rootMenu)
return;
if (submenu === this._openedSubMenu)
return;
if (this._openedSubMenu && this._openedSubMenu.isOpen)
this._openedSubMenu.close(true);
this._openedSubMenu = submenu;
}
_onRootChildAdded(dbusItem, child, position) {
// Menu additions can be expensive, so let's do it in different chunks
const basePriority = this.isOpen ? GLib.PRIORITY_DEFAULT : GLib.PRIORITY_LOW;
const idlePromise = new PromiseUtils.IdlePromise(
basePriority + this._itemsBeingAdded.size, this.cancellable);
this._itemsBeingAdded.add(child);
idlePromise.then(() => {
if (!this._itemsBeingAdded.has(child))
return;
this._rootMenu.addMenuItem(
MenuItemFactory.createItem(this, child), position);
}).catch(e => {
if (!e.matches(Gio.IOErrorEnum, Gio.IOErrorEnum.CANCELLED))
logError(e);
}).finally(() => this._itemsBeingAdded.delete(child));
}
_onRootChildRemoved(dbusItem, child) {
// children like to play hide and seek
// but we know how to find it for sure!
const item = this._rootMenu._getMenuItems().find(it =>
it._dbusItem === child);
if (item)
item.destroy();
else
this._itemsBeingAdded.delete(child);
}
_onRootChildMoved(dbusItem, child, oldpos, newpos) {
MenuUtils.moveItemInMenu(this._rootMenu, dbusItem, newpos);
}
_onMenuOpened(menu, state) {
if (!this._rootItem)
return;
this._client.active = state;
if (state) {
if (this._openedSubMenu && this._openedSubMenu.isOpen)
this._openedSubMenu.close();
this._rootItem.handleEvent('opened', null, 0);
this._rootItem.sendAboutToShow();
} else {
this._rootItem.handleEvent('closed', null, 0);
}
}
destroy() {
this.emit('destroy');
if (this._client)
this._client.destroy();
this._client = null;
this._rootItem = null;
this._rootMenu = null;
this.indicator = null;
this._itemsBeingAdded = null;
}
}

View File

@ -0,0 +1,103 @@
import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
import GObject from 'gi://GObject';
import {CancellableChild, Logger} from './util.js';
Gio._promisify(Gio.DBusProxy.prototype, 'init_async');
export const DBusProxy = GObject.registerClass({
Signals: {'destroy': {}},
}, class DBusProxy extends Gio.DBusProxy {
static get TUPLE_VARIANT_TYPE() {
if (!this._tupleVariantType)
this._tupleVariantType = new GLib.VariantType('(v)');
return this._tupleVariantType;
}
static destroy() {
delete this._tupleType;
}
_init(busName, objectPath, interfaceInfo, flags = Gio.DBusProxyFlags.NONE) {
if (interfaceInfo.signals.length)
Logger.warn('Avoid exposing signals to gjs!');
super._init({
gConnection: Gio.DBus.session,
gInterfaceName: interfaceInfo.name,
gInterfaceInfo: interfaceInfo,
gName: busName,
gObjectPath: objectPath,
gFlags: flags,
});
this._signalIds = [];
if (!(flags & Gio.DBusProxyFlags.DO_NOT_CONNECT_SIGNALS)) {
this._signalIds.push(this.connect('g-signal',
(_proxy, ...args) => this._onSignal(...args)));
}
this._signalIds.push(this.connect('notify::g-name-owner', () =>
this._onNameOwnerChanged()));
}
async initAsync(cancellable) {
cancellable = new CancellableChild(cancellable);
await this.init_async(GLib.PRIORITY_DEFAULT, cancellable);
this._cancellable = cancellable;
this.gInterfaceInfo.methods.map(m => m.name).forEach(method =>
this._ensureAsyncMethod(method));
}
destroy() {
this.emit('destroy');
this._signalIds.forEach(id => this.disconnect(id));
if (this._cancellable)
this._cancellable.cancel();
}
// This can be removed when we will have GNOME 43 as minimum version
_ensureAsyncMethod(method) {
if (this[`${method}Async`])
return;
if (!this[`${method}Remote`])
throw new Error(`Missing remote method '${method}'`);
this[`${method}Async`] = function (...args) {
return new Promise((resolve, reject) => {
this[`${method}Remote`](...args, (ret, e) => {
if (e)
reject(e);
else
resolve(ret);
});
});
};
}
_onSignal() {
}
getProperty(propertyName, cancellable) {
return this.gConnection.call(this.gName,
this.gObjectPath, 'org.freedesktop.DBus.Properties', 'Get',
GLib.Variant.new('(ss)', [this.gInterfaceName, propertyName]),
DBusProxy.TUPLE_VARIANT_TYPE, Gio.DBusCallFlags.NONE, -1,
cancellable);
}
getProperties(cancellable) {
return this.gConnection.call(this.gName,
this.gObjectPath, 'org.freedesktop.DBus.Properties', 'GetAll',
GLib.Variant.new('(s)', [this.gInterfaceName]),
GLib.VariantType.new('(a{sv})'), Gio.DBusCallFlags.NONE, -1,
cancellable);
}
});

View File

@ -0,0 +1,89 @@
// This file is part of the AppIndicator/KStatusNotifierItem GNOME Shell extension
//
// 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 2
// 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, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
import * as Extension from 'resource:///org/gnome/shell/extensions/extension.js';
import * as StatusNotifierWatcher from './statusNotifierWatcher.js';
import * as Interfaces from './interfaces.js';
import * as TrayIconsManager from './trayIconsManager.js';
import * as Util from './util.js';
import {SettingsManager} from './settingsManager.js';
export default class DashToDockExtension extends Extension.Extension {
constructor(...args) {
super(...args);
Util.Logger.init(this);
Interfaces.initialize(this);
this._isEnabled = false;
this._statusNotifierWatcher = null;
this._watchDog = new Util.NameWatcher(StatusNotifierWatcher.WATCHER_BUS_NAME);
this._watchDog.connect('vanished', () => this._maybeEnableAfterNameAvailable());
// HACK: we want to leave the watchdog alive when disabling the extension,
// but if we are being reloaded, we destroy it since it could be considered
// a leak and spams our log, too.
/* eslint-disable no-undef */
if (typeof global['--appindicator-extension-on-reload'] === 'function')
global['--appindicator-extension-on-reload']();
global['--appindicator-extension-on-reload'] = () => {
Util.Logger.debug('Reload detected, destroying old watchdog');
this._watchDog.destroy();
this._watchDog = null;
};
/* eslint-enable no-undef */
}
enable() {
this._isEnabled = true;
SettingsManager.initialize(this);
Util.tryCleanupOldIndicators();
this._maybeEnableAfterNameAvailable();
TrayIconsManager.TrayIconsManager.initialize();
}
disable() {
this._isEnabled = false;
TrayIconsManager.TrayIconsManager.destroy();
if (this._statusNotifierWatcher !== null) {
this._statusNotifierWatcher.destroy();
this._statusNotifierWatcher = null;
}
SettingsManager.destroy();
}
// FIXME: when entering/leaving the lock screen, the extension might be
// enabled/disabled rapidly.
// This will create very bad side effects in case we were not done unowning
// the name while trying to own it again. Since g_bus_unown_name doesn't
// fire any callback when it's done, we need to monitor the bus manually
// to find out when the name vanished so we can reclaim it again.
_maybeEnableAfterNameAvailable() {
// by the time we get called whe might not be enabled
if (!this._isEnabled || this._statusNotifierWatcher)
return;
if (this._watchDog.nameAcquired && this._watchDog.nameOnBus)
return;
this._statusNotifierWatcher = new StatusNotifierWatcher.StatusNotifierWatcher(
this._watchDog);
}
}

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