FelixKratz / SbarLua

A Lua API for SketchyBar
GNU General Public License v3.0
139 stars 11 forks source link

Adding Support for Item space_separator #31

Closed jrock2004 closed 2 months ago

jrock2004 commented 3 months ago

When I tried to use space_separator I got errors that its not supported

#!/usr/bin/env lua

local colors = require 'colors'
local icons = require 'icons'

local spaces = {}

local function space_selection(env)
  if env.SELECTED == 'true' then
    Sbar.set(env.NAME, {
      background = {
        drawing = 'on',
        color = colors.accent,
      },
      label = {
        color = colors.bar,
      },
      icon = {
        color = colors.bar,
      },
    })
  else
    Sbar.set(env.NAME, {
      background = {
        drawing = 'off',
      },
      label = {
        color = colors.accent,
      },
      icon = {
        color = colors.accent,
      },
    })
  end
end

for i = 1, 10, 1 do
  local space = Sbar.add('space', {
    associated_space = i,
    icon = i,
    label = {
      font = ' sketchybar-app-font:Regular:16.0',
      padding_right = 20,
      y_offset = -1,
    },
  })

  space:subscribe('space_change', space_selection)
end

local seperator = Sbar.add('space_separator', {
  position = 'left',
  -- icon = icons.separator,
  icon = {
    color = colors.accent,
    padding_left = 4,
  },
})

seperator:subscribe('space_separator', function(env)
  print(env)
end)

If I comment out the following the code works but if I leave it I get errors about not supported

seperator:subscribe('space_separator', function(env)
  print(env)
end)
FelixKratz commented 2 months ago

The first argument of the add domain is not the item name but its type, see the readme for more information.