-
Notifications
You must be signed in to change notification settings - Fork 2
low battery alert #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unneccesory |
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unneccesory |
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks boring and don't match the existing look. Wallpaper based dynamic color mode deciding would be welcomed. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,25 @@ | ||
| @use "/home/shreyas/.cache/wal/colors.scss" as wal; | ||
| @use "./colors.scss" as wal; | ||
|
|
||
| .clock-container { | ||
| font-weight: bold; | ||
| font-family: Electroharmonix; | ||
| color: wal.$background; | ||
|
|
||
|
|
||
| } | ||
| .clock-time { | ||
| font-size: 100px; | ||
| font-size: 75px; | ||
| text-shadow: | ||
| -1px -1px 0 wal.$foreground, | ||
| 1px -1px 0 wal.$foreground, | ||
| -1px 1px 0 wal.$foreground, | ||
| 1px 1px 0 wal.$foreground; | ||
| } | ||
| .clock-date { | ||
| font-size: 25px; | ||
| text-shadow: | ||
| -1px -1px 0 rgba(wal.$foreground,0.5), | ||
| 1px -1px 0 rgba(wal.$foreground,0.5), | ||
| -1px 1px 0 rgba(wal.$foreground,0.5), | ||
| 1px 1px 0 rgba(wal.$foreground,0.5); | ||
| } |
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Repeatation of code |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| @use "./colors.scss" as wal; | ||
|
|
||
| .low-battery-box { | ||
| border: 4px solid rgba(#ff0000, 0.3); | ||
| background: wal.$background; | ||
| min-width: 200px; | ||
| min-height: 200px; | ||
| border-radius: 50%; | ||
| label { | ||
| font-family: "Electroharmonix", Times, serif; | ||
| color: wal.$color6; | ||
| font-size: 3rem; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| // SCSS Variables | ||
| // Generated by 'wal' | ||
| $wallpaper: "/home/abancp/Pictures/wallpapers/wallpapers/City/m01.jpg"; | ||
|
|
||
| // Special | ||
| $background: #071F34; | ||
| $foreground: #dba089; | ||
| $cursor: #dba089; | ||
|
|
||
| // Colors | ||
| $color0: #071F34; | ||
| $color1: #302F41; | ||
| $color2: #4B3641; | ||
| $color3: #6B4243; | ||
| $color4: #865636; | ||
| $color5: #AE4C2D; | ||
| $color6: #85613B; | ||
| $color7: #dba089; | ||
| $color8: #99705f; | ||
| $color9: #302F41; | ||
| $color10: #4B3641; | ||
| $color11: #6B4243; | ||
| $color12: #865636; | ||
| $color13: #AE4C2D; | ||
| $color14: #85613B; | ||
| $color15: #dba089; |
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Animation time should not be changed unless its necessory. Should include result with screenrecord |
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Animation is overused. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| import { App, Astal, Gtk, Gdk } from "astal/gtk3"; | ||
| import Battery from "gi://AstalBattery"; | ||
| import { bind } from "astal"; | ||
| import Gio from "gi://Gio"; | ||
| import GLib from "gi://GLib"; | ||
| import {playSound,fadeIn,fadeOut,exec} from "./ChargingAlert.tsx" | ||
|
|
||
|
|
||
| const battery = Battery.get_default() | ||
| let alertWindow = null; | ||
| let fadeInId = 0; | ||
| let fadeOutId = 0; | ||
| let timeoutId = 0; | ||
|
|
||
| export default function LowBatteryAlert(gdkmonitor: Gdk.Monitor) { | ||
| const battery = Battery.get_default(); | ||
| const homeDir = GLib.get_home_dir(); | ||
|
|
||
| const batteryPercentage = bind(battery, "percentage").as( | ||
| (val) => `${(val * 100).toFixed(0)}%`, | ||
| ); | ||
|
|
||
| const chargingIcon = bind(battery, "charging").as((val) => (val ? "" : "")); | ||
|
|
||
| const labelClass = bind(battery, "charging").as( | ||
| (val) => `charging-label${val ? "" : " not"}`, | ||
| ); | ||
|
|
||
| alertWindow = ( | ||
| <window | ||
| className="charging-widget" | ||
| gdkmonitor={gdkmonitor} | ||
| exclusivity={Astal.Exclusivity.IGNORE} | ||
| application={App} | ||
| layer={Astal.Layer.TOP} | ||
| visible={false} | ||
| opacity={0} | ||
| title="Charging Alert" | ||
| > | ||
| <box className="low-battery-box"> | ||
| <box | ||
| halign={Gtk.Align.CENTER} | ||
| valign={Gtk.Align.CENTER} | ||
| spacing={10} | ||
| hexpand={true} | ||
| vexpand={true} | ||
| > | ||
| <label label={chargingIcon} className="charging-label" /> | ||
| <label label={batteryPercentage} className={labelClass} /> | ||
| </box> | ||
| </box> | ||
| </window> | ||
| ); | ||
|
|
||
|
|
||
| battery.connect("notify::percentage", () => { | ||
| const per = battery.percentage; | ||
| log(per) | ||
| if(per == 0.15 && !battery.charging){ | ||
| playSound(`~/.config/ags/audio/unplug.mp3`); | ||
|
|
||
| fadeIn(alertWindow); | ||
|
|
||
| timeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 2500, () => { | ||
| fadeOut(alertWindow); | ||
| timeoutId = 0; | ||
| return GLib.SOURCE_REMOVE; | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
|
|
||
| return alertWindow; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not be in upstream branch.