Flake for my NixOS devices

Fix battery notification script

bwc9876.dev 335239d1 fa2cb1ea

verified
+3 -3
+3 -3
res/battery_notif.nu
··· 11 dbus get-all --system --dest=$BUS_NAME $"($PATH_PREFIX)/devices/($name)" $"($BUS_NAME).Device" 12 } 13 14 - def should_consider [device: record] : bool -> bool { 15 match $device.Type { 16 2 => $device.PowerSupply, # Battery, we want to make sure PowerSupply is true to ensure it's a laptop battery 17 17 => true # Bluetooth Headset ··· 20 } 21 22 23 - def get_name [device: record] : string -> string { 24 25 let fallback = "(" + ($device.upower_path | path basename) + ")"; 26 ··· 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 } 52 53 - def should_display_notif [device: record] : bool -> bool { 54 55 let charging = match ($device.State? | default 0) { 56 1 | 4 | 5 => true, # Charging or Fully Charged or Pending Charge
··· 11 dbus get-all --system --dest=$BUS_NAME $"($PATH_PREFIX)/devices/($name)" $"($BUS_NAME).Device" 12 } 13 14 + def should_consider [device: record] { 15 match $device.Type { 16 2 => $device.PowerSupply, # Battery, we want to make sure PowerSupply is true to ensure it's a laptop battery 17 17 => true # Bluetooth Headset ··· 20 } 21 22 23 + def get_name [device: record] { 24 25 let fallback = "(" + ($device.upower_path | path basename) + ")"; 26 ··· 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 } 52 53 + def should_display_notif [device: record] { 54 55 let charging = match ($device.State? | default 0) { 56 1 | 4 | 5 => true, # Charging or Fully Charged or Pending Charge