about summary refs log tree commit diff
path: root/.local/bin/battery-screen
diff options
context:
space:
mode:
authorvenomade <venomade@venomade.com>2026-02-16 17:31:16 +0000
committervenomade <venomade@venomade.com>2026-02-16 17:31:16 +0000
commita568a964fd6a9efba388b2b4919339c0b7dfe51d (patch)
tree0c6adbf753de1c0b469e911668a82c6b2002f5f8 /.local/bin/battery-screen
parent9d2c3f898a97de16b986d4e494f31e6c6f3d176a (diff)
MacOS Nix HEAD master
Asahi is just not perfectly usable yet.
Moved stuff, went nix.
Diffstat (limited to '.local/bin/battery-screen')
-rwxr-xr-x.local/bin/battery-screen70
1 files changed, 0 insertions, 70 deletions
diff --git a/.local/bin/battery-screen b/.local/bin/battery-screen
deleted file mode 100755
index 26ac78a..0000000
--- a/.local/bin/battery-screen
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/env lua
-
-local function read(path)
-  local f = io.open(path)
-  if not f then return nil end
-  local v = tonumber(f:read('*l'))
-  f:close()
-  return v
-end
-
-local function batterytext()
-  local base        = '/sys/class/power_supply/macsmc-battery/'
-
-  local energy_now  = read(base .. 'energy_now')
-  local energy_full = read(base .. 'energy_full')
-  local status_f    = io.open(base .. 'status')
-
-  if not energy_now or not energy_full or not status_f then
-    return { { full_text = 'bat ?' } }
-  end
-
-  local status = status_f:read('*l')
-  status_f:close()
-
-  local capacity = math.floor(energy_now / energy_full * 100 + 0.5)
-
-  local text_color = '#ffffff'
-  local battery_symbol = ' '
-
-  if capacity < 30 then
-    text_color = '#ed8796'
-    battery_symbol = '󰁼'
-  elseif capacity > 70 then
-    text_color = '#a6da95'
-    battery_symbol = '󰂁'
-  else
-    text_color = '#eed49f'
-    battery_symbol = '󰁾'
-  end
-
-  local symbol = ({
-    Charging    = '󱐋',
-    Discharging = battery_symbol,
-  })[status] or ' '
-
-  return string.format('%s %2d%%', symbol, capacity), text_color
-end
-
-function hexToRgb(hex)
-  hex = hex:gsub("#", "")
-
-  local r = tonumber(hex:sub(1, 2), 16)
-  local g = tonumber(hex:sub(3, 4), 16)
-  local b = tonumber(hex:sub(5, 6), 16)
-
-  return r, g, b
-end
-
-function printHexColor(text, hex)
-  local r, g, b = hexToRgb(hex)
-  local colorCode = string.format("\27[38;2;%d;%d;%dm", r, g, b)
-  local resetCode = "\27[0m"
-
-  print(colorCode .. text .. resetCode)
-end
-
-while true do
-  printHexColor(batterytext())
-  os.execute("sleep 1")   -- Wait for 1 second
-end