├── .gitignore
├── LICENSE
├── README.md
├── icons.html
├── install.sh
├── make.sh
├── po
├── en.po
├── example.pot
├── hu.po
├── nl.po
├── uk.po
└── zh_TW.po
├── screenshot.png
└── src
├── components.js
├── config.js
├── extension.js
├── icons
├── icon-disconnected.svg
├── icon-erroneous.svg
├── icon-idle.svg
├── icon-paused.svg
├── icon-scanning.svg
├── icon-syncing.svg
├── syncthing-disconnected-symbolic.svg
├── syncthing-idle-symbolic.svg
├── syncthing-indicator.svg
├── syncthing-paused-symbolic.svg
└── syncthing-working-symbolic.svg
├── metadata.json
├── panelMenu.js
├── prefs.js
├── quickSetting.js
├── schemas
└── org.gnome.shell.extensions.syncthing.gschema.xml
├── stylesheet.css
├── syncthing.js
├── syncthing.service
└── utils.js
/.gitignore:
--------------------------------------------------------------------------------
1 | *.zip
2 | src/locale
3 | src/schemas/gschemas.compiled
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | #
Gnome Shell - Syncthing Indicator
2 |
3 | 
4 |
5 | Shell indicator for starting, monitoring and controlling the Syncthing daemon using SystemD
6 |
7 | What is [Syncthing](https://syncthing.net/)?
8 |
9 | Please note that this extension does not install Syncthing itself, refer the guide on the Syncthing website for more information
10 |
11 | ## Installation from gnome extension website
12 | https://extensions.gnome.org/extension/1070/syncthing-indicator/
13 |
14 | ## Manual installation
15 | 1. `git clone https://github.com/2nv2u/gnome-shell-extension-syncthing-indicator.git`
16 | 1. `./gnome-shell-extension-syncthing-indicator/install.sh`
17 | 1. Restart shell or log out & log in
18 |
19 | ## Debugging during development
20 | `clear && export G_MESSAGES_DEBUG=all && dbus-run-session -- gnome-shell --nested --wayland | grep syncthing-indicator`
--------------------------------------------------------------------------------
/icons.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/install.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #======================================================================================================
4 | # Extension install script
5 | #======================================================================================================
6 |
7 | SCRIPT=$(readlink -f "${BASH_SOURCE[0]}")
8 | SCRIPT_PATH=$(dirname "$SCRIPT")
9 |
10 | source "$SCRIPT_PATH/make.sh"
11 |
12 | gnome-extensions install $CUR_PATH/$EXT_NAME.zip --force
13 | gnome-extensions enable $EXT_NAME
14 | rm -f $CUR_PATH/$EXT_NAME.zip
--------------------------------------------------------------------------------
/make.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | #======================================================================================================
4 | # Extension make script
5 | #======================================================================================================
6 |
7 | SCRIPT=$(readlink -f "${BASH_SOURCE[0]}")
8 | SCRIPT_PATH=$(dirname "$SCRIPT")
9 | CUR_PATH=$(pwd)
10 |
11 | EXT_NAME="syncthing@gnome.2nv2u.com"
12 |
13 | # Generate translations
14 | [ -d $SCRIPT_PATH/src/locale ] && rm -rf $SCRIPT_PATH/src/locale
15 | for LANG_FILE in $SCRIPT_PATH/po/*.po; do
16 | MO_PATH=$SCRIPT_PATH/src/locale/$(basename "${LANG_FILE%.*}")/LC_MESSAGES
17 | mkdir -p $MO_PATH
18 | msgfmt $LANG_FILE -o $MO_PATH/$EXT_NAME.mo
19 | done
20 |
21 | # Compile schemas
22 | [ -f $CUR_PATH/src/schemas/gschemas.compiled ] && rm -f $CUR_PATH/src/schemas/gschemas.compiled
23 | glib-compile-schemas $SCRIPT_PATH/src/schemas/
24 |
25 | # Zip extensions files
26 | [ -f $CUR_PATH/$EXT_NAME.zip ] && rm -f $CUR_PATH/$EXT_NAME.zip
27 | (cd $SCRIPT_PATH/src && zip -r $CUR_PATH/$EXT_NAME.zip *)
28 | zip -r $CUR_PATH/$EXT_NAME.zip -j $SCRIPT_PATH/LICENSE
29 |
--------------------------------------------------------------------------------
/po/en.po:
--------------------------------------------------------------------------------
1 |
2 | msgid ""
3 | msgstr ""
4 | "POT-Creation-Date: 2025-04-01 00:16+0200\n"
5 | "Language: en\n"
6 | "MIME-Version: 1.0\n"
7 | "Content-Type: text/plain; charset=UTF-8\n"
8 | "Content-Transfer-Encoding: 8bit\n"
9 |
10 | #: src/components.js:129
11 | msgid "unknown-error"
12 | msgstr "Extension encountered an unknown error, check log for more details"
13 |
14 | #: src/components.js:132
15 | msgid "daemon-error"
16 | msgstr "Syncthing daemon cannot be started, check log for more details"
17 |
18 | #: src/components.js:135
19 | msgid "service-error"
20 | msgstr "Syncthing service reported an error, check log for more details"
21 |
22 | #: src/components.js:138
23 | msgid "decoding-error"
24 | msgstr "Syncthing connection decoding error, check log for more details"
25 |
26 | #: src/components.js:141
27 | msgid "connection-error"
28 | msgstr "Syncthing connection status error, check log for more details"
29 |
30 | #: src/components.js:144
31 | msgid "config-error"
32 | msgstr "Cannot find Syncthing config, syncthing might not be installed, check log for more details"
33 |
34 | #: src/components.js:148 src/prefs.js:235
35 | msgid "syncthing-indicator"
36 | msgstr "Syncthing Indicator"
37 |
38 | #: src/components.js:226
39 | msgid "folders"
40 | msgstr "Folders"
41 |
42 | #: src/components.js:330
43 | msgid "this-device"
44 | msgstr "This Device"
45 |
46 | #: src/components.js:493
47 | msgid "devices"
48 | msgstr "Remote Devices"
49 |
50 | #: src/components.js:515
51 | msgid "not-connected"
52 | msgstr "Not connected..."
53 |
54 | #: src/components.js:542
55 | msgid "service"
56 | msgstr "Service"
57 |
58 | #: src/components.js:603
59 | msgid "autostart"
60 | msgstr "Autostart"
61 |
62 | #: src/components.js:654
63 | msgid "rescan"
64 | msgstr "Rescan all folders"
65 |
66 | #: src/components.js:690
67 | msgid "web-interface"
68 | msgstr "Open web interface"
69 |
70 | #: src/components.js:729
71 | msgid "settings"
72 | msgstr "Settings"
73 |
74 | #: src/panelMenu.js:77 src/quickSetting.js:29 src/quickSetting.js:37
75 | msgid "syncthing"
76 | msgstr "Syncthing"
77 |
78 | #: src/prefs.js:62
79 | msgid "settings-group-title"
80 | msgstr "Synchting Indicator settings"
81 |
82 | #: src/prefs.js:63
83 | msgid "settings-group-description"
84 | msgstr "Change the location of the panel and/or hide switches & buttons."
85 |
86 | #: src/prefs.js:69
87 | msgid "quick-settings"
88 | msgstr "Quick settings"
89 |
90 | #: src/prefs.js:70
91 | msgid "main-panel"
92 | msgstr "Main panel"
93 |
94 | #: src/prefs.js:74
95 | msgid "menu-type-title"
96 | msgstr "Menu type"
97 |
98 | #: src/prefs.js:75
99 | msgid "menu-type-subtitle"
100 | msgstr "Select the menu integration type"
101 |
102 | #: src/prefs.js:88
103 | msgid "icon-state-title"
104 | msgstr "Icon state"
105 |
106 | #: src/prefs.js:89
107 | msgid "icon-state-subtitle"
108 | msgstr "Show Syncthing state with different icons"
109 |
110 | #: src/prefs.js:101
111 | msgid "auto-start-item"
112 | msgstr "Autostart switch"
113 |
114 | #: src/prefs.js:102
115 | msgid "auto-start-item-subtitle"
116 | msgstr "Show extension autostart switch"
117 |
118 | #: src/prefs.js:114
119 | msgid "setting-button-title"
120 | msgstr "Settings button"
121 |
122 | #: src/prefs.js:115
123 | msgid "setting-button-subtitle"
124 | msgstr "Show extension settings button"
125 |
126 | #: src/prefs.js:127
127 | msgid "auto-config-group-title"
128 | msgstr "Auto & manual configuration"
129 |
130 | #: src/prefs.js:128
131 | msgid "auto-config-group-description"
132 | msgstr "The connection will be extracted from the config by parsing the command 'syncthing --paths' or it will be searched in the default locations.\nIf this fails you can change the API key and URI yourself."
133 |
134 | #: src/prefs.js:134
135 | msgid "auto-config-title"
136 | msgstr "Use auto configuration"
137 |
138 | #: src/prefs.js:135
139 | msgid "auto-config-subtitle"
140 | msgstr "Read API key from the Syncthing configuration by searching for the config file"
141 |
142 | #: src/prefs.js:147
143 | msgid "config-file-title"
144 | msgstr "Configuration file location"
145 |
146 | #: src/prefs.js:151 src/prefs.js:164 src/prefs.js:178
147 | msgid "unknown"
148 | msgstr "Unknown"
149 |
150 | #: src/prefs.js:163 src/prefs.js:190
151 | msgid "service-uri-title"
152 | msgstr "Service URI & port"
153 |
154 | #: src/prefs.js:176 src/prefs.js:210
155 | msgid "api-key-title"
156 | msgstr "API key"
157 |
158 | #: src/prefs.js:191
159 | msgid "service-uri-tooltip"
160 | msgstr "Service URI used to connect to the Syncthing API"
161 |
162 | #: src/prefs.js:211
163 | msgid "api-key-tooltip"
164 | msgstr "API key used to authenticate to the Syncthing API"
165 |
166 | #: src/prefs.js:241
167 | msgid "copyright"
168 | msgstr "Copyright"
169 |
--------------------------------------------------------------------------------
/po/example.pot:
--------------------------------------------------------------------------------
1 | # SOME DESCRIPTIVE TITLE.
2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3 | # This file is distributed under the same license as the PACKAGE package.
4 | # FIRST AUTHOR , YEAR.
5 | #
6 | #, fuzzy
7 | msgid ""
8 | msgstr ""
9 | "Project-Id-Version: PACKAGE VERSION\n"
10 | "Report-Msgid-Bugs-To: \n"
11 | "POT-Creation-Date: 2025-04-01 00:16+0200\n"
12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13 | "Last-Translator: FULL NAME \n"
14 | "Language-Team: LANGUAGE \n"
15 | "Language: \n"
16 | "MIME-Version: 1.0\n"
17 | "Content-Type: text/plain; charset=CHARSET\n"
18 | "Content-Transfer-Encoding: 8bit\n"
19 |
20 | #: src/components.js:129
21 | msgid "unknown-error"
22 | msgstr ""
23 |
24 | #: src/components.js:132
25 | msgid "daemon-error"
26 | msgstr ""
27 |
28 | #: src/components.js:135
29 | msgid "service-error"
30 | msgstr ""
31 |
32 | #: src/components.js:138
33 | msgid "decoding-error"
34 | msgstr ""
35 |
36 | #: src/components.js:141
37 | msgid "connection-error"
38 | msgstr ""
39 |
40 | #: src/components.js:144
41 | msgid "config-error"
42 | msgstr ""
43 |
44 | #: src/components.js:148 src/prefs.js:235
45 | msgid "syncthing-indicator"
46 | msgstr ""
47 |
48 | #: src/components.js:226
49 | msgid "folders"
50 | msgstr ""
51 |
52 | #: src/components.js:330
53 | msgid "this-device"
54 | msgstr ""
55 |
56 | #: src/components.js:493
57 | msgid "devices"
58 | msgstr ""
59 |
60 | #: src/components.js:515
61 | msgid "not-connected"
62 | msgstr ""
63 |
64 | #: src/components.js:542
65 | msgid "service"
66 | msgstr ""
67 |
68 | #: src/components.js:603
69 | msgid "autostart"
70 | msgstr ""
71 |
72 | #: src/components.js:654
73 | msgid "rescan"
74 | msgstr ""
75 |
76 | #: src/components.js:690
77 | msgid "web-interface"
78 | msgstr ""
79 |
80 | #: src/components.js:729
81 | msgid "settings"
82 | msgstr ""
83 |
84 | #: src/panelMenu.js:77 src/quickSetting.js:29 src/quickSetting.js:37
85 | msgid "syncthing"
86 | msgstr ""
87 |
88 | #: src/prefs.js:62
89 | msgid "settings-group-title"
90 | msgstr ""
91 |
92 | #: src/prefs.js:63
93 | msgid "settings-group-description"
94 | msgstr ""
95 |
96 | #: src/prefs.js:69
97 | msgid "quick-settings"
98 | msgstr ""
99 |
100 | #: src/prefs.js:70
101 | msgid "main-panel"
102 | msgstr ""
103 |
104 | #: src/prefs.js:74
105 | msgid "menu-type-title"
106 | msgstr ""
107 |
108 | #: src/prefs.js:75
109 | msgid "menu-type-subtitle"
110 | msgstr ""
111 |
112 | #: src/prefs.js:88
113 | msgid "icon-state-title"
114 | msgstr ""
115 |
116 | #: src/prefs.js:89
117 | msgid "icon-state-subtitle"
118 | msgstr ""
119 |
120 | #: src/prefs.js:101
121 | msgid "auto-start-item"
122 | msgstr ""
123 |
124 | #: src/prefs.js:102
125 | msgid "auto-start-item-subtitle"
126 | msgstr ""
127 |
128 | #: src/prefs.js:114
129 | msgid "setting-button-title"
130 | msgstr ""
131 |
132 | #: src/prefs.js:115
133 | msgid "setting-button-subtitle"
134 | msgstr ""
135 |
136 | #: src/prefs.js:127
137 | msgid "auto-config-group-title"
138 | msgstr ""
139 |
140 | #: src/prefs.js:128
141 | msgid "auto-config-group-description"
142 | msgstr ""
143 |
144 | #: src/prefs.js:134
145 | msgid "auto-config-title"
146 | msgstr ""
147 |
148 | #: src/prefs.js:135
149 | msgid "auto-config-subtitle"
150 | msgstr ""
151 |
152 | #: src/prefs.js:147
153 | msgid "config-file-title"
154 | msgstr ""
155 |
156 | #: src/prefs.js:151 src/prefs.js:164 src/prefs.js:178
157 | msgid "unknown"
158 | msgstr ""
159 |
160 | #: src/prefs.js:163 src/prefs.js:190
161 | msgid "service-uri-title"
162 | msgstr ""
163 |
164 | #: src/prefs.js:176 src/prefs.js:210
165 | msgid "api-key-title"
166 | msgstr ""
167 |
168 | #: src/prefs.js:191
169 | msgid "service-uri-tooltip"
170 | msgstr ""
171 |
172 | #: src/prefs.js:211
173 | msgid "api-key-tooltip"
174 | msgstr ""
175 |
176 | #: src/prefs.js:241
177 | msgid "copyright"
178 | msgstr ""
179 |
--------------------------------------------------------------------------------
/po/hu.po:
--------------------------------------------------------------------------------
1 | # Gellert Gyuris , 2021.
2 | msgid ""
3 | msgstr ""
4 | "Last-Translator: Gellert Gyuris \n"
5 | "Language-Team: Hungarian \n"
6 | "Language: hu_HU\n"
7 | "MIME-Version: 1.0\n"
8 | "Content-Type: text/plain; charset=UTF-8\n"
9 | "Content-Transfer-Encoding: 8bit\n"
10 | "PO-Revision-Date: 2021-11-29 22:43+0100\n"
11 | "Project-Id-Version: \n"
12 | "Plural-Forms: nplurals=2; plural=(n != 1);\n"
13 | "X-Generator: Lokalize 21.08.1\n"
14 |
15 | #: extension.js:101
16 | msgid "folders"
17 | msgstr "Mappák"
18 |
19 | #: extension.js:155 extension.js:334
20 | msgid "failed-URI"
21 | msgstr "Nem sikerült elindítani az URI-t"
22 |
23 | #: extension.js:167
24 | msgid "this-device"
25 | msgstr "Ez az eszköz"
26 |
27 | #: extension.js:298
28 | msgid "rescan"
29 | msgstr "Minden mappa átnézése"
30 |
31 | #: extension.js:324
32 | msgid "web-interface"
33 | msgstr "Webes felület megnyitása"
34 |
35 | #: extension.js:346
36 | msgid "service"
37 | msgstr "Szolgáltatás"
38 |
39 | #: extension.js:366
40 | msgid "autostart"
41 | msgstr "Automatikus indítás"
42 |
43 | #: extension.js:413
44 | msgid "daemon-error"
45 | msgstr "Syncthing Indicator démon hiba"
46 |
47 | #: extension.js:416
48 | msgid "service-error"
49 | msgstr "Syncthing Indicator szolgáltatási hiba"
50 |
51 | #: extension.js:419
52 | msgid "decoding-error"
53 | msgstr "Syncthing Indicator dekódolási hiba"
54 |
55 | #: extension.js:422
56 | msgid "connection-error"
57 | msgstr "Syncthing Indicator kapcsolati hiba"
58 |
59 | #: extension.js:425
60 | msgid "config-error"
61 | msgstr "Syncthing Indicator beállítási hiba"
62 |
--------------------------------------------------------------------------------
/po/nl.po:
--------------------------------------------------------------------------------
1 |
2 | msgid ""
3 | msgstr ""
4 | "POT-Creation-Date: 2025-04-01 00:16+0200\n"
5 | "Language: nl\n"
6 | "MIME-Version: 1.0\n"
7 | "Content-Type: text/plain; charset=UTF-8\n"
8 | "Content-Transfer-Encoding: 8bit\n"
9 |
10 | #: src/components.js:129
11 | msgid "unknown-error"
12 | msgstr "Extensie ondervond een onbekende error, controleer log voor meer details"
13 |
14 | #: src/components.js:132
15 | msgid "daemon-error"
16 | msgstr "Syncthing daemon kon niet gestart worden, controleer log voor meer details"
17 |
18 | #: src/components.js:135
19 | msgid "service-error"
20 | msgstr "Syncthing service heeft een fout gerapporteerd, controleer log voor meer details"
21 |
22 | #: src/components.js:138
23 | msgid "decoding-error"
24 | msgstr "Syncthing connectie decodeer fout, controleer log voor meer details"
25 |
26 | #: src/components.js:141
27 | msgid "connection-error"
28 | msgstr "Syncthing connectie status fout, controleer log voor meer details"
29 |
30 | #: src/components.js:144
31 | msgid "config-error"
32 | msgstr "Kan Syncthing config niet vinden, syncthing is mogelijk niet geinstalleerd, controleer log voor meer details"
33 |
34 | #: src/components.js:148 src/prefs.js:235
35 | msgid "syncthing-indicator"
36 | msgstr "Syncthing Indicator"
37 |
38 | #: src/components.js:226
39 | msgid "folders"
40 | msgstr "Mappen"
41 |
42 | #: src/components.js:330
43 | msgid "this-device"
44 | msgstr "Dit Apparaat"
45 |
46 | #: src/components.js:493
47 | msgid "devices"
48 | msgstr "Apparaten Op Afstand"
49 |
50 | #: src/components.js:515
51 | msgid "not-connected"
52 | msgstr "Niet verbonden..."
53 |
54 | #: src/components.js:542
55 | msgid "service"
56 | msgstr "Service"
57 |
58 | #: src/components.js:603
59 | msgid "autostart"
60 | msgstr "Autostart"
61 |
62 | #: src/components.js:654
63 | msgid "rescan"
64 | msgstr "Alle mappen scannen"
65 |
66 | #: src/components.js:690
67 | msgid "web-interface"
68 | msgstr "Open web beheer"
69 |
70 | #: src/components.js:729
71 | msgid "settings"
72 | msgstr "Settings"
73 |
74 | #: src/panelMenu.js:77 src/quickSetting.js:29 src/quickSetting.js:37
75 | msgid "syncthing"
76 | msgstr "Syncthing"
77 |
78 | #: src/prefs.js:62
79 | msgid "settings-group-title"
80 | msgstr "Synchting Indicator settings"
81 |
82 | #: src/prefs.js:63
83 | msgid "settings-group-description"
84 | msgstr "Locatie van het paneel wijzigen en/of schakelaars & knoppen verbergen."
85 |
86 | #: src/prefs.js:69
87 | msgid "quick-settings"
88 | msgstr "Quick settings"
89 |
90 | #: src/prefs.js:70
91 | msgid "main-panel"
92 | msgstr "Main paneel"
93 |
94 | #: src/prefs.js:74
95 | msgid "menu-type-title"
96 | msgstr "Menu type"
97 |
98 | #: src/prefs.js:75
99 | msgid "menu-type-subtitle"
100 | msgstr "Selecteer de menu integratie type"
101 |
102 | #: src/prefs.js:88
103 | msgid "icon-state-title"
104 | msgstr "Icoon status"
105 |
106 | #: src/prefs.js:89
107 | msgid "icon-state-subtitle"
108 | msgstr "Geef Syncthing status weer met verschillende iconen"
109 |
110 | #: src/prefs.js:101
111 | msgid "auto-start-item"
112 | msgstr "Autostart switch"
113 |
114 | #: src/prefs.js:102
115 | msgid "auto-start-item-subtitle"
116 | msgstr "Geef extensie autostart schakelaar weer"
117 |
118 | #: src/prefs.js:114
119 | msgid "setting-button-title"
120 | msgstr "Settings knop"
121 |
122 | #: src/prefs.js:115
123 | msgid "setting-button-subtitle"
124 | msgstr "Geef extensie settings knop weer"
125 |
126 | #: src/prefs.js:127
127 | msgid "auto-config-group-title"
128 | msgstr "Auto & handmatige configuratie"
129 |
130 | #: src/prefs.js:128
131 | msgid "auto-config-group-description"
132 | msgstr "De connectie zal uit de de config worden gehaald doormiddel van het commando 'syncthing --paths' of het zal worden opgezocht uit de standaard locaties.\nAls dit mislukt kun je de API key en URI zelf wijzigen."
133 |
134 | #: src/prefs.js:134
135 | msgid "auto-config-title"
136 | msgstr "Gebruik automatische configuratie"
137 |
138 | #: src/prefs.js:135
139 | msgid "auto-config-subtitle"
140 | msgstr "Lees API key uit de Syncthing configuratie door naar het config bestand te zoeken"
141 |
142 | #: src/prefs.js:147
143 | msgid "config-file-title"
144 | msgstr "Configuratie bestandslocatie"
145 |
146 | #: src/prefs.js:151 src/prefs.js:164 src/prefs.js:178
147 | msgid "unknown"
148 | msgstr "Onbekend"
149 |
150 | #: src/prefs.js:163 src/prefs.js:190
151 | msgid "service-uri-title"
152 | msgstr "Service URI & poort"
153 |
154 | #: src/prefs.js:176 src/prefs.js:210
155 | msgid "api-key-title"
156 | msgstr "API key"
157 |
158 | #: src/prefs.js:191
159 | msgid "service-uri-tooltip"
160 | msgstr "Service URI gebruikt om aan de Syncthing API te verbinden"
161 |
162 | #: src/prefs.js:211
163 | msgid "api-key-tooltip"
164 | msgstr "API key gebruikt om aan de Syncthing API te authenticeren"
165 |
166 | #: src/prefs.js:241
167 | msgid "copyright"
168 | msgstr "Copyright"
169 |
--------------------------------------------------------------------------------
/po/uk.po:
--------------------------------------------------------------------------------
1 | #
2 | # Ihor Romanyshyn <>, 2025.
3 | #
4 | msgid ""
5 | msgstr ""
6 | "POT-Creation-Date: 2025-04-01 00:16+0200\n"
7 | "Language: uk\n"
8 | "MIME-Version: 1.0\n"
9 | "Content-Type: text/plain; charset=UTF-8\n"
10 | "Content-Transfer-Encoding: 8bit\n"
11 | "Project-Id-Version: unnamed project\n"
12 | "Last-Translator: Ihor Romanyshyn <>\n"
13 | "Language-Team: Ukrainian\n"
14 | "Plural-Forms: nplurals=4; plural=n==1 ? 3 : n%10==1 && n%100!=11 ? 0 : "
15 | "n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
16 | "PO-Revision-Date: 2025-04-26 13:08+0300\n"
17 | "X-Generator: Gtranslator 47.1\n"
18 |
19 | #: src/components.js:129
20 | msgid "unknown-error"
21 | msgstr "Доповнення зазнало невідомої помилки, перевірте журнал для уточнення"
22 |
23 | #: src/components.js:132
24 | msgid "daemon-error"
25 | msgstr "Демон Syncthing не може запуститися, перегляньте журнал для уточнень"
26 |
27 | #: src/components.js:135
28 | msgid "service-error"
29 | msgstr "Демон Syncthing повідомив про помилку, перевірте журнал для уточнень"
30 |
31 | #: src/components.js:138
32 | msgid "decoding-error"
33 | msgstr "Не вдалося розкодувати з'єднання з Syncthing, перевірте журнал"
34 |
35 | #: src/components.js:141
36 | msgid "connection-error"
37 | msgstr "Помилка з'єднання із Syncthing, перегляньте журнал для уточнень"
38 |
39 | #: src/components.js:144
40 | msgid "config-error"
41 | msgstr ""
42 | "Не вдалося знайти конфігурацію Syncthing, або пакет syncthing не встановлений"
43 |
44 | #: src/components.js:148 src/prefs.js:235
45 | msgid "syncthing-indicator"
46 | msgstr "Індикатор Syncthing"
47 |
48 | #: src/components.js:226
49 | msgid "folders"
50 | msgstr "Каталоги"
51 |
52 | #: src/components.js:330
53 | msgid "this-device"
54 | msgstr "Цей пристрій"
55 |
56 | #: src/components.js:493
57 | msgid "devices"
58 | msgstr "Віддалені пристрої"
59 |
60 | #: src/components.js:515
61 | msgid "not-connected"
62 | msgstr "Немає з'єднання…"
63 |
64 | #: src/components.js:542
65 | msgid "service"
66 | msgstr "Сервіс"
67 |
68 | #: src/components.js:603
69 | msgid "autostart"
70 | msgstr "Автозапуск"
71 |
72 | #: src/components.js:654
73 | msgid "rescan"
74 | msgstr "Пересканувати каталоги"
75 |
76 | #: src/components.js:690
77 | msgid "web-interface"
78 | msgstr "Відкрити вебінтерфейс"
79 |
80 | #: src/components.js:729
81 | msgid "settings"
82 | msgstr "Налаштування"
83 |
84 | #: src/panelMenu.js:77 src/quickSetting.js:29 src/quickSetting.js:37
85 | msgid "syncthing"
86 | msgstr "Syncthing"
87 |
88 | #: src/prefs.js:62
89 | msgid "settings-group-title"
90 | msgstr "Налаштування Індикатора Synchting"
91 |
92 | #: src/prefs.js:63
93 | msgid "settings-group-description"
94 | msgstr "Змінити розташування панелі чи заховати перемикачі та кнопки."
95 |
96 | #: src/prefs.js:69
97 | msgid "quick-settings"
98 | msgstr "Швидкі налаштування"
99 |
100 | #: src/prefs.js:70
101 | msgid "main-panel"
102 | msgstr "Основна панель"
103 |
104 | #: src/prefs.js:74
105 | msgid "menu-type-title"
106 | msgstr "Тип меню"
107 |
108 | #: src/prefs.js:75
109 | msgid "menu-type-subtitle"
110 | msgstr "Оберіть тип інтеграції меню"
111 |
112 | #: src/prefs.js:88
113 | msgid "icon-state-title"
114 | msgstr "Статус у значку"
115 |
116 | #: src/prefs.js:89
117 | msgid "icon-state-subtitle"
118 | msgstr "Показувати стан Syncthing за допомогою різних іконок"
119 |
120 | #: src/prefs.js:101
121 | msgid "auto-start-item"
122 | msgstr "Перемикач автозапуску"
123 |
124 | #: src/prefs.js:102
125 | msgid "auto-start-item-subtitle"
126 | msgstr "Показувати перемикач автоматичного запуску"
127 |
128 | #: src/prefs.js:114
129 | msgid "setting-button-title"
130 | msgstr "Кнопка налаштувань"
131 |
132 | #: src/prefs.js:115
133 | msgid "setting-button-subtitle"
134 | msgstr "Показувати кнопку налаштувань доповнення"
135 |
136 | #: src/prefs.js:127
137 | msgid "auto-config-group-title"
138 | msgstr "Автоматичні та ручні налаштування"
139 |
140 | #: src/prefs.js:128
141 | msgid "auto-config-group-description"
142 | msgstr ""
143 | "Налаштування з'єднання будуть витягнуті з файлу конфігурації за допомогою "
144 | "парсингу результату команди 'syncthing --paths' або буде проведено пошук по "
145 | "типових шляхах.\n"
146 | "Якщо це не спрацює, ви все ще зможете вказати API ключ та URI самостійно."
147 |
148 | #: src/prefs.js:134
149 | msgid "auto-config-title"
150 | msgstr "Автоматична конфігурація"
151 |
152 | #: src/prefs.js:135
153 | msgid "auto-config-subtitle"
154 | msgstr "Знайти API ключ у конфігураційному файлі Syncthing"
155 |
156 | #: src/prefs.js:147
157 | msgid "config-file-title"
158 | msgstr "Розташування файлу конфігурації"
159 |
160 | #: src/prefs.js:151 src/prefs.js:164 src/prefs.js:178
161 | msgid "unknown"
162 | msgstr "Невідомо"
163 |
164 | #: src/prefs.js:163 src/prefs.js:190
165 | msgid "service-uri-title"
166 | msgstr "URI та порт сервісу"
167 |
168 | #: src/prefs.js:176 src/prefs.js:210
169 | msgid "api-key-title"
170 | msgstr "API ключ"
171 |
172 | #: src/prefs.js:191
173 | msgid "service-uri-tooltip"
174 | msgstr "URI сервісу використовується для приєднання до Syncthing API"
175 |
176 | #: src/prefs.js:211
177 | msgid "api-key-tooltip"
178 | msgstr "API ключ використовується для аутентифікації у Syncthing API"
179 |
180 | #: src/prefs.js:241
181 | msgid "copyright"
182 | msgstr "Авторське право"
183 |
--------------------------------------------------------------------------------
/po/zh_TW.po:
--------------------------------------------------------------------------------
1 | msgid ""
2 | msgstr ""
3 | "Project-Id-Version: \n"
4 | "POT-Creation-Date: \n"
5 | "PO-Revision-Date: \n"
6 | "Last-Translator: Victor Tseng \n"
7 | "Language-Team: \n"
8 | "Language: zh_TW\n"
9 | "MIME-Version: 1.0\n"
10 | "Content-Type: text/plain; charset=UTF-8\n"
11 | "Content-Transfer-Encoding: 8bit\n"
12 | "X-Generator: Poedit 3.2.2\n"
13 |
14 | #: extension.js:101
15 | msgid "folders"
16 | msgstr "資料夾"
17 |
18 | #: extension.js:155 extension.js:334
19 | msgid "failed-URI"
20 | msgstr "無法開啟 URI"
21 |
22 | #: extension.js:167
23 | msgid "this-device"
24 | msgstr "這個設備"
25 |
26 | #: extension.js:298
27 | msgid "rescan"
28 | msgstr "重新掃描所有資料夾"
29 |
30 | #: extension.js:324
31 | msgid "web-interface"
32 | msgstr "打開網頁界面"
33 |
34 | #: extension.js:346
35 | msgid "service"
36 | msgstr "服務"
37 |
38 | #: extension.js:366
39 | msgid "autostart"
40 | msgstr "重新啟動"
41 |
42 | #: extension.js:413
43 | msgid "daemon-error"
44 | msgstr "無法啟動 Syncthing 伺服程式,檢視紀錄檔取得更多資訊。"
45 |
46 | #: extension.js:416
47 | msgid "service-error"
48 | msgstr "Syncthing 服務回報了錯誤,檢視紀錄檔取得更多資訊。"
49 |
50 | #: extension.js:419
51 | msgid "decoding-error"
52 | msgstr "Syncthing 連線解碼失敗,檢視紀錄檔取得更多資訊。"
53 |
54 | #: extension.js:422
55 | msgid "connection-error"
56 | msgstr "Syncthing 連線錯誤,檢視紀錄檔取得更多資訊。"
57 |
58 | #: extension.js:425
59 | msgid "config-error"
60 | msgstr "無法找到 Syncthing 設定檔,可能沒有安裝?檢視紀錄檔取得更多資訊。"
61 |
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/2nv2u/gnome-shell-extension-syncthing-indicator/81334873d3bf84c95872232de083ee50dc722bb8/screenshot.png
--------------------------------------------------------------------------------
/src/components.js:
--------------------------------------------------------------------------------
1 | /* =============================================================================================================
2 | SyncthingIndicator 0.46
3 | ================================================================================================================
4 |
5 | GJS syncthing gnome-shell panel indicator components.
6 |
7 | Copyright (c) 2019-2025, 2nv2u
8 | This work is distributed under GPLv3, see LICENSE for more information.
9 | ============================================================================================================= */
10 |
11 | import Gio from "gi://Gio";
12 | import GObject from "gi://GObject";
13 | import St from "gi://St";
14 |
15 | import * as Main from "resource:///org/gnome/shell/ui/main.js";
16 | import * as PopupMenu from "resource:///org/gnome/shell/ui/popupMenu.js";
17 | import { gettext as _ } from "resource:///org/gnome/shell/extensions/extension.js";
18 |
19 | import * as Syncthing from "./syncthing.js";
20 |
21 | const LOG_PREFIX = "syncthing-indicator-components:";
22 |
23 | // Syncthing indicator panel icon
24 | export const SyncthingPanelIcon = GObject.registerClass(
25 | class SyncthingPanelIcon extends St.Icon {
26 | _init(extension) {
27 | super._init({
28 | icon_size: 18,
29 | });
30 |
31 | let iconPath = extension.metadata.path + "/icons/";
32 | this._showState = extension.settings.get_boolean("icon-state");
33 |
34 | this._actors = [this];
35 | this._idleGIcon = Gio.icon_new_for_string(
36 | iconPath + "syncthing-idle-symbolic.svg"
37 | );
38 | if (this._showState) {
39 | this._workingGIcon = Gio.icon_new_for_string(
40 | iconPath + "syncthing-working-symbolic.svg"
41 | );
42 | this._pausedGIcon = Gio.icon_new_for_string(
43 | iconPath + "syncthing-paused-symbolic.svg"
44 | );
45 | this._disconnectedGIcon = Gio.icon_new_for_string(
46 | iconPath + "syncthing-disconnected-symbolic.svg"
47 | );
48 | this.setGIcon(this._disconnectedGIcon);
49 | } else {
50 | this.setGIcon(this._idleGIcon);
51 | }
52 |
53 | extension.manager.connect(
54 | Syncthing.Signal.HOST_ADD,
55 | (manager, device) => {
56 | device.connect(
57 | Syncthing.Signal.STATE_CHANGE,
58 | (device, state) => {
59 | this.setState(state);
60 | }
61 | );
62 | }
63 | );
64 | }
65 |
66 | setState(state) {
67 | if (!this._showState) return;
68 | switch (state) {
69 | case Syncthing.State.SYNCING:
70 | case Syncthing.State.SCANNING:
71 | this.setGIcon(this._workingGIcon);
72 | break;
73 | case Syncthing.State.PAUSED:
74 | this.setGIcon(this._pausedGIcon);
75 | break;
76 | case Syncthing.State.UNKNOWN:
77 | case Syncthing.State.DISCONNECTED:
78 | this.setGIcon(this._disconnectedGIcon);
79 | break;
80 | default:
81 | this.setGIcon(this._idleGIcon);
82 | break;
83 | }
84 | }
85 |
86 | addActor(actor) {
87 | actor.gicon = this._activeIcon;
88 | this._actors.push(actor);
89 | }
90 |
91 | setGIcon(gicon) {
92 | this._activeIcon = gicon;
93 | for (let i = 0; i < this._actors.length; i++) {
94 | this._actors[i].gicon = gicon;
95 | }
96 | }
97 | }
98 | );
99 |
100 | // Syncthing indicator menu
101 | export class SyncthingPanel {
102 | constructor(extension, menu) {
103 | this.menu = menu;
104 | this.icon = new SyncthingPanelIcon(extension);
105 |
106 | // No config item
107 | this._notConnectedItem = new NotConnectedItem(extension);
108 | this.menu.addMenuItem(this._notConnectedItem);
109 |
110 | // Device & folder section
111 | this._deviceMenu = new DeviceMenu(extension);
112 | this.menu.addMenuItem(this._deviceMenu);
113 | this._deviceMenu.menu.connect("open-state-changed", (menu, open) => {
114 | if (this.menu.isOpen && !open) this._folderMenu.menu.open(true);
115 | });
116 |
117 | this._folderMenu = new FolderMenu(extension);
118 | this.menu.addMenuItem(this._folderMenu);
119 | this._folderMenu.menu.connect("open-state-changed", (menu, open) => {
120 | if (this.menu.isOpen && !open) this._deviceMenu.menu.open(true);
121 | });
122 |
123 | this.menu.connect("open-state-changed", (menu, open) => {
124 | if (open) this.open(false);
125 | });
126 |
127 | extension.manager.connect(Syncthing.Signal.ERROR, (manager, error) => {
128 | // Use line based gettext function to be able to generate right text pot output
129 | let errorText = _("unknown-error");
130 | switch (error.type) {
131 | case Syncthing.Error.DAEMON:
132 | errorText = _("daemon-error");
133 | break;
134 | case Syncthing.Error.SERVICE:
135 | errorText = _("service-error");
136 | break;
137 | case Syncthing.Error.STREAM:
138 | errorText = _("decoding-error");
139 | break;
140 | case Syncthing.Error.CONNECTION:
141 | errorText = _("connection-error");
142 | break;
143 | case Syncthing.Error.CONFIG:
144 | errorText = _("config-error");
145 | break;
146 | }
147 | console.error(LOG_PREFIX, errorText, error);
148 | Main.notifyError(_("syncthing-indicator"), errorText);
149 | });
150 | }
151 |
152 | showServiceSwitch(toggle) {
153 | this._deviceMenu.showServiceSwitch(toggle);
154 | }
155 |
156 | showAutostartSwitch(toggle) {
157 | this._deviceMenu.showAutostartSwitch(toggle);
158 | }
159 |
160 | open(animate) {
161 | if (this._folderMenu.getSensitive()) {
162 | this._folderMenu.menu.open(animate);
163 | } else {
164 | this._deviceMenu.menu.open(animate);
165 | }
166 | }
167 |
168 | close() {
169 | this.menu.close();
170 | }
171 | }
172 |
173 | // Syncthing suspendable switch menu item
174 | export const SwitchMenuItem = GObject.registerClass(
175 | class SwitchMenuItem extends PopupMenu.PopupSwitchMenuItem {
176 | activate(event) {
177 | if (this._switch.mapped) this.toggle();
178 | }
179 |
180 | _attachSwitchSignal() {
181 | this._switchSignalID = this.connect(
182 | "toggled",
183 | this._process.bind(this)
184 | );
185 | }
186 |
187 | _detachSwitchSignal() {
188 | this.disconnect(this._switchSignalID);
189 | }
190 |
191 | _process(event, state) {
192 | // Process action when toggle signal is attached
193 | }
194 | }
195 | );
196 |
197 | // Syncthing indicator section menu
198 | export const SectionMenu = GObject.registerClass(
199 | class SectionMenu extends PopupMenu.PopupSubMenuMenuItem {
200 | _init(title, icon) {
201 | super._init(title, true);
202 | this.icon.icon_name = icon;
203 | this.section = new PopupMenu.PopupMenuSection();
204 | this.menu.addMenuItem(this.section);
205 | }
206 |
207 | addSectionItem(item) {
208 | this.section.addMenuItem(item);
209 | }
210 |
211 | removeSectionItems() {
212 | this.section.removeAll();
213 | }
214 |
215 | destroy() {
216 | this.section.destroy();
217 | super.destroy();
218 | }
219 | }
220 | );
221 |
222 | // Syncthing indicator fodler menu
223 | export const FolderMenu = GObject.registerClass(
224 | class FolderMenu extends SectionMenu {
225 | _init(extension) {
226 | super._init(_("folders"), "system-file-manager-symbolic");
227 | this.setSensitive(false);
228 | this.visible = false;
229 |
230 | extension.manager.connect(
231 | Syncthing.Signal.SERVICE_CHANGE,
232 | (manager, state) => {
233 | switch (state) {
234 | case Syncthing.ServiceState.CONNECTED:
235 | this.setSensitive(true);
236 | this.visible = true;
237 | break;
238 | case Syncthing.ServiceState.DISCONNECTED:
239 | this.removeSectionItems();
240 | this.setSensitive(false);
241 | this.visible = false;
242 | break;
243 | }
244 | }
245 | );
246 |
247 | extension.manager.connect(
248 | Syncthing.Signal.FOLDER_ADD,
249 | (manager, folder) => {
250 | this.addSectionItem(new FolderMenuItem(folder));
251 | }
252 | );
253 | }
254 | }
255 | );
256 |
257 | // Syncthing indicator fodler menu item
258 | export const FolderMenuItem = GObject.registerClass(
259 | class FolderMenuItem extends PopupMenu.PopupBaseMenuItem {
260 | _init(folder) {
261 | super._init();
262 | this._folder = folder;
263 | let gicon;
264 | // Remove ~ from folders, resolving this doesn not work
265 | this.file = Gio.File.new_for_path(
266 | this._folder.path.replace("~/", "")
267 | );
268 | try {
269 | gicon = this.file
270 | .query_info("standard::symbolic-icon", 0, null)
271 | .get_symbolic_icon();
272 | } catch (e) {
273 | if (e instanceof Gio.IOErrorEnum) {
274 | if (!this.file.is_native()) {
275 | icon = new Gio.ThemedIcon({
276 | name: "folder-remote-symbolic",
277 | });
278 | } else {
279 | icon = new Gio.ThemedIcon({ name: "folder-symbolic" });
280 | }
281 | } else {
282 | throw e;
283 | }
284 | }
285 |
286 | this.icon = new St.Icon({
287 | gicon: gicon,
288 | style_class: "popup-menu-icon syncthing-state-icon",
289 | });
290 | this.actor.add_child(this.icon);
291 |
292 | this.label = new St.Label({
293 | text: folder.getName(),
294 | style_class: "syncthing-state-label",
295 | });
296 | this.actor.add_child(this.label);
297 | this.actor.label_actor = this.label;
298 |
299 | this._folder.connect(
300 | Syncthing.Signal.STATE_CHANGE,
301 | (folder, state) => {
302 | this.icon.style_class =
303 | "popup-menu-icon syncthing-state-icon " + state;
304 | }
305 | );
306 |
307 | this._folder.connect(
308 | Syncthing.Signal.NAME_CHANGE,
309 | (folder, name) => {
310 | this.label.text = name;
311 | }
312 | );
313 |
314 | this._folder.connect(Syncthing.Signal.DESTROY, (folder) => {
315 | this.destroy();
316 | });
317 | }
318 |
319 | activate(event) {
320 | Gio.AppInfo.launch_default_for_uri(this.file.get_uri(), null);
321 | super.activate(event);
322 | }
323 | }
324 | );
325 |
326 | // Syncthing indicator device menu
327 | export const DeviceMenu = GObject.registerClass(
328 | class DeviceMenu extends SectionMenu {
329 | _init(extension) {
330 | super._init(_("this-device"), "computer-symbolic");
331 | this.label.style_class = "syncthing-state-label";
332 |
333 | // TODO: hide on no devices
334 | this._deviceSeparator = new DevicesMenuSeparator();
335 | this.menu.addMenuItem(this._deviceSeparator, 0);
336 |
337 | this._autoSwitch = new AutoSwitchMenuItem(extension);
338 | this.menu.addMenuItem(this._autoSwitch, 0);
339 |
340 | this._serviceSwitch = new ServiceSwitchMenuItem(extension);
341 | this.menu.addMenuItem(this._serviceSwitch, 0);
342 |
343 | this._toggleVisibility(false);
344 |
345 | extension.manager.connect(
346 | Syncthing.Signal.SERVICE_CHANGE,
347 | (manager, state) => {
348 | switch (state) {
349 | case Syncthing.ServiceState.CONNECTED:
350 | this._toggleVisibility(true);
351 | break;
352 | case Syncthing.ServiceState.DISCONNECTED:
353 | this.removeSectionItems();
354 | this._toggleVisibility(false);
355 | break;
356 | }
357 | }
358 | );
359 |
360 | extension.manager.connect(
361 | Syncthing.Signal.DEVICE_ADD,
362 | (manager, device) => {
363 | this.addSectionItem(new DeviceMenuItem(device));
364 | }
365 | );
366 |
367 | extension.manager.connect(
368 | Syncthing.Signal.HOST_ADD,
369 | (manager, device) => {
370 | this.setHost(device);
371 | }
372 | );
373 | }
374 |
375 | setHost(device) {
376 | this._host = device;
377 | this.label.text = device.getName();
378 |
379 | this._host.connect(
380 | Syncthing.Signal.STATE_CHANGE,
381 | (device, state) => {
382 | this.icon.style_class =
383 | "popup-menu-icon syncthing-state-icon " + state;
384 | }
385 | );
386 |
387 | this._host.connect(Syncthing.Signal.NAME_CHANGE, (device, name) => {
388 | this.label.text = name;
389 | });
390 | }
391 |
392 | addSectionItem(item) {
393 | super.addSectionItem(item);
394 | this._toggleVisibility(true);
395 | }
396 |
397 | showAutostartSwitch(toggle) {
398 | this._autoSwitch.visible = toggle;
399 | this._toggleVisibility(toggle);
400 | }
401 |
402 | showServiceSwitch(toggle) {
403 | this._serviceSwitch.visible = toggle;
404 | this._toggleVisibility(toggle);
405 | }
406 |
407 | _toggleVisibility(toggle) {
408 | let elementsVisible =
409 | this._autoSwitch.visible ||
410 | this._serviceSwitch.visible ||
411 | this.section.numMenuItems > 0;
412 | if (toggle) {
413 | this.setSensitive(toggle);
414 | this.visible = toggle;
415 | } else {
416 | this.setSensitive(elementsVisible);
417 | this.visible = elementsVisible;
418 | }
419 | this._deviceSeparator.visible =
420 | (this._autoSwitch.visible || this._serviceSwitch.visible) &&
421 | this.section.numMenuItems > 0;
422 | }
423 | }
424 | );
425 |
426 | // Syncthing indicator device menu item
427 | export const DeviceMenuItem = GObject.registerClass(
428 | class DeviceMenuItem extends SwitchMenuItem {
429 | _init(device) {
430 | super._init(device.getName(), false, null);
431 | this._device = device;
432 | // let icon = new Gio.ThemedIcon({ name: 'network-computer-symbolic' });
433 | let icon = new Gio.ThemedIcon({ name: "network-server-symbolic" });
434 | this.icon = new St.Icon({
435 | gicon: icon,
436 | style_class: "popup-menu-icon syncthing-state-icon",
437 | });
438 | this.actor.insert_child_at_index(this.icon, 1);
439 |
440 | this.label.style_class = "syncthing-state-label";
441 |
442 | this.setSensitive(false);
443 |
444 | this._device.connect(Syncthing.Signal.STATE_CHANGE, (device) => {
445 | let state = device.getState();
446 | this._detachSwitchSignal();
447 | switch (state) {
448 | case Syncthing.State.DISCONNECTED:
449 | this.setSensitive(false);
450 | this.setToggleState(false);
451 | break;
452 | case Syncthing.State.PAUSED:
453 | this.setSensitive(true);
454 | this.setToggleState(false);
455 | break;
456 | default:
457 | this.setSensitive(true);
458 | this.setToggleState(true);
459 | break;
460 | }
461 | this._attachSwitchSignal();
462 | this.icon.style_class =
463 | "popup-menu-icon syncthing-state-icon " + state;
464 | });
465 |
466 | this._device.connect(
467 | Syncthing.Signal.NAME_CHANGE,
468 | (device, name) => {
469 | this.label.text = name;
470 | }
471 | );
472 |
473 | this._device.connect(Syncthing.Signal.DESTROY, () => {
474 | this.destroy();
475 | });
476 | }
477 |
478 | _process(event, state) {
479 | this.setSensitive(false);
480 | if (state) {
481 | this._device.resume();
482 | } else {
483 | this._device.pause();
484 | }
485 | }
486 | }
487 | );
488 |
489 | // Syncthing indicator device menu item
490 | export const DevicesMenuSeparator = GObject.registerClass(
491 | class DevicesMenuSeparator extends PopupMenu.PopupMenuItem {
492 | _init() {
493 | super._init(_("devices"), {
494 | can_focus: false,
495 | hover: false,
496 | reactive: false,
497 | style_class: "separator",
498 | });
499 | this.visible = false;
500 | this.icon = new St.Icon({
501 | gicon: new Gio.ThemedIcon({
502 | name: "network-workgroup-symbolic",
503 | }),
504 | style_class: "popup-menu-icon syncthing-state-icon",
505 | });
506 | this.actor.insert_child_at_index(this.icon, 1);
507 | }
508 | }
509 | );
510 |
511 | // Syncthing indicator no config item
512 | export const NotConnectedItem = GObject.registerClass(
513 | class NotConnectedItem extends PopupMenu.PopupMenuItem {
514 | _init(extension) {
515 | super._init(_("not-connected"), {
516 | can_focus: false,
517 | hover: false,
518 | reactive: false,
519 | });
520 |
521 | extension.manager.connect(
522 | Syncthing.Signal.SERVICE_CHANGE,
523 | (manager, state) => {
524 | switch (state) {
525 | case Syncthing.ServiceState.CONNECTED:
526 | this.visible = false;
527 | break;
528 | case Syncthing.ServiceState.DISCONNECTED:
529 | this.visible = true;
530 | break;
531 | }
532 | }
533 | );
534 | }
535 | }
536 | );
537 |
538 | // Syncthing service switch menu item
539 | export const ServiceSwitchMenuItem = GObject.registerClass(
540 | class ServiceSwitchMenuItem extends SwitchMenuItem {
541 | _init(extension) {
542 | super._init(_("service"), false);
543 | this.extension = extension;
544 | this.visible = false;
545 |
546 | extension.manager.connect(
547 | Syncthing.Signal.SERVICE_CHANGE,
548 | (manager, state) => {
549 | this._detachSwitchSignal();
550 | switch (state) {
551 | case Syncthing.ServiceState.USER_ACTIVE:
552 | this.setSensitive(true);
553 | this.setToggleState(true);
554 | break;
555 | case Syncthing.ServiceState.SYSTEM_ACTIVE:
556 | this.setSensitive(false);
557 | this.setToggleState(true);
558 | break;
559 | case Syncthing.ServiceState.USER_STOPPED:
560 | this.setSensitive(true);
561 | this.setToggleState(false);
562 | break;
563 | case Syncthing.ServiceState.SYSTEM_STOPPED:
564 | this.setSensitive(false);
565 | case Syncthing.ServiceState.ERROR:
566 | this.setToggleState(false);
567 | break;
568 | }
569 | this._attachSwitchSignal();
570 | }
571 | );
572 |
573 | extension.manager.connect(
574 | Syncthing.Signal.ERROR,
575 | (manager, error) => {
576 | this._detachSwitchSignal();
577 | switch (error.type) {
578 | case Syncthing.Error.DAEMON:
579 | this.setSensitive(true);
580 | this.setToggleState(false);
581 | break;
582 | }
583 | this._attachSwitchSignal();
584 | }
585 | );
586 | }
587 |
588 | _process(event, state) {
589 | this.setSensitive(false);
590 | if (state) {
591 | this.extension.manager.startService();
592 | } else {
593 | this.extension.manager.stopService();
594 | }
595 | }
596 | }
597 | );
598 |
599 | // Syncthing service switch menu item
600 | export const AutoSwitchMenuItem = GObject.registerClass(
601 | class AutoSwitchMenuItem extends SwitchMenuItem {
602 | _init(extension) {
603 | super._init(_("autostart"), false);
604 | this.extension = extension;
605 | this.visible = false;
606 |
607 | extension.manager.connect(
608 | Syncthing.Signal.SERVICE_CHANGE,
609 | (manager, state) => {
610 | this._detachSwitchSignal();
611 | switch (state) {
612 | case Syncthing.ServiceState.USER_ENABLED:
613 | this.setSensitive(true);
614 | this.setToggleState(true);
615 | break;
616 | case Syncthing.ServiceState.SYSTEM_ENABLED:
617 | this.setSensitive(false);
618 | this.setToggleState(true);
619 | break;
620 | case Syncthing.ServiceState.USER_DISABLED:
621 | this.setSensitive(true);
622 | this.setToggleState(false);
623 | break;
624 | case Syncthing.ServiceState.SYSTEM_DISABLED:
625 | this.setSensitive(false);
626 | case Syncthing.ServiceState.ERROR:
627 | this.setToggleState(false);
628 | break;
629 | }
630 | this._attachSwitchSignal();
631 | }
632 | );
633 | }
634 |
635 | _process(event, state) {
636 | this.setSensitive(false);
637 | if (state) {
638 | this.extension.manager.enableService();
639 | } else {
640 | this.extension.manager.disableService();
641 | }
642 | }
643 | }
644 | );
645 |
646 | // Syncthing service rescan button
647 | export const RescanButton = GObject.registerClass(
648 | class RescanButton extends St.Button {
649 | _init(extension) {
650 | super._init({
651 | style_class: "icon-button",
652 | can_focus: true,
653 | icon_name: "view-refresh-symbolic",
654 | accessible_name: _("rescan"),
655 | reactive: false,
656 | });
657 |
658 | this.extension = extension;
659 |
660 | this.connect("clicked", () => {
661 | this.extension.indicator.open(true);
662 | this.extension.manager.rescan();
663 | });
664 |
665 | extension.manager.connect(
666 | Syncthing.Signal.SERVICE_CHANGE,
667 | (manager, state) => {
668 | switch (state) {
669 | case Syncthing.ServiceState.CONNECTED:
670 | this.reactive = true;
671 | break;
672 | case Syncthing.ServiceState.DISCONNECTED:
673 | this.reactive = false;
674 | break;
675 | }
676 | }
677 | );
678 | }
679 | }
680 | );
681 |
682 | // Syncthing advanced service settings button (web interface)
683 | export const AdvancedButton = GObject.registerClass(
684 | class AdvancedButton extends St.Button {
685 | _init(extension) {
686 | super._init({
687 | style_class: "icon-button",
688 | can_focus: true,
689 | icon_name: "system-run-symbolic",
690 | accessible_name: _("web-interface"),
691 | reactive: false,
692 | });
693 |
694 | this.extension = extension;
695 |
696 | this.connect("clicked", () => {
697 | Gio.AppInfo.launch_default_for_uri(
698 | this.extension.manager.getServiceURI(),
699 | null
700 | );
701 | this.extension.indicator.close();
702 | });
703 |
704 | extension.manager.connect(
705 | Syncthing.Signal.SERVICE_CHANGE,
706 | (manager, state) => {
707 | switch (state) {
708 | case Syncthing.ServiceState.CONNECTED:
709 | this.reactive = true;
710 | break;
711 | case Syncthing.ServiceState.DISCONNECTED:
712 | this.reactive = false;
713 | break;
714 | }
715 | }
716 | );
717 | }
718 | }
719 | );
720 |
721 | // Syncthing extension settings button
722 | export const SettingsButton = GObject.registerClass(
723 | class SettingsButton extends St.Button {
724 | _init(extension) {
725 | super._init({
726 | style_class: "icon-button",
727 | can_focus: true,
728 | icon_name: "org.gnome.Settings-symbolic",
729 | accessible_name: _("settings"),
730 | });
731 |
732 | this.extension = extension;
733 |
734 | this.connect("clicked", () => {
735 | this.extension.openPreferences();
736 | this.extension.indicator.close();
737 | });
738 | }
739 | }
740 | );
741 |
--------------------------------------------------------------------------------
/src/config.js:
--------------------------------------------------------------------------------
1 | /* =============================================================================================================
2 | SyncthingManager 0.45
3 | ================================================================================================================
4 |
5 | GJS syncthing config.
6 |
7 | Copyright (c) 2019-2025, 2nv2u
8 | This work is distributed under GPLv3, see LICENSE for more information.
9 | ============================================================================================================= */
10 |
11 | import Gio from "gi://Gio";
12 | // Temporary promise fix Gio.Subprocess, it fails in prefs.js
13 | Gio._promisify(Gio.Subprocess.prototype, "communicate_utf8_async");
14 |
15 | import GLib from "gi://GLib";
16 |
17 | const LOG_PREFIX = "syncthing-indicator-config:";
18 |
19 | // Synthing configuration
20 | export default class Config {
21 | CONFIG_PATH_KEY = "Configuration file";
22 |
23 | constructor(settings, parseAll, extensionPath = null) {
24 | this.settings = settings;
25 | this._parseAll = parseAll;
26 | this._extensionPath = extensionPath;
27 | this.clear();
28 | }
29 |
30 | destroy() {
31 | this.clear();
32 | }
33 |
34 | clear() {
35 | this.filePath = null;
36 | this.fileURI = null;
37 | this.fileApiKey = null;
38 | this.prefURI = null;
39 | this.prefApiKey = null;
40 | this._autoConfig = true;
41 | this._exists = false;
42 | }
43 |
44 | async load() {
45 | this.clear();
46 | this._autoConfig = this.settings.get_boolean("auto-config");
47 | if (this._parseAll || this._autoConfig) {
48 | await this.loadFromConfigFile();
49 | }
50 | if (this._parseAll || !this._autoConfig) {
51 | this.loadFromPreferences();
52 | }
53 | }
54 |
55 | async loadFromConfigFile() {
56 | this.filePath = Gio.File.new_for_path("");
57 | // Extract syncthing config file location from the synthing path command
58 | let proc = Gio.Subprocess.new(
59 | ["syncthing", "--paths"],
60 | Gio.SubprocessFlags.STDOUT_PIPE
61 | );
62 | let pathArray = (await proc.communicate_utf8_async(null, null))
63 | .toString()
64 | .split("\n\n");
65 | let paths = {};
66 | for (let i = 0; i < pathArray.length; i++) {
67 | let items = pathArray[i].split(":\n\t");
68 | if (items.length == 2) paths[items[0]] = items[1].split("\n\t");
69 | }
70 | if (this.CONFIG_PATH_KEY in paths) {
71 | this.filePath = Gio.File.new_for_path(
72 | paths[this.CONFIG_PATH_KEY][0]
73 | );
74 | }
75 | // As alternative, extract syncthing configuration from the default user config file
76 | if (!this.filePath.query_exists(null)) {
77 | this.filePath = Gio.File.new_for_path(
78 | GLib.get_user_state_dir() + "/syncthing/config.xml"
79 | );
80 | }
81 | // As alternative, extract syncthing configuration from the deprecated user config file
82 | if (!this.filePath.query_exists(null)) {
83 | this.filePath = Gio.File.new_for_path(
84 | GLib.get_user_config_dir() + "/syncthing/config.xml"
85 | );
86 | }
87 | if (this.filePath.query_exists(null)) {
88 | let configInputStream = this.filePath.read(null);
89 | let configDataInputStream =
90 | Gio.DataInputStream.new(configInputStream);
91 | let config = configDataInputStream.read_until("", null).toString();
92 | configInputStream.close(null);
93 | let regExp = new GLib.Regex(
94 | '.*?(.*?).*?(.*?).*?',
95 | GLib.RegexCompileFlags.DOTALL,
96 | 0
97 | );
98 | let reMatch = regExp.match(config, 0);
99 | if (reMatch[0]) {
100 | let address = reMatch[1].fetch(2);
101 | this.fileApiKey = reMatch[1].fetch(3);
102 | this.fileURI =
103 | "http" +
104 | (reMatch[1].fetch(1) == "true" ? "s" : "") +
105 | "://" +
106 | address;
107 | this._exists = true;
108 | console.info(
109 | LOG_PREFIX,
110 | "found config from file",
111 | this.fileURI,
112 | this.fileApiKey.substr(0, 5) + "...",
113 | this.filePath.get_path()
114 | );
115 | } else {
116 | console.error(LOG_PREFIX, "can't find gui xml node in config");
117 | }
118 | } else {
119 | console.error(LOG_PREFIX, "can't find config file");
120 | }
121 | }
122 |
123 | loadFromPreferences() {
124 | if (
125 | this.settings.get_string("api-key").length >= 0 &&
126 | this.settings
127 | .get_string("service-uri")
128 | .search("https?://[-a-zA-Z0-9.]{1,256}:[0-9]{2,5}") >= 0
129 | ) {
130 | this.prefApiKey = this.settings.get_string("api-key");
131 | this.prefURI = this.settings.get_string("service-uri");
132 | this._exists = true;
133 | console.info(
134 | LOG_PREFIX,
135 | "found config from preferences",
136 | this.prefURI,
137 | this.prefApiKey.substr(0, 5) + "..."
138 | );
139 | } else {
140 | console.error(LOG_PREFIX, "can't find valid custom config");
141 | }
142 | }
143 |
144 | async exists() {
145 | if (!this._exists) await this.load();
146 | return this._exists;
147 | }
148 |
149 | getAPIKey() {
150 | if (this._autoConfig) {
151 | return this.fileApiKey;
152 | } else {
153 | return this.prefApiKey;
154 | }
155 | }
156 |
157 | getURI() {
158 | if (this._autoConfig) {
159 | return this.fileURI;
160 | } else {
161 | return this.prefURI;
162 | }
163 | }
164 | }
165 |
--------------------------------------------------------------------------------
/src/extension.js:
--------------------------------------------------------------------------------
1 | /* =============================================================================================================
2 | SyncthingIndicator 0.46
3 | ================================================================================================================
4 |
5 | GJS syncthing gnome-shell panel indicator signalling the Syncthing deamon status.
6 |
7 | Copyright (c) 2019-2025, 2nv2u
8 | This work is distributed under GPLv3, see LICENSE for more information.
9 | ============================================================================================================= */
10 |
11 | import GLib from "gi://GLib";
12 |
13 | import * as Main from "resource:///org/gnome/shell/ui/main.js";
14 | import {
15 | Extension,
16 | gettext as _,
17 | } from "resource:///org/gnome/shell/extensions/extension.js";
18 |
19 | import * as Syncthing from "./syncthing.js";
20 | import * as PanelMenu from "./panelMenu.js";
21 | import * as QuickSetting from "./quickSetting.js";
22 | import * as Utils from "./utils.js";
23 | import Config from "./config.js";
24 |
25 | const SETTINGS_DELAY = 500;
26 |
27 | // Syncthing indicator extension
28 | export default class SyncthingIndicatorExtension extends Extension {
29 | // Syncthing indicator enabler
30 | enable() {
31 | this._settingTimer = new Utils.Timer(SETTINGS_DELAY);
32 | this.settings = this.getSettings();
33 | this.settings.connect("changed", () => {
34 | this._settingTimer.run(() => {
35 | this.indicator.close();
36 | this.disable();
37 | this.enable();
38 | });
39 | });
40 | this.manager = new Syncthing.Manager(
41 | new Config(this.settings, false),
42 | this.metadata.path
43 | );
44 | switch (this.settings.get_int("menu")) {
45 | case 0:
46 | this.indicator =
47 | new QuickSetting.SyncthingIndicatorQuickSetting(this);
48 | Main.panel.statusArea.quickSettings.addExternalIndicator(
49 | this.indicator
50 | );
51 | break;
52 | case 1:
53 | this.indicator = new PanelMenu.SyncthingIndicatorPanel(this);
54 | Main.panel.addToStatusArea(
55 | "SyncthingIndicatorPanel",
56 | this.indicator
57 | );
58 | break;
59 | }
60 | this.manager.attach();
61 | }
62 |
63 | // Syncthing indicator disabler
64 | disable() {
65 | this.settings = null;
66 | this.indicator.destroy();
67 | this.indicator = null;
68 | this.manager.destroy();
69 | this.manager = null;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/icons/icon-disconnected.svg:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
--------------------------------------------------------------------------------
/src/icons/icon-erroneous.svg:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
--------------------------------------------------------------------------------
/src/icons/icon-idle.svg:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
--------------------------------------------------------------------------------
/src/icons/icon-paused.svg:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
--------------------------------------------------------------------------------
/src/icons/icon-scanning.svg:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
--------------------------------------------------------------------------------
/src/icons/icon-syncing.svg:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
--------------------------------------------------------------------------------
/src/icons/syncthing-disconnected-symbolic.svg:
--------------------------------------------------------------------------------
1 |
2 |
29 |
30 |
--------------------------------------------------------------------------------
/src/icons/syncthing-idle-symbolic.svg:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
--------------------------------------------------------------------------------
/src/icons/syncthing-indicator.svg:
--------------------------------------------------------------------------------
1 |
2 |
21 |
--------------------------------------------------------------------------------
/src/icons/syncthing-paused-symbolic.svg:
--------------------------------------------------------------------------------
1 |
2 |
29 |
30 |
--------------------------------------------------------------------------------
/src/icons/syncthing-working-symbolic.svg:
--------------------------------------------------------------------------------
1 |
2 |
39 |
40 |
--------------------------------------------------------------------------------
/src/metadata.json:
--------------------------------------------------------------------------------
1 | {
2 | "description": "Shell indicator for starting, monitoring and controlling the Syncthing daemon using SystemD",
3 | "name": "Syncthing Indicator",
4 | "shell-version": [
5 | "47",
6 | "48"
7 | ],
8 | "url": "https://github.com/2nv2u/gnome-shell-extension-syncthing-indicator",
9 | "uuid": "syncthing@gnome.2nv2u.com",
10 | "gettext-domain": "syncthing@gnome.2nv2u.com",
11 | "settings-schema": "org.gnome.shell.extensions.syncthing",
12 | "version": 46
13 | }
--------------------------------------------------------------------------------
/src/panelMenu.js:
--------------------------------------------------------------------------------
1 | /* =============================================================================================================
2 | SyncthingIndicator 0.46
3 | ================================================================================================================
4 |
5 | GJS syncthing gnome-shell panel indicator signalling the Syncthing deamon status.
6 |
7 | Copyright (c) 2019-2025, 2nv2u
8 | This work is distributed under GPLv3, see LICENSE for more information.
9 | ============================================================================================================= */
10 |
11 | import GObject from "gi://GObject";
12 | import Clutter from "gi://Clutter";
13 | import St from "gi://St";
14 |
15 | import * as Main from "resource:///org/gnome/shell/ui/main.js";
16 | import * as PanelMenu from "resource:///org/gnome/shell/ui/panelMenu.js";
17 | import { gettext as _ } from "resource:///org/gnome/shell/extensions/extension.js";
18 |
19 | import * as Components from "./components.js";
20 | import * as Syncthing from "./syncthing.js";
21 |
22 | const LOG_PREFIX = "syncthing-indicator-panel-menu:";
23 |
24 | // Syncthing indicator controller panel
25 | export const SyncthingIndicatorPanel = GObject.registerClass(
26 | class SyncthingIndicatorPanel extends PanelMenu.Button {
27 | _init(extension) {
28 | super._init(0.0, "SyncthingIndicatorPanel");
29 |
30 | this.menu.box.add_style_class_name("syncthing-indicator");
31 | this.menu.box.add_style_class_name("panel");
32 | this.menu.box.add_style_class_name("quick-toggle-menu");
33 |
34 | // Header section
35 | // This is too instrusive in the implementation of the QuickToggleMenu
36 | // Find another way to create the header
37 | // TODO: Revisit
38 | const headerLayout = new Clutter.GridLayout();
39 | this._header = new St.Widget({
40 | style_class: "header",
41 | layout_manager: headerLayout,
42 | });
43 | headerLayout.hookup_style(this._header);
44 | this.menu.box.add_child(this._header);
45 | this._headerIcon = new St.Icon({
46 | style_class: "icon",
47 | y_align: Clutter.ActorAlign.CENTER,
48 | });
49 | this._headerTitle = new St.Label({
50 | style_class: "title",
51 | y_align: Clutter.ActorAlign.CENTER,
52 | y_expand: true,
53 | });
54 | this._headerSpacer = new Clutter.Actor({ x_expand: true });
55 | const side =
56 | this.menu.actor.text_direction === Clutter.TextDirection.RTL
57 | ? Clutter.GridPosition.LEFT
58 | : Clutter.GridPosition.RIGHT;
59 | headerLayout.attach(this._headerIcon, 0, 0, 1, 2);
60 | headerLayout.attach_next_to(
61 | this._headerTitle,
62 | this._headerIcon,
63 | side,
64 | 1,
65 | 1
66 | );
67 | headerLayout.attach_next_to(
68 | this._headerSpacer,
69 | this._headerTitle,
70 | side,
71 | 1,
72 | 1
73 | );
74 | this._headerTitle.text = _("syncthing");
75 | // Header action bar section
76 | const actionLayout = new Clutter.GridLayout();
77 | const actionBar = new St.Widget({
78 | layout_manager: actionLayout,
79 | });
80 | this._headerSpacer.x_align = Clutter.ActorAlign.END;
81 | this._headerSpacer.add_child(actionBar);
82 |
83 | const rescanButton = new Components.RescanButton(extension);
84 | actionLayout.attach(rescanButton, 0, 0, 1, 1);
85 |
86 | const advancedButton = new Components.AdvancedButton(extension);
87 | actionLayout.attach_next_to(
88 | advancedButton,
89 | rescanButton,
90 | Clutter.GridPosition.RIGHT,
91 | 1,
92 | 1
93 | );
94 | if (extension.settings.get_boolean("settings-button")) {
95 | const settingsButton = new Components.SettingsButton(extension);
96 | actionLayout.attach_next_to(
97 | settingsButton,
98 | advancedButton,
99 | Clutter.GridPosition.RIGHT,
100 | 1,
101 | 1
102 | );
103 | }
104 |
105 | this.panel = new Components.SyncthingPanel(extension, this.menu);
106 | this.panel.showServiceSwitch(true);
107 | this.panel.showAutostartSwitch(
108 | extension.settings.get_boolean("auto-start-item")
109 | );
110 | this.panel.icon.addActor(this._headerIcon);
111 | this.add_child(this.panel.icon);
112 |
113 | extension.manager.connect(
114 | Syncthing.Signal.SERVICE_CHANGE,
115 | (manager, state) => {
116 | switch (state) {
117 | case Syncthing.ServiceState.USER_ACTIVE:
118 | case Syncthing.ServiceState.SYSTEM_ACTIVE:
119 | this._headerIcon.add_style_class_name("active");
120 | break;
121 | case Syncthing.ServiceState.USER_STOPPED:
122 | case Syncthing.ServiceState.SYSTEM_STOPPED:
123 | case Syncthing.ServiceState.ERROR:
124 | this._headerIcon.remove_style_class_name("active");
125 | break;
126 | }
127 | }
128 | );
129 | }
130 |
131 | open(animate) {
132 | this.panel.open(false);
133 | }
134 |
135 | close() {
136 | this.panel.close();
137 | }
138 | }
139 | );
140 |
--------------------------------------------------------------------------------
/src/prefs.js:
--------------------------------------------------------------------------------
1 | /* =============================================================================================================
2 | SyncthingIndicator 0.46
3 | ================================================================================================================
4 |
5 | GJS syncthing gnome-shell panel indicator preferences.
6 |
7 | Copyright (c) 2019-2025, 2nv2u
8 | This work is distributed under GPLv3, see LICENSE for more information.
9 | ============================================================================================================= */
10 |
11 | import Adw from "gi://Adw";
12 | import Gio from "gi://Gio";
13 | import Gtk from "gi://Gtk";
14 |
15 | import {
16 | ExtensionPreferences,
17 | gettext as _,
18 | } from "resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js";
19 | import Config from "./config.js";
20 |
21 | export default class SyncthingIndicatorExtensionPreferences extends ExtensionPreferences {
22 | fillPreferencesWindow(window) {
23 | this._window = window;
24 |
25 | const iconTheme = Gtk.IconTheme.get_for_display(window.get_display());
26 | const iconsDirectory = this.dir.get_child("icons").get_path();
27 | iconTheme.add_search_path(iconsDirectory);
28 |
29 | this._general();
30 | }
31 |
32 | _general() {
33 | const page = new Adw.PreferencesPage();
34 | this._window.add(page);
35 |
36 | // About button
37 | const aboutButton = new Gtk.Button({
38 | child: new Adw.ButtonContent({
39 | icon_name: "help-about-symbolic",
40 | }),
41 | });
42 | const pagesStack = page.get_parent(); // AdwViewStack
43 | const contentStack = pagesStack.get_parent().get_parent(); // GtkStack
44 | const preferences = contentStack.get_parent(); // GtkBox
45 | const headerBar = preferences
46 | .get_first_child()
47 | .get_next_sibling()
48 | .get_first_child()
49 | .get_first_child()
50 | .get_first_child(); // AdwHeaderBar
51 | headerBar.pack_start(aboutButton);
52 | aboutButton.connect("clicked", () => {
53 | this.showAbout();
54 | });
55 |
56 | let settings = this.getSettings("org.gnome.shell.extensions.syncthing");
57 | let config = new Config(settings, true);
58 |
59 | // Settings group
60 | const settingsGroup = new Adw.PreferencesGroup({
61 | title: _("settings-group-title"),
62 | description: _("settings-group-description"),
63 | });
64 | page.add(settingsGroup);
65 |
66 | // Menu type model
67 | let menuTypesModel = new Gtk.StringList();
68 | menuTypesModel.append(_("quick-settings"));
69 | menuTypesModel.append(_("main-panel"));
70 |
71 | // Menu type combo selector
72 | const typeCombo = new Adw.ComboRow({
73 | title: _("menu-type-title", "Menu type"),
74 | subtitle: _("menu-type-subtitle"),
75 | model: menuTypesModel,
76 | });
77 | settings.bind(
78 | "menu",
79 | typeCombo,
80 | "selected",
81 | Gio.SettingsBindFlags.DEFAULT
82 | );
83 | settingsGroup.add(typeCombo);
84 |
85 | // Icon state switch
86 | const iconStateSwitch = new Adw.SwitchRow({
87 | title: _("icon-state-title", "Icon state"),
88 | subtitle: _("icon-state-subtitle"),
89 | });
90 | settings.bind(
91 | "icon-state",
92 | iconStateSwitch,
93 | "active",
94 | Gio.SettingsBindFlags.DEFAULT
95 | );
96 | settingsGroup.add(iconStateSwitch);
97 |
98 | // Settings button switch
99 | const autoStartItemSwitch = new Adw.SwitchRow({
100 | title: _("auto-start-item"),
101 | subtitle: _("auto-start-item-subtitle"),
102 | });
103 | settings.bind(
104 | "auto-start-item",
105 | autoStartItemSwitch,
106 | "active",
107 | Gio.SettingsBindFlags.DEFAULT
108 | );
109 | settingsGroup.add(autoStartItemSwitch);
110 |
111 | // Settings button switch
112 | const settingsButtonSwitch = new Adw.SwitchRow({
113 | title: _("setting-button-title"),
114 | subtitle: _("setting-button-subtitle"),
115 | });
116 | settings.bind(
117 | "settings-button",
118 | settingsButtonSwitch,
119 | "active",
120 | Gio.SettingsBindFlags.DEFAULT
121 | );
122 | settingsGroup.add(settingsButtonSwitch);
123 |
124 | // Automatic configuration group
125 | const autoGroup = new Adw.PreferencesGroup({
126 | title: _("auto-config-group-title", ""),
127 | description: _("auto-config-group-description"),
128 | });
129 | page.add(autoGroup);
130 |
131 | // Automatic configuration switch
132 | const autoConfigSwitch = new Adw.SwitchRow({
133 | title: _("auto-config-title"),
134 | subtitle: _("auto-config-subtitle"),
135 | });
136 | settings.bind(
137 | "auto-config",
138 | autoConfigSwitch,
139 | "active",
140 | Gio.SettingsBindFlags.DEFAULT
141 | );
142 | autoGroup.add(autoConfigSwitch);
143 |
144 | // Config file view
145 | const configFileView = new Adw.ActionRow({
146 | title: _("config-file-title"),
147 | subtitle: _("unknown"),
148 | });
149 | settings.bind(
150 | "auto-config",
151 | configFileView,
152 | "visible",
153 | Gio.SettingsBindFlags.DEFAULT
154 | );
155 | autoGroup.add(configFileView);
156 |
157 | // Service URI & port view
158 | const serviceAddressView = new Adw.ActionRow({
159 | title: _("service-uri-title"),
160 | subtitle: _("unknown"),
161 | });
162 | settings.bind(
163 | "auto-config",
164 | serviceAddressView,
165 | "visible",
166 | Gio.SettingsBindFlags.DEFAULT
167 | );
168 | autoGroup.add(serviceAddressView);
169 |
170 | // API key view
171 | const apiKeyView = new Adw.ActionRow({
172 | title: _("api-key-title"),
173 | subtitle: _("unknown"),
174 | });
175 | settings.bind(
176 | "auto-config",
177 | apiKeyView,
178 | "visible",
179 | Gio.SettingsBindFlags.DEFAULT
180 | );
181 | autoGroup.add(apiKeyView);
182 |
183 | // Load config and set fields
184 | config
185 | .load()
186 | .then(() => {
187 | console.log("dfg");
188 | configFileView.subtitle =
189 | config.filePath != null
190 | ? config.filePath.get_path()
191 | : _("unknown");
192 | serviceAddressView.subtitle =
193 | config.fileURI != null ? config.fileURI : _("unknown");
194 | apiKeyView.subtitle =
195 | config.fileApiKey != null
196 | ? config.fileApiKey
197 | : _("unknown");
198 | })
199 | .catch((error) => {
200 | console.log(error);
201 | });
202 |
203 | // Service URI & port entry
204 | const serviceAddressEntry = new Adw.EntryRow({
205 | title: _("service-uri-title"),
206 | tooltip_text: _("service-uri-tooltip"),
207 | show_apply_button: true,
208 | });
209 | settings.bind(
210 | "auto-config",
211 | serviceAddressEntry,
212 | "visible",
213 | Gio.SettingsBindFlags.INVERT_BOOLEAN
214 | );
215 | settings.bind(
216 | "service-uri",
217 | serviceAddressEntry,
218 | "text",
219 | Gio.SettingsBindFlags.DEFAULT
220 | );
221 | autoGroup.add(serviceAddressEntry);
222 |
223 | // API key entry
224 | const apiKeyEntry = new Adw.EntryRow({
225 | title: _("api-key-title"),
226 | tooltip_text: _("api-key-tooltip"),
227 | show_apply_button: true,
228 | });
229 | settings.bind(
230 | "auto-config",
231 | apiKeyEntry,
232 | "visible",
233 | Gio.SettingsBindFlags.INVERT_BOOLEAN
234 | );
235 | settings.bind(
236 | "api-key",
237 | apiKeyEntry,
238 | "text",
239 | Gio.SettingsBindFlags.DEFAULT
240 | );
241 | autoGroup.add(apiKeyEntry);
242 | }
243 |
244 | showAbout() {
245 | const about_window = new Adw.AboutWindow({
246 | transient_for: this._window,
247 | modal: true,
248 | });
249 | about_window.set_application_icon("syncthing-indicator");
250 | about_window.set_application_name(_("syncthing-indicator"));
251 | about_window.set_version(`${this.metadata.version}`);
252 | about_window.set_developer_name("2nv2u");
253 | about_window.set_issue_url(this.metadata.url + "/issues");
254 | about_window.set_website(this.metadata.url);
255 | about_window.set_license_type(Gtk.License.GPL_3_0);
256 | about_window.set_copyright(_("copyright") + " © 2025 2nv2u");
257 | about_window.show();
258 | }
259 | }
260 |
--------------------------------------------------------------------------------
/src/quickSetting.js:
--------------------------------------------------------------------------------
1 | /* =============================================================================================================
2 | SyncthingIndicator 0.46
3 | ================================================================================================================
4 |
5 | GJS syncthing gnome-shell quick setting indicator signalling the Syncthing deamon status.
6 |
7 | Copyright (c) 2019-2025, 2nv2u
8 | This work is distributed under GPLv3, see LICENSE for more information.
9 | ============================================================================================================= */
10 |
11 | import GObject from "gi://GObject";
12 | import Clutter from "gi://Clutter";
13 | import St from "gi://St";
14 |
15 | import * as Main from "resource:///org/gnome/shell/ui/main.js";
16 | import * as QuickSettings from "resource:///org/gnome/shell/ui/quickSettings.js";
17 | import { gettext as _ } from "resource:///org/gnome/shell/extensions/extension.js";
18 |
19 | import * as Components from "./components.js";
20 | import * as Syncthing from "./syncthing.js";
21 |
22 | const LOG_PREFIX = "syncthing-indicator-quick-setting:";
23 |
24 | // Syncthing indicator controller toggle
25 | export const SyncthingIndicatorToggle = GObject.registerClass(
26 | class SyncthingIndicatorToggle extends QuickSettings.QuickMenuToggle {
27 | _init(extension) {
28 | super._init({
29 | title: _("syncthing"),
30 | toggleMode: true,
31 | });
32 |
33 | this.extension = extension;
34 |
35 | this.menu.box.add_style_class_name("syncthing-indicator");
36 | this.menu.box.add_style_class_name("toggle");
37 | this.menu.setHeader(null, _("syncthing"));
38 |
39 | // Header action bar section
40 | // This is too instrusive in the implementation of the QuickToggleMenu
41 | // Find another way to control the header
42 | // TODO: Revisit
43 | const actionLayout = new Clutter.GridLayout();
44 | const actionBar = new St.Widget({
45 | layout_manager: actionLayout,
46 | });
47 | this.menu._headerSpacer.x_align = Clutter.ActorAlign.END;
48 | this.menu._headerSpacer.add_child(actionBar);
49 |
50 | const rescanButton = new Components.RescanButton(extension);
51 | actionLayout.attach(rescanButton, 0, 0, 1, 1);
52 |
53 | const advancedButton = new Components.AdvancedButton(extension);
54 | actionLayout.attach_next_to(
55 | advancedButton,
56 | rescanButton,
57 | Clutter.GridPosition.RIGHT,
58 | 1,
59 | 1
60 | );
61 | if (extension.settings.get_boolean("settings-button")) {
62 | const settingsButton = new Components.SettingsButton(extension);
63 | actionLayout.attach_next_to(
64 | settingsButton,
65 | advancedButton,
66 | Clutter.GridPosition.RIGHT,
67 | 1,
68 | 1
69 | );
70 | }
71 |
72 | // Toggle action
73 | this.connect("clicked", () => {
74 | if (this.reactive) {
75 | this.reactive = false;
76 | if (this.checked) {
77 | this.extension.manager.startService();
78 | } else {
79 | this.extension.manager.stopService();
80 | }
81 | }
82 | });
83 |
84 | extension.manager.connect(
85 | Syncthing.Signal.HOST_ADD,
86 | (manager, device) => {
87 | this.subtitle = device.getName();
88 | }
89 | );
90 |
91 | extension.manager.connect(
92 | Syncthing.Signal.SERVICE_CHANGE,
93 | (manager, state) => {
94 | switch (state) {
95 | case Syncthing.ServiceState.USER_ACTIVE:
96 | this.set({ reactive: true, checked: true });
97 | break;
98 | case Syncthing.ServiceState.SYSTEM_ACTIVE:
99 | this.set({ reactive: false, checked: true });
100 | break;
101 | case Syncthing.ServiceState.USER_STOPPED:
102 | this.set({ reactive: true, checked: false });
103 | break;
104 | case Syncthing.ServiceState.SYSTEM_STOPPED:
105 | this.set({ reactive: false });
106 | case Syncthing.ServiceState.ERROR:
107 | this.set({ checked: false });
108 | break;
109 | }
110 | }
111 | );
112 |
113 | extension.manager.connect(
114 | Syncthing.Signal.ERROR,
115 | (manager, error) => {
116 | switch (error.type) {
117 | case Syncthing.Error.DAEMON:
118 | this.set({ reactive: true, checked: false });
119 | break;
120 | }
121 | }
122 | );
123 | }
124 | }
125 | );
126 |
127 | export const SyncthingIndicatorQuickSetting = GObject.registerClass(
128 | class SyncthingIndicatorQuickSetting extends QuickSettings.SystemIndicator {
129 | _init(extension) {
130 | super._init();
131 |
132 | this.toggle = new SyncthingIndicatorToggle(extension);
133 | this.quickSettingsItems.push(this.toggle);
134 |
135 | this.panel = new Components.SyncthingPanel(
136 | extension,
137 | this.toggle.menu
138 | );
139 | this.panel.showAutostartSwitch(
140 | extension.settings.get_boolean("auto-start-item")
141 | );
142 | this.panel.icon.addActor(this._addIndicator());
143 | this.panel.icon.addActor(this.toggle);
144 | this.panel.icon.addActor(this.toggle.menu._headerIcon);
145 |
146 | this.panel.menu.connect("open-state-changed", (menu, open) => {
147 | if (!open) Main.panel.statusArea.quickSettings.menu.close();
148 | });
149 | }
150 |
151 | destroy() {
152 | this.quickSettingsItems.forEach((item) => item.destroy());
153 | super.destroy();
154 | }
155 |
156 | open(animate) {
157 | this.panel.open(false);
158 | }
159 |
160 | close() {
161 | this.panel.close();
162 | }
163 | }
164 | );
165 |
--------------------------------------------------------------------------------
/src/schemas/org.gnome.shell.extensions.syncthing.gschema.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 | 0
7 | Menu type
8 | Select the menu integration type
9 |
10 |
11 | true
12 | Icon state
13 | Show Syncthing state with different icons
14 |
15 |
16 | true
17 | Settings button
18 | Show extension settings button
19 |
20 |
21 | true
22 | Autostart switch
23 | Show extension autostart switch
24 |
25 |
26 | true
27 | Use auto configuration
28 | Read API key from the Syncthing configuration by searching for the config file
29 |
30 |
31 | ""
32 | Service URI & port
33 | Service URI used to connect to the Syncthing API
34 |
35 |
36 | ""
37 | API key
38 | API key used to authenticate to the Syncthing API
39 |
40 |
41 |
--------------------------------------------------------------------------------
/src/stylesheet.css:
--------------------------------------------------------------------------------
1 | .syncthing-indicator {
2 | min-width: 306px;
3 | }
4 |
5 | .syncthing-indicator .syncthing-state-icon {
6 | padding-right: 6px;
7 | }
8 |
9 | .syncthing-indicator .syncthing-state-label {
10 | padding-left: 6px;
11 | }
12 |
13 | .syncthing-indicator .syncthing-state-icon.idle {
14 | background-image: url(icons/icon-idle.svg);
15 | }
16 |
17 | .syncthing-indicator .syncthing-state-icon.scanning {
18 | background-image: url(icons/icon-scanning.svg);
19 | }
20 |
21 | .syncthing-indicator .syncthing-state-icon.syncing {
22 | background-image: url(icons/icon-syncing.svg);
23 | }
24 |
25 | .syncthing-indicator .syncthing-state-icon.erroneous {
26 | background-image: url(icons/icon-erroneous.svg);
27 | }
28 |
29 | .syncthing-indicator .syncthing-state-icon.paused {
30 | background-image: url(icons/icon-paused.svg);
31 | }
32 |
33 | .syncthing-indicator .syncthing-state-icon.disconnected {
34 | background-image: url(icons/icon-disconnected.svg);
35 | }
36 |
37 | .syncthing-indicator .icon-button {
38 | margin-left: 10px;
39 | background-color: rgba(255,255,255,0.1);
40 | }
41 |
42 | .syncthing-indicator .icon-button:hover {
43 | margin-left: 10px;
44 | background-color: rgba(255,255,255,0.2);
45 | }
46 |
47 | .syncthing-indicator .separator {
48 | background-color: rgba(255,255,255,0.1);
49 | }
--------------------------------------------------------------------------------
/src/syncthing.js:
--------------------------------------------------------------------------------
1 | /* =============================================================================================================
2 | SyncthingManager 0.45
3 | ================================================================================================================
4 |
5 | GJS syncthing systemd manager.
6 |
7 | Copyright (c) 2019-2025, 2nv2u
8 | This work is distributed under GPLv3, see LICENSE for more information.
9 | ============================================================================================================= */
10 |
11 | import Gio from "gi://Gio";
12 | import GLib from "gi://GLib";
13 | import Soup from "gi://Soup";
14 |
15 | import * as Utils from "./utils.js";
16 |
17 | const LOG_PREFIX = "syncthing-indicator-manager:";
18 | const POLL_TIME = 20000;
19 | const START_DELAY_TIME = 1000;
20 | const POLL_CONNECTION_HOOK_COUNT = 6; // Poll time * count = every 2 minutes
21 | const POLL_CONFIG_HOOK_COUNT = 45; // Poll time * count = every 15 minutes
22 | const CONNECTION_RETRY_DELAY = 1000;
23 | const DEVICE_STATE_DELAY = 600;
24 | const ITEM_STATE_DELAY = 200;
25 | const RESCHEDULE_EVENT_DELAY = 50;
26 | const HTTP_ERROR_RETRIES = 3;
27 |
28 | // Error constants
29 | export const Error = {
30 | LOGIN: "Login attempt failed",
31 | DAEMON: "Service failed to start",
32 | SERVICE: "Service reported error",
33 | STREAM: "Stream parsing error",
34 | CONNECTION: "Connection status error",
35 | CONFIG: "Config not found",
36 | };
37 |
38 | // Service constants
39 | export const Service = {
40 | NAME: "syncthing",
41 | };
42 |
43 | // Signal constants
44 | export const Signal = {
45 | LOGIN: "login",
46 | ADD: "add",
47 | DESTROY: "destroy",
48 | NAME_CHANGE: "nameChange",
49 | SERVICE_CHANGE: "serviceChange",
50 | HOST_ADD: "hostAdd",
51 | FOLDER_ADD: "folderAdd",
52 | DEVICE_ADD: "deviceAdd",
53 | STATE_CHANGE: "stateChange",
54 | ERROR: "error",
55 | };
56 |
57 | // State constants
58 | export const State = {
59 | UNKNOWN: "unknown",
60 | IDLE: "idle",
61 | SCANNING: "scanning",
62 | SYNCING: "syncing",
63 | PAUSED: "paused",
64 | ERRONEOUS: "erroneous",
65 | DISCONNECTED: "disconnected",
66 | };
67 |
68 | // Service state constants
69 | export const ServiceState = {
70 | USER_ACTIVE: "userActive",
71 | USER_STOPPED: "userStopped",
72 | USER_ENABLED: "userEnabled",
73 | USER_DISABLED: "userDisabled",
74 | SYSTEM_ACTIVE: "systemActive",
75 | SYSTEM_STOPPED: "systemStopped",
76 | SYSTEM_ENABLED: "systemEnabled",
77 | SYSTEM_DISABLED: "systemDisabled",
78 | CONNECTED: "connected",
79 | DISCONNECTED: "disconnected",
80 | ERROR: "error",
81 | };
82 |
83 | // Signal constants
84 | export const EventType = {
85 | CONFIG_SAVED: "ConfigSaved",
86 | DEVICE_CONNECTED: "DeviceConnected",
87 | DEVICE_DISCONNECTED: "DeviceDisconnected",
88 | DEVICE_DISCOVERED: "DeviceDiscovered",
89 | DEVICE_PAUSED: "DevicePaused",
90 | DEVICE_REJECTED: "DeviceRejected",
91 | DEVICE_RESUMED: "DeviceResumed",
92 | DOWNLOAD_PROGRESS: "DownloadProgress",
93 | FAILURE: "Failure",
94 | FOLDER_COMPLETION: "FolderCompletion",
95 | FOLDER_ERRORS: "FolderErrors",
96 | FOLDER_PAUSED: "FolderPaused",
97 | FOLDER_REJECTED: "FolderRejected",
98 | FOLDER_RESUMED: "FolderResumed",
99 | FOLDER_SCAN_PROGRESS: "FolderScanProgress",
100 | FOLDER_SUMMARY: "FolderSummary",
101 | ITEM_FINISHED: "ItemFinished",
102 | ITEM_STARTED: "ItemStarted",
103 | LISTEN_ADDRESSES_CHANGED: "ListenAddressesChanged",
104 | LOCAL_CHANGE_DETECTED: "LocalChangeDetected",
105 | LOCAL_INDEX_UPDATED: "LocalIndexUpdated",
106 | LOGIN_ATTEMPT: "LoginAttempt",
107 | PENDING_DEVICES_CHANGED: "PendingDevicesChanged",
108 | PENDING_FOLDERS_CHANGED: "PendingFoldersChanged",
109 | REMOTE_CHANGE_DETECTED: "RemoteChangeDetected",
110 | REMOTE_DOWNLOAD_PROGRESS: "RemoteDownloadProgress",
111 | REMOTE_INDEX_UPDATED: "RemoteIndexUpdated",
112 | STARTING: "Starting",
113 | STARTUP_COMPLETE: "StartupComplete",
114 | STATE_CHANGED: "StateChanged",
115 | };
116 |
117 | // Abstract item used for folders and devices
118 | class Item extends Utils.Emitter {
119 | constructor(data, manager) {
120 | super();
121 | this._state = State.UNKNOWN;
122 | this._stateEmitted = State.UNKNOWN;
123 | this._stateTimer = new Utils.Timer(ITEM_STATE_DELAY);
124 | this.id = data.id;
125 | this._name = data.name;
126 | this._manager = manager;
127 | }
128 |
129 | isBusy() {
130 | return (
131 | this.getState() == State.SYNCING ||
132 | this.getState() == State.SCANNING
133 | );
134 | }
135 |
136 | setState(state) {
137 | if (state.length > 0 && this._state != state) {
138 | this._stateTimer.cancel();
139 | console.info(LOG_PREFIX, "state change", this._name, state);
140 | this._state = state;
141 | // Stop items from excessive state changes by only emitting 1 state per stateDelay
142 | this._stateTimer.run(() => {
143 | if (this._stateEmitted != this._state) {
144 | console.debug(
145 | LOG_PREFIX,
146 | "emit state change",
147 | this._name,
148 | this._state
149 | );
150 | this._stateEmitted = this._state;
151 | this.emit(Signal.STATE_CHANGE, this._state);
152 | }
153 | });
154 | }
155 | }
156 |
157 | getState() {
158 | return this._state;
159 | }
160 |
161 | setName(name) {
162 | if (name.length > 0 && this._name != name) {
163 | console.info(LOG_PREFIX, "emit name change", this._name, name);
164 | this._name = name;
165 | this.emit(Signal.NAME_CHANGE, this._name);
166 | }
167 | }
168 |
169 | getName() {
170 | return this._name;
171 | }
172 |
173 | destroy() {
174 | this._stateTimer.cancel();
175 | this.emit(Signal.DESTROY);
176 | }
177 | }
178 |
179 | // Abstract item collection used for folders and devices
180 | class ItemCollection extends Utils.Emitter {
181 | constructor() {
182 | super();
183 | this._collection = {};
184 | }
185 |
186 | add(item) {
187 | if (item instanceof Item) {
188 | console.info(
189 | LOG_PREFIX,
190 | "add",
191 | item.constructor.name,
192 | item.getName()
193 | );
194 | this._collection[item.id] = item;
195 | item.connect(Signal.DESTROY, (_item) => {
196 | delete this._collection[_item.id];
197 | });
198 | this.emit(Signal.ADD, item);
199 | }
200 | }
201 |
202 | destroy(id) {
203 | if (id) {
204 | let item = this._collection[id];
205 | delete this._collection[id];
206 | item.destroy();
207 | this.emit(Signal.DESTROY, item);
208 | } else {
209 | this.foreach((_item) => {
210 | this.destroy(_item.id);
211 | });
212 | }
213 | }
214 |
215 | get(id) {
216 | return this._collection[id];
217 | }
218 |
219 | exists(id) {
220 | return id in this._collection;
221 | }
222 |
223 | foreach(handler) {
224 | for (let itemID in this._collection) {
225 | handler(this._collection[itemID]);
226 | }
227 | }
228 | }
229 |
230 | // Device
231 | class Device extends Item {
232 | constructor(data, manager) {
233 | super(data, manager);
234 | this._determineTimer = new Utils.Timer(DEVICE_STATE_DELAY);
235 | this.folders = new ItemCollection();
236 | this.folders.connect(Signal.ADD, (collection, folder) => {
237 | folder.connect(
238 | Signal.STATE_CHANGE,
239 | this.determineStateDelayed.bind(this)
240 | );
241 | });
242 | }
243 |
244 | isOnline() {
245 | return (
246 | this.getState() != State.DISCONNECTED &&
247 | this.getState() != State.PAUSED
248 | );
249 | }
250 |
251 | determineStateDelayed() {
252 | // Stop items from excessive state change calculations by only emitting 1 state per stateDelay
253 | this._determineTimer.run(this.determineState.bind(this));
254 | }
255 |
256 | determineState() {
257 | if (this.isOnline()) {
258 | this.setState(State.PAUSED);
259 | this.folders.foreach((folder) => {
260 | if (!this.isBusy()) {
261 | console.info(
262 | LOG_PREFIX,
263 | "determine device state",
264 | this.getName(),
265 | folder.getName(),
266 | folder.getState()
267 | );
268 | this.setState(folder.getState());
269 | }
270 | });
271 | }
272 | }
273 |
274 | pause() {
275 | this._manager.pause(this);
276 | }
277 |
278 | resume() {
279 | this._manager.resume(this);
280 | }
281 |
282 | destroy() {
283 | this._determineTimer.cancel();
284 | super.destroy();
285 | }
286 | }
287 |
288 | // Device host
289 | class HostDevice extends Device {
290 | constructor(data, manager) {
291 | super(data, manager);
292 | this._manager.connect(Signal.DEVICE_ADD, (manager, device) => {
293 | device.connect(
294 | Signal.STATE_CHANGE,
295 | this.determineStateDelayed.bind(this)
296 | );
297 | });
298 | this._manager.devices.foreach((device) => {
299 | device.connect(
300 | Signal.STATE_CHANGE,
301 | this.determineStateDelayed.bind(this)
302 | );
303 | });
304 | this.determineState();
305 | }
306 |
307 | determineState() {
308 | this.setState(State.PAUSED);
309 | this._manager.devices.foreach((device) => {
310 | if (this != device && !this.isBusy() && device.isOnline()) {
311 | console.info(
312 | LOG_PREFIX,
313 | "determine host device state",
314 | this.getName(),
315 | device.getName(),
316 | device.getState()
317 | );
318 | this.setState(device.getState());
319 | }
320 | });
321 | if (!this.isBusy()) {
322 | super.determineState();
323 | }
324 | }
325 | }
326 |
327 | // Folder
328 | class Folder extends Item {
329 | constructor(data, manager) {
330 | super(data, manager);
331 | this.path = data.path;
332 | this.devices = new ItemCollection();
333 | }
334 |
335 | rescan() {
336 | this._manager.rescan(this);
337 | }
338 | }
339 |
340 | // Folder completion proxy per device
341 | class FolderCompletionProxy extends Folder {
342 | constructor(data) {
343 | super(data.folder);
344 | this._name = data.folder.getName() + " (" + data.device.getName() + ")";
345 | this._folder = data.folder;
346 | this._device = data.device;
347 | }
348 |
349 | setCompletion(percentage) {
350 | if (percentage < 100) {
351 | this.setState(State.SYNCING);
352 | } else {
353 | this.setState(State.IDLE);
354 | }
355 | }
356 | }
357 |
358 | // Main system manager
359 | export class Manager extends Utils.Emitter {
360 | constructor(extensionConfig, extensionPath) {
361 | super();
362 | this.folders = new ItemCollection();
363 | this.devices = new ItemCollection();
364 | this.folders.connect(Signal.ADD, (collection, folder) => {
365 | this.emit(Signal.FOLDER_ADD, folder);
366 | });
367 | this.devices.connect(Signal.ADD, (collection, device) => {
368 | if (device instanceof HostDevice) {
369 | this.host = device;
370 | this.emit(Signal.HOST_ADD, this.host);
371 | } else {
372 | this.emit(Signal.DEVICE_ADD, device);
373 | }
374 | });
375 | this._httpSession = new Soup.Session();
376 | this._httpAborting = false;
377 | this._httpErrorCount = 0;
378 | this._extensionConfig = extensionConfig;
379 | this._extensionPath = extensionPath;
380 | this._serviceConnected = false;
381 | this._serviceActive = false;
382 | this._serviceEnabled = false;
383 | this._serviceUserMode = true;
384 | this._pollTimer = new Utils.Timer(POLL_TIME, true);
385 | this._pollCount = 1; // Start at 1 to stop from cycling the hooks at init
386 | this._lastEventID = 1;
387 | this._hostID = "";
388 | this._lastErrorTime = Date.now();
389 | this.connect(Signal.SERVICE_CHANGE, (manager, state) => {
390 | switch (state) {
391 | case ServiceState.USER_ACTIVE:
392 | case ServiceState.SYSTEM_ACTIVE:
393 | this._openConnection(
394 | "GET",
395 | "/rest/system/status",
396 | (status) => {
397 | this._hostID = status.myID;
398 | this._callConfig((config) => {
399 | this._callEvents("limit=1");
400 | this._pollTimer.run(this._pollState.bind(this));
401 | });
402 | }
403 | );
404 | break;
405 | case ServiceState.USER_STOPPED:
406 | case ServiceState.SYSTEM_STOPPED:
407 | this.destroy();
408 | this._lastEventID = 1;
409 | this._httpErrorCount = 0;
410 | if (this._serviceConnected) {
411 | this._serviceConnected = false;
412 | this.emit(
413 | Signal.SERVICE_CHANGE,
414 | ServiceState.DISCONNECTED
415 | );
416 | }
417 | break;
418 | }
419 | });
420 | }
421 |
422 | _callConfig(handler) {
423 | this._openConnection("GET", "/rest/system/config", (config) => {
424 | this._processConfig(config);
425 | if (handler) handler(config);
426 | });
427 | }
428 |
429 | _callEvents(options) {
430 | this._openConnection("GET", "/rest/events?" + options, (events) => {
431 | for (let i = 0; i < events.length; i++) {
432 | console.debug(
433 | LOG_PREFIX,
434 | "processing event",
435 | events[i].type,
436 | events[i].data
437 | );
438 | try {
439 | switch (events[i].type) {
440 | case EventType.STARTUP_COMPLETE:
441 | this._callConfig();
442 | break;
443 | case EventType.CONFIG_SAVED:
444 | this._processConfig(events[i].data);
445 | break;
446 | case EventType.LOGIN_ATTEMPT:
447 | if (events[i].data.success) {
448 | this.emit(
449 | Signal.LOGIN,
450 | events[i].data.username
451 | );
452 | } else {
453 | this.emit(Error.LOGIN, events[i].data.username);
454 | }
455 | break;
456 | case EventType.FOLDER_ERRORS:
457 | if (this.folders.exists(events[i].data.folder)) {
458 | this.folders
459 | .get(events[i].data.folder)
460 | .setState(State.ERRONEOUS);
461 | }
462 | break;
463 | case EventType.FOLDER_COMPLETION:
464 | if (
465 | this.folders.exists(events[i].data.folder) &&
466 | this.devices.exists(events[i].data.device)
467 | ) {
468 | let device = this.devices.get(
469 | events[i].data.device
470 | );
471 | if (
472 | device.folders.exists(events[i].data.folder)
473 | ) {
474 | if (device.isOnline())
475 | device.setState(State.SCANNING);
476 | device.folders
477 | .get(events[i].data.folder)
478 | .setCompletion(
479 | events[i].data.completion
480 | );
481 | }
482 | }
483 | break;
484 | case EventType.FOLDER_SUMMARY:
485 | if (this.folders.exists(events[i].data.folder)) {
486 | this.folders
487 | .get(events[i].data.folder)
488 | .setState(events[i].data.summary.state);
489 | }
490 | break;
491 | case EventType.FOLDER_PAUSED:
492 | if (this.folders.exists(events[i].data.id)) {
493 | this.folders
494 | .get(events[i].data.id)
495 | .setState(State.PAUSED);
496 | }
497 | break;
498 | case EventType.PENDING_FOLDERS_CHANGED:
499 | this.folders.destroy();
500 | this._callConfig();
501 | break;
502 | case EventType.STATE_CHANGED:
503 | if (this.folders.exists(events[i].data.folder)) {
504 | this.folders
505 | .get(events[i].data.folder)
506 | .setState(events[i].data.to);
507 | }
508 | break;
509 | case EventType.DEVICE_RESUMED:
510 | if (this.devices.exists(events[i].data.device)) {
511 | this.devices
512 | .get(events[i].data.device)
513 | .setState(State.DISCONNECTED);
514 | }
515 | break;
516 | case EventType.DEVICE_PAUSED:
517 | if (this.devices.exists(events[i].data.device)) {
518 | this.devices
519 | .get(events[i].data.device)
520 | .setState(State.PAUSED);
521 | }
522 | break;
523 | case EventType.DEVICE_CONNECTED:
524 | if (this.devices.exists(events[i].data.id)) {
525 | this.devices
526 | .get(events[i].data.id)
527 | .setState(State.IDLE);
528 | }
529 | break;
530 | case EventType.DEVICE_DISCONNECTED:
531 | if (this.devices.exists(events[i].data.id)) {
532 | this.devices
533 | .get(events[i].data.id)
534 | .setState(State.DISCONNECTED);
535 | }
536 | break;
537 | case EventType.PENDING_DEVICES_CHANGED:
538 | this.devices.destroy();
539 | this._callConfig();
540 | break;
541 | }
542 | this._lastEventID = events[i].id;
543 | } catch (error) {
544 | console.warn(
545 | LOG_PREFIX,
546 | "event processing failed",
547 | error.message
548 | );
549 | }
550 | }
551 | // Reschedule this event stream
552 | Utils.Timer.run(RESCHEDULE_EVENT_DELAY, () => {
553 | this._callEvents("since=" + this._lastEventID);
554 | });
555 | });
556 | }
557 |
558 | _callConnections() {
559 | this._openConnection("GET", "/rest/system/connections", (data) => {
560 | let devices = data.connections;
561 | for (let deviceID in devices) {
562 | if (this.devices.exists(deviceID) && deviceID != this._hostID) {
563 | if (devices[deviceID].connected) {
564 | this.devices.get(deviceID).setState(State.IDLE);
565 | } else if (devices[deviceID].paused) {
566 | this.devices.get(deviceID).setState(State.PAUSED);
567 | } else {
568 | this.devices.get(deviceID).setState(State.DISCONNECTED);
569 | }
570 | }
571 | }
572 | });
573 | }
574 |
575 | _processConfig(config) {
576 | // Only include devices which shares folders with this host
577 | let usedDevices = {};
578 | for (let i = 0; i < config.folders.length; i++) {
579 | let name = config.folders[i].label;
580 | if (name.length == 0) name = config.folders[i].id;
581 | if (!this.folders.exists(config.folders[i].id)) {
582 | let folder = new Folder(
583 | {
584 | id: config.folders[i].id,
585 | name: name,
586 | path: config.folders[i].path,
587 | },
588 | this
589 | );
590 | this.folders.add(folder);
591 | } else {
592 | this.folders.get(config.folders[i].id).setName(name);
593 | }
594 | if (config.folders[i].paused) {
595 | this.folders.get(config.folders[i].id).setState(State.PAUSED);
596 | } else {
597 | this._openConnection(
598 | "GET",
599 | "/rest/db/status?folder=" + config.folders[i].id,
600 | (function (folder) {
601 | return (data) => {
602 | folder.setState(data.state);
603 | };
604 | })(this.folders.get(config.folders[i].id))
605 | );
606 | }
607 | for (let j = 0; j < config.folders[i].devices.length; j++) {
608 | if (!(config.folders[i].devices[j].deviceID in usedDevices)) {
609 | usedDevices[config.folders[i].devices[j].deviceID] = [];
610 | }
611 | usedDevices[config.folders[i].devices[j].deviceID].push(
612 | this.folders.get(config.folders[i].id)
613 | );
614 | }
615 | }
616 | // TODO: remove / update old devices & folders, current destroy is way to invasive
617 | for (let i = 0; i < config.devices.length; i++) {
618 | if (config.devices[i].deviceID in usedDevices) {
619 | let device;
620 | if (!this.devices.exists(config.devices[i].deviceID)) {
621 | if (this._hostID == config.devices[i].deviceID) {
622 | device = new HostDevice(
623 | {
624 | id: config.devices[i].deviceID,
625 | name: config.devices[i].name,
626 | },
627 | this
628 | );
629 | } else {
630 | device = new Device(
631 | {
632 | id: config.devices[i].deviceID,
633 | name: config.devices[i].name,
634 | },
635 | this
636 | );
637 | }
638 | this.devices.add(device);
639 | for (
640 | let j = 0;
641 | j < usedDevices[config.devices[i].deviceID].length;
642 | j++
643 | ) {
644 | let folder = usedDevices[config.devices[i].deviceID][j];
645 | if (device != this.host) {
646 | let proxy = new FolderCompletionProxy({
647 | folder: folder,
648 | device: device,
649 | });
650 | if (folder.getState() != State.PAUSED) {
651 | this._openConnection(
652 | "GET",
653 | "/rest/db/completion?folder=" +
654 | proxy.id +
655 | "&device=" +
656 | device.id,
657 | (function (proxy) {
658 | return (data) => {
659 | proxy.setCompletion(
660 | data.completion
661 | );
662 | };
663 | })(proxy)
664 | );
665 | }
666 | folder = proxy;
667 | }
668 | device.folders.add(folder);
669 | }
670 | } else {
671 | device = this.devices.get(config.devices[i].deviceID);
672 | device.setName(config.devices[i].name);
673 | }
674 | }
675 | }
676 | this._callConnections();
677 | }
678 |
679 | async _pollState() {
680 | console.debug(
681 | LOG_PREFIX,
682 | "poll state",
683 | this._pollCount,
684 | this._pollCount % POLL_CONFIG_HOOK_COUNT,
685 | this._pollCount % POLL_CONNECTION_HOOK_COUNT
686 | );
687 | if (
688 | (await this._extensionConfig.exists()) &&
689 | (await this._isServiceActive())
690 | ) {
691 | if (this._pollCount % POLL_CONFIG_HOOK_COUNT == 0) {
692 | // TODO: this should not be necessary, we should remove old items
693 | this.folders.destroy();
694 | this.devices.destroy();
695 | this._callConfig();
696 | }
697 | if (this._pollCount % POLL_CONNECTION_HOOK_COUNT == 0) {
698 | await this._isServiceEnabled();
699 | this._callConnections();
700 | }
701 | this._openConnection("GET", "/rest/system/error", (data) => {
702 | let errorTime;
703 | let errors = data.errors;
704 | if (errors != null) {
705 | for (let i = 0; i < errors.length; i++) {
706 | errorTime = new Date(errors[i].when);
707 | if (errorTime > this._lastErrorTime) {
708 | this._lastErrorTime = errorTime;
709 | console.error(LOG_PREFIX, Error.SERVICE, errors[i]);
710 | this.emit(Signal.ERROR, {
711 | type: Error.SERVICE,
712 | message: errors[i].message,
713 | });
714 | }
715 | }
716 | }
717 | });
718 | } else {
719 | await this._isServiceEnabled();
720 | }
721 | this._pollCount++;
722 | }
723 |
724 | _setService(force = false) {
725 | // (Force) Copy systemd config file to systemd's configuration directory (if it doesn't exist)
726 | let systemDConfigPath = GLib.get_user_config_dir() + "/systemd/user";
727 | let systemDConfigFile = Service.NAME + ".service";
728 | let systemDConfigFileTo = Gio.File.new_for_path(
729 | systemDConfigPath + "/" + systemDConfigFile
730 | );
731 | if (force || !systemDConfigFileTo.query_exists(null)) {
732 | let systemDConfigFileFrom = Gio.File.new_for_path(
733 | this._extensionPath + "/" + systemDConfigFile
734 | );
735 | let systemdConfigDirectory =
736 | Gio.File.new_for_path(systemDConfigPath);
737 | if (!systemdConfigDirectory.query_exists(null)) {
738 | systemdConfigDirectory.make_directory_with_parents(null);
739 | }
740 | let copyFlag = Gio.FileCopyFlags.NONE;
741 | if (force) copyFlag = Gio.FileCopyFlags.OVERWRITE;
742 | if (
743 | systemDConfigFileFrom.copy(
744 | systemDConfigFileTo,
745 | copyFlag,
746 | null,
747 | null
748 | )
749 | ) {
750 | console.info(
751 | LOG_PREFIX,
752 | "systemd configuration file copied to " +
753 | systemDConfigFileTo
754 | );
755 | } else {
756 | console.warn(
757 | LOG_PREFIX,
758 | "couldn't copy systemd configuration file to " +
759 | systemDConfigFileTo
760 | );
761 | }
762 | }
763 | }
764 |
765 | async _isServiceActive() {
766 | let command = await this._serviceCommand(
767 | "is-active",
768 | this._serviceUserMode
769 | ),
770 | active = command == "active",
771 | failed = command == "failed";
772 | if (failed) {
773 | this._serviceActive = !failed;
774 | console.error(LOG_PREFIX, Error.DAEMON, Service.NAME);
775 | this.emit(Signal.ERROR, { type: Error.DAEMON });
776 | }
777 | console.info(
778 | LOG_PREFIX,
779 | "service active",
780 | this._serviceUserMode,
781 | active,
782 | this._serviceActive
783 | );
784 | if (active != this._serviceActive) {
785 | this._serviceActive = active;
786 | if (this._serviceUserMode) {
787 | this.emit(
788 | Signal.SERVICE_CHANGE,
789 | active
790 | ? ServiceState.USER_ACTIVE
791 | : ServiceState.USER_STOPPED
792 | );
793 | } else {
794 | this.emit(
795 | Signal.SERVICE_CHANGE,
796 | active
797 | ? ServiceState.SYSTEM_ACTIVE
798 | : ServiceState.SYSTEM_STOPPED
799 | );
800 | }
801 | if (this.host)
802 | this.host.setState(active ? State.IDLE : State.DISCONNECTED);
803 | }
804 | return active;
805 | }
806 |
807 | async _isServiceEnabled(user = true) {
808 | let command = await this._serviceCommand("is-enabled", user),
809 | enabled = command == "enabled",
810 | disabled = command == "disabled";
811 | if (!enabled && user) {
812 | return await this._isServiceEnabled(false);
813 | }
814 | console.debug(
815 | LOG_PREFIX,
816 | "service enabled",
817 | user,
818 | this._serviceUserMode,
819 | enabled,
820 | this._serviceEnabled,
821 | disabled
822 | );
823 | if (enabled != this._serviceEnabled) {
824 | this._serviceUserMode = user;
825 | this._serviceEnabled = enabled;
826 | if (this._serviceUserMode) {
827 | this.emit(
828 | Signal.SERVICE_CHANGE,
829 | enabled
830 | ? ServiceState.USER_ENABLED
831 | : ServiceState.USER_DISABLED
832 | );
833 | } else {
834 | this.emit(
835 | Signal.SERVICE_CHANGE,
836 | enabled
837 | ? ServiceState.SYSTEM_ENABLED
838 | : ServiceState.SYSTEM_DISABLED
839 | );
840 | }
841 | }
842 | return enabled;
843 | }
844 |
845 | async _serviceCommand(command, user = true) {
846 | let args = ["systemctl", command];
847 | if (user) {
848 | args.push(Service.NAME);
849 | args.push("--user");
850 | } else {
851 | args.push(Service.NAME + "@" + GLib.get_user_name());
852 | }
853 | let result;
854 | try {
855 | let proc = Gio.Subprocess.new(
856 | args,
857 | Gio.SubprocessFlags.STDOUT_PIPE
858 | );
859 | result = (await proc.communicate_utf8_async(null, null))
860 | .toString()
861 | .replace(/[^a-z].?/, "");
862 | } catch (error) {
863 | console.error(
864 | LOG_PREFIX,
865 | "calling systemd",
866 | command,
867 | user,
868 | args.toString(),
869 | error
870 | );
871 | this.emit(Signal.ERROR, { type: Error.DAEMON });
872 | result = "error";
873 | }
874 | console.debug(
875 | LOG_PREFIX,
876 | "calling systemd",
877 | command,
878 | user,
879 | args.toString(),
880 | result
881 | );
882 | return result;
883 | }
884 |
885 | _abortConnections() {
886 | this._httpAborting = true;
887 | this._httpSession.abort();
888 | }
889 |
890 | async _openConnection(method, path, callback) {
891 | if (await this._extensionConfig.exists()) {
892 | console.debug(
893 | LOG_PREFIX,
894 | "opening connection",
895 | method,
896 | this._extensionConfig.getURI() + path
897 | );
898 | let msg = Soup.Message.new(
899 | method,
900 | this._extensionConfig.getURI() + path
901 | );
902 | // Accept self signed certificates (for now)
903 | msg.connect("accept-certificate", () => {
904 | return true;
905 | });
906 | msg.request_headers.append(
907 | "X-API-Key",
908 | this._extensionConfig.getAPIKey()
909 | );
910 | this._openConnectionMessage(msg, callback);
911 | }
912 | }
913 |
914 | async _openConnectionMessage(msg, callback) {
915 | if ((await this._extensionConfig.exists()) && this._serviceActive) {
916 | console.debug(
917 | LOG_PREFIX,
918 | "opening connection",
919 | msg.method + ":" + msg.uri.get_path()
920 | );
921 | this._httpAborting = false;
922 | this._httpSession.send_and_read_async(
923 | msg,
924 | GLib.PRIORITY_DEFAULT,
925 | null,
926 | (session, result) => {
927 | let connected = false;
928 | if (msg.status_code == Soup.Status.OK) {
929 | connected = true;
930 | let response;
931 | try {
932 | response = new TextDecoder("utf-8").decode(
933 | session.send_and_read_finish(result).get_data()
934 | );
935 | } catch (error) {
936 | if (error.code == Gio.IOErrorEnum.TIMED_OUT) {
937 | console.info(
938 | LOG_PREFIX,
939 | error.message,
940 | "will retry",
941 | msg.method + ":" + msg.uri.get_path()
942 | );
943 | // Retry this connection attempt
944 | Utils.Timer.run(CONNECTION_RETRY_DELAY, () => {
945 | this._openConnectionMessage(msg, callback);
946 | });
947 | }
948 | }
949 | try {
950 | if (callback && response && response.length > 0) {
951 | console.debug(
952 | LOG_PREFIX,
953 | "callback",
954 | msg.method + ":" + msg.uri.get_path(),
955 | response
956 | );
957 | callback(JSON.parse(response));
958 | }
959 | } catch (error) {
960 | console.error(
961 | LOG_PREFIX,
962 | Error.STREAM,
963 | msg.method + ":" + msg.uri.get_path(),
964 | error.message,
965 | response
966 | );
967 | this.emit(Signal.ERROR, {
968 | type: Error.STREAM,
969 | message: msg.method + ":" + msg.uri.get_path(),
970 | });
971 | }
972 | } else if (!this._httpAborting) {
973 | this._httpErrorCount++;
974 | if (this._httpErrorCount >= HTTP_ERROR_RETRIES) {
975 | this._pollTimer.cancel();
976 | this._httpErrorCount = 0;
977 | connected = false;
978 | this.emit(
979 | Signal.SERVICE_CHANGE,
980 | ServiceState.ERROR
981 | );
982 | }
983 | console.error(
984 | LOG_PREFIX,
985 | Error.CONNECTION,
986 | msg.reason_phrase,
987 | msg.method + ":" + msg.get_uri().get_path(),
988 | msg.status_code,
989 | this._httpErrorCount
990 | );
991 | this.emit(Signal.ERROR, {
992 | type: Error.CONNECTION,
993 | message:
994 | msg.reason_phrase +
995 | " - " +
996 | msg.method +
997 | ":" +
998 | msg.get_uri().get_path(),
999 | });
1000 | }
1001 | if (
1002 | !this._httpAborting &&
1003 | connected != this._serviceConnected
1004 | ) {
1005 | this._serviceConnected = connected;
1006 | this.emit(
1007 | Signal.SERVICE_CHANGE,
1008 | connected
1009 | ? ServiceState.CONNECTED
1010 | : ServiceState.DISCONNECTED
1011 | );
1012 | }
1013 | }
1014 | );
1015 | }
1016 | }
1017 |
1018 | destroy() {
1019 | this._pollTimer.cancel();
1020 | this._extensionConfig.destroy();
1021 | this.folders.destroy();
1022 | this.devices.destroy();
1023 | }
1024 |
1025 | async attach() {
1026 | if (!(await this._extensionConfig.exists())) {
1027 | console.error(LOG_PREFIX, Error.CONFIG);
1028 | this.emit(Signal.SERVICE_CHANGE, ServiceState.ERROR);
1029 | this.emit(Signal.ERROR, { type: Error.CONFIG });
1030 | } else {
1031 | console.info(
1032 | LOG_PREFIX,
1033 | "attach manager",
1034 | await this._isServiceEnabled(),
1035 | await this._isServiceActive()
1036 | );
1037 | }
1038 | }
1039 |
1040 | async enableService() {
1041 | this._setService(true);
1042 | await this._serviceCommand("enable");
1043 | this._isServiceEnabled();
1044 | }
1045 |
1046 | async disableService() {
1047 | await this._serviceCommand("disable");
1048 | this._isServiceEnabled();
1049 | }
1050 |
1051 | async startService() {
1052 | this._setService();
1053 | await this._serviceCommand("start");
1054 | Utils.Timer.run(START_DELAY_TIME, () => {
1055 | this._isServiceActive();
1056 | });
1057 | }
1058 |
1059 | async stopService() {
1060 | this._abortConnections();
1061 | await this._serviceCommand("stop");
1062 | this._isServiceActive();
1063 | }
1064 |
1065 | getServiceURI() {
1066 | return this._extensionConfig.getURI();
1067 | }
1068 |
1069 | rescan(folder) {
1070 | if (folder) {
1071 | this._openConnection("POST", "/rest/db/scan?folder=" + folder.id);
1072 | } else {
1073 | this._openConnection("POST", "/rest/db/scan");
1074 | }
1075 | }
1076 |
1077 | resume(device) {
1078 | if (device) {
1079 | this._openConnection(
1080 | "POST",
1081 | "/rest/system/resume?device=" + device.id
1082 | );
1083 | }
1084 | }
1085 |
1086 | pause(device) {
1087 | if (device) {
1088 | this._openConnection(
1089 | "POST",
1090 | "/rest/system/pause?device=" + device.id
1091 | );
1092 | }
1093 | }
1094 | }
1095 |
--------------------------------------------------------------------------------
/src/syncthing.service:
--------------------------------------------------------------------------------
1 | [Unit]
2 | Description=Syncthing - Open Source Continuous File Synchronization
3 | Documentation=man:syncthing(1)
4 | StartLimitIntervalSec=60
5 | StartLimitBurst=4
6 |
7 | [Service]
8 | ExecStart=/usr/bin/syncthing serve --no-browser --no-restart --logflags=0
9 | Restart=on-failure
10 | RestartSec=1
11 | SuccessExitStatus=3 4
12 | RestartForceExitStatus=3 4
13 |
14 | # Hardening
15 | SystemCallArchitectures=native
16 | MemoryDenyWriteExecute=true
17 | NoNewPrivileges=true
18 |
19 | [Install]
20 | WantedBy=default.target
--------------------------------------------------------------------------------
/src/utils.js:
--------------------------------------------------------------------------------
1 | /* =============================================================================================================
2 | SyncthingManager 0.45
3 | ================================================================================================================
4 |
5 | GJS utils.
6 |
7 | Copyright (c) 2019-2025, 2nv2u
8 | This work is distributed under GPLv3, see LICENSE for more information.
9 | ============================================================================================================= */
10 |
11 | import GLib from "gi://GLib";
12 | const Signals = imports.signals;
13 |
14 | export class Timer {
15 | constructor(
16 | timeout,
17 | recurring = false,
18 | priority = GLib.PRIORITY_DEFAULT_IDLE
19 | ) {
20 | this._timeout = timeout;
21 | this._recurring = recurring;
22 | this._priority = priority;
23 | }
24 |
25 | run(
26 | callback,
27 | timeout = this._timeout,
28 | recurring = this._recurring,
29 | priority = this._priority
30 | ) {
31 | this.cancel();
32 | this._run(callback, timeout, recurring, priority);
33 | }
34 |
35 | _run(callback, timeout, recurring, priority) {
36 | if (!this._source || recurring) {
37 | this._source = GLib.timeout_source_new(timeout);
38 | this._source.set_priority(priority);
39 | this._source.set_callback(() => {
40 | callback();
41 | if (recurring) {
42 | this._run(callback, timeout, recurring, priority);
43 | } else {
44 | return GLib.SOURCE_REMOVE;
45 | }
46 | });
47 | }
48 | this._source.attach(null);
49 | }
50 |
51 | cancel() {
52 | if (this._source) {
53 | this._source.destroy();
54 | this._source = null;
55 | }
56 | }
57 |
58 | static run(
59 | timeout,
60 | callback,
61 | recurring = false,
62 | priority = GLib.PRIORITY_DEFAULT
63 | ) {
64 | return new Timer(timeout, recurring, priority).run(callback);
65 | }
66 | }
67 |
68 | export class Emitter {}
69 | Signals.addSignalMethods(Emitter.prototype);
70 |
--------------------------------------------------------------------------------