format lua files
This commit is contained in:
parent
1efeda4130
commit
b9eea0f86b
14 changed files with 636 additions and 627 deletions
|
|
@ -1,5 +1,7 @@
|
||||||
local function with_alpha(color, alpha)
|
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)
|
return (color & 0x00ffffff) | (math.floor(alpha * 255.0) << 24)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,11 @@ local icons = {
|
||||||
off = "",
|
off = "",
|
||||||
},
|
},
|
||||||
volume = {
|
volume = {
|
||||||
_100="",
|
_100 = "",
|
||||||
_66="",
|
_66 = "",
|
||||||
_33="",
|
_33 = "",
|
||||||
_10="",
|
_10 = "",
|
||||||
_0="",
|
_0 = "",
|
||||||
},
|
},
|
||||||
battery = {
|
battery = {
|
||||||
_100 = "",
|
_100 = "",
|
||||||
|
|
@ -26,7 +26,7 @@ local icons = {
|
||||||
_50 = "",
|
_50 = "",
|
||||||
_25 = "",
|
_25 = "",
|
||||||
_0 = "",
|
_0 = "",
|
||||||
charging = ""
|
charging = "",
|
||||||
},
|
},
|
||||||
wifi = {
|
wifi = {
|
||||||
upload = "",
|
upload = "",
|
||||||
|
|
@ -56,11 +56,11 @@ local icons = {
|
||||||
off = "",
|
off = "",
|
||||||
},
|
},
|
||||||
volume = {
|
volume = {
|
||||||
_100="",
|
_100 = "",
|
||||||
_66="",
|
_66 = "",
|
||||||
_33="",
|
_33 = "",
|
||||||
_10="",
|
_10 = "",
|
||||||
_0="",
|
_0 = "",
|
||||||
},
|
},
|
||||||
battery = {
|
battery = {
|
||||||
_100 = "",
|
_100 = "",
|
||||||
|
|
@ -68,14 +68,14 @@ local icons = {
|
||||||
_50 = "",
|
_50 = "",
|
||||||
_25 = "",
|
_25 = "",
|
||||||
_0 = "",
|
_0 = "",
|
||||||
charging = ""
|
charging = "",
|
||||||
},
|
},
|
||||||
wifi = {
|
wifi = {
|
||||||
upload = "",
|
upload = "",
|
||||||
download = "",
|
download = "",
|
||||||
connected = "",
|
connected = "",
|
||||||
disconnected = "",
|
disconnected = "",
|
||||||
router = "Missing Icon"
|
router = "Missing Icon",
|
||||||
},
|
},
|
||||||
media = {
|
media = {
|
||||||
back = "",
|
back = "",
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,15 @@ local settings = require("settings")
|
||||||
local app_icons = require("app_icons")
|
local app_icons = require("app_icons")
|
||||||
|
|
||||||
local function getAllWorkspaces()
|
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
|
end
|
||||||
|
|
||||||
local function getVisibleWorkspaces()
|
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
|
end
|
||||||
|
|
||||||
local function getAllWindows()
|
local function getAllWindows()
|
||||||
|
|
@ -110,11 +114,10 @@ local function updateState()
|
||||||
return Promise.reject("State is already updating")
|
return Promise.reject("State is already updating")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function highlightSpace(space, space_padding, space_bracket, selected)
|
local function highlightSpace(space, space_padding, space_bracket, selected)
|
||||||
space:set({
|
space:set({
|
||||||
drawing = true,
|
drawing = true,
|
||||||
icon = { highlight = selected, },
|
icon = { highlight = selected },
|
||||||
label = { highlight = selected },
|
label = { highlight = selected },
|
||||||
-- background = { border_color = selected and colors.white or colors.bg2 }
|
-- background = { border_color = selected and colors.white or colors.bg2 }
|
||||||
})
|
})
|
||||||
|
|
@ -192,7 +195,8 @@ local function updateStateAndSync()
|
||||||
end
|
end
|
||||||
|
|
||||||
function setup()
|
function setup()
|
||||||
getAllWorkspaces():thenCall(function(workspaces)
|
getAllWorkspaces()
|
||||||
|
:thenCall(function(workspaces)
|
||||||
for _, workspace in ipairs(workspaces) do
|
for _, workspace in ipairs(workspaces) do
|
||||||
local workspaceid = workspace["workspace"]
|
local workspaceid = workspace["workspace"]
|
||||||
local display = getMonitorId(workspace)
|
local display = getMonitorId(workspace)
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ local apple = sbar.add("item", {
|
||||||
},
|
},
|
||||||
padding_left = 1,
|
padding_left = 1,
|
||||||
padding_right = 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
|
-- Double border for apple using a single item bracket
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ local battery = sbar.add("item", {
|
||||||
font = {
|
font = {
|
||||||
style = "Regular",
|
style = "Regular",
|
||||||
size = 19.0,
|
size = 19.0,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
label = { drawing = false },
|
label = { drawing = false },
|
||||||
update_freq = 120,
|
update_freq = 120,
|
||||||
|
|
@ -16,7 +16,7 @@ local function battery_update()
|
||||||
sbar.exec("pmset -g batt", function(batt_info)
|
sbar.exec("pmset -g batt", function(batt_info)
|
||||||
local icon = "!"
|
local icon = "!"
|
||||||
|
|
||||||
if (string.find(batt_info, 'AC Power')) then
|
if string.find(batt_info, "AC Power") then
|
||||||
icon = icons.battery.charging
|
icon = icons.battery.charging
|
||||||
else
|
else
|
||||||
local found, _, charge = batt_info:find("(%d+)%%")
|
local found, _, charge = batt_info:find("(%d+)%%")
|
||||||
|
|
@ -41,5 +41,4 @@ local function battery_update()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
battery:subscribe({ "routine", "power_source_change", "system_woke" }, battery_update)
|
||||||
battery:subscribe({"routine", "power_source_change", "system_woke"}, battery_update)
|
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,6 @@ sbar.add("item", { position = "right", width = settings.group_paddings })
|
||||||
cal:subscribe({ "forced", "routine", "system_woke" }, function(env)
|
cal:subscribe({ "forced", "routine", "system_woke" }, function(env)
|
||||||
cal:set({
|
cal:set({
|
||||||
icon = os.date(" %B %d %a"),
|
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)
|
end)
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ local settings = require("settings")
|
||||||
-- the cpu load data, which is fired every 2.0 seconds.
|
-- 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")
|
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",
|
position = "right",
|
||||||
graph = { color = colors.blue },
|
graph = { color = colors.blue },
|
||||||
background = {
|
background = {
|
||||||
|
|
@ -26,9 +26,9 @@ local cpu = sbar.add("graph", "widgets.cpu" , 42, {
|
||||||
align = "right",
|
align = "right",
|
||||||
padding_right = 0,
|
padding_right = 0,
|
||||||
width = 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)
|
cpu:subscribe("cpu_update", function(env)
|
||||||
|
|
@ -59,11 +59,11 @@ end)
|
||||||
|
|
||||||
-- Background around the cpu item
|
-- Background around the cpu item
|
||||||
sbar.add("bracket", "widgets.cpu.bracket", { cpu.name }, {
|
sbar.add("bracket", "widgets.cpu.bracket", { cpu.name }, {
|
||||||
background = { color = colors.bg1 }
|
background = { color = colors.bg1 },
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Background around the cpu item
|
-- Background around the cpu item
|
||||||
sbar.add("item", "widgets.cpu.padding", {
|
sbar.add("item", "widgets.cpu.padding", {
|
||||||
position = "right",
|
position = "right",
|
||||||
width = settings.group_paddings
|
width = settings.group_paddings,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -2,21 +2,21 @@ local settings = require("settings")
|
||||||
|
|
||||||
local front_app = sbar.add("item", {
|
local front_app = sbar.add("item", {
|
||||||
icon = {
|
icon = {
|
||||||
drawing = false
|
drawing = false,
|
||||||
},
|
},
|
||||||
label = {
|
label = {
|
||||||
font = {
|
font = {
|
||||||
style = settings.font.style_map["Bold"],
|
style = settings.font.style_map["Bold"],
|
||||||
size = 12.0,
|
size = 12.0,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
front_app:subscribe("front_app_switched", function(env)
|
front_app:subscribe("front_app_switched", function(env)
|
||||||
front_app:set({
|
front_app:set({
|
||||||
label = {
|
label = {
|
||||||
string = env.INFO:upper()
|
string = env.INFO:upper(),
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Or equivalently:
|
-- Or equivalently:
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ for i = 1, max_items, 1 do
|
||||||
icon = { drawing = false },
|
icon = { drawing = false },
|
||||||
label = {
|
label = {
|
||||||
font = {
|
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_left = 6,
|
||||||
padding_right = 6,
|
padding_right = 6,
|
||||||
|
|
@ -33,24 +33,26 @@ for i = 1, max_items, 1 do
|
||||||
menu_items[i] = menu
|
menu_items[i] = menu
|
||||||
end
|
end
|
||||||
|
|
||||||
sbar.add("bracket", { '/menu\\..*/' }, {
|
sbar.add("bracket", { "/menu\\..*/" }, {
|
||||||
background = { color = colors.bg1 }
|
background = { color = colors.bg1 },
|
||||||
})
|
})
|
||||||
|
|
||||||
local menu_padding = sbar.add("item", "menu.padding", {
|
local menu_padding = sbar.add("item", "menu.padding", {
|
||||||
drawing = false,
|
drawing = false,
|
||||||
width = 5
|
width = 5,
|
||||||
})
|
})
|
||||||
|
|
||||||
local function update_menus(env)
|
local function update_menus(env)
|
||||||
sbar.exec("sk-menus -l", function(menus)
|
sbar.exec("sk-menus -l", function(menus)
|
||||||
sbar.set('/menu\\..*/', { drawing = false })
|
sbar.set("/menu\\..*/", { drawing = false })
|
||||||
menu_padding:set({ drawing = true })
|
menu_padding:set({ drawing = true })
|
||||||
id = 1
|
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
|
if id < max_items then
|
||||||
menu_items[id]:set( { label = menu, drawing = true } )
|
menu_items[id]:set({ label = menu, drawing = true })
|
||||||
else break end
|
else
|
||||||
|
break
|
||||||
|
end
|
||||||
id = id + 1
|
id = id + 1
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
@ -61,12 +63,12 @@ menu_watcher:subscribe("front_app_switched", update_menus)
|
||||||
space_menu_swap:subscribe("swap_menus_and_spaces", function(env)
|
space_menu_swap:subscribe("swap_menus_and_spaces", function(env)
|
||||||
local drawing = menu_items[1]:query().geometry.drawing == "on"
|
local drawing = menu_items[1]:query().geometry.drawing == "on"
|
||||||
if drawing then
|
if drawing then
|
||||||
menu_watcher:set( { updates = false })
|
menu_watcher:set({ updates = false })
|
||||||
sbar.set("/menu\\..*/", { drawing = false })
|
sbar.set("/menu\\..*/", { drawing = false })
|
||||||
sbar.set("/space\\..*/", { drawing = true })
|
sbar.set("/space\\..*/", { drawing = true })
|
||||||
sbar.set("front_app", { drawing = true })
|
sbar.set("front_app", { drawing = true })
|
||||||
else
|
else
|
||||||
menu_watcher:set( { updates = true })
|
menu_watcher:set({ updates = true })
|
||||||
sbar.set("/space\\..*/", { drawing = false })
|
sbar.set("/space\\..*/", { drawing = false })
|
||||||
sbar.set("front_app", { drawing = false })
|
sbar.set("front_app", { drawing = false })
|
||||||
update_menus()
|
update_menus()
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ local volume_slider = sbar.add("slider", 100, {
|
||||||
corner_radius = 3,
|
corner_radius = 3,
|
||||||
color = colors.bg2,
|
color = colors.bg2,
|
||||||
},
|
},
|
||||||
knob= {
|
knob = {
|
||||||
string = "",
|
string = "",
|
||||||
drawing = false,
|
drawing = false,
|
||||||
},
|
},
|
||||||
|
|
@ -66,7 +66,7 @@ end)
|
||||||
|
|
||||||
local function animate_slider_width(width)
|
local function animate_slider_width(width)
|
||||||
sbar.animate("tanh", 30.0, function()
|
sbar.animate("tanh", 30.0, function()
|
||||||
volume_slider:set({ slider = { width = width }})
|
volume_slider:set({ slider = { width = width } })
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,17 +64,17 @@ local wifi = sbar.add("item", "widgets.wifi.padding", {
|
||||||
local wifi_bracket = sbar.add("bracket", "widgets.wifi.bracket", {
|
local wifi_bracket = sbar.add("bracket", "widgets.wifi.bracket", {
|
||||||
wifi.name,
|
wifi.name,
|
||||||
wifi_up.name,
|
wifi_up.name,
|
||||||
wifi_down.name
|
wifi_down.name,
|
||||||
}, {
|
}, {
|
||||||
-- background = { color = colors.bar.bg },
|
-- background = { color = colors.bar.bg },
|
||||||
popup = { align = "center", height = 30 }
|
popup = { align = "center", height = 30 },
|
||||||
})
|
})
|
||||||
|
|
||||||
local ssid = sbar.add("item", {
|
local ssid = sbar.add("item", {
|
||||||
position = "popup." .. wifi_bracket.name,
|
position = "popup." .. wifi_bracket.name,
|
||||||
icon = {
|
icon = {
|
||||||
font = {
|
font = {
|
||||||
style = settings.font.style_map["Bold"]
|
style = settings.font.style_map["Bold"],
|
||||||
},
|
},
|
||||||
string = icons.wifi.router,
|
string = icons.wifi.router,
|
||||||
},
|
},
|
||||||
|
|
@ -83,7 +83,7 @@ local ssid = sbar.add("item", {
|
||||||
label = {
|
label = {
|
||||||
font = {
|
font = {
|
||||||
size = 15,
|
size = 15,
|
||||||
style = settings.font.style_map["Bold"]
|
style = settings.font.style_map["Bold"],
|
||||||
},
|
},
|
||||||
max_chars = 18,
|
max_chars = 18,
|
||||||
string = "????????????",
|
string = "????????????",
|
||||||
|
|
@ -91,8 +91,8 @@ local ssid = sbar.add("item", {
|
||||||
background = {
|
background = {
|
||||||
height = 2,
|
height = 2,
|
||||||
color = colors.bar.bg,
|
color = colors.bar.bg,
|
||||||
y_offset = -15
|
y_offset = -15,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
local hostname = sbar.add("item", {
|
local hostname = sbar.add("item", {
|
||||||
|
|
@ -107,7 +107,7 @@ local hostname = sbar.add("item", {
|
||||||
string = "????????????",
|
string = "????????????",
|
||||||
width = popup_width / 2,
|
width = popup_width / 2,
|
||||||
align = "right",
|
align = "right",
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
local ip = sbar.add("item", {
|
local ip = sbar.add("item", {
|
||||||
|
|
@ -121,7 +121,7 @@ local ip = sbar.add("item", {
|
||||||
string = "???.???.???.???",
|
string = "???.???.???.???",
|
||||||
width = popup_width / 2,
|
width = popup_width / 2,
|
||||||
align = "right",
|
align = "right",
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
local mask = sbar.add("item", {
|
local mask = sbar.add("item", {
|
||||||
|
|
@ -135,7 +135,7 @@ local mask = sbar.add("item", {
|
||||||
string = "???.???.???.???",
|
string = "???.???.???.???",
|
||||||
width = popup_width / 2,
|
width = popup_width / 2,
|
||||||
align = "right",
|
align = "right",
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
local router = sbar.add("item", {
|
local router = sbar.add("item", {
|
||||||
|
|
@ -161,19 +161,19 @@ wifi_up:subscribe("network_update", function(env)
|
||||||
icon = { color = up_color },
|
icon = { color = up_color },
|
||||||
label = {
|
label = {
|
||||||
string = env.upload,
|
string = env.upload,
|
||||||
color = up_color
|
color = up_color,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
wifi_down:set({
|
wifi_down:set({
|
||||||
icon = { color = down_color },
|
icon = { color = down_color },
|
||||||
label = {
|
label = {
|
||||||
string = env.download,
|
string = env.download,
|
||||||
color = down_color
|
color = down_color,
|
||||||
}
|
},
|
||||||
})
|
})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
wifi:subscribe({"wifi_change", "system_woke"}, function(env)
|
wifi:subscribe({ "wifi_change", "system_woke" }, function(env)
|
||||||
sbar.exec("ipconfig getifaddr en0", function(ip)
|
sbar.exec("ipconfig getifaddr en0", function(ip)
|
||||||
local connected = not (ip == "")
|
local connected = not (ip == "")
|
||||||
wifi:set({
|
wifi:set({
|
||||||
|
|
@ -192,7 +192,7 @@ end
|
||||||
local function toggle_details()
|
local function toggle_details()
|
||||||
local should_draw = wifi_bracket:query().popup.drawing == "off"
|
local should_draw = wifi_bracket:query().popup.drawing == "off"
|
||||||
if should_draw then
|
if should_draw then
|
||||||
wifi_bracket:set({ popup = { drawing = true }})
|
wifi_bracket:set({ popup = { drawing = true } })
|
||||||
sbar.exec("networksetup -getcomputername", function(result)
|
sbar.exec("networksetup -getcomputername", function(result)
|
||||||
hostname:set({ label = result })
|
hostname:set({ label = result })
|
||||||
end)
|
end)
|
||||||
|
|
@ -220,8 +220,8 @@ wifi:subscribe("mouse.exited.global", hide_details)
|
||||||
|
|
||||||
local function copy_label_to_clipboard(env)
|
local function copy_label_to_clipboard(env)
|
||||||
local label = sbar.query(env.NAME).label.value
|
local label = sbar.query(env.NAME).label.value
|
||||||
sbar.exec("echo \"" .. label .. "\" | pbcopy")
|
sbar.exec('echo "' .. label .. '" | pbcopy')
|
||||||
sbar.set(env.NAME, { label = { string = icons.clipboard, align="center" } })
|
sbar.set(env.NAME, { label = { string = icons.clipboard, align = "center" } })
|
||||||
sbar.delay(1, function()
|
sbar.delay(1, function()
|
||||||
sbar.set(env.NAME, { label = { string = label, align = "right" } })
|
sbar.set(env.NAME, { label = { string = label, align = "right" } })
|
||||||
end)
|
end)
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,9 @@
|
||||||
{ pkgs, ... }:
|
{ pkgs, ... }:
|
||||||
treefmt-nix.lib.evalModule pkgs {
|
treefmt-nix.lib.evalModule pkgs {
|
||||||
projectRootFile = "flake.nix";
|
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" ];
|
settings.global.excludes = [ "flake.lock" ];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
@ -137,7 +139,7 @@
|
||||||
sops
|
sops
|
||||||
age
|
age
|
||||||
ssh-to-age
|
ssh-to-age
|
||||||
nixfmt-rfc-style
|
# nixfmt-rfc-style
|
||||||
];
|
];
|
||||||
DIRENV_LOG_FORMAT = "";
|
DIRENV_LOG_FORMAT = "";
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue