tangled
alpha
login
or
join now
bwc9876.dev
/
nixos-config
1
fork
atom
Flake for my NixOS devices
1
fork
atom
overview
issues
pulls
pipelines
Fix battery notification script
bwc9876.dev
1 year ago
335239d1
fa2cb1ea
verified
This commit was signed with the committer's
known signature
.
bwc9876.dev
SSH Key Fingerprint:
SHA256:DanMEP/RNlSC7pAVbnXO6wzQV00rqyKj053tz4uH5gQ=
+3
-3
1 changed file
expand all
collapse all
unified
split
res
battery_notif.nu
+3
-3
res/battery_notif.nu
···
11
11
dbus get-all --system --dest=$BUS_NAME $"($PATH_PREFIX)/devices/($name)" $"($BUS_NAME).Device"
12
12
}
13
13
14
14
-
def should_consider [device: record] : bool -> bool {
14
14
+
def should_consider [device: record] {
15
15
match $device.Type {
16
16
2 => $device.PowerSupply, # Battery, we want to make sure PowerSupply is true to ensure it's a laptop battery
17
17
17 => true # Bluetooth Headset
···
20
20
}
21
21
22
22
23
23
-
def get_name [device: record] : string -> string {
23
23
+
def get_name [device: record] {
24
24
25
25
let fallback = "(" + ($device.upower_path | path basename) + ")";
26
26
···
50
50
$devices | each {|it| device_info ($it | path basename) | insert "upower_path" $it} | each {|it| $it | insert "friendly_name" (get_name $it)} | where {|it| should_consider $it}
51
51
}
52
52
53
53
-
def should_display_notif [device: record] : bool -> bool {
53
53
+
def should_display_notif [device: record] {
54
54
55
55
let charging = match ($device.State? | default 0) {
56
56
1 | 4 | 5 => true, # Charging or Fully Charged or Pending Charge