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)
|
||||
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
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ local icons = {
|
|||
_50 = "",
|
||||
_25 = "",
|
||||
_0 = "",
|
||||
charging = ""
|
||||
charging = "",
|
||||
},
|
||||
wifi = {
|
||||
upload = "",
|
||||
|
|
@ -68,14 +68,14 @@ local icons = {
|
|||
_50 = "",
|
||||
_25 = "",
|
||||
_0 = "",
|
||||
charging = ""
|
||||
charging = "",
|
||||
},
|
||||
wifi = {
|
||||
upload = "",
|
||||
download = "",
|
||||
connected = "",
|
||||
disconnected = "",
|
||||
router = "Missing Icon"
|
||||
router = "Missing Icon",
|
||||
},
|
||||
media = {
|
||||
back = "",
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -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:
|
||||
|
|
|
|||
|
|
@ -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
|
||||
else
|
||||
break
|
||||
end
|
||||
id = id + 1
|
||||
end
|
||||
end)
|
||||
|
|
|
|||
|
|
@ -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,15 +161,15 @@ 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)
|
||||
|
||||
|
|
@ -220,7 +220,7 @@ 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.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" } })
|
||||
|
|
|
|||
|
|
@ -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 = "";
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue