skhd + yabai + sketchybar
This commit is contained in:
72
__sketchybar/items/battery.lua
Normal file
72
__sketchybar/items/battery.lua
Normal file
@@ -0,0 +1,72 @@
|
||||
local icons = require("icons")
|
||||
local colors = require("colors")
|
||||
local settings = require("settings")
|
||||
|
||||
local battery = sbar.add("item", "widgets.battery", {
|
||||
position = "right",
|
||||
icon = {
|
||||
font = {
|
||||
style = settings.font.style_map["Regular"],
|
||||
size = 14.0,
|
||||
},
|
||||
},
|
||||
label = { font = { family = settings.font.numbers } },
|
||||
update_freq = 180,
|
||||
popup = { align = "center" },
|
||||
})
|
||||
|
||||
battery:subscribe({ "routine", "power_source_change", "system_woke" }, function()
|
||||
sbar.exec("pmset -g batt", function(batt_info)
|
||||
local icon = "!"
|
||||
local label = "?"
|
||||
|
||||
local found, _, charge = batt_info:find("(%d+)%%")
|
||||
if found then
|
||||
charge = tonumber(charge)
|
||||
label = charge .. "%"
|
||||
end
|
||||
|
||||
local color = colors.green
|
||||
local charging, _, _ = batt_info:find("AC Power")
|
||||
|
||||
if charging then
|
||||
icon = icons.battery.charging
|
||||
else
|
||||
if found and charge > 80 then
|
||||
icon = icons.battery._100
|
||||
elseif found and charge > 60 then
|
||||
icon = icons.battery._75
|
||||
elseif found and charge > 40 then
|
||||
icon = icons.battery._50
|
||||
elseif found and charge > 20 then
|
||||
icon = icons.battery._25
|
||||
color = colors.orange
|
||||
else
|
||||
icon = icons.battery._0
|
||||
color = colors.red
|
||||
end
|
||||
end
|
||||
|
||||
local lead = ""
|
||||
if found and charge < 10 then
|
||||
lead = "0"
|
||||
end
|
||||
|
||||
battery:set({
|
||||
icon = {
|
||||
string = icon,
|
||||
color = color,
|
||||
},
|
||||
label = { string = lead .. label },
|
||||
})
|
||||
end)
|
||||
end)
|
||||
|
||||
sbar.add("bracket", "widgets.battery.bracket", { battery.name }, {
|
||||
background = { color = colors.bg1 },
|
||||
})
|
||||
|
||||
sbar.add("item", "widgets.battery.padding", {
|
||||
position = "right",
|
||||
width = settings.group_paddings,
|
||||
})
|
||||
35
__sketchybar/items/calendar.lua
Normal file
35
__sketchybar/items/calendar.lua
Normal file
@@ -0,0 +1,35 @@
|
||||
local settings = require("settings")
|
||||
local colors = require("colors")
|
||||
|
||||
sbar.add("item", { position = "right", width = settings.group_paddings })
|
||||
|
||||
local cal = sbar.add("item", {
|
||||
icon = {
|
||||
color = colors.white,
|
||||
padding_left = 8,
|
||||
font = {
|
||||
style = settings.font.style_map["Black"],
|
||||
size = 12.0,
|
||||
},
|
||||
},
|
||||
label = {
|
||||
color = colors.white,
|
||||
padding_right = 8,
|
||||
width = 49,
|
||||
align = "right",
|
||||
font = { family = settings.font.numbers },
|
||||
},
|
||||
position = "right",
|
||||
update_freq = 30,
|
||||
padding_left = 1,
|
||||
padding_right = 1,
|
||||
background = {
|
||||
color = colors.bg1,
|
||||
},
|
||||
})
|
||||
|
||||
sbar.add("item", { position = "right", width = settings.group_paddings })
|
||||
|
||||
cal:subscribe({ "forced", "routine", "system_woke" }, function(env)
|
||||
cal:set({ icon = os.date("%a %d %b"), label = os.date("%H:%M") })
|
||||
end)
|
||||
21
__sketchybar/items/front_app.lua
Normal file
21
__sketchybar/items/front_app.lua
Normal file
@@ -0,0 +1,21 @@
|
||||
local settings = require("settings")
|
||||
|
||||
local front_app = sbar.add("item", "front_app", {
|
||||
display = "active",
|
||||
icon = { drawing = false },
|
||||
label = {
|
||||
font = {
|
||||
style = settings.font.style_map["Bold"],
|
||||
size = 13.0,
|
||||
},
|
||||
},
|
||||
updates = true,
|
||||
})
|
||||
|
||||
front_app:subscribe("front_app_switched", function(env)
|
||||
front_app:set({ label = { string = env.INFO } })
|
||||
end)
|
||||
|
||||
front_app:subscribe("mouse.clicked", function(env)
|
||||
sbar.trigger("swap_menus_and_spaces")
|
||||
end)
|
||||
4
__sketchybar/items/init.lua
Normal file
4
__sketchybar/items/init.lua
Normal file
@@ -0,0 +1,4 @@
|
||||
require("items.spaces")
|
||||
require("items.front_app")
|
||||
require("items.calendar")
|
||||
require("items.battery")
|
||||
103
__sketchybar/items/spaces.lua
Normal file
103
__sketchybar/items/spaces.lua
Normal file
@@ -0,0 +1,103 @@
|
||||
local colors = require("colors")
|
||||
local settings = require("settings")
|
||||
local app_icons = require("app_icons")
|
||||
|
||||
local spaces = {}
|
||||
|
||||
for i = 1, 10, 1 do
|
||||
local space = sbar.add("space", "space." .. i, {
|
||||
space = i,
|
||||
icon = {
|
||||
font = { family = settings.font.numbers },
|
||||
string = i,
|
||||
padding_left = 15,
|
||||
padding_right = 8,
|
||||
color = colors.white,
|
||||
highlight_color = colors.red,
|
||||
},
|
||||
label = {
|
||||
padding_right = 20,
|
||||
color = colors.grey,
|
||||
highlight_color = colors.white,
|
||||
font = "sketchybar-app-font:Regular:15.0",
|
||||
y_offset = -1,
|
||||
},
|
||||
padding_right = 1,
|
||||
padding_left = 1,
|
||||
background = {
|
||||
color = colors.bg1,
|
||||
border_width = 1,
|
||||
height = 21,
|
||||
border_color = colors.black,
|
||||
},
|
||||
popup = { background = { border_width = 5, border_color = colors.black } },
|
||||
})
|
||||
|
||||
spaces[i] = space
|
||||
|
||||
-- Single item bracket for space items to achieve double border on highlight
|
||||
local space_bracket = sbar.add("bracket", { space.name }, {
|
||||
background = {
|
||||
color = colors.transparent,
|
||||
border_color = colors.bg2,
|
||||
height = 24,
|
||||
border_width = 3,
|
||||
},
|
||||
})
|
||||
|
||||
-- Padding space
|
||||
sbar.add("space", "space.padding." .. i, {
|
||||
space = i,
|
||||
script = "",
|
||||
width = settings.group_paddings,
|
||||
})
|
||||
|
||||
--[[ local space_popup = sbar.add("item", {
|
||||
position = "popup." .. space.name,
|
||||
padding_left = 5,
|
||||
padding_right = 0,
|
||||
background = {
|
||||
drawing = true,
|
||||
image = {
|
||||
corner_radius = 9,
|
||||
scale = 0.2,
|
||||
},
|
||||
},
|
||||
}) ]]
|
||||
|
||||
space:subscribe("space_change", function(env)
|
||||
local selected = env.SELECTED == "true"
|
||||
-- local color = selected and colors.grey or colors.bg2
|
||||
space:set({
|
||||
icon = { highlight = selected },
|
||||
label = { highlight = selected },
|
||||
background = { border_color = selected and colors.black or colors.bg2 },
|
||||
})
|
||||
space_bracket:set({
|
||||
background = { border_color = selected and colors.grey or colors.bg2 },
|
||||
})
|
||||
end)
|
||||
end
|
||||
|
||||
local space_window_observer = sbar.add("item", {
|
||||
drawing = false,
|
||||
updates = true,
|
||||
})
|
||||
|
||||
space_window_observer:subscribe("space_windows_change", function(env)
|
||||
local icon_line = ""
|
||||
local no_app = true
|
||||
for app, _ in pairs(env.INFO.apps) do
|
||||
no_app = false
|
||||
local lookup = app_icons[app]
|
||||
local icon = ((lookup == nil) and app_icons["default"] or lookup)
|
||||
icon_line = icon_line .. " " .. icon
|
||||
end
|
||||
|
||||
if no_app then
|
||||
icon_line = " —"
|
||||
end
|
||||
sbar.animate("tanh", 10, function()
|
||||
spaces[env.INFO.space]:set({ label = icon_line })
|
||||
end)
|
||||
end)
|
||||
Reference in New Issue
Block a user