From 6dd71581a38041cf69ebdf1de1e7f8529b78b0e1 Mon Sep 17 00:00:00 2001 From: Wayne-Cole <77279425+Wacky404@users.noreply.github.com> Date: Sat, 22 Feb 2025 11:46:20 -0600 Subject: feat: rewrite of sketchybar (broken) and ditched yabai and skhd for aerospace --- .config/aerospace/aerospace.toml | 166 ++++++++++ .config/borders/bordersrc | 2 +- .config/sketchybar/bar.lua | 17 +- .config/sketchybar/colors.lua | 36 --- .config/sketchybar/config/colors.lua | 80 +++++ .config/sketchybar/config/dimensions.lua | 40 +++ .config/sketchybar/config/fonts.lua | 14 + .config/sketchybar/config/icons.lua | 412 ++++++++++++++++++++++++ .config/sketchybar/config/init.lua | 1 + .config/sketchybar/config/settings.lua | 11 + .config/sketchybar/constants.lua | 34 ++ .config/sketchybar/default.lua | 82 +++-- .config/sketchybar/helpers/app_icons.lua | 210 ------------ .config/sketchybar/helpers/default_font.lua | 13 - .config/sketchybar/icons.lua | 92 ------ .config/sketchybar/init.lua | 7 + .config/sketchybar/install/init.lua | 1 + .config/sketchybar/install/sbar.lua | 25 ++ .config/sketchybar/items/apple.lua | 41 +-- .config/sketchybar/items/calendar.lua | 50 --- .config/sketchybar/items/front_app.lua | 22 -- .config/sketchybar/items/front_apps.lua | 69 ++++ .config/sketchybar/items/init.lua | 9 +- .config/sketchybar/items/media.lua | 20 +- .config/sketchybar/items/menu_spaces_toggle.lua | 71 ++++ .config/sketchybar/items/menus.lua | 102 +++--- .config/sketchybar/items/message.lua | 57 ++++ .config/sketchybar/items/spaces.lua | 250 +++++--------- .config/sketchybar/items/widgets/calendar.lua | 17 + .config/sketchybar/items/widgets/init.lua | 1 + .config/sketchybar/settings.lua | 50 --- .config/sketchybar/sketchybarrc | 4 +- .config/sketchybar_backup/plugins/battery.sh | 28 -- .config/sketchybar_backup/plugins/clock.sh | 7 - .config/sketchybar_backup/plugins/front_app.sh | 10 - .config/sketchybar_backup/plugins/space.sh | 7 - .config/sketchybar_backup/plugins/volume.sh | 20 -- .config/sketchybar_backup/sketchybarrc | 91 ------ 38 files changed, 1225 insertions(+), 944 deletions(-) create mode 100644 .config/aerospace/aerospace.toml delete mode 100644 .config/sketchybar/colors.lua create mode 100644 .config/sketchybar/config/colors.lua create mode 100644 .config/sketchybar/config/dimensions.lua create mode 100644 .config/sketchybar/config/fonts.lua create mode 100644 .config/sketchybar/config/icons.lua create mode 100644 .config/sketchybar/config/init.lua create mode 100644 .config/sketchybar/config/settings.lua create mode 100644 .config/sketchybar/constants.lua delete mode 100644 .config/sketchybar/helpers/app_icons.lua delete mode 100644 .config/sketchybar/helpers/default_font.lua delete mode 100644 .config/sketchybar/icons.lua create mode 100644 .config/sketchybar/install/init.lua create mode 100644 .config/sketchybar/install/sbar.lua delete mode 100644 .config/sketchybar/items/calendar.lua delete mode 100644 .config/sketchybar/items/front_app.lua create mode 100644 .config/sketchybar/items/front_apps.lua create mode 100644 .config/sketchybar/items/menu_spaces_toggle.lua create mode 100644 .config/sketchybar/items/message.lua create mode 100644 .config/sketchybar/items/widgets/calendar.lua delete mode 100644 .config/sketchybar/settings.lua delete mode 100755 .config/sketchybar_backup/plugins/battery.sh delete mode 100755 .config/sketchybar_backup/plugins/clock.sh delete mode 100755 .config/sketchybar_backup/plugins/front_app.sh delete mode 100755 .config/sketchybar_backup/plugins/space.sh delete mode 100755 .config/sketchybar_backup/plugins/volume.sh delete mode 100755 .config/sketchybar_backup/sketchybarrc diff --git a/.config/aerospace/aerospace.toml b/.config/aerospace/aerospace.toml new file mode 100644 index 0000000..b0abe5e --- /dev/null +++ b/.config/aerospace/aerospace.toml @@ -0,0 +1,166 @@ +# 'start-at-login' needs to be 'true' for 'after-login-command' to work +# Available commands: https://nikitabobko.github.io/AeroSpace/commands +after-login-command = [] + +# 'after-startup-command' is run after 'after-login-command' +# Available commands : https://nikitabobko.github.io/AeroSpace/commands +after-startup-command = [] + +# Start AeroSpace at login +start-at-login = true + +# Normalizations. See: https://nikitabobko.github.io/AeroSpace/guide#normalization +enable-normalization-flatten-containers = true +enable-normalization-opposite-orientation-for-nested-containers = true + +# See: https://nikitabobko.github.io/AeroSpace/guide#layouts +# The 'accordion-padding' specifies the size of accordion padding +# You can set 0 to disable the padding feature +accordion-padding = 30 + +# Possible values: tiles|accordion +default-root-container-layout = 'tiles' + +# Possible values: horizontal|vertical|auto +# 'auto' means: wide monitor (anything wider than high) gets horizontal orientation, +# tall monitor (anything higher than wide) gets vertical orientation +default-root-container-orientation = 'auto' + +# Mouse follows focus when focused monitor changes +# Drop it from your config, if you don't like this behavior +# See https://nikitabobko.github.io/AeroSpace/guide#on-focus-changed-callbacks +# See https://nikitabobko.github.io/AeroSpace/commands#move-mouse +# Fallback value (if you omit the key): on-focused-monitor-changed = [] +on-focused-monitor-changed = ['move-mouse monitor-lazy-center'] + +# You can effectively turn off macOS "Hide application" (cmd-h) feature by toggling this flag +# Useful if you don't use this macOS feature, but accidentally hit cmd-h or cmd-alt-h key +# Also see: https://nikitabobko.github.io/AeroSpace/goodies#disable-hide-app +automatically-unhide-macos-hidden-apps = true + +# Possible values: (qwerty|dvorak) +# See https://nikitabobko.github.io/AeroSpace/guide#key-mapping +[key-mapping] + preset = 'qwerty' + +# Gaps between windows (inner-*) and between monitor edges (outer-*). +# Possible values: +# - Constant: gaps.outer.top = 8 +# - Per monitor: gaps.outer.top = [{ monitor.main = 16 }, { monitor."some-pattern" = 32 }, 24] +# In this example, 24 is a default value when there is no match. +# Monitor pattern is the same as for 'workspace-to-monitor-force-assignment'. +# See: +# https://nikitabobko.github.io/AeroSpace/guide#assign-workspaces-to-monitors +[gaps] + inner.horizontal = 10 + inner.vertical = 10 + outer.left = 10 + outer.bottom = 10 + outer.top = 45 + outer.right = 10 + +# 'main' binding mode declaration +# See: https://nikitabobko.github.io/AeroSpace/guide#binding-modes +# 'main' binding mode must be always presented +# Fallback value (if you omit the key): mode.main.binding = {} +[mode.main.binding] + + # All possible keys: + # - Letters. a, b, c, ..., z + # - Numbers. 0, 1, 2, ..., 9 + # - Keypad numbers. keypad0, keypad1, keypad2, ..., keypad9 + # - F-keys. f1, f2, ..., f20 + # - Special keys. minus, equal, period, comma, slash, backslash, quote, semicolon, + # backtick, leftSquareBracket, rightSquareBracket, space, enter, esc, + # backspace, tab + # - Keypad special. keypadClear, keypadDecimalMark, keypadDivide, keypadEnter, keypadEqual, + # keypadMinus, keypadMultiply, keypadPlus + # - Arrows. left, down, up, right + + # All possible modifiers: cmd, alt, ctrl, shift + + # All possible commands: https://nikitabobko.github.io/AeroSpace/commands + + # See: https://nikitabobko.github.io/AeroSpace/commands#exec-and-forget + # You can uncomment the following lines to open up terminal with alt + enter shortcut + # (like in i3) + # This is cool, going to use this more + alt-t = '''exec-and-forget osascript -e ' + tell application "iTerm" + do script + activate + end tell' + ''' + + # See: https://nikitabobko.github.io/AeroSpace/commands#layout + alt-slash = 'layout tiles horizontal vertical' + alt-comma = 'layout accordion horizontal vertical' + + # See: https://nikitabobko.github.io/AeroSpace/commands#focus + alt-h = 'focus left' + alt-j = 'focus down' + alt-k = 'focus up' + alt-l = 'focus right' + + # See: https://nikitabobko.github.io/AeroSpace/commands#move + ctrl-shift-h = 'move left' + ctrl-shift-j = 'move down' + ctrl-shift-k = 'move up' + ctrl-shift-l = 'move right' + + # See: https://nikitabobko.github.io/AeroSpace/commands#resize + alt-minus = 'resize smart -50' + alt-equal = 'resize smart +50' + + # See: https://nikitabobko.github.io/AeroSpace/commands#workspace + cmd-1 = 'workspace 1' + cmd-2 = 'workspace 2' + cmd-3 = 'workspace 3' + cmd-4 = 'workspace 4' + cmd-5 = 'workspace 5' + cmd-6 = 'workspace 6' + + # See: https://nikitabobko.github.io/AeroSpace/commands#move-node-to-workspace + ctrl-1 = 'move-node-to-workspace 1' + ctrl-2 = 'move-node-to-workspace 2' + ctrl-3 = 'move-node-to-workspace 3' + ctrl-4 = 'move-node-to-workspace 4' + ctrl-5 = 'move-node-to-workspace 5' + ctrl-6 = 'move-node-to-workspace 6' + + # See: https://nikitabobko.github.io/AeroSpace/commands#workspace-back-and-forth + ctrl-tab = 'workspace-back-and-forth' + # See: https://nikitabobko.github.io/AeroSpace/commands#move-workspace-to-monitor + ctrl-shift-tab = 'move-workspace-to-monitor --wrap-around next' + + # See: https://nikitabobko.github.io/AeroSpace/commands#mode + alt-shift-semicolon = 'mode service' + +# 'service' binding mode declaration. +# See: https://nikitabobko.github.io/AeroSpace/guide#binding-modes +[mode.service.binding] + esc = ['reload-config', 'mode main'] + r = ['flatten-workspace-tree', 'mode main'] # reset layout + f = ['layout floating tiling', 'mode main'] # Toggle between floating and tiling layout + backspace = ['close-all-windows-but-current', 'mode main'] + + # sticky is not yet supported https://github.com/nikitabobko/AeroSpace/issues/2 + #s = ['layout sticky tiling', 'mode main'] + + alt-shift-h = ['join-with left', 'mode main'] + alt-shift-j = ['join-with down', 'mode main'] + alt-shift-k = ['join-with up', 'mode main'] + alt-shift-l = ['join-with right', 'mode main'] + + down = 'volume down' + up = 'volume up' + shift-down = ['volume set 0', 'mode main'] + +# make sure these apps are in floating win +[[on-window-detected]] +if .app-name-regex-substring = 'finder' +run = 'layout floating' + +[[on-window-detected]] +if .app-name-regex-substring = 'discord' +run = 'layout floating' diff --git a/.config/borders/bordersrc b/.config/borders/bordersrc index 6f7410d..5db34bc 100755 --- a/.config/borders/bordersrc +++ b/.config/borders/bordersrc @@ -25,7 +25,7 @@ transparent=0x00000000 options=( # square; other option style=round - width=10.0 + width=5.0 hidpi=off active_color=$orange_brown inactive_color=$grey diff --git a/.config/sketchybar/bar.lua b/.config/sketchybar/bar.lua index 659ccae..c22d4c1 100644 --- a/.config/sketchybar/bar.lua +++ b/.config/sketchybar/bar.lua @@ -1,11 +1,14 @@ -local colors = require("colors") +local settings = require("config.settings") --- Equivalent to the --bar domain sbar.bar({ topmost = "window", - height = 40, - -- changes the whole bar color - color = colors.transparent, - padding_right = 2, - padding_left = 2, + height = settings.dimensions.graphics.height, + color = settings.colors.transparent, + padding_right = settings.dimensions.paddings.right, + padding_left = settings.dimensions.paddings.left, + margin = settings.dimensions.paddings.bar, + corner_radius = settings.dimensions.graphics.background.corner_radius, + y_offset = settings.dimensions.graphics.bar.offset, + blur_radius = settings.dimensions.graphics.blur_radius, + border_width = 0, }) diff --git a/.config/sketchybar/colors.lua b/.config/sketchybar/colors.lua deleted file mode 100644 index 751cfd6..0000000 --- a/.config/sketchybar/colors.lua +++ /dev/null @@ -1,36 +0,0 @@ -return { - -- in hex - black = 0xff181819, - white = 0xffe2e2e3, - red = 0xfffc5d7c, - blood = 0xFF8A0303, - green = 0xff9ed072, - blue = 0xff76cce0, - cog_blue = 0xff6a97b8, - yellow = 0xffe7c664, - orange = 0xfff39660, - orange_brown = 0xffC46210, - magenta = 0xffb39df3, - grey = 0xff7f8490, - pink = 0xffffc0cb, - purple = 0xff8a00c2, - transparent = 0x00000000, - - bar = { - bg = 0xf02c2e34, - border = 0xff2c2e34, - }, - popup = { - bg = 0xc02c2e34, - border = 0xff7f8490, - }, - bg1 = 0xff363944, - bg2 = 0xff414550, - - with_alpha = function(color, alpha) - if alpha > 1.0 or alpha < 0.0 then - return color - end - return (color & 0x00ffffff) | (math.floor(alpha * 255.0) << 24) - end, -} diff --git a/.config/sketchybar/config/colors.lua b/.config/sketchybar/config/colors.lua new file mode 100644 index 0000000..22c4f27 --- /dev/null +++ b/.config/sketchybar/config/colors.lua @@ -0,0 +1,80 @@ +Black = 0xff181819 +White = 0xffe2e2e3 +Red = 0xfffc5d7c +Blood = 0xFF8A0303 +Green = 0xff9ed072 +Blue = 0xff76cce0 +Cog_blue = 0xff6a97b8 +Yellow = 0xffe7c664 +Orange = 0xfff39660 +Orange_brown = 0xffC46210 +Magenta = 0xffb39df3 +Grey = 0xff7f8490 +Pink = 0xffffc0cb +Purple = 0xff8a00c2 +Transparent = 0x00000000 + +local colors = { + black = Black, + white = White, + red = Red, + blood = Blood, + green = Green, + blue = Blue, + cog_blue = Cog_blue, + yellow = Yellow, + orange = Orange, + orange_brown = Orange_brown, + magenta = Magenta, + grey = Grey, + pink = Pink, + purple = Purple, + transparent = Transparent, + + bar = { + bg = 0xf02c2e34, + border = 0xff2c2e34, + }, + popup = { + bg = 0xc02c2e34, + border = 0xff7f8490, + }, + bg1 = 0xff363944, + bg2 = 0xff414550, + + with_alpha = function(color, alpha) + if alpha > 1.0 or alpha < 0.0 then + return color + end + return (color & 0x00ffffff) | (math.floor(alpha * 255.0) << 24) + end, + + -- widgets borders; cpu, wifi, vol, batt + widget_borders = Grey, + -- battery widget + batt_background = Black, + batt_color_default = Green, + batt_color_25 = Orange_brown, + batt_color_0 = Grey, + -- cpu widget + cpu_background = Black, + -- volume widget + volume_background = Black, + -- wifi widget + wifi_background = Black, + -- apple.lua + apple_icon = White, + apple_background = Black, + apple_border = Black, + -- calendar.lua + calendar_background = Black, + calendar_border = Black, + -- spaces.lua + spaces_highlight = White, + spaces_icon = Grey, + spaces_background = Black, + spaces_border = Grey, + spaces_selected = White, +} + +return colors diff --git a/.config/sketchybar/config/dimensions.lua b/.config/sketchybar/config/dimensions.lua new file mode 100644 index 0000000..f5fb211 --- /dev/null +++ b/.config/sketchybar/config/dimensions.lua @@ -0,0 +1,40 @@ +local paddings = { + background = 8, + icon = 10, + label = 8, + bar = 39, + left = 12, + right = 12, + item = 18, + popup = 8, +} + +local graphics = { + bar = { + height = 40, + offset = 12, + }, + background = { + height = 24, + corner_radius = 9, + }, + slider = { + height = 20, + }, + popup = { + width = 200, + large_width = 300, + }, + blur_radius = 30, +} + +local text = { + icon = 16.0, + label = 14.0, +} + +return { + paddings = paddings, + graphics = graphics, + text = text, +} diff --git a/.config/sketchybar/config/fonts.lua b/.config/sketchybar/config/fonts.lua new file mode 100644 index 0000000..51cb0ee --- /dev/null +++ b/.config/sketchybar/config/fonts.lua @@ -0,0 +1,14 @@ +local dimens = require("config.dimensions") + +return { + text = "SpaceMono Nerd Font", + numbers = "SpaceMono Nerd Font", + icons = function(size) + local font = "sketchybar-app-font:Regular" + return size and font .. ":" .. size or font .. ":" .. dimens.text.icon + end, + styles = { + regular = "Regular", + bold = "Bold", + }, +} diff --git a/.config/sketchybar/config/icons.lua b/.config/sketchybar/config/icons.lua new file mode 100644 index 0000000..6bbf155 --- /dev/null +++ b/.config/sketchybar/config/icons.lua @@ -0,0 +1,412 @@ +local apps = { + ["Live"] = ":ableton:", + ["Adobe Bridge 2024"] = ":adobe_bridge:", + ["Affinity Designer"] = ":affinity_designer:", + ["Affinity Designer 2"] = ":affinity_designer_2:", + ["Affinity Photo"] = ":affinity_photo:", + ["Affinity Photo 2"] = ":affinity_photo_2:", + ["Affinity Publisher"] = ":affinity_publisher:", + ["Affinity Publisher 2"] = ":affinity_publisher_2:", + ["Airmail"] = ":airmail:", + ["Alacritty"] = ":alacritty:", + ["Alfred Preferences"] = ":alfred:", + ["Android Messages"] = ":android_messages:", + ["Android Studio"] = ":android_studio:", + ["Anytype"] = ":anytype:", + ["App Eraser"] = ":app_eraser:", + ["App Store"] = ":app_store:", + ["Arc"] = ":arc:", + ["Atom"] = ":atom:", + ["Audacity"] = ":audacity:", + ["Bambu Studio"] = ":bambu_studio:", + ["MoneyMoney"] = ":bank:", + ["Bear"] = ":bear:", + ["BetterTouchTool"] = ":bettertouchtool:", + ["Bilibili"] = ":bilibili:", + ["哔哩哔哩"] = ":bilibili:", + ["Bitwarden"] = ":bit_warden:", + ["Blender"] = ":blender:", + ["BluOS Controller"] = ":bluos_controller:", + ["Calibre"] = ":book:", + ["Brave Browser"] = ":brave_browser:", + ["Calculator"] = ":calculator:", + ["Soulver 3"] = ":calculator:", + ["Calculette"] = ":calculator:", + ["Calendar"] = ":calendar:", + ["日历"] = ":calendar:", + ["Fantastical"] = ":calendar:", + ["Cron"] = ":calendar:", + ["Amie"] = ":calendar:", + ["Calendrier"] = ":calendar:", + ["Notion Calendar"] = ":calendar:", + ["Caprine"] = ":caprine:", + ["Citrix Workspace"] = ":citrix:", + ["Citrix Viewer"] = ":citrix:", + ["ClickUp"] = ":click_up:", + ["Code"] = ":code:", + ["Code - Insiders"] = ":code:", + ["Color Picker"] = ":color_picker:", + ["数码测色计"] = ":color_picker:", + ["CotEditor"] = ":coteditor:", + ["Cypress"] = ":cypress:", + ["DataGrip"] = ":datagrip:", + ["DataSpell"] = ":dataspell:", + ["DaVinci Resolve"] = ":davinciresolve:", + ["Default"] = ":default:", + ["CleanMyMac X"] = ":desktop:", + ["DEVONthink 3"] = ":devonthink3:", + ["DingTalk"] = ":dingtalk:", + ["钉钉"] = ":dingtalk:", + ["阿里钉"] = ":dingtalk:", + ["Discord"] = ":discord:", + ["Discord Canary"] = ":discord:", + ["Discord PTB"] = ":discord:", + ["Docker"] = ":docker:", + ["Docker Desktop"] = ":docker:", + ["GrandTotal"] = ":dollar:", + ["Receipts"] = ":dollar:", + ["Double Commander"] = ":doublecmd:", + ["Drafts"] = ":drafts:", + ["Dropbox"] = ":dropbox:", + ["Element"] = ":element:", + ["Emacs"] = ":emacs:", + ["Evernote Legacy"] = ":evernote_legacy:", + ["FaceTime"] = ":face_time:", + ["FaceTime 通话"] = ":face_time:", + ["Figma"] = ":figma:", + ["Final Cut Pro"] = ":final_cut_pro:", + ["Finder"] = ":finder:", + ["访达"] = ":finder:", + ["Firefox"] = ":firefox:", + ["Firefox Developer Edition"] = ":firefox_developer_edition:", + ["Firefox Nightly"] = ":firefox_developer_edition:", + ["Folx"] = ":folx:", + ["Fusion"] = ":fusion:", + ["System Preferences"] = ":gear:", + ["System Settings"] = ":gear:", + ["Systemeinstellungen"] = ":gear:", + ["系统设置"] = ":gear:", + ["Réglages Système"] = ":gear:", + ["GitHub Desktop"] = ":git_hub:", + ["Godot"] = ":godot:", + ["GoLand"] = ":goland:", + ["Chromium"] = ":google_chrome:", + ["Google Chrome"] = ":google_chrome:", + ["Google Chrome Canary"] = ":google_chrome:", + ["Grammarly Editor"] = ":grammarly:", + ["Home Assistant"] = ":home_assistant:", + ["Hyper"] = ":hyper:", + ["IntelliJ IDEA"] = ":idea:", + ["Inkdrop"] = ":inkdrop:", + ["Inkscape"] = ":inkscape:", + ["Insomnia"] = ":insomnia:", + ["Iris"] = ":iris:", + ["iTerm"] = ":iterm:", + ["iTerm2"] = ":iterm:", + ["Jellyfin Media Player"] = ":jellyfin:", + ["Joplin"] = ":joplin:", + ["카카오톡"] = ":kakaotalk:", + ["KakaoTalk"] = ":kakaotalk:", + ["Kakoune"] = ":kakoune:", + ["KeePassXC"] = ":kee_pass_x_c:", + ["Secrets"] = ":one_password:", + ["Keyboard Maestro"] = ":keyboard_maestro:", + ["Keynote"] = ":keynote:", + ["Keynote 讲演"] = ":keynote:", + ["kitty"] = ":kitty:", + ["League of Legends"] = ":league_of_legends:", + ["LibreWolf"] = ":libre_wolf:", + ["Adobe Lightroom"] = ":lightroom:", + ["Lightroom Classic"] = ":lightroomclassic:", + ["LINE"] = ":line:", + ["Linear"] = ":linear:", + ["LM Studio"] = ":lm_studio:", + ["LocalSend"] = ":localsend:", + ["Logic Pro"] = ":logicpro:", + ["Logseq"] = ":logseq:", + ["Canary Mail"] = ":mail:", + ["HEY"] = ":mail:", + ["Mail"] = ":mail:", + ["Mailspring"] = ":mail:", + ["MailMate"] = ":mail:", + ["Superhuman"] = ":mail:", + ["邮件"] = ":mail:", + ["MAMP"] = ":mamp:", + ["MAMP PRO"] = ":mamp:", + ["Maps"] = ":maps:", + ["Google Maps"] = ":maps:", + ["Matlab"] = ":matlab:", + ["Mattermost"] = ":mattermost:", + ["Messages"] = ":messages:", + ["信息"] = ":messages:", + ["Nachrichten"] = ":messages:", + ["Messenger"] = ":messenger:", + ["Microsoft Edge"] = ":microsoft_edge:", + ["Microsoft Excel"] = ":microsoft_excel:", + ["Microsoft Outlook"] = ":microsoft_outlook:", + ["Microsoft PowerPoint"] = ":microsoft_power_point:", + ["Microsoft Remote Desktop"] = ":microsoft_remote_desktop:", + ["Microsoft Teams"] = ":microsoft_teams:", + ["Microsoft Teams (work or school)"] = ":microsoft_teams:", + ["Microsoft Word"] = ":microsoft_word:", + ["Min"] = ":min_browser:", + ["Miro"] = ":miro:", + ["MongoDB Compass"] = ":mongodb:", + ["mpv"] = ":mpv:", + ["Mullvad Browser"] = ":mullvad_browser:", + ["Music"] = ":music:", + ["音乐"] = ":music:", + ["Musique"] = ":music:", + ["Neovide"] = ":neovide:", + ["neovide"] = ":neovide:", + ["Neovim"] = ":neovim:", + ["neovim"] = ":neovim:", + ["nvim"] = ":neovim:", + ["网易云音乐"] = ":netease_music:", + ["Noodl"] = ":noodl:", + ["Noodl Editor"] = ":noodl:", + ["NordVPN"] = ":nord_vpn:", + ["Notability"] = ":notability:", + ["Notes"] = ":notes:", + ["Notizen"] = ":notes:", + ["备忘录"] = ":notes:", + ["Notion"] = ":notion:", + ["Nova"] = ":nova:", + ["Numbers"] = ":numbers:", + ["Numbers 表格"] = ":numbers:", + ["Obsidian"] = ":obsidian:", + ["OBS"] = ":obsstudio:", + ["OmniFocus"] = ":omni_focus:", + ["1Password"] = ":one_password:", + ["ChatGPT"] = ":openai:", + ["OpenVPN Connect"] = ":openvpn_connect:", + ["Opera"] = ":opera:", + ["OrcaSlicer"] = ":orcaslicer:", + ["Orion"] = ":orion:", + ["Orion RC"] = ":orion:", + ["Pages"] = ":pages:", + ["Pages 文稿"] = ":pages:", + ["Parallels Desktop"] = ":parallels:", + ["Parsec"] = ":parsec:", + ["Preview"] = ":pdf:", + ["预览"] = ":pdf:", + ["Skim"] = ":pdf:", + ["zathura"] = ":pdf:", + ["Aperçu"] = ":pdf:", + ["PDF Expert"] = ":pdf_expert:", + ["Adobe Photoshop"] = ":photoshop:", + ["Pi-hole Remote"] = ":pihole:", + ["Pine"] = ":pine:", + ["Podcasts"] = ":podcasts:", + ["播客"] = ":podcasts:", + ["PomoDone App"] = ":pomodone:", + ["Postman"] = ":postman:", + ["PrusaSlicer"] = ":prusaslicer:", + ["SuperSlicer"] = ":prusaslicer:", + ["PyCharm"] = ":pycharm:", + ["QQ"] = ":qq:", + ["QQ音乐"] = ":qqmusic:", + ["QQMusic"] = ":qqmusic:", + ["Quantumult X"] = ":quantumult_x:", + ["qutebrowser"] = ":qute_browser:", + ["Raindrop.io"] = ":raindrop_io:", + ["Reeder"] = ":reeder5:", + ["Reminders"] = ":reminders:", + ["提醒事项"] = ":reminders:", + ["Rappels"] = ":reminders:", + ["Replit"] = ":replit:", + ["Rider"] = ":rider:", + ["JetBrains Rider"] = ":rider:", + ["Safari"] = ":safari:", + ["Safari浏览器"] = ":safari:", + ["Safari Technology Preview"] = ":safari:", + ["Sequel Ace"] = ":sequel_ace:", + ["Sequel Pro"] = ":sequel_pro:", + ["Setapp"] = ":setapp:", + ["SF Symbols"] = ":sf_symbols:", + ["Signal"] = ":signal:", + ["Sketch"] = ":sketch:", + ["Skype"] = ":skype:", + ["Slack"] = ":slack:", + ["Spark"] = ":spark:", + ["Spotify"] = ":spotify:", + ["Spotlight"] = ":spotlight:", + ["Sublime Text"] = ":sublime_text:", + ["Tana"] = ":tana:", + ["TeamSpeak 3"] = ":team_speak:", + ["Telegram"] = ":telegram:", + ["Terminal"] = ":terminal:", + ["终端"] = ":terminal:", + ["Typora"] = ":text:", + ["Microsoft To Do"] = ":things:", + ["Things"] = ":things:", + ["Thunderbird"] = ":thunderbird:", + ["TickTick"] = ":tick_tick:", + ["TIDAL"] = ":tidal:", + ["Tiny RDM"] = ":tinyrdm:", + ["Todoist"] = ":todoist:", + ["Toggl Track"] = ":toggl_track:", + ["Tor Browser"] = ":tor_browser:", + ["Tower"] = ":tower:", + ["Transmit"] = ":transmit:", + ["Trello"] = ":trello:", + ["Tweetbot"] = ":twitter:", + ["Twitter"] = ":twitter:", + ["MacVim"] = ":vim:", + ["Vim"] = ":vim:", + ["VimR"] = ":vim:", + ["Vivaldi"] = ":vivaldi:", + ["VLC"] = ":vlc:", + ["VMware Fusion"] = ":vmware_fusion:", + ["VSCodium"] = ":vscodium:", + ["Warp"] = ":warp:", + ["WebStorm"] = ":web_storm:", + ["微信"] = ":wechat:", + ["WeChat"] = ":wechat:", + ["企业微信"] = ":wecom:", + ["WeCom"] = ":wecom:", + ["WezTerm"] = ":wezterm:", + ["WhatsApp"] = ":whats_app:", + ["‎WhatsApp"] = ":whats_app:", + ["Xcode"] = ":xcode:", + ["Яндекс Музыка"] = ":yandex_music:", + ["Yuque"] = ":yuque:", + ["语雀"] = ":yuque:", + ["Zed"] = ":zed:", + ["Zeplin"] = ":zeplin:", + ["zoom.us"] = ":zoom:", + ["Zotero"] = ":zotero:", + ["Zulip"] = ":zulip:", + ["default"] = ":default:", +} + +local text = { + nerdfont = { + plus = "", + loading = "", + apple = "", + gear = "", + cpu = "􀫥", + clipboard = "󰅇", + switch = { + on = "󱨥", + off = "󱨦", + }, + volume = { + _100 = "", + _66 = "", + _33 = "", + _10 = "", + _0 = "􀊣", + }, + battery = { + _100 = "", + _75 = "", + _50 = "", + _25 = "", + _0 = "", + charging = "", + }, + wifi = { + upload = "", + download = "", + connected = "󰖩", + disconnected = "󰖪", + router = "󰑩", + }, + media = { + back = "", + forward = "", + play_pause = "", + }, + slider = { + knob = "", + }, + }, + sf_symbols = { + plus = "􀅼", + loading = "􀖇", + apple = "􀣺", + gear = "􀍟", + cpu = "􀫥", + clipboard = "􀉄", + + switch = { + on = "􁏮", + off = "􁏯", + }, + volume = { + _100 = "􀊩", + _66 = "􀊧", + _33 = "􀊥", + _10 = "􀊡", + _0 = "􀊣", + }, + battery = { + _100 = "􀛨", + _75 = "􀺸", + _50 = "􀺶", + _25 = "􀛩", + _0 = "􀛪", + charging = "􀢋", + }, + wifi = { + upload = "􀄨", + download = "􀄩", + connected = "􀙇", + disconnected = "􀙈", + router = "􁓤", + }, + media = { + back = "􀊊", + forward = "􀊌", + play_pause = "􀊈", + }, + }, + + -- Alternative NerdFont icons + nerdfont = { + plus = "", + loading = "", + apple = "", + gear = "", + cpu = "", + clipboard = "Missing Icon", + + switch = { + on = "󱨥", + off = "󱨦", + }, + volume = { + _100 = "", + _66 = "", + _33 = "", + _10 = "", + _0 = "", + }, + battery = { + _100 = "", + _75 = "", + _50 = "", + _25 = "", + _0 = "", + charging = "", + }, + wifi = { + upload = "", + download = "", + connected = "󰖩", + disconnected = "󰖪", + router = "Missing Icon", + }, + media = { + back = "", + forward = "", + play_pause = "", + }, + }, +} +return { + text = text, + apps = apps, +} diff --git a/.config/sketchybar/config/init.lua b/.config/sketchybar/config/init.lua new file mode 100644 index 0000000..910b0eb --- /dev/null +++ b/.config/sketchybar/config/init.lua @@ -0,0 +1 @@ +require("config.settings") diff --git a/.config/sketchybar/config/settings.lua b/.config/sketchybar/config/settings.lua new file mode 100644 index 0000000..54aa840 --- /dev/null +++ b/.config/sketchybar/config/settings.lua @@ -0,0 +1,11 @@ +local dimensions = require("config.dimensions") +local colors = require("config.colors") +local fonts = require("config.fonts") +local icons = require("config.icons") + +return { + colors = colors, + dimensions = dimensions, + fonts = fonts, + icons = icons, +} diff --git a/.config/sketchybar/constants.lua b/.config/sketchybar/constants.lua new file mode 100644 index 0000000..c3543b4 --- /dev/null +++ b/.config/sketchybar/constants.lua @@ -0,0 +1,34 @@ +local events = { + AEROSPACE_WORKSPACE_CHANGED = "aerospace_workspace_changed", + AEROSPACE_SWITCH = "aerospace_switch", + SWAP_MENU_AND_SPACES = "swap_menu_and_spaces", + FRONT_APP_SWITCHED = "front_app_switched", + UPDATE_WINDOWS = "update_windows", + SEND_MESSAGE = "send_message", + HIDE_MESSAGE = "hide_message", +} + +local items = { + SPACES = "workspaces", + MENU = "menu", + MENU_TOGGLE = "menu_toggle", + FRONT_APPS = "front_apps", + MESSAGE = "message", + VOLUME = "widgets.volume", + WIFI = "widgets.wifi", + BATTERY = "widgets.battery", + CALENDAR = "widgets.calendar", +} + +local aerospace = { + LIST_ALL_WORKSPACES = "aerospace list-workspaces --all", + GET_CURRENT_WORKSPACE = "aerospace list-workspaces --focused", + LIST_WINDOWS = 'aerospace list-windows --workspace focused --format "id=%{window-id}, name=%{app-name}"', + GET_CURRENT_WINDOW = "aerospace list-windows --focused --format %{app-name}", +} + +return { + items = items, + events = events, + aerospace = aerospace, +} diff --git a/.config/sketchybar/default.lua b/.config/sketchybar/default.lua index aec37a4..93cee08 100644 --- a/.config/sketchybar/default.lua +++ b/.config/sketchybar/default.lua @@ -1,58 +1,72 @@ -local settings = require("settings") -local colors = require("colors") -local sbar = require("sketchybar") +local settings = require("config.settings") --- Equivalent to the --default domain sbar.default({ updates = "when_shown", icon = { font = { - family = settings.font.text, - style = settings.font.style_map["Bold"], - size = 14.0, + family = settings.fonts.text, + style = settings.fonts.styles.regular, + size = settings.dimensions.text.icon, }, - -- changed the applel logo & cpu - color = settings.apple_icon, - padding_left = settings.paddings, - padding_right = settings.paddings, - background = { image = { corner_radius = 9 } }, + -- changed the apple logo & cpu + color = settings.colors.white, + padding_left = settings.dimensions.paddings.icon, + padding_right = settings.dimensions.paddings.icon, }, label = { font = { - family = settings.font.text, - style = settings.font.style_map["Semibold"], - size = 13.0, + family = settings.fonts.text, + style = settings.fonts.styles.regular, + size = settings.dimensions.text.label, }, -- text color for widgets - color = colors.white, - padding_left = settings.paddings, - padding_right = settings.paddings, + color = settings.colors.white, + padding_left = settings.dimensions.paddings.label, + padding_right = settings.dimensions.paddings.label, }, background = { - height = 28, - corner_radius = 9, - border_width = 2, + height = settings.dimensions.graphics.background.height, + corner_radius = settings.dimensions.graphics.background.corner_radius, + border_width = 0, -- changes border color for widgets - border_color = settings.widget_borders, + -- border_color = settings.colors.widget_borders, image = { - corner_radius = 9, - border_color = colors.grey, - border_width = 1, + corner_radius = settings.dimensions.graphics.background.corner_radius, + -- border_color = settings.colors.grey, + -- border_width = 1, }, }, popup = { + y_offset = settings.dimensions.paddings.popup, + align = "center", background = { - border_width = 2, - corner_radius = 9, - -- colors.popup.border - border_color = colors.popup.border, - -- colors.popup.bg - color = colors.popup.bg, + border_width = 0, + corner_radius = settings.dimensions.graphics.background.corner_radius, + color = settings.colors.popup.bg, shadow = { drawing = true }, + padding_left = settings.dimensions.paddings.icon, + padding_right = settings.dimensions.paddings.icon, + }, + blur_radius = settings.dimensions.graphics.blur_radius, + }, + slider = { + highlight_color = settings.colors.orange, + background = { + height = settings.dimens.graphics.slider.height, + corner_radius = settings.dimens.graphics.background.corner_radius, + color = settings.colors.slider.bg, + border_color = settings.colors.slider.border, + border_width = 1, + }, + knob = { + font = { + family = settings.fonts.text, + style = settings.fonts.styles.regular, + size = 32, + }, + string = settings.icons.text.slider.knob, + drawing = false, }, - blur_radius = 50, }, - padding_left = 5, - padding_right = 5, scroll_texts = true, }) diff --git a/.config/sketchybar/helpers/app_icons.lua b/.config/sketchybar/helpers/app_icons.lua deleted file mode 100644 index 3487782..0000000 --- a/.config/sketchybar/helpers/app_icons.lua +++ /dev/null @@ -1,210 +0,0 @@ -return { - ["Typora"] = ":text:", - ["Orion"] = ":orion:", - ["Orion RC"] = ":orion:", - ["Grammarly Editor"] = ":grammarly:", - ["kitty"] = ":kitty:", - ["ClickUp"] = ":click_up:", - ["Iris"] = ":iris:", - ["PomoDone App"] = ":pomodone:", - ["qutebrowser"] = ":qute_browser:", - ["Raindrop.io"] = ":raindrop_io:", - ["Airmail"] = ":airmail:", - ["Affinity Publisher 2"] = ":affinity_publisher_2:", - ["Calendar"] = ":calendar:", - ["日历"] = ":calendar:", - ["Fantastical"] = ":calendar:", - ["Cron"] = ":calendar:", - ["Amie"] = ":calendar:", - ["Figma"] = ":figma:", - ["Element"] = ":element:", - ["Signal"] = ":signal:", - ["Mattermost"] = ":mattermost:", - ["Caprine"] = ":caprine:", - ["Microsoft To Do"] = ":things:", - ["Things"] = ":things:", - ["Godot"] = ":godot:", - ["Android Messages"] = ":android_messages:", - ["Zed"] = ":zed:", - ["Anytype"] = ":anytype:", - ["TeamSpeak 3"] = ":team_speak:", - ["LibreWolf"] = ":libre_wolf:", - ["neovide"] = ":neovide:", - ["Spotlight"] = ":spotlight:", - ["微信"] = ":wechat:", - ["Dropbox"] = ":dropbox:", - ["Transmit"] = ":transmit:", - ["TickTick"] = ":tick_tick:", - ["Parallels Desktop"] = ":parallels:", - ["Audacity"] = ":audacity:", - ["Rider"] = ":rider:", - ["JetBrains Rider"] = ":rider:", - ["DEVONthink 3"] = ":devonthink3:", - ["Docker"] = ":docker:", - ["Docker Desktop"] = ":docker:", - ["Matlab"] = ":matlab:", - ["VLC"] = ":vlc:", - ["Alacritty"] = ":alacritty:", - ["Pages"] = ":pages:", - ["Pages 文稿"] = ":pages:", - ["Bear"] = ":bear:", - ["Pine"] = ":pine:", - ["Affinity Designer 2"] = ":affinity_designer_2:", - ["Keyboard Maestro"] = ":keyboard_maestro:", - ["Joplin"] = ":joplin:", - ["mpv"] = ":mpv:", - ["zoom.us"] = ":zoom:", - ["Affinity Photo 2"] = ":affinity_photo_2:", - ["Music"] = ":music:", - ["音乐"] = ":music:", - ["League of Legends"] = ":league_of_legends:", - ["Tor Browser"] = ":tor_browser:", - ["Hyper"] = ":hyper:", - ["‎WhatsApp"] = ":whats_app:", - ["카카오톡"] = ":kakaotalk:", - ["Discord"] = ":discord:", - ["Discord Canary"] = ":discord:", - ["Discord PTB"] = ":discord:", - ["Neovide"] = ":vim:", - ["MacVim"] = ":vim:", - ["Vim"] = ":vim:", - ["VimR"] = ":vim:", - ["Keynote"] = ":keynote:", - ["Keynote 讲演"] = ":keynote:", - ["iTerm"] = ":iterm:", - ["IntelliJ IDEA"] = ":idea:", - ["Finder"] = ":finder:", - ["访达"] = ":finder:", - ["Xcode"] = ":xcode:", - ["GoLand"] = ":goland:", - ["Android Studio"] = ":android_studio:", - ["MoneyMoney"] = ":bank:", - ["Spotify"] = ":spotify:", - ["KeePassXC"] = ":kee_pass_x_c:", - ["Alfred"] = ":alfred:", - ["Color Picker"] = ":color_picker:", - ["数码测色计"] = ":color_picker:", - ["Microsoft Word"] = ":microsoft_word:", - ["Microsoft PowerPoint"] = ":microsoft_power_point:", - ["Notes"] = ":notes:", - ["备忘录"] = ":notes:", - ["Microsoft Edge"] = ":microsoft_edge:", - ["Sublime Text"] = ":sublime_text:", - ["Sequel Ace"] = ":sequel_ace:", - ["Folx"] = ":folx:", - ["DingTalk"] = ":dingtalk:", - ["钉钉"] = ":dingtalk:", - ["阿里钉"] = ":dingtalk:", - ["WebStorm"] = ":web_storm:", - ["Sequel Pro"] = ":sequel_pro:", - ["Skype"] = ":skype:", - ["网易云音乐"] = ":netease_music:", - ["PyCharm"] = ":pycharm:", - ["Canary Mail"] = ":mail:", - ["HEY"] = ":mail:", - ["Mail"] = ":mail:", - ["Mailspring"] = ":mail:", - ["MailMate"] = ":mail:", - ["邮件"] = ":mail:", - ["Default"] = ":default:", - ["App Store"] = ":app_store:", - ["Calibre"] = ":book:", - ["Todoist"] = ":todoist:", - ["Emacs"] = ":emacs:", - ["Messenger"] = ":messenger:", - ["Tower"] = ":tower:", - ["VSCodium"] = ":vscodium:", - ["Drafts"] = ":drafts:", - ["Cypress"] = ":cypress:", - ["GitHub Desktop"] = ":git_hub:", - ["Telegram"] = ":telegram:", - ["Firefox Developer Edition"] = ":firefox_developer_edition:", - ["Firefox Nightly"] = ":firefox_developer_edition:", - ["Min"] = ":min_browser:", - ["Sketch"] = ":sketch:", - ["Affinity Photo"] = ":affinity_photo:", - ["MAMP"] = ":mamp:", - ["MAMP PRO"] = ":mamp:", - ["Insomnia"] = ":insomnia:", - ["Bitwarden"] = ":bit_warden:", - ["Warp"] = ":warp:", - ["System Preferences"] = ":gear:", - ["System Settings"] = ":gear:", - ["系统设置"] = ":gear:", - ["Affinity Designer"] = ":affinity_designer:", - ["Live"] = ":ableton:", - ["Arc"] = ":arc:", - ["Chromium"] = ":google_chrome:", - ["Google Chrome"] = ":google_chrome:", - ["Google Chrome Canary"] = ":google_chrome:", - ["Jellyfin Media Player"] = ":jellyfin:", - ["Zulip"] = ":zulip:", - ["1Password"] = ":one_password:", - ["FaceTime"] = ":face_time:", - ["FaceTime 通话"] = ":face_time:", - ["Citrix Workspace"] = ":citrix:", - ["Citrix Viewer"] = ":citrix:", - ["Logseq"] = ":logseq:", - ["Reeder"] = ":reeder5:", - ["Code"] = ":code:", - ["Code - Insiders"] = ":code:", - ["Notion"] = ":notion:", - ["Final Cut Pro"] = ":final_cut_pro:", - ["Zotero"] = ":zotero:", - ["Safari"] = ":safari:", - ["Safari浏览器"] = ":safari:", - ["Safari Technology Preview"] = ":safari:", - ["Blender"] = ":blender:", - ["Affinity Publisher"] = ":affinity_publisher:", - ["Spark Desktop"] = ":spark:", - ["Zeplin"] = ":zeplin:", - ["Replit"] = ":replit:", - ["Podcasts"] = ":podcasts:", - ["播客"] = ":podcasts:", - ["NordVPN"] = ":nord_vpn:", - ["Notability"] = ":notability:", - ["Numbers"] = ":numbers:", - ["Numbers 表格"] = ":numbers:", - ["Nova"] = ":nova:", - ["Microsoft Excel"] = ":microsoft_excel:", - ["Trello"] = ":trello:", - ["Pi-hole Remote"] = ":pihole:", - ["Linear"] = ":linear:", - ["CleanMyMac X"] = ":desktop:", - ["GrandTotal"] = ":dollar:", - ["Receipts"] = ":dollar:", - ["Evernote Legacy"] = ":evernote_legacy:", - ["OmniFocus"] = ":omni_focus:", - ["Terminal"] = ":terminal:", - ["终端"] = ":terminal:", - ["Atom"] = ":atom:", - ["Kakoune"] = ":kakoune:", - ["Reminders"] = ":reminders:", - ["提醒事项"] = ":reminders:", - ["Tana"] = ":tana:", - ["OBS"] = ":obsstudio:", - ["VMware Fusion"] = ":vmware_fusion:", - ["Tweetbot"] = ":twitter:", - ["Twitter"] = ":twitter:", - ["Microsoft Teams"] = ":microsoft_teams:", - ["Yuque"] = ":yuque:", - ["语雀"] = ":yuque:", - ["Slack"] = ":slack:", - ["Vivaldi"] = ":vivaldi:", - ["Setapp"] = ":setapp:", - ["TIDAL"] = ":tidal:", - ["Miro"] = ":miro:", - ["Messages"] = ":messages:", - ["信息"] = ":messages:", - ["Nachrichten"] = ":messages:", - ["Brave Browser"] = ":brave_browser:", - ["Preview"] = ":pdf:", - ["预览"] = ":pdf:", - ["Skim"] = ":pdf:", - ["zathura"] = ":pdf:", - ["Obsidian"] = ":obsidian:", - ["Thunderbird"] = ":thunderbird:", - ["Firefox"] = ":firefox:", - ["WezTerm"] = ":wezterm:", - ["default"] = ":default:", -} diff --git a/.config/sketchybar/helpers/default_font.lua b/.config/sketchybar/helpers/default_font.lua deleted file mode 100644 index fb1f16e..0000000 --- a/.config/sketchybar/helpers/default_font.lua +++ /dev/null @@ -1,13 +0,0 @@ -return { - text = "SF Pro", -- Used for text - numbers = "SF Mono", -- Used for numbers - - -- Unified font style map - style_map = { - ["Regular"] = "Regular", - ["Semibold"] = "Semibold", - ["Bold"] = "Bold", - ["Heavy"] = "Heavy", - ["Black"] = "Black", - } -} diff --git a/.config/sketchybar/icons.lua b/.config/sketchybar/icons.lua deleted file mode 100644 index 844b35c..0000000 --- a/.config/sketchybar/icons.lua +++ /dev/null @@ -1,92 +0,0 @@ -local settings = require("settings") - -local icons = { - sf_symbols = { - plus = "􀅼", - loading = "􀖇", - apple = "􀣺", - gear = "􀍟", - cpu = "􀫥", - clipboard = "􀉄", - - switch = { - on = "􁏮", - off = "􁏯", - }, - volume = { - _100 = "􀊩", - _66 = "􀊧", - _33 = "􀊥", - _10 = "􀊡", - _0 = "􀊣", - }, - battery = { - _100 = "􀛨", - _75 = "􀺸", - _50 = "􀺶", - _25 = "􀛩", - _0 = "􀛪", - charging = "􀢋", - }, - wifi = { - upload = "􀄨", - download = "􀄩", - connected = "􀙇", - disconnected = "􀙈", - router = "􁓤", - }, - media = { - back = "􀊊", - forward = "􀊌", - play_pause = "􀊈", - }, - }, - - -- Alternative NerdFont icons - nerdfont = { - plus = "", - loading = "", - apple = "", - gear = "", - cpu = "", - clipboard = "Missing Icon", - - switch = { - on = "󱨥", - off = "󱨦", - }, - volume = { - _100 = "", - _66 = "", - _33 = "", - _10 = "", - _0 = "", - }, - battery = { - _100 = "", - _75 = "", - _50 = "", - _25 = "", - _0 = "", - charging = "", - }, - wifi = { - upload = "", - download = "", - connected = "󰖩", - disconnected = "󰖪", - router = "Missing Icon", - }, - media = { - back = "", - forward = "", - play_pause = "", - }, - }, -} - -if not (settings.icons == "NerdFont") then - return icons.sf_symbols -else - return icons.nerdfont -end diff --git a/.config/sketchybar/init.lua b/.config/sketchybar/init.lua index e1bf892..e48ef58 100644 --- a/.config/sketchybar/init.lua +++ b/.config/sketchybar/init.lua @@ -1,3 +1,5 @@ +require("install.sbar") + -- Require the sketchybar module sbar = require("sketchybar") @@ -6,9 +8,14 @@ sbar = require("sketchybar") -- Bundle the entire initial configuration into a single message to sketchybar sbar.begin_config() +sbar.hotload(true) + +require("constants") +require("config") require("bar") require("default") require("items") + sbar.end_config() -- Run the event loop of the sketchybar module (without this there will be no diff --git a/.config/sketchybar/install/init.lua b/.config/sketchybar/install/init.lua new file mode 100644 index 0000000..bde1a41 --- /dev/null +++ b/.config/sketchybar/install/init.lua @@ -0,0 +1 @@ +require("install.sbar") diff --git a/.config/sketchybar/install/sbar.lua b/.config/sketchybar/install/sbar.lua new file mode 100644 index 0000000..1150569 --- /dev/null +++ b/.config/sketchybar/install/sbar.lua @@ -0,0 +1,25 @@ +local sbarpath = "/Users/" .. os.getenv("USER") .. "/.local/share/sketchybar_lua/" + +local function exists(file) + local ok, err, code = os.rename(file, file) + if not ok then + if code == 13 then + return true + end + end + return ok, err +end + +local function isdir(path) + return exists(path .. "/") +end + +if not isdir(sbarpath) then + os.execute( + "git clone https://github.com/FelixKratz/SbarLua.git /tmp/SbarLua && cd /tmp/SbarLua && make install && rm -rf /tmp/SbarLua/" + ) +end + +package.cpath = package.cpath .. ";" .. sbarpath .. "?.so" + +os.execute("(cd bridge && make)") diff --git a/.config/sketchybar/items/apple.lua b/.config/sketchybar/items/apple.lua index 00e9f44..b134620 100644 --- a/.config/sketchybar/items/apple.lua +++ b/.config/sketchybar/items/apple.lua @@ -1,38 +1,7 @@ -local colors = require("colors") -local icons = require("icons") -local settings = require("settings") -local sbar = require("sketchybar") +local settings = require("config.settings") --- Padding item required because of bracket -sbar.add("item", { width = 5 }) - -local apple = sbar.add("item", { - icon = { - font = { size = 16.0 }, - string = icons.apple, - padding_right = 8, - padding_left = 8, - }, - label = { drawing = false }, - background = { - -- was bg2 - color = settings.apple_background, - border_color = settings.apple_border, - border_width = 1, - }, - padding_left = 1, - padding_right = 1, - click_script = "$CONFIG_DIR/helpers/menus/bin/menus -s 0", -}) - --- Double border for apple using a single item bracket -sbar.add("bracket", { apple.name }, { - background = { - color = colors.transparent, - height = 30, - border_color = colors.grey, - }, +local apple = sbar.add("item", "apple", { + icon = { string = settings.icons.text.apple }, + label = { drawing = true }, + click_script = "$CONFIG_DIR/items/menus/bin/menus -s 0", }) - --- Padding item required because of bracket -sbar.add("item", { width = 7 }) diff --git a/.config/sketchybar/items/calendar.lua b/.config/sketchybar/items/calendar.lua deleted file mode 100644 index 36ca093..0000000 --- a/.config/sketchybar/items/calendar.lua +++ /dev/null @@ -1,50 +0,0 @@ -local settings = require("settings") -local colors = require("colors") -local sbar = require("sketchybar") - --- Padding item required because of bracket -sbar.add("item", { position = "right", width = settings.group_paddings }) - -local cal = sbar.add("item", { - icon = { - color = colors.white, - padding_left = 8, - font = { - style = settings.font.style_map["Black"], - size = 12.0, - }, - }, - label = { - color = colors.white, - padding_right = 8, - width = 49, - align = "right", - font = { family = settings.font.numbers }, - }, - position = "right", - update_freq = 30, - padding_left = 1, - padding_right = 1, - background = { - -- changes the color of background widget - color = settings.calendar_background, - border_color = settings.calendar_border, - border_width = 1, - }, -}) - --- Double border for calendar using a single item bracket -sbar.add("bracket", { cal.name }, { - background = { - color = colors.transparent, - height = 30, - border_color = colors.grey, - }, -}) - --- Padding item required because of bracket -sbar.add("item", { position = "right", width = settings.group_paddings }) - -cal:subscribe({ "forced", "routine", "system_woke" }, function(env) - cal:set({ icon = os.date("%a. %d %b."), label = os.date("%H:%M") }) -end) diff --git a/.config/sketchybar/items/front_app.lua b/.config/sketchybar/items/front_app.lua deleted file mode 100644 index d7dab4b..0000000 --- a/.config/sketchybar/items/front_app.lua +++ /dev/null @@ -1,22 +0,0 @@ -local settings = require("settings") -local sbar = require("sketchybar") - -local front_app = sbar.add("item", "front_app", { - display = "active", - icon = { drawing = false }, - label = { - font = { - style = settings.font.style_map["Black"], - size = 12.0, - }, - }, - updates = true, -}) - -front_app:subscribe("front_app_switched", function(env) - front_app:set({ label = { string = env.INFO } }) -end) - -front_app:subscribe("mouse.clicked", function(env) - sbar.trigger("swap_menus_and_spaces") -end) diff --git a/.config/sketchybar/items/front_apps.lua b/.config/sketchybar/items/front_apps.lua new file mode 100644 index 0000000..30fbd25 --- /dev/null +++ b/.config/sketchybar/items/front_apps.lua @@ -0,0 +1,69 @@ +local constants = require("constants") +local settings = require("config.settings") + +local frontApps = {} + +sbar.add("bracket", constants.items.FRONT_APPS, {}, { position = "left" }) + +local frontAppWatcher = sbar.add("item", { + drawing = false, + updates = true, +}) + +local function selectFocusedWindow(frontAppName) + for appName, app in pairs(frontApps) do + local isSelected = appName == frontAppName + local color = isSelected and settings.colors.orange or settings.colors.white + app:set({ + label = { color = color }, + icon = { color = color }, + }) + end +end + +local function updateWindows(windows) + sbar.remove("/" .. constants.items.FRONT_APPS .. "\\.*/") + + frontApps = {} + local foundWindows = string.gmatch(windows, "[^\n]+") + for window in foundWindows do + local parsedWindow = {} + for key, value in string.gmatch(window, "(%w+)=([%w%s]+)") do + parsedWindow[key] = value + end + + local windowId = parsedWindow["id"] + local windowName = parsedWindow["name"] + local icon = settings.icons.apps[windowName] or settings.icons.apps["default"] + + frontApps[windowName] = sbar.add("item", constants.items.FRONT_APPS .. "." .. windowName, { + label = { + padding_left = 0, + string = windowName, + }, + icon = { + string = icon, + font = settings.fonts.icons(), + }, + click_script = "aerospace focus --window-id " .. windowId, + }) + + frontApps[windowName]:subscribe(constants.events.FRONT_APP_SWITCHED, function(env) + selectFocusedWindow(env.INFO) + end) + end + + sbar.exec(constants.aerospace.GET_CURRENT_WINDOW, function(frontAppName) + selectFocusedWindow(frontAppName:gsub("[\n\r]", "")) + end) +end + +local function getWindows() + sbar.exec(constants.aerospace.LIST_WINDOWS, updateWindows) +end + +frontAppWatcher:subscribe(constants.events.UPDATE_WINDOWS, function() + getWindows() +end) + +getWindows() diff --git a/.config/sketchybar/items/init.lua b/.config/sketchybar/items/init.lua index dad59fa..18f0eb2 100644 --- a/.config/sketchybar/items/init.lua +++ b/.config/sketchybar/items/init.lua @@ -1,7 +1,12 @@ +-- left items require("items.apple") +require("items.menu_spaces_toggle") require("items.menus") require("items.spaces") -require("items.front_app") -require("items.calendar") +require("items.front_apps") + +-- right items +require("items.message") require("items.widgets") + require("items.media") diff --git a/.config/sketchybar/items/media.lua b/.config/sketchybar/items/media.lua index 8a9ef7d..31b7b60 100644 --- a/.config/sketchybar/items/media.lua +++ b/.config/sketchybar/items/media.lua @@ -1,15 +1,15 @@ -local icons = require("icons") -local colors = require("colors") -local sbar = require("sketchybar") +local colors = require("config.colors") -local whitelist = { ["Spotify"] = true, ["Music"] = true, ["Sound Cloud"] = true } +local whitelist = { + ["Psst"] = true, +} local media_cover = sbar.add("item", { - position = "right", + position = "left", background = { image = { string = "media.artwork", - scale = 0.85, + scale = 0.80, }, color = colors.transparent, }, @@ -24,7 +24,7 @@ local media_cover = sbar.add("item", { }) local media_artist = sbar.add("item", { - position = "right", + position = "left", drawing = false, padding_left = 3, padding_right = 0, @@ -34,13 +34,13 @@ local media_artist = sbar.add("item", { width = 0, font = { size = 9 }, color = colors.with_alpha(colors.white, 0.6), - max_chars = 18, + max_chars = 24, y_offset = 6, }, }) local media_title = sbar.add("item", { - position = "right", + position = "left", drawing = false, padding_left = 3, padding_right = 0, @@ -48,7 +48,7 @@ local media_title = sbar.add("item", { label = { font = { size = 11 }, width = 0, - max_chars = 16, + max_chars = 35, y_offset = -5, }, }) diff --git a/.config/sketchybar/items/menu_spaces_toggle.lua b/.config/sketchybar/items/menu_spaces_toggle.lua new file mode 100644 index 0000000..0a49cce --- /dev/null +++ b/.config/sketchybar/items/menu_spaces_toggle.lua @@ -0,0 +1,71 @@ +local constants = require("constants") +local settings = require("config.settings") + +sbar.add("event", constants.events.SWAP_MENU_AND_SPACES) + +local function switchToggle(menuToggle) + local isShowingMenu = menuToggle:query().icon.value == settings.icons.text.switch.on + + menuToggle:set({ + icon = isShowingMenu and settings.icons.text.switch.off or settings.icons.text.switch.on, + label = isShowingMenu and "Menus" or "Spaces", + }) + + sbar.trigger(constants.events.SWAP_MENU_AND_SPACES, { isShowingMenu = isShowingMenu }) +end + +local function addToggle() + local menuToggle = sbar.add("item", constants.items.MENU_TOGGLE, { + icon = { + string = settings.icons.text.switch.on, + }, + label = { + width = 0, + color = settings.colors.bg1, + string = "Spaces", + }, + background = { + color = settings.colors.with_alpha(settings.colors.dirty_white, 0.0), + }, + }) + + sbar.add("item", constants.items.MENU_TOGGLE .. ".padding", { + width = settings.dimens.padding.label, + }) + + menuToggle:subscribe("mouse.entered", function(env) + sbar.animate("tanh", 30, function() + menuToggle:set({ + background = { + color = { alpha = 1.0 }, + border_color = { alpha = 0.5 }, + }, + icon = { color = settings.colors.bg1 }, + label = { width = "dynamic" }, + }) + end) + end) + + menuToggle:subscribe("mouse.exited", function(env) + sbar.animate("tanh", 30, function() + menuToggle:set({ + background = { + color = { alpha = 0.0 }, + border_color = { alpha = 0.0 }, + }, + icon = { color = settings.colors.white }, + label = { width = 0 }, + }) + end) + end) + + menuToggle:subscribe("mouse.clicked", function(env) + switchToggle(menuToggle) + end) + + menuToggle:subscribe(constants.events.AEROSPACE_SWITCH, function(env) + switchToggle(menuToggle) + end) +end + +addToggle() diff --git a/.config/sketchybar/items/menus.lua b/.config/sketchybar/items/menus.lua index 66cdd4a..805162a 100644 --- a/.config/sketchybar/items/menus.lua +++ b/.config/sketchybar/items/menus.lua @@ -1,78 +1,72 @@ -local colors = require("colors") -local settings = require("settings") -local sbar = require("sketchybar") +local constants = require("constants") +local settings = require("config.settings") -local menu_watcher = sbar.add("item", { +local maxItems = 15 +local menuItems = {} +local isShowingMenu = false + +local frontAppWatcher = sbar.add("item", { drawing = false, - updates = false, + updates = true, }) -local space_menu_swap = sbar.add("item", { + +local swapWatcher = sbar.add("item", { drawing = false, updates = true, }) -sbar.add("event", "swap_menus_and_spaces") -local max_items = 15 -local menu_items = {} -for i = 1, max_items, 1 do - local menu = sbar.add("item", "menu." .. i, { - padding_left = settings.paddings, - padding_right = settings.paddings, - drawing = false, - icon = { drawing = false }, - label = { - font = { - style = settings.font.style_map[i == 1 and "Heavy" or "Semibold"], +local function createPlaceholders() + for index = 1, maxItems, 1 do + local menu = sbar.add("item", constants.items.MENU .. "." .. index, { + drawing = false, + icon = { drawing = false }, + width = "dynamic", + label = { + font = { + style = index == 1 and settings.fonts.styles.bold or settings.fonts.styles.regular, + }, }, - padding_left = 6, - padding_right = 6, + click_script = "$CONFIG_DIR/bridge/menus/bin/menus -s " .. index, + }) + menuItems[index] = menu + end + + sbar.add("bracket", { "/" .. constants.items.MENU .. "\\..*/" }, { + background = { + color = settings.colors.bg1, + padding_left = settings.dimens.padding.item, + padding_right = settings.dimens.padding.item, }, - click_script = "$CONFIG_DIR/helpers/menus/bin/menus -s " .. i, }) - - menu_items[i] = menu end -sbar.add("bracket", { "/menu\\..*/" }, { - background = { color = colors.bg1 }, -}) - -local menu_padding = sbar.add("item", "menu.padding", { - drawing = false, - width = 5, -}) +local function updateMenus() + sbar.set("/" .. constants.items.MENU .. "\\..*/", { drawing = false }) -local function update_menus(env) - sbar.exec("$CONFIG_DIR/helpers/menus/bin/menus -l", function(menus) - sbar.set("/menu\\..*/", { drawing = false }) - menu_padding:set({ drawing = true }) - id = 1 + sbar.exec("$CONFIG_DIR/bridge/menus/bin/menus -l", function(menus) + local index = 1 for menu in string.gmatch(menus, "[^\r\n]+") do - if id < max_items then - menu_items[id]:set({ label = menu, drawing = true }) + if index < maxItems then + menuItems[index]:set({ + width = "dynamic", + label = menu, + drawing = isShowingMenu, + }) else break end - id = id + 1 + index = index + 1 end end) + + sbar.set(constants.items.MENU .. ".padding", { drawing = isShowingMenu }) end -menu_watcher:subscribe("front_app_switched", update_menus) +frontAppWatcher:subscribe(constants.events.FRONT_APP_SWITCHED, updateMenus) -space_menu_swap:subscribe("swap_menus_and_spaces", function(env) - local drawing = menu_items[1]:query().geometry.drawing == "on" - if drawing then - menu_watcher:set({ updates = false }) - sbar.set("/menu\\..*/", { drawing = false }) - sbar.set("/space\\..*/", { drawing = true }) - sbar.set("front_app", { drawing = true }) - else - menu_watcher:set({ updates = true }) - sbar.set("/space\\..*/", { drawing = false }) - sbar.set("front_app", { drawing = false }) - update_menus() - end +swapWatcher:subscribe(constants.events.SWAP_MENU_AND_SPACES, function(env) + isShowingMenu = env.isShowingMenu == "on" + updateMenus() end) -return menu_watcher +createPlaceholders() diff --git a/.config/sketchybar/items/message.lua b/.config/sketchybar/items/message.lua new file mode 100644 index 0000000..da04091 --- /dev/null +++ b/.config/sketchybar/items/message.lua @@ -0,0 +1,57 @@ +local constants = require("constants") +local settings = require("config.settings") + +local message = sbar.add("item", constants.items.MESSAGE, { + width = 0, + position = "center", + popup = { align = "center" }, + label = { + padding_left = 0, + padding_right = 0, + }, + background = { + padding_left = 0, + padding_right = 0, + }, +}) + +local messagePopup = sbar.add("item", { + position = "popup." .. message.name, + width = "dynamic", + label = { + padding_right = settings.dimens.padding.label, + padding_left = settings.dimens.padding.label, + }, + icon = { + padding_left = 0, + padding_right = 0, + }, +}) + +local function hideMessage() + message:set({ popup = { drawing = false } }) +end + +local function showMessage(content, hold) + hideMessage() + + message:set({ popup = { drawing = true } }) + messagePopup:set({ label = { string = content } }) + + if hold == false then + sbar.delay(5, function() + if hold then + return + end + hideMessage() + end) + end +end + +message:subscribe(constants.events.SEND_MESSAGE, function(env) + local content = env.MESSAGE + local hold = env.HOLD ~= nil and env.HOLD == "true" or false + showMessage(content, hold) +end) + +message:subscribe(constants.events.HIDE_MESSAGE, hideMessage) diff --git a/.config/sketchybar/items/spaces.lua b/.config/sketchybar/items/spaces.lua index 100b050..d8cec5f 100644 --- a/.config/sketchybar/items/spaces.lua +++ b/.config/sketchybar/items/spaces.lua @@ -1,186 +1,112 @@ -local colors = require("colors") -local icons = require("icons") -local settings = require("settings") -local app_icons = require("helpers.app_icons") -local sbar = require("sketchybar") +local constants = require("constants") +local settings = require("config.settings") local spaces = {} -for i = 1, 10, 1 do - local space = sbar.add("space", "space." .. i, { - space = i, - icon = { - font = { family = settings.font.numbers }, - string = i, - padding_left = 15, - padding_right = 8, - color = colors.white, - -- the highlighter color - highlight_color = settings.spaces_highlight, - }, - label = { - padding_right = 20, - -- icon coloring for spaces - color = settings.spaces_icon, - highlight_color = colors.white, - font = "sketchybar-app-font:Regular:16.0", - y_offset = -1, - }, - padding_right = 1, - padding_left = 1, - background = { - -- this is bg color for spaces - color = settings.spaces_background, - border_width = 1, - height = 26, - border_color = settings.spaces_border, - }, - popup = { background = { border_width = 5, border_color = colors.black } }, - }) +local swapWatcher = sbar.add("item", { + drawing = false, + updates = true, +}) + +local currentWorkspaceWatcher = sbar.add("item", { + drawing = false, + updates = true, +}) - spaces[i] = space +-- Modify this file with Visual Studio Code - at least vim does have problems with the icons +-- copy "Icons" from the nerd fonts cheat sheet and replace icon and name accordingly below +-- https://www.nerdfonts.com/cheat-sheet +local spaceConfigs = { + ["1"] = { icon = "󱞁", name = "Notes" }, + ["2"] = { icon = "", name = "Terminal" }, + ["3"] = { icon = "󰖟", name = "Browser" }, + ["4"] = { icon = "", name = "AltBrowser" }, + ["5"] = { icon = "", name = "Remote" }, + ["6"] = { icon = "", name = "Database" }, + ["7"] = { icon = "󰙯", name = "Chat" }, + ["8"] = { icon = "", name = "Mail" }, + ["9"] = { icon = "", name = "Music" }, + ["10"] = { icon = "󰌾", name = "Secrets" }, + ["t"] = { icon = "", name = "Meeting" }, +} + +local function selectCurrentWorkspace(focusedWorkspaceName) + for sid, item in pairs(spaces) do + if item ~= nil then + local isSelected = sid == constants.items.SPACES .. "." .. focusedWorkspaceName + item:set({ + icon = { color = isSelected and settings.colors.bg1 or settings.colors.white }, + label = { color = isSelected and settings.colors.bg1 or settings.colors.white }, + background = { color = isSelected and settings.colors.white or settings.colors.bg1 }, + }) + end + end - -- Single item bracket for space items to achieve double border on highlight - local space_bracket = sbar.add("bracket", { space.name }, { - background = { - color = colors.transparent, - border_color = colors.bg2, - height = 28, - border_width = 2, - }, - }) + sbar.trigger(constants.events.UPDATE_WINDOWS) +end - -- Padding space - sbar.add("space", "space.padding." .. i, { - space = i, - script = "", - width = settings.group_paddings, - }) +local function findAndSelectCurrentWorkspace() + sbar.exec(constants.aerospace.GET_CURRENT_WORKSPACE, function(focusedWorkspaceOutput) + local focusedWorkspaceName = focusedWorkspaceOutput:match("[^\r\n]+") + selectCurrentWorkspace(focusedWorkspaceName) + end) +end + +local function addWorkspaceItem(workspaceName) + local spaceName = constants.items.SPACES .. "." .. workspaceName + local spaceConfig = spaceConfigs[workspaceName] - local space_popup = sbar.add("item", { - position = "popup." .. space.name, - padding_left = 5, - padding_right = 0, + spaces[spaceName] = sbar.add("item", spaceName, { + label = { + width = 0, + padding_left = 0, + string = spaceConfig.name, + }, + icon = { + string = spaceConfig.icon or settings.icons.apps["default"], + color = settings.colors.white, + }, background = { - drawing = true, - image = { - corner_radius = 9, - scale = 0.2, - }, + color = settings.colors.bg1, }, + click_script = "aerospace workspace " .. workspaceName, }) - space:subscribe("space_change", function(env) - local selected = env.SELECTED == "true" - local color = selected and colors.grey or colors.bg2 - space:set({ - icon = { highlight = selected }, - label = { highlight = selected }, - background = { border_color = selected and colors.black or colors.bg2 }, - }) - space_bracket:set({ - background = { border_color = selected and colors.grey or colors.bg2 }, - }) + spaces[spaceName]:subscribe("mouse.entered", function(env) + sbar.animate("tanh", 30, function() + spaces[spaceName]:set({ label = { width = "dynamic" } }) + end) end) - space:subscribe("mouse.clicked", function(env) - if env.BUTTON == "other" then - space_popup:set({ background = { image = "space." .. env.SID } }) - space:set({ popup = { drawing = "toggle" } }) - else - local op = (env.BUTTON == "right") and "--destroy" or "--focus" - os.execute("yabai -m space " .. op .. " " .. env.SID) - -- sbar.exec() is acting weird - -- sbar.exec("yabai -m space " .. op .. " " .. env.SID) - end + spaces[spaceName]:subscribe("mouse.exited", function(env) + sbar.animate("tanh", 30, function() + spaces[spaceName]:set({ label = { width = 0 } }) + end) end) - space:subscribe("mouse.exited", function(_) - space:set({ popup = { drawing = false } }) - end) + sbar.add("item", spaceName .. ".padding", { + width = settings.dimens.padding.label, + }) end -local space_window_observer = sbar.add("item", { - drawing = false, - updates = true, -}) - -local spaces_indicator = sbar.add("item", { - padding_left = -3, - padding_right = 0, - icon = { - padding_left = 8, - padding_right = 9, - -- changed coloring of selected app icon - color = settings.spaces_selected, - string = icons.switch.on, - }, - label = { - width = 0, - padding_left = 0, - padding_right = 8, - string = "Spaces", - -- bg1 - color = colors.bg1, - }, - background = { - -- grey - color = colors.with_alpha(colors.grey, 0.0), - border_color = colors.with_alpha(colors.bg1, 0.0), - }, -}) - -space_window_observer:subscribe("space_windows_change", function(env) - local icon_line = "" - local no_app = true - for app, count in pairs(env.INFO.apps) do - no_app = false - local lookup = app_icons[app] - local icon = ((lookup == nil) and app_icons["default"] or lookup) - icon_line = icon_line .. " " .. icon - end +local function createWorkspaces() + sbar.exec(constants.aerospace.LIST_ALL_WORKSPACES, function(workspacesOutput) + for workspaceName in workspacesOutput:gmatch("[^\r\n]+") do + addWorkspaceItem(workspaceName) + end - if no_app then - icon_line = " —" - end - sbar.animate("tanh", 10, function() - spaces[env.INFO.space]:set({ label = icon_line }) + findAndSelectCurrentWorkspace() end) -end) - -spaces_indicator:subscribe("swap_menus_and_spaces", function(env) - local currently_on = spaces_indicator:query().icon.value == icons.switch.on - spaces_indicator:set({ - icon = currently_on and icons.switch.off or icons.switch.on, - }) -end) +end -spaces_indicator:subscribe("mouse.entered", function(env) - sbar.animate("tanh", 30, function() - spaces_indicator:set({ - background = { - color = { alpha = 1.0 }, - border_color = { alpha = 1.0 }, - }, - icon = { color = colors.bg1 }, - label = { width = "dynamic" }, - }) - end) +swapWatcher:subscribe(constants.events.SWAP_MENU_AND_SPACES, function(env) + local isShowingSpaces = env.isShowingMenu == "off" and true or false + sbar.set("/" .. constants.items.SPACES .. "\\..*/", { drawing = isShowingSpaces }) end) -spaces_indicator:subscribe("mouse.exited", function(env) - sbar.animate("tanh", 30, function() - spaces_indicator:set({ - background = { - color = { alpha = 0.0 }, - border_color = { alpha = 0.0 }, - }, - icon = { color = colors.grey }, - label = { width = 0 }, - }) - end) +currentWorkspaceWatcher:subscribe(constants.events.AEROSPACE_WORKSPACE_CHANGED, function(env) + selectCurrentWorkspace(env.FOCUSED_WORKSPACE) + sbar.trigger(constants.events.UPDATE_WINDOWS) end) -spaces_indicator:subscribe("mouse.clicked", function(env) - sbar.trigger("swap_menus_and_spaces") -end) +createWorkspaces() diff --git a/.config/sketchybar/items/widgets/calendar.lua b/.config/sketchybar/items/widgets/calendar.lua new file mode 100644 index 0000000..dbd17ea --- /dev/null +++ b/.config/sketchybar/items/widgets/calendar.lua @@ -0,0 +1,17 @@ +local constants = require("constants") + +local calendar = sbar.add("item", constants.items.CALENDAR, { + position = "right", + update_freq = 1, + icon = { padding_left = 0, padding_right = 0 }, +}) + +calendar:subscribe({ "forced", "routine", "system_woke" }, function(env) + calendar:set({ + label = os.date("%a %d %b, %H:%M"), + }) +end) + +calendar:subscribe("mouse.clicked", function(env) + sbar.exec("open -a 'Calendar'") +end) diff --git a/.config/sketchybar/items/widgets/init.lua b/.config/sketchybar/items/widgets/init.lua index c919c76..3416c52 100644 --- a/.config/sketchybar/items/widgets/init.lua +++ b/.config/sketchybar/items/widgets/init.lua @@ -1,4 +1,5 @@ require("items.widgets.battery") +require("items.widgets.calendar") require("items.widgets.volume") require("items.widgets.wifi") require("items.widgets.cpu") diff --git a/.config/sketchybar/settings.lua b/.config/sketchybar/settings.lua deleted file mode 100644 index af5e7cc..0000000 --- a/.config/sketchybar/settings.lua +++ /dev/null @@ -1,50 +0,0 @@ -local colors = require("colors") -return { - -- widgets borders; cpu, wifi, vol, batt - widget_borders = colors.grey, - -- battery widget - batt_background = colors.black, - batt_color_default = colors.green, - batt_color_25 = colors.orange_brown, - batt_color_0 = colors.grey, - -- cpu widget - cpu_background = colors.black, - -- volume widget - volume_background = colors.black, - -- wifi widget - wifi_background = colors.black, - -- apple.lua - apple_icon = colors.white, - apple_background = colors.black, - apple_border = colors.black, - -- calendar.lua - calendar_background = colors.black, - calendar_border = colors.black, - -- spaces.lua - spaces_highlight = colors.white, - spaces_icon = colors.grey, - spaces_background = colors.black, - spaces_border = colors.grey, - spaces_selected = colors.white, - - paddings = 3, - group_paddings = 5, - - icons = "sf-symbols", -- alternatively available: NerdFont - - -- This is a font configuration for SF Pro and SF Mono (installed manually) - font = require("helpers.default_font"), - - -- Alternatively, this is a font config for JetBrainsMono Nerd Font - -- font = { - -- text = "JetBrainsMono Nerd Font", -- Used for text - -- numbers = "JetBrainsMono Nerd Font", -- Used for numbers - -- style_map = { - -- ["Regular"] = "Regular", - -- ["Semibold"] = "Medium", - -- ["Bold"] = "SemiBold", - -- ["Heavy"] = "Bold", - -- ["Black"] = "ExtraBold", - -- }, - -- }, -} diff --git a/.config/sketchybar/sketchybarrc b/.config/sketchybar/sketchybarrc index 95ece11..6b608a1 100755 --- a/.config/sketchybar/sketchybarrc +++ b/.config/sketchybar/sketchybarrc @@ -1,5 +1,5 @@ #!/usr/bin/env lua --- Load the sketchybar-package and prepare the helper binaries -require("helpers") +-- Load the sketchybar-package and preps the helper binaries +-- require("helpers") require("init") diff --git a/.config/sketchybar_backup/plugins/battery.sh b/.config/sketchybar_backup/plugins/battery.sh deleted file mode 100755 index fad0c18..0000000 --- a/.config/sketchybar_backup/plugins/battery.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh - -PERCENTAGE="$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)" -CHARGING="$(pmset -g batt | grep 'AC Power')" - -if [ "$PERCENTAGE" = "" ]; then - exit 0 -fi - -case "${PERCENTAGE}" in - 9[0-9]|100) ICON="" - ;; - [6-8][0-9]) ICON="" - ;; - [3-5][0-9]) ICON="" - ;; - [1-2][0-9]) ICON="" - ;; - *) ICON="" -esac - -if [[ "$CHARGING" != "" ]]; then - ICON="󱐋" -fi - -# The item invoking this script (name $NAME) will get its icon and label -# updated with the current battery status -sketchybar --set "$NAME" icon="$ICON" label="${PERCENTAGE}%" diff --git a/.config/sketchybar_backup/plugins/clock.sh b/.config/sketchybar_backup/plugins/clock.sh deleted file mode 100755 index 9f5624a..0000000 --- a/.config/sketchybar_backup/plugins/clock.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -# The $NAME variable is passed from sketchybar and holds the name of -# the item invoking this script: -# https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting -ICON="󰸘" -sketchybar --set "$NAME" icon="$ICON" label="$(date '+%m/%d %I:%M %p')" diff --git a/.config/sketchybar_backup/plugins/front_app.sh b/.config/sketchybar_backup/plugins/front_app.sh deleted file mode 100755 index fb6d0b3..0000000 --- a/.config/sketchybar_backup/plugins/front_app.sh +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -# Some events send additional information specific to the event in the $INFO -# variable. E.g. the front_app_switched event sends the name of the newly -# focused application in the $INFO variable: -# https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting - -if [ "$SENDER" = "front_app_switched" ]; then - sketchybar --set "$NAME" label="$INFO" -fi diff --git a/.config/sketchybar_backup/plugins/space.sh b/.config/sketchybar_backup/plugins/space.sh deleted file mode 100755 index b8602b5..0000000 --- a/.config/sketchybar_backup/plugins/space.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -# The $SELECTED variable is available for space components and indicates if -# the space invoking this script (with name: $NAME) is currently selected: -# https://felixkratz.github.io/SketchyBar/config/components#space----associate-mission-control-spaces-with-an-item - -sketchybar --set "$NAME" background.drawing="$SELECTED" diff --git a/.config/sketchybar_backup/plugins/volume.sh b/.config/sketchybar_backup/plugins/volume.sh deleted file mode 100755 index 6e69a5d..0000000 --- a/.config/sketchybar_backup/plugins/volume.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -# The volume_change event supplies a $INFO variable in which the current volume -# percentage is passed to the script. - -if [ "$SENDER" = "volume_change" ]; then - VOLUME="$INFO" - - case "$VOLUME" in - [6-9][0-9]|100) ICON="󰕾" - ;; - [3-5][0-9]) ICON="󰖀" - ;; - [1-9]|[1-2][0-9]) ICON="󰕿" - ;; - *) ICON="󰖁" - esac - - sketchybar --set "$NAME" icon="$ICON" label="$VOLUME%" -fi diff --git a/.config/sketchybar_backup/sketchybarrc b/.config/sketchybar_backup/sketchybarrc deleted file mode 100755 index ed7bae1..0000000 --- a/.config/sketchybar_backup/sketchybarrc +++ /dev/null @@ -1,91 +0,0 @@ -# This is a demo config to showcase some of the most important commands. -# It is meant to be changed and configured, as it is intentionally kept sparse. -# For a (much) more advanced configuration example see my dotfiles: -# https://github.com/FelixKratz/dotfiles - -PLUGIN_DIR="$CONFIG_DIR/plugins" - -##### Bar Appearance ##### -# Configuring the general appearance of the bar. -# These are only some of the options available. For all options see: -# https://felixkratz.github.io/SketchyBar/config/bar -# If you are looking for other colors, see the color picker: -# https://felixkratz.github.io/SketchyBar/config/tricks#color-picker - -sketchybar --bar position=top height=40 blur_radius=20 color=0x40000000 - -##### Changing Defaults ##### -# We now change some default values, which are applied to all further items. -# For a full list of all available item properties see: -# https://felixkratz.github.io/SketchyBar/config/items - -default=( - padding_left=5 - padding_right=5 - icon.font="Hack Nerd Font:Bold:17.0" - label.font="Hack Nerd Font:Bold:14.0" - icon.color=0xffffffff - label.color=0xffffffff - icon.padding_left=3 - icon.padding_right=4 - label.padding_left=4 - label.padding_right=4 -) -sketchybar --default "${default[@]}" - -##### Adding Mission Control Space Indicators ##### -# Let's add some mission control spaces: -# https://felixkratz.github.io/SketchyBar/config/components#space----associate-mission-control-spaces-with-an-item -# to indicate active and available mission control spaces. - -SPACE_ICONS=("1" "2" "3" "4" "5" "6" "7" "8" "9" "10") -for i in "${!SPACE_ICONS[@]}" -do - sid="$(($i+1))" - space=( - space="$sid" - icon="${SPACE_ICONS[i]}" - icon.padding_left=7 - icon.padding_right=7 - background.color=0x40ffffff - background.corner_radius=5 - background.height=25 - label.drawing=off - script="$PLUGIN_DIR/space.sh" - click_script="yabai -m space --focus $sid" - ) - sketchybar --add space space."$sid" left --set space."$sid" "${space[@]}" -done - -##### Adding Left Items ##### -# We add some regular items to the left side of the bar, where -# only the properties deviating from the current defaults need to be set - -sketchybar --add item chevron left \ - --set chevron icon= label.drawing=off \ - --add item front_app left \ - --set front_app icon.drawing=off script="$PLUGIN_DIR/front_app.sh" \ - --subscribe front_app front_app_switched - -##### Adding Right Items ##### -# In the same way as the left items we can add items to the right side. -# Additional position (e.g. center) are available, see: -# https://felixkratz.github.io/SketchyBar/config/items#adding-items-to-sketchybar - -# Some items refresh on a fixed cycle, e.g. the clock runs its script once -# every 10s. Other items respond to events they subscribe to, e.g. the -# volume.sh script is only executed once an actual change in system audio -# volume is registered. More info about the event system can be found here: -# https://felixkratz.github.io/SketchyBar/config/events - -sketchybar --add item clock right \ - --set clock update_freq=10 icon= script="$PLUGIN_DIR/clock.sh" \ - --add item volume right \ - --set volume script="$PLUGIN_DIR/volume.sh" \ - --subscribe volume volume_change \ - --add item battery right \ - --set battery update_freq=120 script="$PLUGIN_DIR/battery.sh" \ - --subscribe battery system_woke power_source_change - -##### Force all scripts to run the first time (never do this in a script) ##### -sketchybar --update -- cgit v1.3-3-g829e