Skip to content

Commit

Permalink
Fixing erros
Browse files Browse the repository at this point in the history
  • Loading branch information
Jac-Zac committed Nov 26, 2024
1 parent 7c382cf commit 2089cf6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 33 deletions.
35 changes: 6 additions & 29 deletions .config/sketchybar/items/widgets/volume.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ local popup_width = 250
local volume_percent = sbar.add("item", "widgets.volume1", {
position = "right",
icon = { drawing = false },
label = { drawing = false },
label = {
drawing = false,
},
})

local volume_icon = sbar.add("item", "widgets.volume2", {
position = "right",
padding_right = settings.item_padding,
padding_right = settings.item_padding - 3.0,
padding_left = settings.item_padding,
icon = {
drawing = true,
width = 21,
align = "center",
color = colors.white,
},
})

Expand All @@ -44,19 +45,17 @@ local volume_slider = sbar.add("slider", popup_width, {
background = {
height = 80,
y_offset = 20,
color = colors.popup.background,
},
slider = {
highlight_color = colors.spaces.active,
highlight_color = colors.quicksilver,
background = {
height = 6,
corner_radius = 3,
color = colors.quicksilver,
color = colors.bg2,
},
knob = {
string = "􀀁",
drawing = true,
color = colors.white,
},
},
click_script = 'osascript -e "set volume output volume $PERCENTAGE"',
Expand Down Expand Up @@ -143,29 +142,7 @@ local function volume_scroll(env)
sbar.exec('osascript -e "set volume output volume (output volume of (get volume settings) + ' .. delta .. ')"')
end

local function is_click_inside_popup(env)
local popup_rect = volume_bracket:query().popup.rect
if popup_rect then
return env.X >= popup_rect.x
and env.X <= popup_rect.x + popup_rect.width
and env.Y >= popup_rect.y
and env.Y <= popup_rect.y + popup_rect.height
else
return false
end
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.scrolled", volume_scroll)

-- Add a new subscription to close the popup when clicking outside
sbar.subscribe("mouse.clicked.global", function(env)
if env.BUTTON == "left" and not is_click_inside_popup(env) then
local is_popup_visible = volume_bracket:query().popup.drawing == "on"
if is_popup_visible then
volume_collapse_details()
end
end
end)
12 changes: 8 additions & 4 deletions .config/sketchybar/items/widgets/wifi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ local ssid = sbar.add("item", {
icon = {
padding_right = 16,
font = {
font = settings.font.text,
family = settings.font.icons,
style = settings.font.style_map["Bold"],
size = settings.font.sizes.text,
},
Expand All @@ -46,6 +46,7 @@ local ssid = sbar.add("item", {
width = popup_width,
label = {
font = {
family = settings.font.text,
style = settings.font.style_map["SemiBold"],
size = settings.font.sizes.text,
},
Expand All @@ -64,13 +65,14 @@ local hostname = sbar.add("item", {
string = "Hostname:",
width = popup_width / 2,
font = {
font = settings.font.text,
family = settings.font.icons,
style = settings.font.style_map["Bold"],
size = settings.font.sizes.text,
},
},
label = {
font = {
family = settings.font.text,
style = settings.font.style_map["Regular"],
size = settings.font.sizes.text,
},
Expand All @@ -90,13 +92,14 @@ local ip = sbar.add("item", {
string = "IP:",
width = popup_width / 2,
font = {
font = settings.font.text,
family = settings.font.icons,
style = settings.font.style_map["Bold"],
size = settings.font.sizes.text,
},
},
label = {
font = {
family = settings.font.text,
style = settings.font.style_map["Regular"],
size = settings.font.sizes.text,
},
Expand All @@ -116,13 +119,14 @@ local router = sbar.add("item", {
string = "Router:",
width = popup_width / 2,
font = {
font = settings.font.text,
family = settings.font.icons,
style = settings.font.style_map["Bold"],
size = settings.font.sizes.text,
},
},
label = {
font = {
family = settings.font.text,
style = settings.font.style_map["Regular"],
size = settings.font.sizes.text,
},
Expand Down

0 comments on commit 2089cf6

Please sign in to comment.