Skip to content

Commit

Permalink
sketchybar: use sbarlua
Browse files Browse the repository at this point in the history
  • Loading branch information
khaneliman committed Feb 25, 2024
1 parent 9d16ad0 commit c52b9dd
Show file tree
Hide file tree
Showing 32 changed files with 1,848 additions and 1 deletion.
2 changes: 2 additions & 0 deletions modules/darwin/desktop/addons/sketchybar/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ in
gnugrep
gnused
jq
lua5_4
wttrbar
];

# TODO: need to update nixpkg to support complex configurations
Expand Down
2 changes: 1 addition & 1 deletion modules/home/desktop/addons/sketchybar/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ in
xdg.configFile = {
"sketchybar" = {
source = lib.cleanSourceWith {
src = lib.cleanSource ./config/.;
src = lib.cleanSource ./lua-config/.;
};

recursive = true;
Expand Down
20 changes: 20 additions & 0 deletions modules/home/desktop/addons/sketchybar/lua-config/bar.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
local colors = require("colors")

-- Equivalent to the --bar domain
sbar.bar({
blur_radius = 30,
border_color = colors.surface1,
border_width = 2,
color = colors.base,
corner_radius = 9,
height = 40,
margin = 10,
notch_width = 0,
padding_left = 18,
padding_right = 10,
position = "top",
shadow = true,
sticky = true,
topmost = false,
y_offset = 10,
})
40 changes: 40 additions & 0 deletions modules/home/desktop/addons/sketchybar/lua-config/colors.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
local colors = {
base = 0xff24273a,
mantle = 0xff1e2030,
crust = 0xff181926,
text = 0xffcad3f5,
subtext0 = 0xffb8c0e0,
subtext1 = 0xffa5adcb,
surface0 = 0xff363a4f,
surface1 = 0xff494d64,
surface2 = 0xff5b6078,
overlay0 = 0xff6e738d,
overlay1 = 0xff8087a2,
overlay2 = 0xff939ab7,
blue = 0xff8aadf4,
lavender = 0xffb7bdf8,
sapphire = 0xff7dc4e4,
sky = 0xff91d7e3,
teal = 0xff8bd5ca,
green = 0xffa6da95,
yellow = 0xffeed49f,
peach = 0xfff5a97f,
maroon = 0xffee99a0,
red = 0xffed8796,
mauve = 0xffc6a0f6,
pink = 0xfff5bde6,
flamingo = 0xfff0c6c6,
rosewater = 0xfff4dbd6,
}

local random_cat_color = {
colors.blue, colors.lavender, colors.sapphire, colors.sky, colors.teal,
colors.green, colors.yellow, colors.peach, colors.maroon, colors.red,
colors.mauve, colors.pink, colors.flamingo, colors.rosewater,
}

local function getRandomCatColor()
return random_cat_color[math.random(1, #random_cat_color)]
end

return colors
46 changes: 46 additions & 0 deletions modules/home/desktop/addons/sketchybar/lua-config/default.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
local settings = require("settings")
local colors = require("colors")

-- Equivalent to the --default domain
sbar.default({
updates = "when_shown",
icon = {
color = colors.text,
font = {
family = settings.nerd_font,
style = "Bold",
size = 16.0
},
padding_left = settings.paddings,
padding_right = settings.paddings,
},
label = {
color = colors.text,
font = {
family = settings.font,
style = "Semibold",
size = 13.0
},
padding_left = settings.paddings,
padding_right = settings.paddings,
},
background = {
corner_radius = 9,
height = 30,
padding_left = settings.paddings,
padding_right = settings.paddings,
},
popup = {
height = 30,
horizontal = false,
background = {
border_color = colors.blue,
border_width = 2,
color = colors.mantle,
corner_radius = 11,
shadow = {
drawing = true
}
}
}
})
93 changes: 93 additions & 0 deletions modules/home/desktop/addons/sketchybar/lua-config/icons.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
return {
loading = "􀖇",
apple = "􀣺",
preferences = "􀺽",
activity = "􀒓",
lock = "􀒳",
logout = "",
power = "",
reboot = "",
sleep = "",
ical = "􀉉",
volume = {
_100 = "􀊩",
_66 = "􀊧",
_33 = "􀊥",
_10 = "􀊡",
_0 = "􀊣",
},
battery = {
non_charging = {
_100 = "󰁹",
_90 = "󰂂",
_80 = "󰂁",
_70 = "󰂀",
_60 = "󰁿",
_50 = "󰁾",
_40 = "󰁽",
_30 = "󰁼",
_20 = "󰁻",
_10 = "󰁺",
_0 = "󰂃",
},
charging = {
_100 = "󰂅",
_90 = "󰂋",
_80 = "󰂊",
_70 = "󰢞",
_60 = "󰂉",
_50 = "󰢝",
_40 = "󰂈",
_30 = "󰂇",
_20 = "󰂆",
_10 = "󰢜",
_0 = "󰢟",
}
},
stats = {
cpu = "",
disk = "󰋊",
memory = "",
network = "",
network_down = "",
network_up = "",
},
bell = "􀋚",
bell_dot = "􀝗",
bluetooth = "󰂯",
bluetooth_off = "󰂲",
brew = "􀐛",
wifi = "󰖩",
wifi_off = "󰖪",
git = {
issue = "􀍷",
discussion = "􀒤",
pull_request = "􀙡",
commit = "􀡚",
indicator = "",
},
spotify = {
back = "􀊎",
play_pause = "􀊈",
next = "􀊐",
shuffle = "􀊝",
-- repeat = "􀊞",
},
yabai = {
stack = "􀏭",
fullscreen_zoom = "􀏜",
parent_zoom = "􀥃",
float = "􀢌",
grid = "􀧍"
},
spaces = {
_1 = "",
_2 = "",
_3 = "󰆍",
_4 = "",
_5 = "",
_6 = "",
_7 = "",
_8 = ""
}
}
3 changes: 3 additions & 0 deletions modules/home/desktop/addons/sketchybar/lua-config/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require("bar")
require("default")
require("items")
172 changes: 172 additions & 0 deletions modules/home/desktop/addons/sketchybar/lua-config/items/apple.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
local icons = require("icons")
local colors = require("colors")

local popup_toggle = "sketchybar --set $NAME popup.drawing=toggle"

local apple_logo = sbar.add("item", "apple_logo", {
padding_right = 15,
click_script = popup_toggle,
icon = {
string = icons.apple,
font = {
style = "Black",
size = 16.0,
},
color = colors.green,
},
label = {
drawing = false,
},
popup = {
height = 0
}
})

local apple_prefs = sbar.add("item", "apple_prefs", {
position = "popup." .. apple_logo.name,
icon = icons.preferences,
label = "Preferences",
background = {
color = 0x00000000,
height = 30,
drawing = true
}
})

apple_prefs:subscribe("mouse.clicked", function(_)
os.execute("open -a 'System Preferences'")
apple_logo:set({ popup = { drawing = false } })
end)

local apple_activity = sbar.add("item", "apple_activity", {
position = "popup." .. apple_logo.name,
icon = {
string = icons.activity
},
label = "Activity",
background = {
color = 0x00000000,
height = 30,
drawing = true,
},
click_script = "open -a 'Activity Monitor'; " .. popup_toggle,
})

apple_activity:subscribe("mouse.clicked", function(_)
apple_logo:set({ popup = { drawing = false } })
end)

local apple_divider = sbar.add("item", "apple_divider", {
position = "popup." .. apple_logo.name,
icon = {
drawing = false,
},
label = {
drawing = false,
},
background = {
color = colors.blue,
height = 1,
drawing = true,
},
padding_left = 7,
padding_right = 7,
width = 110,
})

local apple_lock = sbar.add("item", "apple_lock", {
position = "popup." .. apple_logo.name,
icon = {
string = icons.lock
},
label = "Lock Screen",
background = {
color = 0x00000000,
height = 30,
drawing = true,
},
click_script =
"osascript -e 'tell application \"System Events\" to keystroke \"q\" using {command down,control down}'; " ..
popup_toggle,
})

apple_lock:subscribe("mouse.clicked", function(_)
apple_logo:set({ popup = { drawing = false } })
end)

local apple_logout = sbar.add("item", "apple_logout", {
position = "popup." .. apple_logo.name,
icon = {
string = icons.logout,
padding_left = 7,
},
label = "Logout",
background = {
color = 0x00000000,
height = 30,
drawing = true,
},
click_script = "osascript -e 'tell application \"System Events\" to keystroke \"q\" using {command down,shift down}'; " ..
popup_toggle,
})

apple_logout:subscribe("mouse.clicked", function(_)
apple_logo:set({ popup = { drawing = false } })
end)

local apple_sleep = sbar.add("item", "apple_sleep", {
position = "popup." .. apple_logo.name,
icon = {
string = icons.sleep,
padding_left = 5,
},
label = "Sleep",
background = {
color = 0x00000000,
height = 30,
drawing = true,
},
click_script = "osascript -e 'tell app \"System Events\" to sleep'; " .. popup_toggle,
})

apple_sleep:subscribe("mouse.clicked", function(_)
apple_logo:set({ popup = { drawing = false } })
end)

local apple_reboot = sbar.add("item", "apple_reboot", {
position = "popup." .. apple_logo.name,
icon = {
string = icons.reboot,
padding_left = 5,
},
label = "Reboot",
background = {
color = 0x00000000,
height = 30,
drawing = true,
},
click_script = "osascript -e 'tell app \"loginwindow\" to «event aevtrrst»'; " .. popup_toggle,
})

apple_reboot:subscribe("mouse.clicked", function(_)
apple_logo:set({ popup = { drawing = false } })
end)

local apple_shutdown = sbar.add("item", "apple_shutdown", {
position = "popup." .. apple_logo.name,
icon = {
string = icons.power,
padding_left = 5,
},
label = "Shutdown",
background = {
color = 0x00000000,
height = 30,
drawing = true,
},
click_script = "osascript -e 'tell app \"loginwindow\" to «event aevtrsdn»'; " .. popup_toggle,
})

apple_shutdown:subscribe("mouse.clicked", function(_)
apple_logo:set({ popup = { drawing = false } })
end)
Loading

0 comments on commit c52b9dd

Please sign in to comment.