diff --git a/build/nixpkgs/packages/sketchybar-font/default.nix b/build/nixpkgs/packages/sketchybar-font/default.nix index 715c0fa2..d98b3e15 100644 --- a/build/nixpkgs/packages/sketchybar-font/default.nix +++ b/build/nixpkgs/packages/sketchybar-font/default.nix @@ -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 ''; } diff --git a/home/modules/base/gui/darwin/xdg/configFile/default.nix b/home/modules/base/gui/darwin/xdg/configFile/default.nix index 2c10b91d..237f7937 100644 --- a/home/modules/base/gui/darwin/xdg/configFile/default.nix +++ b/home/modules/base/gui/darwin/xdg/configFile/default.nix @@ -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; diff --git a/home/modules/base/gui/darwin/xdg/configFile/sketchybar/colors.lua b/home/modules/base/gui/darwin/xdg/configFile/sketchybar/colors.lua index 97da6fc8..351315c3 100644 --- a/home/modules/base/gui/darwin/xdg/configFile/sketchybar/colors.lua +++ b/home/modules/base/gui/darwin/xdg/configFile/sketchybar/colors.lua @@ -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 diff --git a/home/modules/base/gui/darwin/xdg/configFile/sketchybar/emojis.lua b/home/modules/base/gui/darwin/xdg/configFile/sketchybar/emojis.lua new file mode 100644 index 00000000..851df51f --- /dev/null +++ b/home/modules/base/gui/darwin/xdg/configFile/sketchybar/emojis.lua @@ -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:", +} diff --git a/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/battery.lua b/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/battery.lua index 11159f42..662bcaad 100644 --- a/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/battery.lua +++ b/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/battery.lua @@ -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 diff --git a/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/spaces.lua b/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/spaces.lua index fdfaa615..2e792af9 100644 --- a/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/spaces.lua +++ b/home/modules/base/gui/darwin/xdg/configFile/sketchybar/items/spaces.lua @@ -1,4 +1,5 @@ local colors = require("colors") +local emojis = require("emojis") local settings = require("settings") local function mouse_click(env) @@ -14,7 +15,7 @@ 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, }, @@ -22,32 +23,52 @@ local function space_selection(env) }) 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