Refactor icons jammy (#108)

* chore: add icons and installation

* refactor: use the new battery icons

* refactor: use audio applet icons

* chore dependency cleanup

* chore: remove icons included in cosmic-icons package

* refactor: use icons for signal strength and fix handling of new connections

* fix: improve some logic for the networking applet

* chore: add cosmic-icons to Depends

* feat: use notifications icons

* chore: set bluetooth icon depending on state

* fix: set default font and text size

* feat (network): add airplane-mode message

* feat (battery): add display icons to the battery applet

* fix (battery): logic for selecting the battery icon & use new battery icons
This commit is contained in:
Ashley Wulber 2023-08-08 16:18:12 -04:00 • committed by GitHub
parent 76ce8838b5
commit 3ad64df5f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
77 changed files with 653 additions and 615 deletions

View file

@ -0,0 +1,12 @@
<svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_412_3870)">
<path d="M0 0.00701904H16V16.007H0V0.00701904Z" fill="#808080" fill-opacity="0.01"/>
<path d="M2 0.00701904C0 0.00701904 0 2.00702 0 2.00702V11.007C0 11.007 0 13.007 2 13.007H14C14 13.007 16 13.007 16 11.007V2.00702C16 2.00702 16 0.00701904 14 0.00701904H2ZM2 2.00702H14V10.007H2V2.00702ZM3 15.007V16.004H13V15.007C13 14.007 12 14.007 12 14.007H3.978C3.978 14.007 3 14.007 3 15.007Z" fill="#232323"/>
<path d="M13 3.00702H3V9.00702H13V3.00702Z" fill="#232323"/>
</g>
<defs>
<clipPath id="clip0_412_3870">
<rect width="16" height="16" fill="white" transform="translate(0 0.00701904)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 745 B

View file

@ -0,0 +1,13 @@
<svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_412_3869)">
<path d="M0 0.00701904H16V16.007H0V0.00701904Z" fill="#808080" fill-opacity="0.01"/>
<path d="M2 0.00701904C0 0.00701904 0 2.00702 0 2.00702V11.007C0 11.007 0 13.007 2 13.007H14C14 13.007 16 13.007 16 11.007V2.00702C16 2.00702 16 0.00701904 14 0.00701904H2ZM2 2.00702H14V10.007H2V2.00702ZM3 15.007V16.004H13V15.007C13 14.007 12 14.007 12 14.007H3.978C3.978 14.007 3 14.007 3 15.007Z" fill="#232323"/>
<path opacity="0.35" d="M13 3.00702H3V9.00702H13V3.00702Z" fill="#232323"/>
<path d="M13 7.00702H3V9.00702H13V7.00702Z" fill="#232323"/>
</g>
<defs>
<clipPath id="clip0_412_3869">
<rect width="16" height="16" fill="white" transform="translate(0 0.00701904)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 821 B

View file

@ -0,0 +1,13 @@
<svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_412_3868)">
<path d="M0 0.00701904H16V16.007H0V0.00701904Z" fill="#808080" fill-opacity="0.01"/>
<path d="M2 0.00701904C0 0.00701904 0 2.00702 0 2.00702V11.007C0 11.007 0 13.007 2 13.007H14C14 13.007 16 13.007 16 11.007V2.00702C16 2.00702 16 0.00701904 14 0.00701904H2ZM2 2.00702H14V10.007H2V2.00702ZM3 15.007V16.004H13V15.007C13 14.007 12 14.007 12 14.007H3.978C3.978 14.007 3 14.007 3 15.007Z" fill="#232323"/>
<path opacity="0.35" d="M13 3.00702H3V9.00702H13V3.00702Z" fill="#232323"/>
<path d="M13 5.00702H3V9.00702H13V5.00702Z" fill="#232323"/>
</g>
<defs>
<clipPath id="clip0_412_3868">
<rect width="16" height="16" fill="white" transform="translate(0 0.00701904)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 821 B

View file

@ -0,0 +1,12 @@
<svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_412_3867)">
<path d="M0 0.00701904H16V16.007H0V0.00701904Z" fill="#808080" fill-opacity="0.01"/>
<path d="M2 0.00701904C0 0.00701904 0 2.00702 0 2.00702V11.007C0 11.007 0 13.007 2 13.007H14C14 13.007 16 13.007 16 11.007V2.00702C16 2.00702 16 0.00701904 14 0.00701904H2ZM2 2.00702H14V10.007H2V2.00702ZM3 15.007V16.004H13V15.007C13 14.007 12 14.007 12 14.007H3.978C3.978 14.007 3 14.007 3 15.007Z" fill="#232323"/>
<path opacity="0.35" d="M13 8.00702H3V9.00702H13V8.00702Z" fill="#232323"/>
</g>
<defs>
<clipPath id="clip0_412_3867">
<rect width="16" height="16" fill="white" transform="translate(0 0.00701904)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 760 B

View file

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
<path d="M9 7H7V5L5 9H7V11L9 7Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 537 B

View file

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H10C10.5523 4 11 4.44772 11 5V11C11 11.5523 10.5523 12 10 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
<path d="M9 7H7V5L5 9H7V11L9 7Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 537 B

View file

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H10C10.5523 4 11 4.44772 11 5V11C11 11.5523 10.5523 12 10 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#F44336"/>
<path d="M5 5H7V8H5V5Z" fill="#F44336"/>
<circle cx="6" cy="10" r="1" fill="#F44336"/>
</svg>

After

Width:  |  Height:  |  Size: 574 B

View file

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#F44336"/>
<path d="M6 5H8V8H6V5Z" fill="#F44336"/>
<circle cx="7" cy="10" r="1" fill="#F44336"/>
</svg>

After

Width:  |  Height:  |  Size: 574 B

View file

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4L2 12Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
<path d="M9 7H7V5L5 9H7V11L9 7Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 645 B

View file

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4L2 12Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H10C10.5523 4 11 4.44772 11 5V11C11 11.5523 10.5523 12 10 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
<path d="M9 7H7V5L5 9H7V11L9 7Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 645 B

View file

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4L2 12Z" fill="#F44336"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H10C10.5523 4 11 4.44772 11 5V11C11 11.5523 10.5523 12 10 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#F44336"/>
</svg>

After

Width:  |  Height:  |  Size: 595 B

View file

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4L2 12Z" fill="#F44336"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#F44336"/>
</svg>

After

Width:  |  Height:  |  Size: 595 B

View file

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect opacity="0.35" x="1" y="12" width="8" height="12" rx="1" transform="rotate(-90 1 12)" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
<path d="M9 7H7V5L5 9H7V11L9 7Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 646 B

View file

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<rect opacity="0.35" x="1" y="12" width="8" height="12" rx="1" transform="rotate(-90 1 12)" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 596 B

View file

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4H3L3 12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
<path d="M9 7H7V5L5 9H7V11L9 7Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 649 B

View file

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4H3L3 12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H10C10.5523 4 11 4.44772 11 5V11C11 11.5523 10.5523 12 10 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
<path d="M9 7H7V5L5 9H7V11L9 7Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 649 B

View file

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4H3L3 12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H10C10.5523 4 11 4.44772 11 5V11C11 11.5523 10.5523 12 10 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 599 B

View file

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4H3L3 12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 599 B

View file

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4H5L5 12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
<path d="M9 7H7V5L5 9H7V11L9 7Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 649 B

View file

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4H5L5 12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H10C10.5523 4 11 4.44772 11 5V11C11 11.5523 10.5523 12 10 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
<path d="M9 7H7V5L5 9H7V11L9 7Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 649 B

View file

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4H5L5 12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H10C10.5523 4 11 4.44772 11 5V11C11 11.5523 10.5523 12 10 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 599 B

View file

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4H5L5 12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 599 B

View file

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4L2 12Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
<path d="M9 7H7V5L5 9H7V11L9 7Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 645 B

View file

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4L2 12Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H10C10.5523 4 11 4.44772 11 5V11C11 11.5523 10.5523 12 10 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
<path d="M9 7H7V5L5 9H7V11L9 7Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 645 B

View file

@ -0,0 +1,6 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4L2 12Z" fill="#F44336"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H10C10.5523 4 11 4.44772 11 5V11C11 11.5523 10.5523 12 10 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#F44336"/>
<path d="M5 5H7V8H5V5Z" fill="#F44336"/>
<circle cx="6" cy="10" r="1" fill="#F44336"/>
</svg>

After

Width:  |  Height:  |  Size: 682 B

View file

@ -0,0 +1,6 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4L2 12Z" fill="#F44336"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#F44336"/>
<path d="M6 5H8V8H6V5Z" fill="#F44336"/>
<circle cx="7" cy="10" r="1" fill="#F44336"/>
</svg>

After

Width:  |  Height:  |  Size: 682 B

View file

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4H7L7 12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
<path d="M9 7H7V5L5 9H7V11L9 7Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 649 B

View file

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4H7L7 12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H10C10.5523 4 11 4.44772 11 5V11C11 11.5523 10.5523 12 10 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
<path d="M9 7H7V5L5 9H7V11L9 7Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 649 B

View file

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4H7L7 12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H10C10.5523 4 11 4.44772 11 5V11C11 11.5523 10.5523 12 10 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 599 B

View file

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4H7L7 12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 599 B

View file

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4H9V12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
<path d="M9 7H7V5L5 9H7V11L9 7Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 647 B

View file

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4H9V12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H10C10.5523 4 11 4.44772 11 5V11C11 11.5523 10.5523 12 10 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
<path d="M9 7H7V5L5 9H7V11L9 7Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 647 B

View file

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4H9V12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H10C10.5523 4 11 4.44772 11 5V11C11 11.5523 10.5523 12 10 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 597 B

View file

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4H9V12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 597 B

View file

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4L11 4V12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
<path d="M9 7H7V5L5 9H7V11L9 7Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 650 B

View file

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4L11 4V12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H10C10.5523 4 11 4.44772 11 5V11C11 11.5523 10.5523 12 10 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
<path d="M9 7H7V5L5 9H7V11L9 7Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 650 B

View file

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4L11 4V12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H10C10.5523 4 11 4.44772 11 5V11C11 11.5523 10.5523 12 10 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 600 B

View file

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44772 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4L11 4V12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 600 B

View file

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44771 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4L12 4V12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
<path d="M9 7H7V5L5 9H7V11L9 7Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 650 B

View file

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path opacity="0.35" d="M2 12C1.44771 12 1 11.5523 1 11L1 5C1 4.44772 1.44772 4 2 4L12 4V12H2Z" fill="#232323"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 5C0 3.89543 0.895431 3 2 3H12C13.1046 3 14 3.89543 14 5V6L14.0018 6C15.1054 6 16 6.89543 16 8C16 9.10457 15.1054 10 14.0018 10L14 10V11C14 12.1046 13.1046 13 12 13H2C0.89543 13 0 12.1046 0 11V5ZM2 4H12C12.5523 4 13 4.44772 13 5V11C13 11.5523 12.5523 12 12 12H2C1.44772 12 1 11.5523 1 11V5C1 4.44772 1.44772 4 2 4Z" fill="#232323"/>
</svg>

After

Width:  |  Height:  |  Size: 600 B

View file

@ -55,9 +55,11 @@ static MAX_CHARGE: Lazy<id::Toggler> = Lazy::new(id::Toggler::unique);
#[derive(Clone, Default)]
struct CosmicBatteryApplet {
icon_name: String,
display_icon_name: String,
theme: Theme,
charging_limit: bool,
battery_percent: f64,
on_battery: bool,
time_remaining: Duration,
kbd_brightness: f64,
screen_brightness: f64,
@ -71,11 +73,65 @@ struct CosmicBatteryApplet {
timeline: Timeline,
}
impl CosmicBatteryApplet {
fn update_battery(&mut self, mut percent: f64, on_battery: bool) {
percent = percent.clamp(0.0, 100.0);
self.on_battery = on_battery;
self.battery_percent = percent;
let battery_percent = if self.battery_percent > 95.0 && !self.charging_limit {
100
} else if self.battery_percent > 80.0 && !self.charging_limit {
90
} else if self.battery_percent > 65.0 {
80
} else if self.battery_percent > 35.0 {
50
} else if self.battery_percent > 20.0 {
35
} else if self.battery_percent > 14.0 {
20
} else if self.battery_percent > 9.0 {
10
} else if self.battery_percent > 5.0 {
5
} else {
0
};
let limited = if self.charging_limit { "limited-" } else { "" };
let charging = if on_battery { "" } else { "charging-" };
self.icon_name =
format!("cosmic-applet-battery-level-{battery_percent}-{limited}{charging}symbolic",);
}
fn update_display(&mut self, mut percent: f64) {
percent = percent.clamp(0.01, 1.0);
self.screen_brightness = percent;
let screen_brightness = if self.screen_brightness < 0.011 {
"off"
} else if self.screen_brightness < 0.333 {
"low"
} else if self.screen_brightness < 0.666 {
"medium"
} else {
"high"
}
.to_string();
self.display_icon_name =
format!("cosmic-applet-battery-display-brightness-{screen_brightness}-symbolic",);
}
fn set_charging_limit(&mut self, limit: bool) {
self.charging_limit = limit;
self.update_battery(self.battery_percent, self.on_battery);
}
}
#[derive(Debug, Clone)]
enum Message {
TogglePopup,
Update {
icon_name: String,
on_battery: bool,
percent: f64,
time_to_empty: i64,
},
@ -108,6 +164,7 @@ impl Application for CosmicBatteryApplet {
(
CosmicBatteryApplet {
icon_name: "battery-symbolic".to_string(),
display_icon_name: "display-brightness-symbolic".to_string(),
applet_helper,
theme,
..Default::default()
@ -130,14 +187,14 @@ impl Application for CosmicBatteryApplet {
}
}
Message::SetScreenBrightness(brightness) => {
self.screen_brightness = (brightness as f64 / 100.0).clamp(0.01, 1.0);
self.update_display((brightness as f64 / 100.0).clamp(0.01, 1.0));
if let Some(tx) = &self.screen_sender {
let _ = tx.send(ScreenBacklightRequest::Set(self.screen_brightness));
}
}
Message::SetChargingLimit(chain, enable) => {
self.timeline.set_chain(chain).start();
self.charging_limit = enable;
self.set_charging_limit(enable);
}
Message::OpenBatterySettings => {
// TODO Ashley
@ -179,12 +236,11 @@ impl Application for CosmicBatteryApplet {
}
}
Message::Update {
icon_name,
on_battery,
percent,
time_to_empty,
} => {
self.icon_name = icon_name;
self.battery_percent = percent;
self.update_battery(percent, on_battery);
self.time_remaining = Duration::from_secs(time_to_empty as u64);
}
Message::UpdateKbdBrightness(b) => {
@ -199,10 +255,10 @@ impl Application for CosmicBatteryApplet {
Message::InitScreenBacklight(tx, brightness) => {
let _ = tx.send(ScreenBacklightRequest::Get);
self.screen_sender = Some(tx);
self.screen_brightness = brightness;
self.update_display(brightness);
}
Message::UpdateScreenBrightness(b) => {
self.screen_brightness = b;
self.update_display(b);
}
Message::InitProfile(tx, profile) => {
self.power_profile_sender.replace(tx);
@ -236,20 +292,16 @@ impl Application for CosmicBatteryApplet {
.into()
} else {
let name = text(fl!("battery")).size(14);
let description = text(
if "battery-full-charging-symbolic" == self.icon_name
|| "battery-full-charged-symbolic" == self.icon_name
{
format!("{}%", self.battery_percent)
} else {
format!(
"{} {} ({:.0}%)",
format_duration(self.time_remaining),
fl!("until-empty"),
self.battery_percent
)
},
)
let description = text(if !self.on_battery {
format!("{}%", self.battery_percent)
} else {
format!(
"{} {} ({:.0}%)",
format_duration(self.time_remaining),
fl!("until-empty"),
self.battery_percent
)
})
.size(10);
self.applet_helper
.popup_container(
@ -342,7 +394,7 @@ impl Application for CosmicBatteryApplet {
.width(Length::Fill)
.padding([0, 12]),
row![
icon("display-brightness-symbolic", 24).style(Svg::Symbolic),
icon(self.display_icon_name.as_str(), 24).style(Svg::Symbolic),
slider(
1..=100,
(self.screen_brightness * 100.0) as i32,
@ -393,11 +445,11 @@ impl Application for CosmicBatteryApplet {
self.applet_helper.theme_subscription(0).map(Message::Theme),
device_subscription(0).map(
|DeviceDbusEvent::Update {
icon_name,
on_battery,
percent,
time_to_empty,
}| Message::Update {
icon_name,
on_battery,
percent,
time_to_empty,
},

View file

@ -168,19 +168,20 @@ pub fn device_subscription<I: 'static + Hash + Copy + Send + Sync + Debug>(
#[derive(Debug)]
pub enum State {
Ready,
Waiting(DeviceProxy<'static>),
Waiting(UPowerProxy<'static>, DeviceProxy<'static>),
Finished,
}
async fn display_device() -> zbus::Result<DeviceProxy<'static>> {
async fn display_device() -> zbus::Result<(UPowerProxy<'static>, DeviceProxy<'static>)> {
let connection = zbus::Connection::system().await?;
let upower = UPowerProxy::new(&connection).await?;
let upower: UPowerProxy<'_> = UPowerProxy::new(&connection).await?;
let device_path = upower.get_display_device().await?;
DeviceProxy::builder(&connection)
.path(device_path)?
.cache_properties(zbus::CacheProperties::Yes)
.build()
.await
.map(|dp| (upower, dp))
}
async fn start_listening(
@ -189,11 +190,11 @@ async fn start_listening(
) -> State {
match state {
State::Ready => {
if let Ok(device) = display_device().await {
if let Ok((upower, device)) = display_device().await {
_ = output
.send(DeviceDbusEvent::Update {
icon_name: device
.cached_icon_name()
on_battery: upower
.cached_on_battery()
.unwrap_or_default()
.unwrap_or_default(),
percent: device
@ -206,13 +207,13 @@ async fn start_listening(
.unwrap_or_default(),
})
.await;
return State::Waiting(device);
return State::Waiting(upower, device);
}
State::Finished
}
State::Waiting(device) => {
State::Waiting(upower, device) => {
let mut stream = futures::stream_select!(
device.receive_icon_name_changed().await.map(|_| ()),
upower.receive_on_battery_changed().await.map(|_| ()),
device.receive_percentage_changed().await.map(|_| ()),
device.receive_time_to_empty_changed().await.map(|_| ()),
);
@ -220,8 +221,8 @@ async fn start_listening(
Some(_) => {
_ = output
.send(DeviceDbusEvent::Update {
icon_name: device
.cached_icon_name()
on_battery: upower
.cached_on_battery()
.unwrap_or_default()
.unwrap_or_default(),
percent: device
@ -235,7 +236,7 @@ async fn start_listening(
})
.await;
State::Waiting(device)
State::Waiting(upower, device)
}
None => State::Finished,
}
@ -247,7 +248,7 @@ async fn start_listening(
#[derive(Debug, Clone)]
pub enum DeviceDbusEvent {
Update {
icon_name: String,
on_battery: bool,
percent: f64,
time_to_empty: i64,
},