diff options
| author | Wayne-Cole <77279425+Wacky404@users.noreply.github.com> | 2025-02-22 21:31:54 -0600 |
|---|---|---|
| committer | Wayne-Cole <77279425+Wacky404@users.noreply.github.com> | 2025-02-22 21:31:54 -0600 |
| commit | aa45aafa2ae7fd7405627c1b7eb6f5623fd1dd1c (patch) | |
| tree | 1ac96d2e50faa3c46be8aa4688f7b59d0ddedece | |
| parent | 6dd71581a38041cf69ebdf1de1e7f8529b78b0e1 (diff) | |
| download | wackys-dev-env-aa45aafa2ae7fd7405627c1b7eb6f5623fd1dd1c.tar.xz wackys-dev-env-aa45aafa2ae7fd7405627c1b7eb6f5623fd1dd1c.zip | |
feat: complete integration of aerospace and rewrite of sketchybar (usable)
| -rw-r--r-- | .config/aerospace/aerospace.toml | 10 | ||||
| -rw-r--r-- | .config/sketchybar/bar.lua | 3 | ||||
| -rw-r--r-- | .config/sketchybar/config/colors.lua | 8 | ||||
| -rw-r--r-- | .config/sketchybar/config/dimensions.lua | 2 | ||||
| -rw-r--r-- | .config/sketchybar/config/icons.lua | 93 | ||||
| -rw-r--r-- | .config/sketchybar/constants.lua | 1 | ||||
| -rw-r--r-- | .config/sketchybar/default.lua | 6 | ||||
| -rw-r--r-- | .config/sketchybar/install/sbar.lua | 2 | ||||
| -rw-r--r-- | .config/sketchybar/items/apple.lua | 6 | ||||
| -rw-r--r-- | .config/sketchybar/items/media.lua | 12 | ||||
| -rw-r--r-- | .config/sketchybar/items/menu_spaces_toggle.lua | 4 | ||||
| -rw-r--r-- | .config/sketchybar/items/menus.lua | 8 | ||||
| -rw-r--r-- | .config/sketchybar/items/message.lua | 4 | ||||
| -rw-r--r-- | .config/sketchybar/items/spaces.lua | 17 | ||||
| -rw-r--r-- | .config/sketchybar/items/widgets/battery.lua | 118 | ||||
| -rw-r--r-- | .config/sketchybar/items/widgets/cpu.lua | 53 | ||||
| -rw-r--r-- | .config/sketchybar/items/widgets/func_utils.lua | 26 | ||||
| -rw-r--r-- | .config/sketchybar/items/widgets/stocks.lua | 16 | ||||
| -rw-r--r-- | .config/sketchybar/items/widgets/volume.lua | 182 | ||||
| -rw-r--r-- | .config/sketchybar/items/widgets/wifi.lua | 237 |
20 files changed, 358 insertions, 450 deletions
diff --git a/.config/aerospace/aerospace.toml b/.config/aerospace/aerospace.toml index b0abe5e..c7c2dd4 100644 --- a/.config/aerospace/aerospace.toml +++ b/.config/aerospace/aerospace.toml @@ -118,7 +118,6 @@ automatically-unhide-macos-hidden-apps = true cmd-3 = 'workspace 3' cmd-4 = 'workspace 4' cmd-5 = 'workspace 5' - cmd-6 = 'workspace 6' # See: https://nikitabobko.github.io/AeroSpace/commands#move-node-to-workspace ctrl-1 = 'move-node-to-workspace 1' @@ -126,7 +125,6 @@ automatically-unhide-macos-hidden-apps = true ctrl-3 = 'move-node-to-workspace 3' ctrl-4 = 'move-node-to-workspace 4' ctrl-5 = 'move-node-to-workspace 5' - ctrl-6 = 'move-node-to-workspace 6' # See: https://nikitabobko.github.io/AeroSpace/commands#workspace-back-and-forth ctrl-tab = 'workspace-back-and-forth' @@ -156,6 +154,14 @@ automatically-unhide-macos-hidden-apps = true up = 'volume up' shift-down = ['volume set 0', 'mode main'] +# setting up multiple monitors, very much NEEDED! +[workspace-to-monitor-force-assignment] + 1 = '^built-in retina display$' + 2 = '^built-in retina display$' + 3 = '^built-in retina display$' + 4 = '^built-in retina display$' + 5 = ['secondary', 'C27F390', '^built-in retina display$'] + # make sure these apps are in floating win [[on-window-detected]] if .app-name-regex-substring = 'finder' diff --git a/.config/sketchybar/bar.lua b/.config/sketchybar/bar.lua index c22d4c1..ec92b13 100644 --- a/.config/sketchybar/bar.lua +++ b/.config/sketchybar/bar.lua @@ -2,9 +2,10 @@ local settings = require("config.settings") sbar.bar({ topmost = "window", - height = settings.dimensions.graphics.height, + height = settings.dimensions.graphics.bar.height, color = settings.colors.transparent, padding_right = settings.dimensions.paddings.right, + padding = settings.dimensions.paddings.bar, padding_left = settings.dimensions.paddings.left, margin = settings.dimensions.paddings.bar, corner_radius = settings.dimensions.graphics.background.corner_radius, diff --git a/.config/sketchybar/config/colors.lua b/.config/sketchybar/config/colors.lua index 22c4f27..4321c17 100644 --- a/.config/sketchybar/config/colors.lua +++ b/.config/sketchybar/config/colors.lua @@ -30,6 +30,10 @@ local colors <const> = { pink = Pink, purple = Purple, transparent = Transparent, + other_purple = 0xff302c45, + cyan = 0xff7bf2de, + dirty_white = 0xc8cad3f5, + dark_grey = 0xff2b2736, bar = { bg = 0xf02c2e34, @@ -39,6 +43,10 @@ local colors <const> = { bg = 0xc02c2e34, border = 0xff7f8490, }, + slider = { + bg = 0xf1151320, + border = 0xff2c2e34, + }, bg1 = 0xff363944, bg2 = 0xff414550, diff --git a/.config/sketchybar/config/dimensions.lua b/.config/sketchybar/config/dimensions.lua index f5fb211..d1c6df5 100644 --- a/.config/sketchybar/config/dimensions.lua +++ b/.config/sketchybar/config/dimensions.lua @@ -11,7 +11,7 @@ local paddings <const> = { local graphics <const> = { bar = { - height = 40, + height = 22.5, offset = 12, }, background = { diff --git a/.config/sketchybar/config/icons.lua b/.config/sketchybar/config/icons.lua index 6bbf155..9f367f1 100644 --- a/.config/sketchybar/config/icons.lua +++ b/.config/sketchybar/config/icons.lua @@ -282,42 +282,43 @@ local apps <const> = { local text <const> = { nerdfont = { - plus = "", - loading = "", - apple = "", - gear = "", + plus = "", + loading = "", + apple = "", + gear = "", cpu = "", - clipboard = "", + clipboard = "", + switch = { - on = "", - off = "", + on = "", + off = "", }, volume = { - _100 = "", - _66 = "", - _33 = "", - _10 = "", + _100 = "", + _66 = "", + _33 = "", + _10 = "", _0 = "", }, battery = { - _100 = "", - _75 = "", - _50 = "", - _25 = "", - _0 = "", - charging = "", + _100 = "", + _75 = "", + _50 = "", + _25 = "", + _0 = "", + charging = "", }, wifi = { - upload = "", - download = "", - connected = "", - disconnected = "", - router = "", + upload = "", + download = "", + connected = "", + disconnected = "", + router = "", }, media = { - back = "", - forward = "", - play_pause = "", + back = "", + forward = "", + play_pause = "", }, slider = { knob = "", @@ -363,48 +364,6 @@ local text <const> = { play_pause = "", }, }, - - -- Alternative NerdFont icons - nerdfont = { - plus = "", - loading = "", - apple = "", - gear = "", - cpu = "", - clipboard = "Missing Icon", - - switch = { - on = "", - off = "", - }, - volume = { - _100 = "", - _66 = "", - _33 = "", - _10 = "", - _0 = "", - }, - battery = { - _100 = "", - _75 = "", - _50 = "", - _25 = "", - _0 = "", - charging = "", - }, - wifi = { - upload = "", - download = "", - connected = "", - disconnected = "", - router = "Missing Icon", - }, - media = { - back = "", - forward = "", - play_pause = "", - }, - }, } return { text = text, diff --git a/.config/sketchybar/constants.lua b/.config/sketchybar/constants.lua index c3543b4..ef3af8d 100644 --- a/.config/sketchybar/constants.lua +++ b/.config/sketchybar/constants.lua @@ -18,6 +18,7 @@ local items <const> = { WIFI = "widgets.wifi", BATTERY = "widgets.battery", CALENDAR = "widgets.calendar", + CPU = "widgets.cpu", } local aerospace <const> = { diff --git a/.config/sketchybar/default.lua b/.config/sketchybar/default.lua index 93cee08..3a721ca 100644 --- a/.config/sketchybar/default.lua +++ b/.config/sketchybar/default.lua @@ -52,8 +52,8 @@ sbar.default({ slider = { highlight_color = settings.colors.orange, background = { - height = settings.dimens.graphics.slider.height, - corner_radius = settings.dimens.graphics.background.corner_radius, + height = settings.dimensions.graphics.slider.height, + corner_radius = settings.dimensions.graphics.background.corner_radius, color = settings.colors.slider.bg, border_color = settings.colors.slider.border, border_width = 1, @@ -64,7 +64,7 @@ sbar.default({ style = settings.fonts.styles.regular, size = 32, }, - string = settings.icons.text.slider.knob, + string = settings.icons.text.nerdfont.slider.knob, drawing = false, }, }, diff --git a/.config/sketchybar/install/sbar.lua b/.config/sketchybar/install/sbar.lua index 1150569..27e8bef 100644 --- a/.config/sketchybar/install/sbar.lua +++ b/.config/sketchybar/install/sbar.lua @@ -22,4 +22,4 @@ end package.cpath = package.cpath .. ";" .. sbarpath .. "?.so" -os.execute("(cd bridge && make)") +os.execute("(cd helpers && make)") diff --git a/.config/sketchybar/items/apple.lua b/.config/sketchybar/items/apple.lua index b134620..782e64b 100644 --- a/.config/sketchybar/items/apple.lua +++ b/.config/sketchybar/items/apple.lua @@ -1,7 +1,7 @@ local settings = require("config.settings") local apple = sbar.add("item", "apple", { - icon = { string = settings.icons.text.apple }, - label = { drawing = true }, - click_script = "$CONFIG_DIR/items/menus/bin/menus -s 0", + icon = { string = settings.icons.text.nerdfont.apple, font = { size = 20 } }, + label = { drawing = false }, + click_script = "$CONFIG_DIR/helpers/menus/bin/menus -s 0", }) diff --git a/.config/sketchybar/items/media.lua b/.config/sketchybar/items/media.lua index 31b7b60..144ef51 100644 --- a/.config/sketchybar/items/media.lua +++ b/.config/sketchybar/items/media.lua @@ -1,4 +1,4 @@ -local colors = require("config.colors") +local settings = require("config.settings") local whitelist = { ["Psst"] = true, @@ -11,7 +11,7 @@ local media_cover = sbar.add("item", { string = "media.artwork", scale = 0.80, }, - color = colors.transparent, + color = settings.colors.transparent, }, label = { drawing = false }, icon = { drawing = false }, @@ -33,7 +33,7 @@ local media_artist = sbar.add("item", { label = { width = 0, font = { size = 9 }, - color = colors.with_alpha(colors.white, 0.6), + color = settings.colors.with_alpha(settings.colors.white, 0.6), max_chars = 24, y_offset = 6, }, @@ -55,19 +55,19 @@ local media_title = sbar.add("item", { sbar.add("item", { position = "popup." .. media_cover.name, - icon = { string = icons.media.back }, + icon = { string = settings.icons.text.nerdfont.media.back }, label = { drawing = false }, click_script = "nowplaying-cli previous", }) sbar.add("item", { position = "popup." .. media_cover.name, - icon = { string = icons.media.play_pause }, + icon = { string = settings.icons.text.nerdfont.media.play_pause }, label = { drawing = false }, click_script = "nowplaying-cli togglePlayPause", }) sbar.add("item", { position = "popup." .. media_cover.name, - icon = { string = icons.media.forward }, + icon = { string = settings.icons.text.nerdfont.media.forward }, label = { drawing = false }, click_script = "nowplaying-cli next", }) diff --git a/.config/sketchybar/items/menu_spaces_toggle.lua b/.config/sketchybar/items/menu_spaces_toggle.lua index 0a49cce..643336d 100644 --- a/.config/sketchybar/items/menu_spaces_toggle.lua +++ b/.config/sketchybar/items/menu_spaces_toggle.lua @@ -17,7 +17,7 @@ end local function addToggle() local menuToggle = sbar.add("item", constants.items.MENU_TOGGLE, { icon = { - string = settings.icons.text.switch.on, + string = settings.icons.text.nerdfont.switch.on, }, label = { width = 0, @@ -30,7 +30,7 @@ local function addToggle() }) sbar.add("item", constants.items.MENU_TOGGLE .. ".padding", { - width = settings.dimens.padding.label, + width = settings.dimensions.paddings.label, }) menuToggle:subscribe("mouse.entered", function(env) diff --git a/.config/sketchybar/items/menus.lua b/.config/sketchybar/items/menus.lua index 805162a..6637f9e 100644 --- a/.config/sketchybar/items/menus.lua +++ b/.config/sketchybar/items/menus.lua @@ -26,7 +26,7 @@ local function createPlaceholders() style = index == 1 and settings.fonts.styles.bold or settings.fonts.styles.regular, }, }, - click_script = "$CONFIG_DIR/bridge/menus/bin/menus -s " .. index, + click_script = "$CONFIG_DIR/helpers/menus/bin/menus -s " .. index, }) menuItems[index] = menu end @@ -34,8 +34,8 @@ local function createPlaceholders() sbar.add("bracket", { "/" .. constants.items.MENU .. "\\..*/" }, { background = { color = settings.colors.bg1, - padding_left = settings.dimens.padding.item, - padding_right = settings.dimens.padding.item, + padding_left = settings.dimensions.paddings.item, + padding_right = settings.dimensions.paddings.item, }, }) end @@ -43,7 +43,7 @@ end local function updateMenus() sbar.set("/" .. constants.items.MENU .. "\\..*/", { drawing = false }) - sbar.exec("$CONFIG_DIR/bridge/menus/bin/menus -l", function(menus) + sbar.exec("$CONFIG_DIR/helpers/menus/bin/menus -l", function(menus) local index = 1 for menu in string.gmatch(menus, "[^\r\n]+") do if index < maxItems then diff --git a/.config/sketchybar/items/message.lua b/.config/sketchybar/items/message.lua index da04091..941b9cf 100644 --- a/.config/sketchybar/items/message.lua +++ b/.config/sketchybar/items/message.lua @@ -19,8 +19,8 @@ local messagePopup = sbar.add("item", { position = "popup." .. message.name, width = "dynamic", label = { - padding_right = settings.dimens.padding.label, - padding_left = settings.dimens.padding.label, + padding_right = settings.dimensions.paddings.label, + padding_left = settings.dimensions.paddings.label, }, icon = { padding_left = 0, diff --git a/.config/sketchybar/items/spaces.lua b/.config/sketchybar/items/spaces.lua index d8cec5f..7595df5 100644 --- a/.config/sketchybar/items/spaces.lua +++ b/.config/sketchybar/items/spaces.lua @@ -17,17 +17,10 @@ local currentWorkspaceWatcher = sbar.add("item", { -- copy "Icons" from the nerd fonts cheat sheet and replace icon and name accordingly below -- https://www.nerdfonts.com/cheat-sheet local spaceConfigs <const> = { - ["1"] = { icon = "", name = "Notes" }, - ["2"] = { icon = "", name = "Terminal" }, - ["3"] = { icon = "", name = "Browser" }, - ["4"] = { icon = "", name = "AltBrowser" }, - ["5"] = { icon = "", name = "Remote" }, - ["6"] = { icon = "", name = "Database" }, - ["7"] = { icon = "", name = "Chat" }, - ["8"] = { icon = "", name = "Mail" }, - ["9"] = { icon = "", name = "Music" }, - ["10"] = { icon = "", name = "Secrets" }, - ["t"] = { icon = "", name = "Meeting" }, + ["1"] = { icon = "", name = "iTerm2" }, + ["2"] = { icon = "", name = "Firefox" }, + ["3"] = { icon = "", name = "Notes" }, + ["4"] = { icon = "", name = "Secrets" }, } local function selectCurrentWorkspace(focusedWorkspaceName) @@ -85,7 +78,7 @@ local function addWorkspaceItem(workspaceName) end) sbar.add("item", spaceName .. ".padding", { - width = settings.dimens.padding.label, + width = settings.dimensions.paddings.label, }) end diff --git a/.config/sketchybar/items/widgets/battery.lua b/.config/sketchybar/items/widgets/battery.lua index 13356f1..35d1f36 100644 --- a/.config/sketchybar/items/widgets/battery.lua +++ b/.config/sketchybar/items/widgets/battery.lua @@ -1,6 +1,25 @@ -local icons = require("icons") -local settings = require("settings") -local sbar = require("sketchybar") +local constants = require("constants") +local settings = require("config.settings") + +local isCharging = false + +local battery = sbar.add("item", constants.items.battery, { + position = "right", + update_freq = 60, +}) + +local batteryPopup = sbar.add("item", { + position = "popup." .. battery.name, + width = "dynamic", + label = { + padding_right = settings.dimensions.paddings.label, + padding_left = settings.dimensions.paddings.label, + }, + icon = { + padding_left = 0, + padding_right = 0, + }, +}) function os.capture(cmd, raw) local file = assert(io.popen(cmd, "r")) @@ -18,43 +37,19 @@ function os.capture(cmd, raw) return output end -local battery = sbar.add("item", "widgets.battery", { - position = "right", - icon = { - font = { - style = settings.font.style_map["Regular"], - size = 19.0, - }, - }, - label = { font = { family = settings.font.numbers } }, - update_freq = 180, - popup = { align = "center" }, -}) - -local remaining_time = sbar.add("item", { - position = "popup." .. battery.name, - icon = { - string = "Time remaining:", - width = 100, - align = "left", - }, - label = { - string = "??:??h", - width = 100, - align = "right", - }, -}) - --- TODO: This is where the battery widget issue is occuring... local function battery_update() - Color = settings.batt_color_default - - local batt_info = os.capture("pmset -g batt", false) + local color = settings.colors.green local icon = "!" local label = "?" + local lead = "" + local batt_info = os.capture("pmset -g batt", true) if batt_info:find("AC Power") then - icon = icons.battery.charging + icon = settings.icons.text.nerdfont.battery.charging + local found, _, charge = batt_info:find("(%d+)%%") + if found then + label = charge .. "%" + end else local found, _, charge = batt_info:find("(%d+)%%") if found then @@ -62,32 +57,37 @@ local function battery_update() label = charge .. "%" end + if found and charge < 10 then + lead = "0" + end + if found and charge > 80 then - icon = icons.battery._100 + icon = settings.icons.text.nerdfont.battery._100 elseif found and charge > 60 then - icon = icons.battery._75 + icon = settings.icons.text.nerdfont.battery._75 elseif found and charge > 40 then - icon = icons.battery._50 + icon = settings.icons.text.nerdfont.battery._50 + elseif found and charge > 30 then + icon = settings.icons.text.nerdfont.battery._50 + color = settings.colors.yellow elseif found and charge > 20 then - icon = icons.battery._25 - Color = settings.batt_color_25 + icon = settings.icons.text.nerdfont.battery._25 + color = settings.colors.orange else - icon = icons.battery._0 - Color = settings.batt_color_0 + icon = settings.icons.text.nerdfont.battery._0 + color = settings.colors.red end end - -- TODO: Add in charging percentage - local lead = "" - if label == "?" then - label = "W" - end battery:set({ icon = { string = icon, - color = Color, + color = color, + }, + label = { + string = lead .. label, + padding_left = 0, }, - label = { string = lead .. label }, }) end @@ -95,23 +95,13 @@ battery:subscribe({ "routine", "power_source_change", "system_woke" }, battery_u battery:subscribe("mouse.clicked", function(env) local drawing = battery:query().popup.drawing + battery:set({ popup = { drawing = "toggle" } }) if drawing == "off" then - sbar.exec("pmset -g batt", function(batt_info) - local found, _, remaining = batt_info:find(" (%d+:%d+) remaining") - local label = found and remaining .. "h" or "No estimate" - remaining_time:set({ label = label }) - end) + local batteryInfo = os.capture("pmset -g batt", true) + local found, _, remaining = batteryInfo:find("(%d+:%d+) remaining") + local label = found and ("Time remaining: " .. remaining .. "h") or (isCharging and "Charging" or "No estimate") + batteryPopup:set({ label = label }) end end) - -sbar.add("bracket", "widgets.battery.bracket", { battery.name }, { - -- changes color of widget background - background = { color = settings.batt_background }, -}) - -sbar.add("item", "widgets.battery.padding", { - position = "right", - width = settings.group_paddings, -}) diff --git a/.config/sketchybar/items/widgets/cpu.lua b/.config/sketchybar/items/widgets/cpu.lua index 89b3647..ff19247 100644 --- a/.config/sketchybar/items/widgets/cpu.lua +++ b/.config/sketchybar/items/widgets/cpu.lua @@ -1,35 +1,40 @@ -local icons = require("icons") -local colors = require("colors") -local settings = require("settings") -local sbar = require("sketchybar") +local constants = require("constants") +local settings = require("config.settings") -- Execute the event provider binary which provides the event "cpu_update" for -- the cpu load data, which is fired every 2.0 seconds. sbar.exec("killall cpu_load >/dev/null; $CONFIG_DIR/helpers/event_providers/cpu_load/bin/cpu_load cpu_update 2.0") -local cpu = sbar.add("graph", "widgets.cpu", 42, { +local cpu = sbar.add("graph", constants.items.CPU, 42, { position = "right", - graph = { color = colors.blue }, + graph = { color = settings.colors.blue }, background = { - height = 22, + height = 16, color = { alpha = 0 }, border_color = { alpha = 0 }, drawing = true, }, - icon = { string = icons.cpu }, + icon = { string = settings.icons.text.nerdfont.cpu }, label = { string = "cpu ??%", font = { - family = settings.font.numbers, - style = settings.font.style_map["Bold"], - size = 9.0, + family = settings.fonts.text, + style = settings.fonts.styles.regular, + size = settings.dimensions.text.label, }, align = "right", + padding_left = settings.dimensions.paddings.label, padding_right = 0, - width = 0, - y_offset = 4, + y_offset = 0, }, - padding_right = settings.paddings + 6, + padding_right = 0, +}) + +-- Background around the cpu item +sbar.add("bracket", constants.items.CPU .. ".bracket", { + cpu.name, +}, { + popup = { align = "center" }, }) cpu:subscribe("cpu_update", function(env) @@ -37,14 +42,14 @@ cpu:subscribe("cpu_update", function(env) local load = tonumber(env.total_load) cpu:push({ load / 100. }) - local color = colors.blue + local color = settings.colors.blue if load > 30 then if load < 60 then - color = colors.yellow + color = settings.colors.yellow elseif load < 80 then - color = colors.orange + color = settings.colors.orange else - color = colors.red + color = settings.colors.red end end @@ -57,15 +62,3 @@ end) cpu:subscribe("mouse.clicked", function(env) sbar.exec("open -a 'Activity Monitor'") end) - --- Background around the cpu item -sbar.add("bracket", "widgets.cpu.bracket", { cpu.name }, { - -- changes color of background widget - background = { color = settings.cpu_background }, -}) - --- Background around the cpu item -sbar.add("item", "widgets.cpu.padding", { - position = "right", - width = settings.group_paddings, -}) diff --git a/.config/sketchybar/items/widgets/func_utils.lua b/.config/sketchybar/items/widgets/func_utils.lua deleted file mode 100644 index b60176d..0000000 --- a/.config/sketchybar/items/widgets/func_utils.lua +++ /dev/null @@ -1,26 +0,0 @@ -function os.capture(cmd, raw) - local file = assert(io.popen(cmd, "r")) - local output = assert(file:read("*a")) - file:close() - - if raw then - return output - end - - output = string.gsub(output, "^%s+", "") - output = string.gsub(output, "%s+$", "") - output = string.gsub(output, "[\n\r]+", "") - - return output -end - --- testing battery info here... works -Batt_info = os.capture("pmset -g batt", false) -if Batt_info:find("AC Power") then - print("Found AC Power in the string.") -else - local found, _, charge = Batt_info:find("(%d+)%%") - print("found: " .. found) - print("_: " .. _) - print("charge: " .. charge) -end diff --git a/.config/sketchybar/items/widgets/stocks.lua b/.config/sketchybar/items/widgets/stocks.lua deleted file mode 100644 index 073c6cb..0000000 --- a/.config/sketchybar/items/widgets/stocks.lua +++ /dev/null @@ -1,16 +0,0 @@ -local icons = require("icons") -local colors = require("colors") -local settings = require("settings") -local sbar = require("sketchybar") - -local popup_width = 250 - -local stock_icon = sbar.add("item", "widgets.stocks", { - position = "middle", - icon = { drawing = false }, - label = { - string = "$??.??", -- this needs to be formatted depending on the data - padding_left = -1, - font = { family = settings.font.numbers }, - }, -}) diff --git a/.config/sketchybar/items/widgets/volume.lua b/.config/sketchybar/items/widgets/volume.lua index ff6a88b..527b960 100644 --- a/.config/sketchybar/items/widgets/volume.lua +++ b/.config/sketchybar/items/widgets/volume.lua @@ -1,157 +1,133 @@ -local colors = require("colors") -local icons = require("icons") -local settings = require("settings") -local sbar = require("sketchybar") +local constants = require("constants") +local settings = require("config.settings") -local popup_width = 250 +local currentAudioDevice = "None" -local volume_percent = sbar.add("item", "widgets.volume1", { +local volumeValue = sbar.add("item", constants.items.VOLUME .. ".value", { position = "right", - icon = { drawing = false }, label = { string = "??%", - padding_left = -1, - font = { family = settings.font.numbers }, + padding_left = 0, }, }) -local volume_icon = sbar.add("item", "widgets.volume2", { - position = "right", - padding_right = -1, - icon = { - string = icons.volume._100, - width = 0, - align = "left", - color = colors.grey, - font = { - style = settings.font.style_map["Regular"], - size = 14.0, - }, - }, - label = { - width = 25, - align = "left", - font = { - style = settings.font.style_map["Regular"], - size = 14.0, - }, +local volumeBracket = sbar.add("bracket", constants.items.VOLUME .. ".bracket", { volumeValue.name }, { + popup = { + align = "center", }, }) -local volume_bracket = sbar.add("bracket", "widgets.volume.bracket", { - volume_icon.name, - volume_percent.name, -}, { - -- changes the background color of widget - background = { color = settings.volume_background }, - popup = { align = "center" }, -}) - -sbar.add("item", "widgets.volume.padding", { - position = "right", - width = settings.group_paddings, -}) - -local volume_slider = sbar.add("slider", popup_width, { - position = "popup." .. volume_bracket.name, - slider = { - highlight_color = colors.blue, - background = { - height = 6, - corner_radius = 3, - color = colors.bg2, - }, - knob = { - string = "", - drawing = true, - }, - }, - background = { color = colors.bg1, height = 2, y_offset = -20 }, +local volumeSlider = sbar.add("slider", constants.items.VOLUME .. ".slider", settings.dimensions.graphics.popup.width, { + position = "popup." .. volumeBracket.name, click_script = 'osascript -e "set volume output volume $PERCENTAGE"', }) -volume_percent:subscribe("volume_change", function(env) +volumeValue:subscribe("volume_change", function(env) + local icon = settings.icons.text.nerdfont.volume._0 local volume = tonumber(env.INFO) - local icon = icons.volume._0 - if volume > 60 then - icon = icons.volume._100 - elseif volume > 30 then - icon = icons.volume._66 - elseif volume > 10 then - icon = icons.volume._33 - elseif volume > 0 then - icon = icons.volume._10 - end - local lead = "" - if volume < 10 then - lead = "0" - end + sbar.exec("SwitchAudioSource -t output -c", function(result) + -- local currentOutputDevice = result:sub(1, -2) + -- if currentOutputDevice == "AirPods Max" then + -- icon = "" + -- elseif currentOutputDevice == "AirPods von Longdong Silver" or currentOutputDevice == "AirPods von Anna" then + -- icon = "" + -- elseif currentOutputDevice == "Arctis Nova Pro Wireless" then + -- icon = "" + -- elseif currentOutputDevice == "Ear (2)" then + -- icon = "" + -- elseif currentOutputDevice == "iD4" then + -- icon = "" + -- else + if volume > 60 then + icon = settings.icons.text.nerdfont.volume._100 + elseif volume > 30 then + icon = settings.icons.text.nerdfont.volume._66 + elseif volume > 10 then + icon = settings.icons.text.nerdfont.volume._33 + elseif volume > 0 then + icon = settings.icons.text.nerdfont.volume._10 + end + -- end + + local lead = "" + if volume < 10 then + lead = "0" + end - volume_icon:set({ label = icon }) - volume_percent:set({ label = lead .. volume .. "%" }) - volume_slider:set({ slider = { percentage = volume } }) + -- volumeIcon:set({ label = icon }) + volumeSlider:set({ slider = { percentage = volume } }) + + local hasVolume = volume ~= 0 + volumeValue:set({ + icon = icon, + label = { + string = hasVolume and lead .. volume .. "%" or "", + padding_right = hasVolume and 8 or 0, + }, + }) + end) end) -local function volume_collapse_details() - local drawing = volume_bracket:query().popup.drawing == "on" +local function hideVolumeDetails() + local drawing = volumeBracket:query().popup.drawing == "on" if not drawing then return end - volume_bracket:set({ popup = { drawing = false } }) - sbar.remove("/volume.device\\.*/") + volumeBracket:set({ popup = { drawing = false } }) + sbar.remove("/" .. constants.items.VOLUME .. ".device\\.*/") end -local current_audio_device = "None" -local function volume_toggle_details(env) +local function toggleVolumeDetails(env) if env.BUTTON == "right" then sbar.exec("open /System/Library/PreferencePanes/Sound.prefpane") return end - local should_draw = volume_bracket:query().popup.drawing == "off" - if should_draw then - volume_bracket:set({ popup = { drawing = true } }) + local shouldDraw = volumeBracket:query().popup.drawing == "off" + if shouldDraw then + volumeBracket:set({ popup = { drawing = true } }) + sbar.exec("SwitchAudioSource -t output -c", function(result) - current_audio_device = result:sub(1, -2) + currentAudioDevice = result:sub(1, -2) + sbar.exec("SwitchAudioSource -a -t output", function(available) - current = current_audio_device - local color = colors.grey + local current = currentAudioDevice local counter = 0 for device in string.gmatch(available, "[^\r\n]+") do - local color = colors.grey + local color = settings.colors.grey if current == device then - color = colors.white + color = settings.colors.white end - sbar.add("item", "volume.device." .. counter, { - position = "popup." .. volume_bracket.name, - width = popup_width, + + sbar.add("item", constants.items.VOLUME .. ".device." .. counter, { + position = "popup." .. volumeBracket.name, align = "center", label = { string = device, color = color }, click_script = 'SwitchAudioSource -s "' .. device - .. '" && sketchybar --set /volume.device\\.*/ label.color=' - .. colors.grey + .. '" && sketchybar --set /' + .. constants.items.VOLUME + .. ".device\\.*/ label.color=" + .. settings.colors.grey .. " --set $NAME label.color=" - .. colors.white, + .. settings.colors.white, }) counter = counter + 1 end end) end) else - volume_collapse_details() + hideVolumeDetails() end end -local function volume_scroll(env) +local function changeVolume(env) local delta = env.SCROLL_DELTA sbar.exec('osascript -e "set volume output volume (output volume of (get volume settings) + ' .. delta .. ')"') end -volume_icon:subscribe("mouse.clicked", volume_toggle_details) -volume_icon:subscribe("mouse.scrolled", volume_scroll) -volume_percent:subscribe("mouse.clicked", volume_toggle_details) -volume_percent:subscribe("mouse.exited.global", volume_collapse_details) -volume_percent:subscribe("mouse.scrolled", volume_scroll) +volumeValue:subscribe("mouse.clicked", toggleVolumeDetails) +volumeValue:subscribe("mouse.scrolled", changeVolume) +-- volumeValue:subscribe("mouse.exited.global", hideVolumeDetails) diff --git a/.config/sketchybar/items/widgets/wifi.lua b/.config/sketchybar/items/widgets/wifi.lua index c403343..75d72ae 100644 --- a/.config/sketchybar/items/widgets/wifi.lua +++ b/.config/sketchybar/items/widgets/wifi.lua @@ -1,202 +1,230 @@ -local icons = require("icons") -local colors = require("colors") -local settings = require("settings") -local sbar = require("sketchybar") +local constants = require("constants") +local settings = require("config.settings") + +local popupWidth <const> = settings.dimensions.graphics.popup.width + 20 --- Execute the event provider binary which provides the event "network_update" --- for the network interface "en0", which is fired every 2.0 seconds. sbar.exec( "killall network_load >/dev/null; $CONFIG_DIR/helpers/event_providers/network_load/bin/network_load en0 network_update 2.0" ) -local popup_width = 250 - -local wifi_up = sbar.add("item", "widgets.wifi1", { +local wifiUp = sbar.add("item", constants.items.WIFI .. ".up", { position = "right", - padding_left = -5, width = 0, icon = { + padding_left = 0, padding_right = 0, font = { - style = settings.font.style_map["Bold"], - size = 9.0, + style = settings.fonts.styles.bold, + size = 10.0, }, - string = icons.wifi.upload, + string = settings.icons.text.nerdfont.wifi.upload, }, label = { font = { - family = settings.font.numbers, - style = settings.font.style_map["Bold"], - size = 9.0, + family = settings.fonts.numbers, + style = settings.fonts.styles.bold, + size = 10.0, }, - color = colors.red, + color = settings.colors.orange, string = "??? Bps", }, y_offset = 4, }) -local wifi_down = sbar.add("item", "widgets.wifi2", { +local wifiDown = sbar.add("item", constants.items.WIFI .. ".down", { position = "right", - padding_left = -5, icon = { + padding_left = 0, padding_right = 0, font = { - style = settings.font.style_map["Bold"], - size = 9.0, + style = settings.fonts.styles.bold, + size = 10.0, }, - string = icons.wifi.download, + string = settings.icons.text.nerdfont.wifi.download, }, label = { font = { - family = settings.font.numbers, - style = settings.font.style_map["Bold"], - size = 9.0, + family = settings.fonts.numbers, + style = settings.fonts.styles.bold, + size = 10, }, - color = colors.blue, + color = settings.colors.blue, string = "??? Bps", }, y_offset = -4, }) -local wifi = sbar.add("item", "widgets.wifi.padding", { +local wifi = sbar.add("item", constants.items.WIFI .. ".padding", { position = "right", label = { drawing = false }, + padding_right = 0, }) --- Background around the item -local wifi_bracket = sbar.add("bracket", "widgets.wifi.bracket", { +local wifiBracket = sbar.add("bracket", constants.items.WIFI .. ".bracket", { wifi.name, - wifi_up.name, - wifi_down.name, + wifiUp.name, + wifiDown.name, }, { - -- changes the background color of widget - background = { color = settings.wifi_background }, - popup = { align = "center", height = 30 }, + popup = { align = "center" }, }) local ssid = sbar.add("item", { - position = "popup." .. wifi_bracket.name, + align = "center", + position = "popup." .. wifiBracket.name, + width = popupWidth, + height = 16, icon = { + string = settings.icons.text.nerdfont.wifi.router, font = { - style = settings.font.style_map["Bold"], + style = settings.fonts.styles.bold, }, - string = icons.wifi.router, }, - width = popup_width, - align = "center", label = { font = { - size = 15, - style = settings.font.style_map["Bold"], + style = settings.fonts.styles.bold, + size = settings.dimensions.text.label, }, max_chars = 18, string = "????????????", }, - background = { - height = 2, - color = colors.grey, - y_offset = -15, - }, }) local hostname = sbar.add("item", { - position = "popup." .. wifi_bracket.name, + position = "popup." .. wifiBracket.name, + background = { + height = 16, + }, icon = { align = "left", string = "Hostname:", - width = popup_width / 2, + width = popupWidth / 2, + font = { + size = settings.dimensions.text.label, + }, }, label = { max_chars = 20, string = "????????????", - width = popup_width / 2, + width = popupWidth / 2, align = "right", }, }) local ip = sbar.add("item", { - position = "popup." .. wifi_bracket.name, + position = "popup." .. wifiBracket.name, + background = { + height = 16, + }, icon = { align = "left", string = "IP:", - width = popup_width / 2, + width = popupWidth / 2, + font = { + size = settings.dimensions.text.label, + }, }, label = { - string = "???.???.???.???", - width = popup_width / 2, align = "right", - }, -}) - -local mask = sbar.add("item", { - position = "popup." .. wifi_bracket.name, - icon = { - align = "left", - string = "Subnet mask:", - width = popup_width / 2, - }, - label = { string = "???.???.???.???", - width = popup_width / 2, - align = "right", + width = popupWidth / 2, }, }) local router = sbar.add("item", { - position = "popup." .. wifi_bracket.name, + position = "popup." .. wifiBracket.name, + background = { + height = 16, + }, icon = { align = "left", string = "Router:", - width = popup_width / 2, + width = popupWidth / 2, + font = { + size = settings.dimensions.text.label, + }, }, label = { - string = "???.???.???.???", - width = popup_width / 2, align = "right", + string = "???.???.???.???", + width = popupWidth / 2, }, }) -sbar.add("item", { position = "right", width = settings.group_paddings }) +sbar.add("item", { position = "right", width = settings.dimensions.paddings.item }) + +wifiUp:subscribe("network_update", function(env) + local upColor = (env.upload == "000 Bps") and settings.colors.grey or settings.colors.orange + local downColor = (env.download == "000 Bps") and settings.colors.grey or settings.colors.blue -wifi_up:subscribe("network_update", function(env) - local up_color = (env.upload == "000 Bps") and colors.grey or colors.red - local down_color = (env.download == "000 Bps") and colors.grey or colors.blue - wifi_up:set({ - icon = { color = up_color }, + wifiUp:set({ + icon = { color = upColor }, label = { string = env.upload, - color = up_color, + color = upColor, }, }) - wifi_down:set({ - icon = { color = down_color }, + wifiDown:set({ + icon = { color = downColor }, label = { string = env.download, - color = down_color, + color = downColor, }, }) end) -wifi:subscribe({ "wifi_change", "system_woke" }, function(env) - sbar.exec("ipconfig getifaddr en0", function(ip) - local connected = not (ip == "") +wifi:subscribe({ "wifi_change", "system_woke", "forced" }, function(env) + wifi:set({ + icon = { + string = settings.icons.text.nerdfont.wifi.disconnected, + color = settings.colors.magenta, + }, + }) + + sbar.exec([[ipconfig getifaddr en0]], function(ip) + local ipConnected = not (ip == "") + + local wifiIcon + local wifiColor + + if ipConnected then + wifiIcon = settings.icons.text.nerdfont.wifi.connected + wifiColor = settings.colors.white + end + wifi:set({ icon = { - string = connected and icons.wifi.connected or icons.wifi.disconnected, - color = connected and colors.white or colors.red, + string = wifiIcon, + color = wifiColor, }, }) + + sbar.exec([[sleep 2; scutil --nwi | grep -m1 'utun' | awk '{ print $1 }']], function(vpn) + local isVPNConnected = not (vpn == "") + + if isVPNConnected then + wifiIcon = settings.icons.text.nerdfont.wifi.vpn + wifiColor = settings.colors.green + end + + wifi:set({ + icon = { + string = wifiIcon, + color = wifiColor, + }, + }) + end) end) end) -local function hide_details() - wifi_bracket:set({ popup = { drawing = false } }) +local function hideDetails() + wifiBracket:set({ popup = { drawing = false } }) end -local function toggle_details() - local should_draw = wifi_bracket:query().popup.drawing == "off" - if should_draw then - wifi_bracket:set({ popup = { drawing = true } }) +local function toggleDetails() + local shouldDrawDetails = wifiBracket:query().popup.drawing == "off" + + if shouldDrawDetails then + wifiBracket:set({ popup = { drawing = true } }) sbar.exec("networksetup -getcomputername", function(result) hostname:set({ label = result }) end) @@ -206,33 +234,28 @@ local function toggle_details() sbar.exec("ipconfig getsummary en0 | awk -F ' SSID : ' '/ SSID : / {print $2}'", function(result) ssid:set({ label = result }) end) - sbar.exec("networksetup -getinfo Wi-Fi | awk -F 'Subnet mask: ' '/^Subnet mask: / {print $2}'", function(result) - mask:set({ label = result }) - end) sbar.exec("networksetup -getinfo Wi-Fi | awk -F 'Router: ' '/^Router: / {print $2}'", function(result) router:set({ label = result }) end) else - hide_details() + hideDetails() end end -wifi_up:subscribe("mouse.clicked", toggle_details) -wifi_down:subscribe("mouse.clicked", toggle_details) -wifi:subscribe("mouse.clicked", toggle_details) -wifi:subscribe("mouse.exited.global", hide_details) - -local function copy_label_to_clipboard(env) +local function copyLabelToClipboard(env) local label = sbar.query(env.NAME).label.value sbar.exec('echo "' .. label .. '" | pbcopy') - sbar.set(env.NAME, { label = { string = icons.clipboard, align = "center" } }) + sbar.set(env.NAME, { label = { string = settings.icons.text.nerdfont.clipboard, align = "center" } }) sbar.delay(1, function() sbar.set(env.NAME, { label = { string = label, align = "right" } }) end) end -ssid:subscribe("mouse.clicked", copy_label_to_clipboard) -hostname:subscribe("mouse.clicked", copy_label_to_clipboard) -ip:subscribe("mouse.clicked", copy_label_to_clipboard) -mask:subscribe("mouse.clicked", copy_label_to_clipboard) -router:subscribe("mouse.clicked", copy_label_to_clipboard) +wifiUp:subscribe("mouse.clicked", toggleDetails) +wifiDown:subscribe("mouse.clicked", toggleDetails) +wifi:subscribe("mouse.clicked", toggleDetails) + +ssid:subscribe("mouse.clicked", copyLabelToClipboard) +hostname:subscribe("mouse.clicked", copyLabelToClipboard) +ip:subscribe("mouse.clicked", copyLabelToClipboard) +router:subscribe("mouse.clicked", copyLabelToClipboard) |
