From 790ca2c632c44d46f4d6693b4903b325c4e02ec5 Mon Sep 17 00:00:00 2001 From: Sukant Hajra Date: Sat, 20 Jan 2024 13:15:20 -0600 Subject: [PATCH] f --- flake.lock | 6 ++-- flake.nix | 2 +- .../xdg/configFile/sketchybar/colors.lua | 6 ++-- .../xdg/configFile/sketchybar/icons.lua | 26 ++++++++------- .../configFile/sketchybar/items/battery.lua | 33 +++++++++++-------- .../configFile/sketchybar/items/spaces.lua | 10 ++---- .../xdg/configFile/sketchybar/items/yabai.lua | 19 ++++------- 7 files changed, 50 insertions(+), 52 deletions(-) diff --git a/flake.lock b/flake.lock index 3c30b45b..529639ce 100644 --- a/flake.lock +++ b/flake.lock @@ -1431,13 +1431,13 @@ "sf-symbols": { "flake": false, "locked": { - "narHash": "sha256-53aF5NbuuFo+2pukPER9SVEL2VKawlaEyObc8W10DJo=", + "narHash": "sha256-NElDo3Y+V5wiW7aJzY+wdEQ82Q750mQjKgrCVHunhkg=", "type": "file", - "url": "https://devimages-cdn.apple.com/design/resources/download/SF-Symbols-5.dmg" + "url": "https://devimages-cdn.apple.com/design/resources/download/SF-Symbols-5.1.dmg" }, "original": { "type": "file", - "url": "https://devimages-cdn.apple.com/design/resources/download/SF-Symbols-5.dmg" + "url": "https://devimages-cdn.apple.com/design/resources/download/SF-Symbols-5.1.dmg" } }, "shajra-private": { diff --git a/flake.nix b/flake.nix index 358256ef..bde96fff 100644 --- a/flake.nix +++ b/flake.nix @@ -23,7 +23,7 @@ lieer = { url = github:gauteh/lieer; flake = false; }; moneydance = { url = tarball+https://infinitekind.com/stabledl/current/moneydance-linux.tar.gz; flake = false; }; pointless-xcompose = { url = github:leoboiko/pointless-xcompose; flake = false; }; - sf-symbols = { url = https://devimages-cdn.apple.com/design/resources/download/SF-Symbols-5.dmg; flake = false; }; + sf-symbols = { url = https://devimages-cdn.apple.com/design/resources/download/SF-Symbols-5.1.dmg; flake = false; }; sketchybar-font-dist = { url = https://github.com/kvndrsslr/sketchybar-app-font/releases/download/v1.0.23/sketchybar-app-font.ttf; flake = false; }; sketchybar-font-src = { url = github:kvndrsslr/sketchybar-app-font; flake = false; }; sketchybar-lua = { url = github:FelixKratz/SbarLua; flake = false; }; diff --git a/home/modules/base/gui/darwin/xdg/configFile/sketchybar/colors.lua b/home/modules/base/gui/darwin/xdg/configFile/sketchybar/colors.lua index 3c67b40a..5fb47074 100644 --- a/home/modules/base/gui/darwin/xdg/configFile/sketchybar/colors.lua +++ b/home/modules/base/gui/darwin/xdg/configFile/sketchybar/colors.lua @@ -1,8 +1,8 @@ return { unifying = tonumber("@colors_unifying@"), - info = tonumber("@colors_info@"), - warning = tonumber("@colors_warning@"), - urgent = tonumber("@colors_urgent@"), + info = tonumber("@colors_info@"), + warning = tonumber("@colors_warning@"), + urgent = tonumber("@colors_urgent@"), primary = { background = tonumber("@colors_primary_bg@"), foreground = tonumber("@colors_primary_fg@") diff --git a/home/modules/base/gui/darwin/xdg/configFile/sketchybar/icons.lua b/home/modules/base/gui/darwin/xdg/configFile/sketchybar/icons.lua index 6152b897..c571800c 100644 --- a/home/modules/base/gui/darwin/xdg/configFile/sketchybar/icons.lua +++ b/home/modules/base/gui/darwin/xdg/configFile/sketchybar/icons.lua @@ -1,28 +1,30 @@ return { - loading = "􀖇", apple = "􀣺", + battery = { + _0 = "􀛪", + _25 = "􀛩", + _50 = "􀺶", + _75 = "􀺸", + _100 = "􀛨", + charging = "􀢋" -- unused for now + }, + cake = "🍰", + cake = "􁖩", + plug = {charging = "􀡸", not_charging = "􀡷􀊅"}, preferences = "􀺽", volume = { _100 = "􀊩", _66 = "􀊧", _33 = "􀊥", _10 = "􀊡", - _0 = "􀊣", + _0 = "􀊣" }, wifi = {connected = "􀙇", disconnected = "􀙈"}, - battery = { - _100 = "􀛨", - _75 = "􀺸", - _50 = "􀺶", - _25 = "􀛩", - _0 = "􀛪", - charging = "􀢋", - }, yabai = { stack = "􀏭", fullscreen_zoom = "􀏜", parent_zoom = "􀥃", float = "􀢌", - grid = "􀧍", - }, + grid = "􀧍" -- unused for now + } } diff --git a/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/battery.lua b/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/battery.lua index 9cdfe306..bcb9f59b 100644 --- a/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/battery.lua +++ b/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/battery.lua @@ -10,29 +10,36 @@ local function battery_update() local handle = assert(io.popen("pmset -g batt")) local batt_info = assert(handle:read("a")) handle:close() - local icon = "!" - - if (string.find(batt_info, 'AC Power')) then - icon = icons.battery.charging - else - local found, _, charge = batt_info:find("(%d+)%%") - if found then charge = tonumber(charge) end + local plug_icon = "" + if string.find(batt_info, 'AC attached; not charging') then + plug_icon = icons.plug.not_charging + elseif string.find(batt_info, '; charging') then + plug_icon = icons.plug.charging + end - if found and charge > 80 then + local label = "" + local battery_icon = "􁁕" + local charge_found, _, charge = batt_info:find("(%d+)%%") + if charge_found then + label = charge + charge = tonumber(charge) + if charge > 80 then icon = icons.battery._100 - elseif found and charge > 60 then + elseif charge > 60 then icon = icons.battery._75 - elseif found and charge > 40 then + elseif charge > 40 then icon = icons.battery._50 - elseif found and charge > 20 then + elseif charge > 20 then icon = icons.battery._25 else icon = icons.battery._0 end end - - battery:set({icon = icon}) + battery:set({icon = plug_icon .. battery_icon, label = label}) end battery:subscribe({"routine", "power_source_change", "system_woke"}, battery_update) + +battery:subscribe("mouse.clicked", + function(env) battery:set({label = {drawing = true}}) end) diff --git a/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/spaces.lua b/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/spaces.lua index b1dd5398..be6def58 100644 --- a/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/spaces.lua +++ b/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/spaces.lua @@ -39,18 +39,14 @@ local function space_windows_change(env) if next(app_emojis) ~= nil then icon_strip = table.concat(app_emojis, " ") end - sbar.animate("tanh", 10, function() - sbar.set(spaces[space], {label = icon_strip}) - end) + sbar.animate("tanh", 10, + function() sbar.set(spaces[space], {label = icon_strip}) end) end for i = 1, 10, 1 do local space = sbar.add("space", { associated_space = i, - background = { - color = colors.unselected.background, - corner_radius = 6 - }, + background = {color = colors.unselected.background, corner_radius = 6}, icon = { string = i, padding_left = 10, diff --git a/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/yabai.lua b/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/yabai.lua index 2fc380ce..15e19d74 100644 --- a/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/yabai.lua +++ b/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/yabai.lua @@ -2,30 +2,23 @@ local icons = require("icons") local colors = require("colors") local yabai = sbar.add("item", { - icon = { - color = colors.info, - font = {style = "Bold"}, - width = 0, - }, - label = { - color = colors.info, - width = 0, - }, + icon = {color = colors.info, font = {style = "Bold"}, width = 0}, + label = {color = colors.info, width = 0} }) yabai:subscribe("window_focus", function(env) local icon = icons.yabai[env.STATE] or "" local label = "" if env.STATE == "stack" then - label = "[" .. env.STACK_INDEX .. "/" .. env.STACK_LAST .. "]" + label = "[" .. env.STACK_INDEX .. "/" .. env.STACK_LAST .. "]" end local icon_width, label_width = 0, 0 - if icon ~= "" then icon_width = 30 end + if icon ~= "" then icon_width = 30 end if label ~= "" then label_width = 40 end sbar.animate("sin", 10, function() yabai:set({ - icon = { string = icon, width = icon_width }, - label = { string = label, width = label_width }, + icon = {string = icon, width = icon_width}, + label = {string = label, width = label_width} }) end) end)