summaryrefslogtreecommitdiffstats
path: root/home-configuration/managed/fetchit/init.lua
diff options
context:
space:
mode:
authorcoast <coasteen@proton.me>2026-09-05 00:31:53 +0330
committercoast <coasteen@proton.me>2026-09-05 00:31:53 +0330
commitd14daa94de3c42da90f1bfc1ce6d9b26363530b3 (patch)
tree86cb6b5739b89f2a81fcca20bdfd660c838dac96 /home-configuration/managed/fetchit/init.lua
parent10275a033e0e3cac0e9f256e262948cbcb98894a (diff)
downloadnix-d14daa94de3c42da90f1bfc1ce6d9b26363530b3.tar.gz
nix-d14daa94de3c42da90f1bfc1ce6d9b26363530b3.tar.bz2
nix-d14daa94de3c42da90f1bfc1ce6d9b26363530b3.tar.xz
nix-d14daa94de3c42da90f1bfc1ce6d9b26363530b3.tar.zst
update
Diffstat (limited to 'home-configuration/managed/fetchit/init.lua')
-rw-r--r--home-configuration/managed/fetchit/init.lua70
1 files changed, 70 insertions, 0 deletions
diff --git a/home-configuration/managed/fetchit/init.lua b/home-configuration/managed/fetchit/init.lua
new file mode 100644
index 0000000..cb5c180
--- /dev/null
+++ b/home-configuration/managed/fetchit/init.lua
@@ -0,0 +1,70 @@
+local function run(cmd)
+ local f = io.popen(cmd)
+ local out = f:read("*a")
+ f:close()
+ return out:gsub("%s+$", "")
+end
+
+local use_color = true
+
+local function c(fn, text)
+ if use_color then
+ return fn(text)
+ end
+ return text
+end
+
+column_padding = 2
+
+local config_dir = os.getenv("HOME") .. "/.config/fetchit"
+
+local function load_logo(path)
+ local lines = {}
+ for line in io.lines(path) do
+ table.insert(lines, line)
+ end
+ return lines
+end
+
+local function colored_logo(path)
+ local lines = load_logo(path)
+ local out = {}
+ for i, line in ipairs(lines) do
+ out[i] = c(color.blue, line)
+ end
+ return out
+end
+
+function fetch()
+ local ip = run("ip -4 -o addr show scope global | awk '{print $4}' | cut -d/ -f1 | head -1")
+ local title = user.name .. "@" .. host.name
+ local sep = string.rep("-", #title)
+
+ local title_out
+ if use_color then
+ title_out = color.green(user.name) .. color.bold(color.green("@")) .. color.green(host.name)
+ else
+ title_out = user.name .. color.bold(color.blue("@")) .. host.name
+ end
+
+ return {
+ columns = {
+ colored_logo(config_dir .. "/logos/nix.txt"),
+ {
+ title_out,
+ sep,
+ c(color.cyan, "os: ") .. string.lower(os.name .. " @ " .. kernel.sysname .. " " .. kernel.release),
+ c(color.cyan, "wm: ") .. "niri wm (v26.04)",
+ c(color.cyan, "res: ") .. "(<)/1920x1080, (>)/1920x1080",
+ c(color.red, "cpu: ") .. "ryzen 7 5700g",
+ c(color.red, "gpu: ") .. "radeon rx 6800xt",
+ c(color.magenta, "ram: ") ..
+ string.format("%.1fgb/%.1fgb (%.1f%%)", memory.used_gb, memory.total_gb, memory.percent),
+ c(color.yellow, "disk: ") .. string.format("%.1fgb/%.1fgb", disk.used_gb, disk.total_gb),
+ c(color.blue, "shell: ") .. string.lower(shell.name),
+ c(color.bright_cyan, "term: ") .. string.lower(terminal.name),
+ c(color.red, "ip: ") .. string.lower(ip),
+ }
+ }
+ }
+end