format lua files

This commit is contained in:
Ray Andrew 2025-04-08 23:41:12 -05:00
parent 1efeda4130
commit b9eea0f86b
Signed by: rayandrew
SSH key fingerprint: SHA256:XYrYrxF0Z3A72n8P/p6mqPRNQZT22F88XcLsG+kX4xw
14 changed files with 636 additions and 627 deletions

View file

@ -1,5 +1,7 @@
local function with_alpha(color, alpha)
if alpha > 1.0 or alpha < 0.0 then return color end
if alpha > 1.0 or alpha < 0.0 then
return color
end
return (color & 0x00ffffff) | (math.floor(alpha * 255.0) << 24)
end

View file

@ -14,11 +14,11 @@ local icons = {
off = "􁏯",
},
volume = {
_100="􀊩",
_66="􀊧",
_33="􀊥",
_10="􀊡",
_0="􀊣",
_100 = "􀊩",
_66 = "􀊧",
_33 = "􀊥",
_10 = "􀊡",
_0 = "􀊣",
},
battery = {
_100 = "􀛨",
@ -26,7 +26,7 @@ local icons = {
_50 = "􀺶",
_25 = "􀛩",
_0 = "􀛪",
charging = "􀢋"
charging = "􀢋",
},
wifi = {
upload = "􀄨",
@ -56,11 +56,11 @@ local icons = {
off = "󱨦",
},
volume = {
_100="",
_66="",
_33="",
_10="",
_0="",
_100 = "",
_66 = "",
_33 = "",
_10 = "",
_0 = "",
},
battery = {
_100 = "",
@ -68,14 +68,14 @@ local icons = {
_50 = "",
_25 = "",
_0 = "",
charging = ""
charging = "",
},
wifi = {
upload = "",
download = "",
connected = "󰖩",
disconnected = "󰖪",
router = "Missing Icon"
router = "Missing Icon",
},
media = {
back = "",

View file

@ -7,11 +7,15 @@ local settings = require("settings")
local app_icons = require("app_icons")
local function getAllWorkspaces()
return utils.sbarExecP("aerospace list-workspaces --all --format '%{workspace}%{monitor-appkit-nsscreen-screens-id}%{monitor-id}%{monitor-name}' --json")
return utils.sbarExecP(
"aerospace list-workspaces --all --format '%{workspace}%{monitor-appkit-nsscreen-screens-id}%{monitor-id}%{monitor-name}' --json"
)
end
local function getVisibleWorkspaces()
return utils.sbarExecP("aerospace list-workspaces --visible --monitor all --format '%{workspace}%{monitor-appkit-nsscreen-screens-id}%{monitor-id}%{monitor-name}' --json")
return utils.sbarExecP(
"aerospace list-workspaces --visible --monitor all --format '%{workspace}%{monitor-appkit-nsscreen-screens-id}%{monitor-id}%{monitor-name}' --json"
)
end
local function getAllWindows()
@ -110,11 +114,10 @@ local function updateState()
return Promise.reject("State is already updating")
end
local function highlightSpace(space, space_padding, space_bracket, selected)
space:set({
drawing = true,
icon = { highlight = selected, },
icon = { highlight = selected },
label = { highlight = selected },
-- background = { border_color = selected and colors.white or colors.bg2 }
})
@ -192,7 +195,8 @@ local function updateStateAndSync()
end
function setup()
getAllWorkspaces():thenCall(function(workspaces)
getAllWorkspaces()
:thenCall(function(workspaces)
for _, workspace in ipairs(workspaces) do
local workspaceid = workspace["workspace"]
local display = getMonitorId(workspace)

View file

@ -20,7 +20,7 @@ local apple = sbar.add("item", {
},
padding_left = 1,
padding_right = 1,
click_script = "sk-menus -s 0"
click_script = "sk-menus -s 0",
})
-- Double border for apple using a single item bracket

View file

@ -6,7 +6,7 @@ local battery = sbar.add("item", {
font = {
style = "Regular",
size = 19.0,
}
},
},
label = { drawing = false },
update_freq = 120,
@ -16,7 +16,7 @@ local function battery_update()
sbar.exec("pmset -g batt", function(batt_info)
local icon = "!"
if (string.find(batt_info, 'AC Power')) then
if string.find(batt_info, "AC Power") then
icon = icons.battery.charging
else
local found, _, charge = batt_info:find("(%d+)%%")
@ -41,5 +41,4 @@ local function battery_update()
end)
end
battery:subscribe({"routine", "power_source_change", "system_woke"}, battery_update)
battery:subscribe({ "routine", "power_source_change", "system_woke" }, battery_update)

View file

@ -45,6 +45,6 @@ sbar.add("item", { position = "right", width = settings.group_paddings })
cal:subscribe({ "forced", "routine", "system_woke" }, function(env)
cal:set({
icon = os.date("􀉉 %B %d %a"),
label = os.date("􀐫 %I:%M %p") -- 12-hour format with AM/PM
label = os.date("􀐫 %I:%M %p"), -- 12-hour format with AM/PM
})
end)

View file

@ -6,7 +6,7 @@ local settings = require("settings")
-- the cpu load data, which is fired every 2.0 seconds.
sbar.exec("killall sk-cpu-load >/dev/null; sk-cpu-load cpu_update 2.0")
local cpu = sbar.add("graph", "widgets.cpu" , 42, {
local cpu = sbar.add("graph", "widgets.cpu", 42, {
position = "right",
graph = { color = colors.blue },
background = {
@ -26,9 +26,9 @@ local cpu = sbar.add("graph", "widgets.cpu" , 42, {
align = "right",
padding_right = 0,
width = 0,
y_offset = 4
y_offset = 4,
},
padding_right = settings.paddings + 6
padding_right = settings.paddings + 6,
})
cpu:subscribe("cpu_update", function(env)
@ -59,11 +59,11 @@ end)
-- Background around the cpu item
sbar.add("bracket", "widgets.cpu.bracket", { cpu.name }, {
background = { color = colors.bg1 }
background = { color = colors.bg1 },
})
-- Background around the cpu item
sbar.add("item", "widgets.cpu.padding", {
position = "right",
width = settings.group_paddings
width = settings.group_paddings,
})

View file

@ -2,21 +2,21 @@ local settings = require("settings")
local front_app = sbar.add("item", {
icon = {
drawing = false
drawing = false,
},
label = {
font = {
style = settings.font.style_map["Bold"],
size = 12.0,
}
}
},
},
})
front_app:subscribe("front_app_switched", function(env)
front_app:set({
label = {
string = env.INFO:upper()
}
string = env.INFO:upper(),
},
})
-- Or equivalently:

View file

@ -22,7 +22,7 @@ for i = 1, max_items, 1 do
icon = { drawing = false },
label = {
font = {
style = settings.font.style_map[i == 1 and "Heavy" or "Semibold"]
style = settings.font.style_map[i == 1 and "Heavy" or "Semibold"],
},
padding_left = 6,
padding_right = 6,
@ -33,24 +33,26 @@ for i = 1, max_items, 1 do
menu_items[i] = menu
end
sbar.add("bracket", { '/menu\\..*/' }, {
background = { color = colors.bg1 }
sbar.add("bracket", { "/menu\\..*/" }, {
background = { color = colors.bg1 },
})
local menu_padding = sbar.add("item", "menu.padding", {
drawing = false,
width = 5
width = 5,
})
local function update_menus(env)
sbar.exec("sk-menus -l", function(menus)
sbar.set('/menu\\..*/', { drawing = false })
sbar.set("/menu\\..*/", { drawing = false })
menu_padding:set({ drawing = true })
id = 1
for menu in string.gmatch(menus, '[^\r\n]+') do
for menu in string.gmatch(menus, "[^\r\n]+") do
if id < max_items then
menu_items[id]:set( { label = menu, drawing = true } )
else break end
menu_items[id]:set({ label = menu, drawing = true })
else
break
end
id = id + 1
end
end)
@ -61,12 +63,12 @@ menu_watcher:subscribe("front_app_switched", update_menus)
space_menu_swap:subscribe("swap_menus_and_spaces", function(env)
local drawing = menu_items[1]:query().geometry.drawing == "on"
if drawing then
menu_watcher:set( { updates = false })
menu_watcher:set({ updates = false })
sbar.set("/menu\\..*/", { drawing = false })
sbar.set("/space\\..*/", { drawing = true })
sbar.set("front_app", { drawing = true })
else
menu_watcher:set( { updates = true })
menu_watcher:set({ updates = true })
sbar.set("/space\\..*/", { drawing = false })
sbar.set("front_app", { drawing = false })
update_menus()

View file

@ -14,7 +14,7 @@ local volume_slider = sbar.add("slider", 100, {
corner_radius = 3,
color = colors.bg2,
},
knob= {
knob = {
string = "􀀁",
drawing = false,
},
@ -66,7 +66,7 @@ end)
local function animate_slider_width(width)
sbar.animate("tanh", 30.0, function()
volume_slider:set({ slider = { width = width }})
volume_slider:set({ slider = { width = width } })
end)
end

View file

@ -64,17 +64,17 @@ local wifi = sbar.add("item", "widgets.wifi.padding", {
local wifi_bracket = sbar.add("bracket", "widgets.wifi.bracket", {
wifi.name,
wifi_up.name,
wifi_down.name
wifi_down.name,
}, {
-- background = { color = colors.bar.bg },
popup = { align = "center", height = 30 }
popup = { align = "center", height = 30 },
})
local ssid = sbar.add("item", {
position = "popup." .. wifi_bracket.name,
icon = {
font = {
style = settings.font.style_map["Bold"]
style = settings.font.style_map["Bold"],
},
string = icons.wifi.router,
},
@ -83,7 +83,7 @@ local ssid = sbar.add("item", {
label = {
font = {
size = 15,
style = settings.font.style_map["Bold"]
style = settings.font.style_map["Bold"],
},
max_chars = 18,
string = "????????????",
@ -91,8 +91,8 @@ local ssid = sbar.add("item", {
background = {
height = 2,
color = colors.bar.bg,
y_offset = -15
}
y_offset = -15,
},
})
local hostname = sbar.add("item", {
@ -107,7 +107,7 @@ local hostname = sbar.add("item", {
string = "????????????",
width = popup_width / 2,
align = "right",
}
},
})
local ip = sbar.add("item", {
@ -121,7 +121,7 @@ local ip = sbar.add("item", {
string = "???.???.???.???",
width = popup_width / 2,
align = "right",
}
},
})
local mask = sbar.add("item", {
@ -135,7 +135,7 @@ local mask = sbar.add("item", {
string = "???.???.???.???",
width = popup_width / 2,
align = "right",
}
},
})
local router = sbar.add("item", {
@ -161,19 +161,19 @@ wifi_up:subscribe("network_update", function(env)
icon = { color = up_color },
label = {
string = env.upload,
color = up_color
}
color = up_color,
},
})
wifi_down:set({
icon = { color = down_color },
label = {
string = env.download,
color = down_color
}
color = down_color,
},
})
end)
wifi:subscribe({"wifi_change", "system_woke"}, function(env)
wifi:subscribe({ "wifi_change", "system_woke" }, function(env)
sbar.exec("ipconfig getifaddr en0", function(ip)
local connected = not (ip == "")
wifi:set({
@ -192,7 +192,7 @@ end
local function toggle_details()
local should_draw = wifi_bracket:query().popup.drawing == "off"
if should_draw then
wifi_bracket:set({ popup = { drawing = true }})
wifi_bracket:set({ popup = { drawing = true } })
sbar.exec("networksetup -getcomputername", function(result)
hostname:set({ label = result })
end)
@ -220,8 +220,8 @@ wifi:subscribe("mouse.exited.global", hide_details)
local function copy_label_to_clipboard(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.exec('echo "' .. label .. '" | pbcopy')
sbar.set(env.NAME, { label = { string = icons.clipboard, align = "center" } })
sbar.delay(1, function()
sbar.set(env.NAME, { label = { string = label, align = "right" } })
end)

View file

@ -87,7 +87,9 @@
{ pkgs, ... }:
treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs.nixfmt-rfc-style.enable = true;
programs.nixfmt.enable = true;
programs.stylua.enable = true;
programs.shfmt.enable = true;
settings.global.excludes = [ "flake.lock" ];
}
);
@ -137,7 +139,7 @@
sops
age
ssh-to-age
nixfmt-rfc-style
# nixfmt-rfc-style
];
DIRENV_LOG_FORMAT = "";
};