Skip to content

Commit

Permalink
WIP: Darwin theming
Browse files Browse the repository at this point in the history
  • Loading branch information
shajra committed Jan 14, 2024
1 parent e45fb4e commit 53ba326
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 51 deletions.
2 changes: 1 addition & 1 deletion build/nixpkgs/packages/sketchybar-font/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ stdenvNoCC.mkDerivation {
dontUnpack = true;
installPhase = ''
runHook preInstall
install -Dm644 "$src" "$out/share/fonts/truetype/sketchybar-font.ttf"
install -Dm644 "$src" "$out/share/fonts/truetype/sketchybar-app-font.ttf"
runHook postInstall
'';
}
20 changes: 18 additions & 2 deletions home/modules/base/gui/darwin/xdg/configFile/default.nix
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
config: pkgs:

let

kitty = "${config.programs.kitty.package}/bin/kitty";
jq = "${pkgs.jq}/bin/jq";
in

{
format = f: x: pkgs.lib.colors.format "0xff%R%G%B" (f x);
id = x: x;
foregroundFor = config.theme.colors.nominal.foregroundFor;
colors = pkgs.lib.colors.transformColors (format id) config.theme.colors;
foreground = pkgs.lib.colors.transformColors (format foregroundFor) config.theme.colors;

in {
"sketchybar".source = pkgs.runCommandNoCC "sketchybarrc" {} ''
cp -r "${./sketchybar}" "$out"
substituteInPlace "$out/sketchybarrc" \
--replace @@LUA@@ "${pkgs.lua5_4}" \
--replace @@SKETCHYBAR_LUA_SO@@ "${pkgs.sketchybar-lua}"
substituteInPlace "$out/colors.lua" \
--replace @@COLORS_UNIFYING@@ ${colors.semantic.unifying} \
--replace @@COLORS_PRIMARY_BG@@ ${colors.semantic.background} \
--replace @@COLORS_PRIMARY_FG@@ ${colors.semantic.foreground} \
--replace @@COLORS_SECONDARY_BG@@ ${colors.semantic.background_highlighted} \
--replace @@COLORS_SECONDARY_FG@@ ${colors.semantic.foreground} \
--replace @@COLORS_UNSELECTED_BG@@ ${colors.window.unselected.background} \
--replace @@COLORS_UNSELECTED_FG@@ ${colors.window.unselected.text} \
--replace @@COLORS_SELECTED_BG@@ ${colors.window.selected.focused.background} \
--replace @@COLORS_SELECTED_FG@@ ${colors.window.selected.focused.text}
chmod +x "$out/sketchybarrc"
'';
"skhd/skhdrc".text = import skhd/skhdrc.nix kitty jq;
Expand Down
57 changes: 18 additions & 39 deletions home/modules/base/gui/darwin/xdg/configFile/sketchybar/colors.lua
Original file line number Diff line number Diff line change
@@ -1,40 +1,19 @@
local colors = {}

colors.solarized = {
white = 0xffeee8d5,
red = 0xffdc322f,
green = 0xff859900,
blue = 0xff268bd2,
yellow = 0xffb58900,
orange = 0xffcb4b16,
magenta = 0xffd33682,
grey = 0xff839496,
cyan = 0xff2aa198,
base03 = 0xff002b36,
base02 = 0xff073642,
base01 = 0xff586e75,
base00 = 0xff657b83,
base0 = 0xff839496,
base1 = 0xff93a1a1,
base2 = 0xffeee8d5,
base3 = 0xfffdf6e3,
return {
unifying = @@COLORS_UNIFYING@@,
primary = {
background = @@COLORS_PRIMARY_BG@@,
foreground = @@COLORS_PRIMARY_FG@@,
},
secondary = {
background = @@COLORS_SECONDARY_BG@@,
foreground = @@COLORS_SECONDARY_FG@@,
},
selected = {
background = @@COLORS_SELECTED_BG@@,
foreground = @@COLORS_SELECTED_FG@@,
},
unselected = {
background = @@COLORS_UNSELECTED_BG@@,
foreground = @@COLORS_UNSELECTED_FG@@,
},
}

colors.unifying = colors.solarized.green

colors.primary = {
background = colors.solarized.base3,
foreground = colors.solarized.base00
}

colors.secondary = {
background = colors.solarized.base2,
foreground = colors.solarized.base00
}

colors.selected = {
background = colors.solarized.green,
foreground = colors.solarized.base3
}

return colors
14 changes: 14 additions & 0 deletions home/modules/base/gui/darwin/xdg/configFile/sketchybar/emojis.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
return {
[".kitty-wrapped"] = ":terminal:",
["Alacritty"] = ":terminal:",
["Discord"] = ":discord:",
["Emacs"] = ":emacs:",
["Firefox"] = ":firefox:",
["Google Chrome Beta"] = ":google_chrome:",
["Google Chrome"] = ":google_chrome:",
["Microsoft Edge"] = ":microsoft_edge:",
["Terminal"] = ":terminal:",
["iTerm2"] = ":terminal:",
["kitty"] = ":terminal:",
["zoom.us"] = ":zoom:",
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ local battery = sbar.add("item", {
})

local function battery_update()
local file = assert(io.popen("pmset -g batt"))
local batt_info = assert(file:read("a"))
local handle = assert(io.popen("pmset -g batt"))
local batt_info = assert(handle:read("a"))
handle:close()
local icon = "!"

if (string.find(batt_info, 'AC Power')) then
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local colors = require("colors")
local emojis = require("emojis")
local settings = require("settings")

local function mouse_click(env)
Expand All @@ -14,40 +15,60 @@ end
local function space_selection(env)
local bg_color = env.SELECTED == "true"
and colors.selected.background
or colors.secondary.background
or colors.unselected.background
sbar.set(env.NAME, {
icon = { highlight = env.SELECTED, },
label = { highlight = env.SELECTED, },
background = { color = bg_color, corner_radius = 0 },
})
end

local function space_windows_change(env)
if tostring(env.INFO.space) == env.SID
then
local app_emojis = {}
for name, _ in pairs(env.INFO.apps) do
table.insert(app_emojis, emojis[name] or ":default:")
end
icon_strip = ""
if next(app_emojis) ~= nil
then
icon_strip = table.concat(app_emojis, " ")
end
sbar.set(env.NAME, {
label = icon_strip
})
end
end

local spaces = {}
for i = 1, 10, 1 do
local space = sbar.add("space", {
associated_space = i,
background = { color = colors.secondary.background, },
background = { color = colors.unselected.background, },
icon = {
string = i,
padding_left = 10,
padding_right = 10,
color = colors.secondary.foreground,
color = colors.unselected.foreground,
highlight_color = colors.selected.foreground,
},
padding_left = 2,
padding_right = 2,
label = {
string = "<>",
padding_right = 20,
color = colors.secondary.foreground,
color = colors.unselected.foreground,
highlight_color = colors.selected.foreground,
font = { family = "sketchybar-app-font" },
font = "sketchybar-app-font:Regular:16.0",
y_offset = -1,
drawing = false,
},
drawing = true,
}
})

spaces[i] = space.name
space:subscribe("space_change", space_selection)
space:subscribe("space_windows_change", space_windows_change)
space:subscribe("mouse.clicked", mouse_click)
end

Expand Down

0 comments on commit 53ba326

Please sign in to comment.