Compare commits
3 Commits
5f0a1d6098
...
86c3bbc1e6
Author | SHA1 | Date | |
---|---|---|---|
86c3bbc1e6 | |||
44da2b9604 | |||
03b48177e6 |
144
darwin/aerospace/default.nix
Normal file
144
darwin/aerospace/default.nix
Normal file
@ -0,0 +1,144 @@
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkIf;
|
||||
cfg = config.my.aerospace;
|
||||
in {
|
||||
options.my.aerospace = {
|
||||
enable = mkEnableOption "aerospace";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services.aerospace = {
|
||||
enable = true;
|
||||
package = pkgs.unstable.aerospace;
|
||||
settings = {
|
||||
# Startup configuration
|
||||
after-login-command = [];
|
||||
after-startup-command = [];
|
||||
|
||||
# Layout normalization
|
||||
enable-normalization-flatten-containers = true;
|
||||
enable-normalization-opposite-orientation-for-nested-containers = true;
|
||||
|
||||
# Layout settings
|
||||
accordion-padding = 30;
|
||||
default-root-container-layout = "tiles";
|
||||
default-root-container-orientation = "auto";
|
||||
|
||||
# Mouse behavior
|
||||
on-focused-monitor-changed = ["move-mouse monitor-lazy-center"];
|
||||
automatically-unhide-macos-hidden-apps = false;
|
||||
|
||||
# Key mapping
|
||||
key-mapping = {
|
||||
preset = "qwerty";
|
||||
};
|
||||
|
||||
# Window gaps
|
||||
gaps = {
|
||||
inner = {
|
||||
horizontal = 2;
|
||||
vertical = 2;
|
||||
};
|
||||
outer = {
|
||||
left = 0;
|
||||
bottom = 0;
|
||||
top = [
|
||||
{monitor."built-in" = 2;}
|
||||
35
|
||||
];
|
||||
right = 0;
|
||||
};
|
||||
};
|
||||
|
||||
# Main mode bindings
|
||||
mode.main.binding = {
|
||||
# Layout commands
|
||||
"alt-slash" = "layout tiles horizontal vertical";
|
||||
"alt-comma" = "layout accordion horizontal vertical";
|
||||
|
||||
# Focus commands
|
||||
"alt-h" = "focus left";
|
||||
"alt-j" = "focus down";
|
||||
"alt-k" = "focus up";
|
||||
"alt-l" = "focus right";
|
||||
|
||||
# Move commands
|
||||
"alt-shift-h" = "move left";
|
||||
"alt-shift-j" = "move down";
|
||||
"alt-shift-k" = "move up";
|
||||
"alt-shift-l" = "move right";
|
||||
|
||||
# Resize commands
|
||||
"alt-minus" = "resize smart -50";
|
||||
"alt-equal" = "resize smart +50";
|
||||
|
||||
# Misc window commands
|
||||
"alt-q" = "close";
|
||||
|
||||
# Workspace commands
|
||||
"alt-1" = "workspace 1";
|
||||
"alt-2" = "workspace 2";
|
||||
"alt-3" = "workspace 3";
|
||||
"alt-4" = "workspace 4";
|
||||
"alt-5" = "workspace 5";
|
||||
"alt-6" = "workspace 6";
|
||||
"alt-7" = "workspace 7";
|
||||
"alt-8" = "workspace 8";
|
||||
"alt-9" = "workspace 9";
|
||||
|
||||
# Move node to workspace commands
|
||||
"alt-shift-1" = "move-node-to-workspace 1";
|
||||
"alt-shift-2" = "move-node-to-workspace 2";
|
||||
"alt-shift-3" = "move-node-to-workspace 3";
|
||||
"alt-shift-4" = "move-node-to-workspace 4";
|
||||
"alt-shift-5" = "move-node-to-workspace 5";
|
||||
"alt-shift-6" = "move-node-to-workspace 6";
|
||||
"alt-shift-7" = "move-node-to-workspace 7";
|
||||
"alt-shift-8" = "move-node-to-workspace 8";
|
||||
"alt-shift-9" = "move-node-to-workspace 9";
|
||||
|
||||
# Applications
|
||||
"alt-t" = ''
|
||||
exec-and-forget osascript -e '
|
||||
tell application "Ghostty"
|
||||
if it is running then
|
||||
activate
|
||||
tell application "System Events" to keystroke "n" using {command down}
|
||||
else
|
||||
activate
|
||||
end if
|
||||
end tell'
|
||||
'';
|
||||
"alt-f" = "exec-and-forget open -n '/Applications/Zen Browser.app'";
|
||||
|
||||
# Other commands
|
||||
# "alt-tab" = "workspace-back-and-forth";
|
||||
# "alt-shift-tab" = "move-workspace-to-monitor --wrap-around next";
|
||||
"alt-shift-semicolon" = "mode service";
|
||||
};
|
||||
|
||||
# Service mode bindings
|
||||
mode.service.binding = {
|
||||
"esc" = ["reload-config" "mode main"];
|
||||
"r" = ["flatten-workspace-tree" "mode main"];
|
||||
"f" = ["layout floating tiling" "mode main"];
|
||||
"backspace" = ["close-all-windows-but-current" "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"];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
3
darwin/sketchybar/config/.luarc.json
Normal file
3
darwin/sketchybar/config/.luarc.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"runtime.version": "Lua 5.4"
|
||||
}
|
16
darwin/sketchybar/config/bar.lua
Normal file
16
darwin/sketchybar/config/bar.lua
Normal file
@ -0,0 +1,16 @@
|
||||
local colors = require("colors").sections.bar
|
||||
|
||||
sbar.bar {
|
||||
topmost = "window",
|
||||
height = 34,
|
||||
notch_display_height = 34,
|
||||
padding_right = 12,
|
||||
padding_left = 12,
|
||||
margin = -1,
|
||||
corner_radius = 0,
|
||||
y_offset = -1,
|
||||
blur_radius = 20,
|
||||
border_color = colors.border,
|
||||
border_width = 1,
|
||||
color = colors.bg,
|
||||
}
|
99
darwin/sketchybar/config/colors.lua
Normal file
99
darwin/sketchybar/config/colors.lua
Normal file
@ -0,0 +1,99 @@
|
||||
local M = {}
|
||||
|
||||
local 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
|
||||
|
||||
local transparent = 0x00000000
|
||||
local black = 0xFF000000
|
||||
|
||||
local gruvbox = {
|
||||
rosewater = 0xFFd4be98, -- Gruvbox light4 (closest to gruvbox rosewater)
|
||||
flamingo = 0xFFea6962, -- Gruvbox bright_red (closest to gruvbox flamingo)
|
||||
pink = 0xFFd3869b, -- Gruvbox bright_purple (closest to gruvbox pink)
|
||||
mauve = 0xFFd3869b, -- Gruvbox bright_purple (closest to gruvbox mauve)
|
||||
red = 0xFFcc241d, -- Gruvbox dark_red
|
||||
maroon = 0xFFfb4934, -- Gruvbox bright_red (closest to gruvbox maroon)
|
||||
peach = 0xFFfe8019, -- Gruvbox bright_orange (closest to gruvbox peach)
|
||||
yellow = 0xFFd79921, -- Gruvbox dark_yellow
|
||||
green = 0xFFb8bb26, -- Gruvbox bright_green (closest to gruvbox green)
|
||||
teal = 0xFF8ec07c, -- Gruvbox bright_aqua (closest to gruvbox teal)
|
||||
sky = 0xFF83a598, -- Gruvbox bright_blue (closest to gruvbox sky)
|
||||
sapphire = 0xFF83a598, -- Gruvbox bright_blue (closest to gruvbox sapphire)
|
||||
blue = 0xFF458588, -- Gruvbox dark_blue
|
||||
lavender = 0xFF83a598, -- Gruvbox bright_blue (closest to gruvbox lavender)
|
||||
text = 0xFFebdbb2, -- Gruvbox light0
|
||||
subtext1 = 0xFFd5c4a1, -- Gruvbox light2
|
||||
subtext0 = 0xFFbdae93, -- Gruvbox light3
|
||||
overlay2 = 0xFFa89984, -- Gruvbox light4
|
||||
overlay1 = 0xFF928374, -- Gruvbox gray
|
||||
overlay0 = 0xFF665c54, -- Gruvbox dark4
|
||||
surface2 = 0xFF504945, -- Gruvbox dark3
|
||||
surface1 = 0xFF3c3836, -- Gruvbox dark2
|
||||
surface0 = 0xFF32302f, -- Gruvbox dark1
|
||||
base = 0xFF282828, -- Gruvbox dark0
|
||||
mantle = 0xFF1d2021, -- Gruvbox dark0_hard
|
||||
crust = 0xFF1d2021, -- Gruvbox dark0_hard
|
||||
}
|
||||
|
||||
M.sections = {
|
||||
-- Core Components
|
||||
bar = {
|
||||
bg = black,
|
||||
border = black,
|
||||
},
|
||||
item = {
|
||||
bg = gruvbox.surface0,
|
||||
border = black,
|
||||
text = gruvbox.text,
|
||||
},
|
||||
popup = {
|
||||
bg = with_alpha(gruvbox.base, 0.7),
|
||||
border = gruvbox.crust,
|
||||
},
|
||||
|
||||
-- Items
|
||||
apple = gruvbox.flamingo,
|
||||
media = { label = gruvbox.text },
|
||||
calendar = { label = gruvbox.text },
|
||||
spaces = {
|
||||
icon = {
|
||||
color = gruvbox.subtext0,
|
||||
highlight = gruvbox.yellow,
|
||||
},
|
||||
label = {
|
||||
color = gruvbox.subtext0,
|
||||
highlight = gruvbox.yellow,
|
||||
},
|
||||
indicator = gruvbox.mauve,
|
||||
},
|
||||
widgets = {
|
||||
battery = {
|
||||
low = gruvbox.red,
|
||||
mid = gruvbox.yellow,
|
||||
high = gruvbox.green,
|
||||
},
|
||||
wifi = {
|
||||
icon = gruvbox.text,
|
||||
},
|
||||
volume = {
|
||||
icon = gruvbox.blue,
|
||||
popup = {
|
||||
item = gruvbox.text,
|
||||
highlight = gruvbox.subtext0,
|
||||
bg = with_alpha(gruvbox.base, 0.7),
|
||||
},
|
||||
slider = {
|
||||
highlight = gruvbox.text,
|
||||
bg = with_alpha(gruvbox.base, 0.7),
|
||||
border = gruvbox.surface0,
|
||||
},
|
||||
},
|
||||
messages = { icon = gruvbox.flamingo },
|
||||
},
|
||||
}
|
||||
|
||||
return M
|
57
darwin/sketchybar/config/default.lua
Normal file
57
darwin/sketchybar/config/default.lua
Normal file
@ -0,0 +1,57 @@
|
||||
local settings = require "settings"
|
||||
local colors = require("colors").sections
|
||||
|
||||
sbar.default {
|
||||
updates = "when_shown",
|
||||
icon = {
|
||||
font = {
|
||||
family = settings.font.text,
|
||||
style = settings.font.style_map["Semibold"],
|
||||
size = 14.0,
|
||||
},
|
||||
color = colors.item.text,
|
||||
padding_left = settings.paddings,
|
||||
padding_right = settings.paddings,
|
||||
background = { image = { corner_radius = 0 } },
|
||||
},
|
||||
label = {
|
||||
font = {
|
||||
family = settings.font.text,
|
||||
style = settings.font.style_map["Semibold"],
|
||||
size = 14.0,
|
||||
},
|
||||
color = colors.item.text,
|
||||
padding_left = settings.paddings,
|
||||
padding_right = settings.paddings,
|
||||
},
|
||||
background = {
|
||||
height = 26,
|
||||
corner_radius = 0,
|
||||
color = colors.item.bg,
|
||||
border_color = colors.item.border,
|
||||
border_width = 2,
|
||||
shadow = {
|
||||
drawing = true,
|
||||
angle = 45,
|
||||
distance = 4,
|
||||
color = colors.item.border,
|
||||
},
|
||||
},
|
||||
popup = {
|
||||
background = {
|
||||
color = colors.popup.bg,
|
||||
border_color = colors.popup.border,
|
||||
border_width = 2,
|
||||
corner_radius = 0,
|
||||
shadow = {
|
||||
drawing = true,
|
||||
angle = 45,
|
||||
distance = 4,
|
||||
color = colors.item.border,
|
||||
},
|
||||
},
|
||||
},
|
||||
padding_left = 4,
|
||||
padding_right = 4,
|
||||
scroll_texts = true,
|
||||
}
|
1
darwin/sketchybar/config/helpers/.gitignore
vendored
Normal file
1
darwin/sketchybar/config/helpers/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
bin
|
12
darwin/sketchybar/config/helpers/default_font.lua
Normal file
12
darwin/sketchybar/config/helpers/default_font.lua
Normal file
@ -0,0 +1,12 @@
|
||||
return {
|
||||
text = "SF Pro", -- Used for text
|
||||
numbers = "SF Mono", -- Used for numbers
|
||||
weather = "Symbols Nerd Font",
|
||||
style_map = {
|
||||
["Regular"] = "Regular",
|
||||
["Semibold"] = "Semibold",
|
||||
["Bold"] = "Bold",
|
||||
["Heavy"] = "Heavy",
|
||||
["Black"] = "Black",
|
||||
}
|
||||
}
|
@ -0,0 +1,58 @@
|
||||
#include <mach/mach.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
|
||||
struct cpu {
|
||||
host_t host;
|
||||
mach_msg_type_number_t count;
|
||||
host_cpu_load_info_data_t load;
|
||||
host_cpu_load_info_data_t prev_load;
|
||||
bool has_prev_load;
|
||||
|
||||
int user_load;
|
||||
int sys_load;
|
||||
int total_load;
|
||||
};
|
||||
|
||||
static inline void cpu_init(struct cpu* cpu) {
|
||||
cpu->host = mach_host_self();
|
||||
cpu->count = HOST_CPU_LOAD_INFO_COUNT;
|
||||
cpu->has_prev_load = false;
|
||||
}
|
||||
|
||||
static inline void cpu_update(struct cpu* cpu) {
|
||||
kern_return_t error = host_statistics(cpu->host,
|
||||
HOST_CPU_LOAD_INFO,
|
||||
(host_info_t)&cpu->load,
|
||||
&cpu->count );
|
||||
|
||||
if (error != KERN_SUCCESS) {
|
||||
printf("Error: Could not read cpu host statistics.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (cpu->has_prev_load) {
|
||||
uint32_t delta_user = cpu->load.cpu_ticks[CPU_STATE_USER]
|
||||
- cpu->prev_load.cpu_ticks[CPU_STATE_USER];
|
||||
|
||||
uint32_t delta_system = cpu->load.cpu_ticks[CPU_STATE_SYSTEM]
|
||||
- cpu->prev_load.cpu_ticks[CPU_STATE_SYSTEM];
|
||||
|
||||
uint32_t delta_idle = cpu->load.cpu_ticks[CPU_STATE_IDLE]
|
||||
- cpu->prev_load.cpu_ticks[CPU_STATE_IDLE];
|
||||
|
||||
cpu->user_load = (double)delta_user / (double)(delta_system
|
||||
+ delta_user
|
||||
+ delta_idle) * 100.0;
|
||||
|
||||
cpu->sys_load = (double)delta_system / (double)(delta_system
|
||||
+ delta_user
|
||||
+ delta_idle) * 100.0;
|
||||
|
||||
cpu->total_load = cpu->user_load + cpu->sys_load;
|
||||
}
|
||||
|
||||
cpu->prev_load = cpu->load;
|
||||
cpu->has_prev_load = true;
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
#include "cpu.h"
|
||||
#include "../sketchybar.h"
|
||||
|
||||
int main (int argc, char** argv) {
|
||||
float update_freq;
|
||||
if (argc < 3 || (sscanf(argv[2], "%f", &update_freq) != 1)) {
|
||||
printf("Usage: %s \"<event-name>\" \"<event_freq>\"\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
alarm(0);
|
||||
struct cpu cpu;
|
||||
cpu_init(&cpu);
|
||||
|
||||
// Setup the event in sketchybar
|
||||
char event_message[512];
|
||||
snprintf(event_message, 512, "--add event '%s'", argv[1]);
|
||||
sketchybar(event_message);
|
||||
|
||||
char trigger_message[512];
|
||||
for (;;) {
|
||||
// Acquire new info
|
||||
cpu_update(&cpu);
|
||||
|
||||
// Prepare the event message
|
||||
snprintf(trigger_message,
|
||||
512,
|
||||
"--trigger '%s' user_load='%d' sys_load='%02d' total_load='%02d'",
|
||||
argv[1],
|
||||
cpu.user_load,
|
||||
cpu.sys_load,
|
||||
cpu.total_load );
|
||||
|
||||
// Trigger the event
|
||||
sketchybar(trigger_message);
|
||||
|
||||
// Wait
|
||||
usleep(update_freq * 1000000);
|
||||
}
|
||||
return 0;
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
bin/cpu_load: cpu_load.c cpu.h ../sketchybar.h | bin
|
||||
clang -std=c99 -O3 $< -o $@
|
||||
|
||||
bin:
|
||||
mkdir bin
|
@ -0,0 +1,3 @@
|
||||
all:
|
||||
(cd cpu_load && $(MAKE))
|
||||
(cd network_load && $(MAKE))
|
@ -0,0 +1,5 @@
|
||||
bin/network_load: network_load.c network.h ../sketchybar.h | bin
|
||||
clang -std=c99 -O3 $< -o $@
|
||||
|
||||
bin:
|
||||
mkdir bin
|
@ -0,0 +1,90 @@
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <net/if.h>
|
||||
#include <net/if_mib.h>
|
||||
#include <sys/select.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
static char unit_str[3][6] = { { " Bps" }, { "KBps" }, { "MBps" }, };
|
||||
|
||||
enum unit {
|
||||
UNIT_BPS,
|
||||
UNIT_KBPS,
|
||||
UNIT_MBPS
|
||||
};
|
||||
struct network {
|
||||
uint32_t row;
|
||||
struct ifmibdata data;
|
||||
struct timeval tv_nm1, tv_n, tv_delta;
|
||||
|
||||
int up;
|
||||
int down;
|
||||
enum unit up_unit, down_unit;
|
||||
};
|
||||
|
||||
static inline void ifdata(uint32_t net_row, struct ifmibdata* data) {
|
||||
static size_t size = sizeof(struct ifmibdata);
|
||||
static int32_t data_option[] = { CTL_NET, PF_LINK, NETLINK_GENERIC, IFMIB_IFDATA, 0, IFDATA_GENERAL };
|
||||
data_option[4] = net_row;
|
||||
sysctl(data_option, 6, data, &size, NULL, 0);
|
||||
}
|
||||
|
||||
static inline void network_init(struct network* net, char* ifname) {
|
||||
memset(net, 0, sizeof(struct network));
|
||||
|
||||
static int count_option[] = { CTL_NET, PF_LINK, NETLINK_GENERIC, IFMIB_SYSTEM, IFMIB_IFCOUNT };
|
||||
uint32_t interface_count = 0;
|
||||
size_t size = sizeof(uint32_t);
|
||||
sysctl(count_option, 5, &interface_count, &size, NULL, 0);
|
||||
|
||||
for (int i = 0; i < interface_count; i++) {
|
||||
ifdata(i, &net->data);
|
||||
if (strcmp(net->data.ifmd_name, ifname) == 0) {
|
||||
net->row = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void network_update(struct network* net) {
|
||||
gettimeofday(&net->tv_n, NULL);
|
||||
timersub(&net->tv_n, &net->tv_nm1, &net->tv_delta);
|
||||
net->tv_nm1 = net->tv_n;
|
||||
|
||||
uint64_t ibytes_nm1 = net->data.ifmd_data.ifi_ibytes;
|
||||
uint64_t obytes_nm1 = net->data.ifmd_data.ifi_obytes;
|
||||
ifdata(net->row, &net->data);
|
||||
|
||||
double time_scale = (net->tv_delta.tv_sec + 1e-6*net->tv_delta.tv_usec);
|
||||
if (time_scale < 1e-6 || time_scale > 1e2) return;
|
||||
double delta_ibytes = (double)(net->data.ifmd_data.ifi_ibytes - ibytes_nm1)
|
||||
/ time_scale;
|
||||
double delta_obytes = (double)(net->data.ifmd_data.ifi_obytes - obytes_nm1)
|
||||
/ time_scale;
|
||||
|
||||
double exponent_ibytes = log10(delta_ibytes);
|
||||
double exponent_obytes = log10(delta_obytes);
|
||||
|
||||
if (exponent_ibytes < 3) {
|
||||
net->down_unit = UNIT_BPS;
|
||||
net->down = delta_ibytes;
|
||||
} else if (exponent_ibytes < 6) {
|
||||
net->down_unit = UNIT_KBPS;
|
||||
net->down = delta_ibytes / 1000.0;
|
||||
} else if (exponent_ibytes < 9) {
|
||||
net->down_unit = UNIT_MBPS;
|
||||
net->down = delta_ibytes / 1000000.0;
|
||||
}
|
||||
|
||||
if (exponent_obytes < 3) {
|
||||
net->up_unit = UNIT_BPS;
|
||||
net->up = delta_obytes;
|
||||
} else if (exponent_obytes < 6) {
|
||||
net->up_unit = UNIT_KBPS;
|
||||
net->up = delta_obytes / 1000.0;
|
||||
} else if (exponent_obytes < 9) {
|
||||
net->up_unit = UNIT_MBPS;
|
||||
net->up = delta_obytes / 1000000.0;
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
#include <unistd.h>
|
||||
#include "network.h"
|
||||
#include "../sketchybar.h"
|
||||
|
||||
int main (int argc, char** argv) {
|
||||
float update_freq;
|
||||
if (argc < 4 || (sscanf(argv[3], "%f", &update_freq) != 1)) {
|
||||
printf("Usage: %s \"<interface>\" \"<event-name>\" \"<event_freq>\"\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
alarm(0);
|
||||
// Setup the event in sketchybar
|
||||
char event_message[512];
|
||||
snprintf(event_message, 512, "--add event '%s'", argv[2]);
|
||||
sketchybar(event_message);
|
||||
|
||||
struct network network;
|
||||
network_init(&network, argv[1]);
|
||||
char trigger_message[512];
|
||||
for (;;) {
|
||||
// Acquire new info
|
||||
network_update(&network);
|
||||
|
||||
// Prepare the event message
|
||||
snprintf(trigger_message,
|
||||
512,
|
||||
"--trigger '%s' upload='%03d%s' download='%03d%s'",
|
||||
argv[2],
|
||||
network.up,
|
||||
unit_str[network.up_unit],
|
||||
network.down,
|
||||
unit_str[network.down_unit]);
|
||||
|
||||
// Trigger the event
|
||||
sketchybar(trigger_message);
|
||||
|
||||
// Wait
|
||||
usleep(update_freq * 1000000);
|
||||
}
|
||||
return 0;
|
||||
}
|
122
darwin/sketchybar/config/helpers/event_providers/sketchybar.h
Normal file
122
darwin/sketchybar/config/helpers/event_providers/sketchybar.h
Normal file
@ -0,0 +1,122 @@
|
||||
#pragma once
|
||||
|
||||
#include <mach/arm/kern_return.h>
|
||||
#include <mach/mach.h>
|
||||
#include <mach/mach_port.h>
|
||||
#include <mach/message.h>
|
||||
#include <bootstrap.h>
|
||||
#include <stdlib.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
|
||||
typedef char* env;
|
||||
|
||||
#define MACH_HANDLER(name) void name(env env)
|
||||
typedef MACH_HANDLER(mach_handler);
|
||||
|
||||
struct mach_message {
|
||||
mach_msg_header_t header;
|
||||
mach_msg_size_t msgh_descriptor_count;
|
||||
mach_msg_ool_descriptor_t descriptor;
|
||||
};
|
||||
|
||||
struct mach_buffer {
|
||||
struct mach_message message;
|
||||
mach_msg_trailer_t trailer;
|
||||
};
|
||||
|
||||
static mach_port_t g_mach_port = 0;
|
||||
|
||||
static inline mach_port_t mach_get_bs_port() {
|
||||
mach_port_name_t task = mach_task_self();
|
||||
|
||||
mach_port_t bs_port;
|
||||
if (task_get_special_port(task,
|
||||
TASK_BOOTSTRAP_PORT,
|
||||
&bs_port ) != KERN_SUCCESS) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
char* name = getenv("BAR_NAME");
|
||||
if (!name) name = "sketchybar";
|
||||
uint32_t lookup_len = 16 + strlen(name);
|
||||
|
||||
char buffer[lookup_len];
|
||||
snprintf(buffer, lookup_len, "git.felix.%s", name);
|
||||
|
||||
mach_port_t port;
|
||||
if (bootstrap_look_up(bs_port, buffer, &port) != KERN_SUCCESS) return 0;
|
||||
return port;
|
||||
}
|
||||
|
||||
static inline bool mach_send_message(mach_port_t port, char* message, uint32_t len) {
|
||||
if (!message || !port) {
|
||||
return false;
|
||||
}
|
||||
|
||||
struct mach_message msg = { 0 };
|
||||
msg.header.msgh_remote_port = port;
|
||||
msg.header.msgh_local_port = 0;
|
||||
msg.header.msgh_id = 0;
|
||||
msg.header.msgh_bits = MACH_MSGH_BITS_SET(MACH_MSG_TYPE_COPY_SEND,
|
||||
MACH_MSG_TYPE_MAKE_SEND,
|
||||
0,
|
||||
MACH_MSGH_BITS_COMPLEX );
|
||||
|
||||
msg.header.msgh_size = sizeof(struct mach_message);
|
||||
msg.msgh_descriptor_count = 1;
|
||||
msg.descriptor.address = message;
|
||||
msg.descriptor.size = len * sizeof(char);
|
||||
msg.descriptor.copy = MACH_MSG_VIRTUAL_COPY;
|
||||
msg.descriptor.deallocate = false;
|
||||
msg.descriptor.type = MACH_MSG_OOL_DESCRIPTOR;
|
||||
|
||||
kern_return_t err = mach_msg(&msg.header,
|
||||
MACH_SEND_MSG,
|
||||
sizeof(struct mach_message),
|
||||
0,
|
||||
MACH_PORT_NULL,
|
||||
MACH_MSG_TIMEOUT_NONE,
|
||||
MACH_PORT_NULL );
|
||||
|
||||
return err == KERN_SUCCESS;
|
||||
}
|
||||
|
||||
static inline uint32_t format_message(char* message, char* formatted_message) {
|
||||
// This is not actually robust, switch to stack based messaging.
|
||||
char outer_quote = 0;
|
||||
uint32_t caret = 0;
|
||||
uint32_t message_length = strlen(message) + 1;
|
||||
for (int i = 0; i < message_length; ++i) {
|
||||
if (message[i] == '"' || message[i] == '\'') {
|
||||
if (outer_quote && outer_quote == message[i]) outer_quote = 0;
|
||||
else if (!outer_quote) outer_quote = message[i];
|
||||
continue;
|
||||
}
|
||||
formatted_message[caret] = message[i];
|
||||
if (message[i] == ' ' && !outer_quote) formatted_message[caret] = '\0';
|
||||
caret++;
|
||||
}
|
||||
|
||||
if (caret > 0 && formatted_message[caret] == '\0'
|
||||
&& formatted_message[caret - 1] == '\0') {
|
||||
caret--;
|
||||
}
|
||||
formatted_message[caret] = '\0';
|
||||
return caret + 1;
|
||||
}
|
||||
|
||||
static inline void sketchybar(char* message) {
|
||||
char formatted_message[strlen(message) + 2];
|
||||
uint32_t length = format_message(message, formatted_message);
|
||||
if (!length) return;
|
||||
|
||||
if (!g_mach_port) g_mach_port = mach_get_bs_port();
|
||||
if (!mach_send_message(g_mach_port, formatted_message, length)) {
|
||||
g_mach_port = mach_get_bs_port();
|
||||
if (!mach_send_message(g_mach_port, formatted_message, length)) {
|
||||
// No sketchybar instance running, exit.
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
328
darwin/sketchybar/config/helpers/icon_map.lua
Normal file
328
darwin/sketchybar/config/helpers/icon_map.lua
Normal file
@ -0,0 +1,328 @@
|
||||
return {
|
||||
["Live"] = ":ableton:",
|
||||
["Adobe Bridge"] = ":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"] = ":alfred:",
|
||||
["Android Messages"] = ":android_messages:",
|
||||
["Android Studio"] = ":android_studio:",
|
||||
["Anki"] = ":anki:",
|
||||
["Anytype"] = ":anytype:",
|
||||
["App Eraser"] = ":app_eraser:",
|
||||
["App Store"] = ":app_store:",
|
||||
["Arc"] = ":arc:",
|
||||
["Arduino"] = ":arduino:",
|
||||
["Arduino IDE"] = ":arduino:",
|
||||
["Atom"] = ":atom:",
|
||||
["Audacity"] = ":audacity:",
|
||||
["Bambu Studio"] = ":bambu_studio:",
|
||||
["MoneyMoney"] = ":bank:",
|
||||
["Battle.net"] = ":battle_net:",
|
||||
["Bear"] = ":bear:",
|
||||
["BetterTouchTool"] = ":bettertouchtool:",
|
||||
["Bilibili"] = ":bilibili:",
|
||||
["哔哩哔哩"] = ":bilibili:",
|
||||
["Bitwarden"] = ":bit_warden:",
|
||||
["Blender"] = ":blender:",
|
||||
["BluOS Controller"] = ":bluos_controller:",
|
||||
["Calibre"] = ":book:",
|
||||
["Brave Browser"] = ":brave_browser:",
|
||||
["BusyCal"] = ":busycal:",
|
||||
["Calculator"] = ":calculator:",
|
||||
["Calculette"] = ":calculator:",
|
||||
["Calendar"] = ":calendar:",
|
||||
["日历"] = ":calendar:",
|
||||
["Fantastical"] = ":calendar:",
|
||||
["Cron"] = ":calendar:",
|
||||
["Amie"] = ":calendar:",
|
||||
["Calendrier"] = ":calendar:",
|
||||
["カレンダー"] = ":calendar:",
|
||||
["Notion Calendar"] = ":calendar:",
|
||||
["calibre"] = ":calibre:",
|
||||
["Caprine"] = ":caprine:",
|
||||
["Amazon Chime"] = ":chime:",
|
||||
["Citrix Workspace"] = ":citrix:",
|
||||
["Citrix Viewer"] = ":citrix:",
|
||||
["Claude"] = ":claude:",
|
||||
["ClickUp"] = ":click_up:",
|
||||
["Code"] = ":code:",
|
||||
["Code - Insiders"] = ":code:",
|
||||
["Cold Turkey Blocker"] = ":cold_turkey_blocker:",
|
||||
["Color Picker"] = ":color_picker:",
|
||||
["数码测色计"] = ":color_picker:",
|
||||
["Copilot"] = ":copilot:",
|
||||
["CotEditor"] = ":coteditor:",
|
||||
["Creative Cloud"] = ":creative_cloud:",
|
||||
["Cursor"] = ":cursor:",
|
||||
["Cypress"] = ":cypress:",
|
||||
["DataGrip"] = ":datagrip:",
|
||||
["DataSpell"] = ":dataspell:",
|
||||
["DaVinci Resolve"] = ":davinciresolve:",
|
||||
["Deezer"] = ":deezer:",
|
||||
["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:",
|
||||
["draw.io"] = ":draw_io:",
|
||||
["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:",
|
||||
["Fork"] = ":fork:",
|
||||
["FreeTube"] = ":freetube:",
|
||||
["Fusion"] = ":fusion:",
|
||||
["System Preferences"] = ":gear:",
|
||||
["System Settings"] = ":gear:",
|
||||
["系统设置"] = ":gear:",
|
||||
["Réglages Système"] = ":gear:",
|
||||
["システム設定"] = ":gear:",
|
||||
["Ghostty"] = ":ghostty:",
|
||||
["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:",
|
||||
["IINA"] = ":iina:",
|
||||
["Adobe Illustrator"] = ":illustrator:",
|
||||
["Illustrator"] = ":illustrator:",
|
||||
["Adobe InDesign"] = ":indesign:",
|
||||
["InDesign"] = ":indesign:",
|
||||
["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:",
|
||||
["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:",
|
||||
["Spark"] = ":mail:",
|
||||
["邮件"] = ":mail:",
|
||||
["メール"] = ":mail:",
|
||||
["MAMP"] = ":mamp:",
|
||||
["MAMP PRO"] = ":mamp:",
|
||||
["Maps"] = ":maps:",
|
||||
["Google Maps"] = ":maps:",
|
||||
["マップ"] = ":maps:",
|
||||
["Marta"] = ":marta:",
|
||||
["Matlab"] = ":matlab:",
|
||||
["Mattermost"] = ":mattermost:",
|
||||
["Messages"] = ":messages:",
|
||||
["信息"] = ":messages:",
|
||||
["Nachrichten"] = ":messages:",
|
||||
["メッセージ"] = ":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:",
|
||||
["Moonlight"] = ":moonlight:",
|
||||
["mpv"] = ":mpv:",
|
||||
["Mullvad Browser"] = ":mullvad_browser:",
|
||||
["Music"] = ":music:",
|
||||
["音乐"] = ":music:",
|
||||
["Musique"] = ":music:",
|
||||
["ミュージック"] = ":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:",
|
||||
["备忘录"] = ":notes:",
|
||||
["メモ"] = ":notes:",
|
||||
["Notion"] = ":notion:",
|
||||
["Nova"] = ":nova:",
|
||||
["Numbers"] = ":numbers:",
|
||||
["Numbers 表格"] = ":numbers:",
|
||||
["Obsidian"] = ":obsidian:",
|
||||
["OBS"] = ":obsstudio:",
|
||||
["OmniFocus"] = ":omni_focus:",
|
||||
["1Password"] = ":one_password:",
|
||||
["Open Video Downloader"] = ":open_video_downloader:",
|
||||
["ChatGPT"] = ":openai:",
|
||||
["OpenVPN Connect"] = ":openvpn_connect:",
|
||||
["Opera"] = ":opera:",
|
||||
["OrbStack"] = ":orbstack:",
|
||||
["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:",
|
||||
["PDF Expert"] = ":pdf_expert:",
|
||||
["Pearcleaner"] = ":pearcleaner:",
|
||||
["Phoenix Slides"] = ":phoenix_slides:",
|
||||
["Adobe Photoshop"] = ":photoshop:",
|
||||
["PhpStorm"] = ":php_storm:",
|
||||
["Pi-hole Remote"] = ":pihole:",
|
||||
["Pine"] = ":pine:",
|
||||
["Plex"] = ":plex:",
|
||||
["Plexamp"] = ":plexamp:",
|
||||
["Podcasts"] = ":podcasts:",
|
||||
["播客"] = ":podcasts:",
|
||||
["PomoDone App"] = ":pomodone:",
|
||||
["Postman"] = ":postman:",
|
||||
["Proton Mail"] = ":proton_mail:",
|
||||
["Proton Mail Bridge"] = ":proton_mail:",
|
||||
["Proton VPN"] = ":proton_vpn:",
|
||||
["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:",
|
||||
["リマインダー"] = ":reminders:",
|
||||
["Replit"] = ":replit:",
|
||||
["Rider"] = ":rider:",
|
||||
["JetBrains Rider"] = ":rider:",
|
||||
["Rio"] = ":rio:",
|
||||
["Royal TSX"] = ":royaltsx:",
|
||||
["Safari"] = ":safari:",
|
||||
["Safari浏览器"] = ":safari:",
|
||||
["Safari Technology Preview"] = ":safari:",
|
||||
["Sequel Ace"] = ":sequel_ace:",
|
||||
["Sequel Pro"] = ":sequel_pro:",
|
||||
["Setapp"] = ":setapp:",
|
||||
["SF Symbols"] = ":sf_symbols:",
|
||||
["Signal"] = ":signal:",
|
||||
["sioyek"] = ":sioyek:",
|
||||
["Sketch"] = ":sketch:",
|
||||
["Skype"] = ":skype:",
|
||||
["Slack"] = ":slack:",
|
||||
["Spark Desktop"] = ":spark:",
|
||||
["Spotify"] = ":spotify:",
|
||||
["Spotlight"] = ":spotlight:",
|
||||
["Sublime Text"] = ":sublime_text:",
|
||||
["superProductivity"] = ":superproductivity:",
|
||||
["Tana"] = ":tana:",
|
||||
["TeamSpeak 3"] = ":team_speak:",
|
||||
["Telegram"] = ":telegram:",
|
||||
["Terminal"] = ":terminal:",
|
||||
["终端"] = ":terminal:",
|
||||
["ターミナル"] = ":terminal:",
|
||||
["Typora"] = ":text:",
|
||||
["Microsoft To Do"] = ":things:",
|
||||
["Things"] = ":things:",
|
||||
["Thunderbird"] = ":thunderbird:",
|
||||
["Thunderbird Beta"] = ":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:",
|
||||
["UTM"] = ":utm:",
|
||||
["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"] = ":yandex_music:",
|
||||
["Yuque"] = ":yuque:",
|
||||
["语雀"] = ":yuque:",
|
||||
["Zed"] = ":zed:",
|
||||
["Zen Browser"] = ":zen_browser:",
|
||||
["Zeplin"] = ":zeplin:",
|
||||
["zoom.us"] = ":zoom:",
|
||||
["Zotero"] = ":zotero:",
|
||||
["Zulip"] = ":zulip:",
|
||||
}
|
1
darwin/sketchybar/config/helpers/init.lua
Normal file
1
darwin/sketchybar/config/helpers/init.lua
Normal file
@ -0,0 +1 @@
|
||||
os.execute("(cd helpers && make)")
|
2
darwin/sketchybar/config/helpers/install.sh
Normal file
2
darwin/sketchybar/config/helpers/install.sh
Normal file
@ -0,0 +1,2 @@
|
||||
# SbarLua
|
||||
(git clone https://github.com/FelixKratz/SbarLua.git /tmp/SbarLua && cd /tmp/SbarLua/ && make install && rm -rf /tmp/SbarLua/)
|
3
darwin/sketchybar/config/helpers/makefile
Normal file
3
darwin/sketchybar/config/helpers/makefile
Normal file
@ -0,0 +1,3 @@
|
||||
all:
|
||||
(cd event_providers && $(MAKE)) >/dev/null
|
||||
(cd menus && $(MAKE)) >/dev/null
|
5
darwin/sketchybar/config/helpers/menus/makefile
Normal file
5
darwin/sketchybar/config/helpers/menus/makefile
Normal file
@ -0,0 +1,5 @@
|
||||
bin/menus: menus.c | bin
|
||||
clang -std=c99 -O3 -F/System/Library/PrivateFrameworks/ -framework Carbon -framework SkyLight $< -o $@
|
||||
|
||||
bin:
|
||||
mkdir bin
|
248
darwin/sketchybar/config/helpers/menus/menus.c
Normal file
248
darwin/sketchybar/config/helpers/menus/menus.c
Normal file
@ -0,0 +1,248 @@
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
void ax_init() {
|
||||
const void *keys[] = { kAXTrustedCheckOptionPrompt };
|
||||
const void *values[] = { kCFBooleanTrue };
|
||||
|
||||
CFDictionaryRef options;
|
||||
options = CFDictionaryCreate(kCFAllocatorDefault,
|
||||
keys,
|
||||
values,
|
||||
sizeof(keys) / sizeof(*keys),
|
||||
&kCFCopyStringDictionaryKeyCallBacks,
|
||||
&kCFTypeDictionaryValueCallBacks );
|
||||
|
||||
bool trusted = AXIsProcessTrustedWithOptions(options);
|
||||
CFRelease(options);
|
||||
if (!trusted) exit(1);
|
||||
}
|
||||
|
||||
void ax_perform_click(AXUIElementRef element) {
|
||||
if (!element) return;
|
||||
AXUIElementPerformAction(element, kAXCancelAction);
|
||||
usleep(150000);
|
||||
AXUIElementPerformAction(element, kAXPressAction);
|
||||
}
|
||||
|
||||
CFStringRef ax_get_title(AXUIElementRef element) {
|
||||
CFTypeRef title = NULL;
|
||||
AXError error = AXUIElementCopyAttributeValue(element,
|
||||
kAXTitleAttribute,
|
||||
&title );
|
||||
|
||||
if (error != kAXErrorSuccess) return NULL;
|
||||
return title;
|
||||
}
|
||||
|
||||
void ax_select_menu_option(AXUIElementRef app, int id) {
|
||||
AXUIElementRef menubars_ref = NULL;
|
||||
CFArrayRef children_ref = NULL;
|
||||
|
||||
AXError error = AXUIElementCopyAttributeValue(app,
|
||||
kAXMenuBarAttribute,
|
||||
(CFTypeRef*)&menubars_ref);
|
||||
if (error == kAXErrorSuccess) {
|
||||
error = AXUIElementCopyAttributeValue(menubars_ref,
|
||||
kAXVisibleChildrenAttribute,
|
||||
(CFTypeRef*)&children_ref );
|
||||
|
||||
if (error == kAXErrorSuccess) {
|
||||
uint32_t count = CFArrayGetCount(children_ref);
|
||||
if (id < count) {
|
||||
AXUIElementRef item = CFArrayGetValueAtIndex(children_ref, id);
|
||||
ax_perform_click(item);
|
||||
}
|
||||
if (children_ref) CFRelease(children_ref);
|
||||
}
|
||||
if (menubars_ref) CFRelease(menubars_ref);
|
||||
}
|
||||
}
|
||||
|
||||
void ax_print_menu_options(AXUIElementRef app) {
|
||||
AXUIElementRef menubars_ref = NULL;
|
||||
CFTypeRef menubar = NULL;
|
||||
CFArrayRef children_ref = NULL;
|
||||
|
||||
AXError error = AXUIElementCopyAttributeValue(app,
|
||||
kAXMenuBarAttribute,
|
||||
(CFTypeRef*)&menubars_ref);
|
||||
if (error == kAXErrorSuccess) {
|
||||
error = AXUIElementCopyAttributeValue(menubars_ref,
|
||||
kAXVisibleChildrenAttribute,
|
||||
(CFTypeRef*)&children_ref );
|
||||
|
||||
if (error == kAXErrorSuccess) {
|
||||
uint32_t count = CFArrayGetCount(children_ref);
|
||||
|
||||
for (int i = 1; i < count; i++) {
|
||||
AXUIElementRef item = CFArrayGetValueAtIndex(children_ref, i);
|
||||
CFTypeRef title = ax_get_title(item);
|
||||
|
||||
if (title) {
|
||||
uint32_t buffer_len = 2*CFStringGetLength(title);
|
||||
char buffer[2*CFStringGetLength(title)];
|
||||
CFStringGetCString(title, buffer, buffer_len, kCFStringEncodingUTF8);
|
||||
printf("%s\n", buffer);
|
||||
CFRelease(title);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (menubars_ref) CFRelease(menubars_ref);
|
||||
if (children_ref) CFRelease(children_ref);
|
||||
}
|
||||
}
|
||||
|
||||
AXUIElementRef ax_get_extra_menu_item(char* alias) {
|
||||
pid_t pid = 0;
|
||||
CGRect bounds = CGRectNull;
|
||||
CFArrayRef window_list = CGWindowListCopyWindowInfo(kCGWindowListOptionAll,
|
||||
kCGNullWindowID );
|
||||
char owner_buffer[256];
|
||||
char name_buffer[256];
|
||||
char buffer[512];
|
||||
int window_count = CFArrayGetCount(window_list);
|
||||
for (int i = 0; i < window_count; ++i) {
|
||||
CFDictionaryRef dictionary = CFArrayGetValueAtIndex(window_list, i);
|
||||
if (!dictionary) continue;
|
||||
|
||||
CFStringRef owner_ref = CFDictionaryGetValue(dictionary,
|
||||
kCGWindowOwnerName);
|
||||
|
||||
CFNumberRef owner_pid_ref = CFDictionaryGetValue(dictionary,
|
||||
kCGWindowOwnerPID);
|
||||
|
||||
CFStringRef name_ref = CFDictionaryGetValue(dictionary, kCGWindowName);
|
||||
CFNumberRef layer_ref = CFDictionaryGetValue(dictionary, kCGWindowLayer);
|
||||
CFDictionaryRef bounds_ref = CFDictionaryGetValue(dictionary,
|
||||
kCGWindowBounds);
|
||||
|
||||
if (!name_ref || !owner_ref || !owner_pid_ref || !layer_ref || !bounds_ref)
|
||||
continue;
|
||||
|
||||
long long int layer = 0;
|
||||
CFNumberGetValue(layer_ref, CFNumberGetType(layer_ref), &layer);
|
||||
uint64_t owner_pid = 0;
|
||||
CFNumberGetValue(owner_pid_ref,
|
||||
CFNumberGetType(owner_pid_ref),
|
||||
&owner_pid );
|
||||
|
||||
if (layer != 0x19) continue;
|
||||
bounds = CGRectNull;
|
||||
if (!CGRectMakeWithDictionaryRepresentation(bounds_ref, &bounds)) continue;
|
||||
CFStringGetCString(owner_ref,
|
||||
owner_buffer,
|
||||
sizeof(owner_buffer),
|
||||
kCFStringEncodingUTF8);
|
||||
|
||||
CFStringGetCString(name_ref,
|
||||
name_buffer,
|
||||
sizeof(name_buffer),
|
||||
kCFStringEncodingUTF8);
|
||||
snprintf(buffer, sizeof(buffer), "%s,%s", owner_buffer, name_buffer);
|
||||
|
||||
if (strcmp(buffer, alias) == 0) {
|
||||
pid = owner_pid;
|
||||
break;
|
||||
}
|
||||
}
|
||||
CFRelease(window_list);
|
||||
if (!pid) return NULL;
|
||||
|
||||
AXUIElementRef app = AXUIElementCreateApplication(pid);
|
||||
if (!app) return NULL;
|
||||
AXUIElementRef result = NULL;
|
||||
CFTypeRef extras = NULL;
|
||||
CFArrayRef children_ref = NULL;
|
||||
AXError error = AXUIElementCopyAttributeValue(app,
|
||||
kAXExtrasMenuBarAttribute,
|
||||
&extras );
|
||||
if (error == kAXErrorSuccess) {
|
||||
error = AXUIElementCopyAttributeValue(extras,
|
||||
kAXVisibleChildrenAttribute,
|
||||
(CFTypeRef*)&children_ref );
|
||||
|
||||
if (error == kAXErrorSuccess) {
|
||||
uint32_t count = CFArrayGetCount(children_ref);
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
AXUIElementRef item = CFArrayGetValueAtIndex(children_ref, i);
|
||||
CFTypeRef position_ref = NULL;
|
||||
CFTypeRef size_ref = NULL;
|
||||
AXUIElementCopyAttributeValue(item, kAXPositionAttribute,
|
||||
&position_ref );
|
||||
AXUIElementCopyAttributeValue(item, kAXSizeAttribute,
|
||||
&size_ref );
|
||||
if (!position_ref || !size_ref) continue;
|
||||
|
||||
CGPoint position = CGPointZero;
|
||||
AXValueGetValue(position_ref, kAXValueCGPointType, &position);
|
||||
CGSize size = CGSizeZero;
|
||||
AXValueGetValue(size_ref, kAXValueCGSizeType, &size);
|
||||
CFRelease(position_ref);
|
||||
CFRelease(size_ref);
|
||||
// The offset is exactly 8 on macOS Sonoma...
|
||||
// printf("%f %f\n", position.x, bounds.origin.x);
|
||||
if (error == kAXErrorSuccess
|
||||
&& fabs(position.x - bounds.origin.x) <= 10) {
|
||||
result = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CFRelease(app);
|
||||
return result;
|
||||
}
|
||||
|
||||
extern int SLSMainConnectionID();
|
||||
extern void SLSSetMenuBarVisibilityOverrideOnDisplay(int cid, int did, bool enabled);
|
||||
extern void SLSSetMenuBarVisibilityOverrideOnDisplay(int cid, int did, bool enabled);
|
||||
extern void SLSSetMenuBarInsetAndAlpha(int cid, double u1, double u2, float alpha);
|
||||
void ax_select_menu_extra(char* alias) {
|
||||
AXUIElementRef item = ax_get_extra_menu_item(alias);
|
||||
if (!item) return;
|
||||
SLSSetMenuBarInsetAndAlpha(SLSMainConnectionID(), 0, 1, 0.0);
|
||||
SLSSetMenuBarVisibilityOverrideOnDisplay(SLSMainConnectionID(), 0, true);
|
||||
SLSSetMenuBarInsetAndAlpha(SLSMainConnectionID(), 0, 1, 0.0);
|
||||
ax_perform_click(item);
|
||||
SLSSetMenuBarVisibilityOverrideOnDisplay(SLSMainConnectionID(), 0, false);
|
||||
SLSSetMenuBarInsetAndAlpha(SLSMainConnectionID(), 0, 1, 1.0);
|
||||
CFRelease(item);
|
||||
}
|
||||
|
||||
extern void _SLPSGetFrontProcess(ProcessSerialNumber* psn);
|
||||
extern void SLSGetConnectionIDForPSN(int cid, ProcessSerialNumber* psn, int* cid_out);
|
||||
extern void SLSConnectionGetPID(int cid, pid_t* pid_out);
|
||||
AXUIElementRef ax_get_front_app() {
|
||||
ProcessSerialNumber psn;
|
||||
_SLPSGetFrontProcess(&psn);
|
||||
int target_cid;
|
||||
SLSGetConnectionIDForPSN(SLSMainConnectionID(), &psn, &target_cid);
|
||||
|
||||
pid_t pid;
|
||||
SLSConnectionGetPID(target_cid, &pid);
|
||||
return AXUIElementCreateApplication(pid);
|
||||
}
|
||||
|
||||
int main (int argc, char **argv) {
|
||||
if (argc == 1) {
|
||||
printf("Usage: %s [-l | -s id/alias ]\n", argv[0]);
|
||||
exit(0);
|
||||
}
|
||||
ax_init();
|
||||
if (strcmp(argv[1], "-l") == 0) {
|
||||
AXUIElementRef app = ax_get_front_app();
|
||||
if (!app) return 1;
|
||||
ax_print_menu_options(app);
|
||||
CFRelease(app);
|
||||
} else if (argc == 3 && strcmp(argv[1], "-s") == 0) {
|
||||
int id = 0;
|
||||
if (sscanf(argv[2], "%d", &id) == 1) {
|
||||
AXUIElementRef app = ax_get_front_app();
|
||||
if (!app) return 1;
|
||||
ax_select_menu_option(app, id);
|
||||
CFRelease(app);
|
||||
} else ax_select_menu_extra(argv[2]);
|
||||
}
|
||||
return 0;
|
||||
}
|
67
darwin/sketchybar/config/icons.lua
Normal file
67
darwin/sketchybar/config/icons.lua
Normal file
@ -0,0 +1,67 @@
|
||||
local settings = require "settings"
|
||||
|
||||
local icons = {
|
||||
sf_symbols = {
|
||||
plus = "",
|
||||
loading = "",
|
||||
apple = "", --
|
||||
gear = "",
|
||||
cpu = "",
|
||||
clipboard = "",
|
||||
music = "",
|
||||
calendar = "",
|
||||
message = "",
|
||||
separators = {
|
||||
left = "",
|
||||
right = "",
|
||||
},
|
||||
space_indicator = {
|
||||
on = "",
|
||||
off = "",
|
||||
},
|
||||
|
||||
switch = {
|
||||
on = "",
|
||||
off = "",
|
||||
},
|
||||
volume = {
|
||||
_100 = "",
|
||||
_66 = "",
|
||||
_33 = "",
|
||||
_10 = "",
|
||||
_0 = "",
|
||||
},
|
||||
battery = {
|
||||
_100 = "",
|
||||
_75 = "",
|
||||
_50 = "",
|
||||
_25 = "",
|
||||
_0 = "",
|
||||
charging = "",
|
||||
},
|
||||
wifi = {
|
||||
upload = "",
|
||||
download = "",
|
||||
connected = "",
|
||||
disconnected = "",
|
||||
router = "",
|
||||
vpn = "",
|
||||
test = "",
|
||||
},
|
||||
media = {
|
||||
back = "",
|
||||
forward = "",
|
||||
play_pause = "",
|
||||
},
|
||||
ramicons = {
|
||||
swap = "",
|
||||
ram = "",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
if not (settings.icons == "NerdFont") then
|
||||
return icons.sf_symbols
|
||||
else
|
||||
return icons.nerdfont
|
||||
end
|
11
darwin/sketchybar/config/init.lua
Normal file
11
darwin/sketchybar/config/init.lua
Normal file
@ -0,0 +1,11 @@
|
||||
sbar = require("sketchybar")
|
||||
|
||||
sbar.begin_config()
|
||||
sbar.hotload(true)
|
||||
|
||||
require("bar")
|
||||
require("default")
|
||||
require("items")
|
||||
|
||||
sbar.end_config()
|
||||
sbar.event_loop()
|
5
darwin/sketchybar/config/items/.luarc.json
Normal file
5
darwin/sketchybar/config/items/.luarc.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"diagnostics.globals": [
|
||||
"sbar"
|
||||
]
|
||||
}
|
39
darwin/sketchybar/config/items/apple.lua
Normal file
39
darwin/sketchybar/config/items/apple.lua
Normal file
@ -0,0 +1,39 @@
|
||||
local colors = require("colors").sections
|
||||
local icons = require("icons")
|
||||
|
||||
local apple = sbar.add("item", {
|
||||
icon = {
|
||||
font = { size = 16 },
|
||||
string = icons.apple,
|
||||
padding_right = 15,
|
||||
padding_left = 15,
|
||||
color = colors.apple,
|
||||
},
|
||||
label = { drawing = false },
|
||||
click_script = "$CONFIG_DIR/helpers/menus/bin/menus -s 0",
|
||||
})
|
||||
|
||||
apple:subscribe("mouse.clicked", function()
|
||||
sbar.animate("tanh", 8, function()
|
||||
apple:set {
|
||||
background = {
|
||||
shadow = {
|
||||
distance = 0,
|
||||
},
|
||||
},
|
||||
y_offset = -4,
|
||||
padding_left = 8,
|
||||
padding_right = 0,
|
||||
}
|
||||
apple:set {
|
||||
background = {
|
||||
shadow = {
|
||||
distance = 4,
|
||||
},
|
||||
},
|
||||
y_offset = 0,
|
||||
padding_left = 4,
|
||||
padding_right = 4,
|
||||
}
|
||||
end)
|
||||
end)
|
53
darwin/sketchybar/config/items/calendar.lua
Normal file
53
darwin/sketchybar/config/items/calendar.lua
Normal file
@ -0,0 +1,53 @@
|
||||
local icons = require("icons")
|
||||
local colors = require("colors").sections.calendar
|
||||
local settings = require("settings")
|
||||
|
||||
local cal = sbar.add("item", {
|
||||
label = {
|
||||
padding_left = 6,
|
||||
padding_right = 12,
|
||||
font = {
|
||||
-- family = settings.font.numbers,
|
||||
style = settings.font.style_map["Bold"],
|
||||
},
|
||||
},
|
||||
-- label = {
|
||||
-- color = colors.label,
|
||||
-- align = "left",
|
||||
-- padding_right = 8,
|
||||
-- },
|
||||
padding_left = 10,
|
||||
position = "right",
|
||||
update_freq = 30,
|
||||
click_script = "open -a 'Calendar'",
|
||||
})
|
||||
|
||||
cal:subscribe("mouse.clicked", function()
|
||||
sbar.animate("tanh", 8, function()
|
||||
cal:set {
|
||||
background = {
|
||||
shadow = {
|
||||
distance = 0,
|
||||
},
|
||||
},
|
||||
y_offset = -4,
|
||||
padding_left = 14,
|
||||
padding_right = 0,
|
||||
}
|
||||
cal:set {
|
||||
background = {
|
||||
shadow = {
|
||||
distance = 4,
|
||||
},
|
||||
},
|
||||
y_offset = 0,
|
||||
padding_left = 10,
|
||||
padding_right = 4,
|
||||
}
|
||||
end)
|
||||
end)
|
||||
|
||||
cal:subscribe({ "forced", "routine", "system_woke" }, function()
|
||||
---@diagnostic disable-next-line: param-type-mismatch
|
||||
cal:set { label = os.date("%I"):gsub("^0+", "") .. ":" .. os.date "%M %p" }
|
||||
end)
|
13
darwin/sketchybar/config/items/init.lua
Normal file
13
darwin/sketchybar/config/items/init.lua
Normal file
@ -0,0 +1,13 @@
|
||||
--left
|
||||
require("items.apple")
|
||||
require("items.spaces")
|
||||
require("items.menus")
|
||||
|
||||
--center
|
||||
require("items.notifications")
|
||||
|
||||
--right (reverse order)
|
||||
require("items.calendar")
|
||||
require("items.widgets")
|
||||
require("items.wifi")
|
||||
require("items.media")
|
92
darwin/sketchybar/config/items/media.lua
Normal file
92
darwin/sketchybar/config/items/media.lua
Normal file
@ -0,0 +1,92 @@
|
||||
local icons = require("icons")
|
||||
local colors = require("colors").sections.media
|
||||
|
||||
local whitelist = { ["Spotify"] = true, ["Psst"] = true }
|
||||
|
||||
local media_playback = sbar.add("item", {
|
||||
position = "right",
|
||||
icon = {
|
||||
string = icons.music,
|
||||
color = colors.label,
|
||||
padding_left = 8,
|
||||
},
|
||||
label = {
|
||||
max_chars = 50,
|
||||
padding_right = 8,
|
||||
},
|
||||
popup = {
|
||||
horizontal = true,
|
||||
align = "center",
|
||||
y_offset = 2,
|
||||
},
|
||||
padding_right = 8,
|
||||
})
|
||||
|
||||
sbar.add("item", {
|
||||
position = "popup." .. media_playback.name,
|
||||
padding_left = 6,
|
||||
padding_right = 6,
|
||||
icon = { string = icons.media.back },
|
||||
label = { drawing = false },
|
||||
background = { drawing = false },
|
||||
click_script = "nowplaying-cli previous",
|
||||
})
|
||||
|
||||
sbar.add("item", {
|
||||
position = "popup." .. media_playback.name,
|
||||
padding_left = 6,
|
||||
padding_right = 6,
|
||||
icon = { string = icons.media.play_pause },
|
||||
label = { drawing = false },
|
||||
background = { drawing = false },
|
||||
click_script = "nowplaying-cli togglePlayPause",
|
||||
})
|
||||
|
||||
sbar.add("item", {
|
||||
position = "popup." .. media_playback.name,
|
||||
padding_left = 6,
|
||||
padding_right = 6,
|
||||
icon = { string = icons.media.forward },
|
||||
label = { drawing = false },
|
||||
background = { drawing = false },
|
||||
click_script = "nowplaying-cli next",
|
||||
})
|
||||
|
||||
media_playback:subscribe("media_change", function(env)
|
||||
if whitelist[env.INFO.app] then
|
||||
local is_playing = (env.INFO.state == "playing")
|
||||
media_playback:set {
|
||||
drawing = is_playing,
|
||||
label = {
|
||||
string = env.INFO.artist .. " - " .. env.INFO.title,
|
||||
padding_left = is_playing and 8 or 0,
|
||||
},
|
||||
}
|
||||
end
|
||||
end)
|
||||
|
||||
media_playback:subscribe("mouse.clicked", function(_)
|
||||
sbar.animate("tanh", 8, function()
|
||||
media_playback:set {
|
||||
background = {
|
||||
shadow = {
|
||||
distance = 0,
|
||||
},
|
||||
},
|
||||
y_offset = -4,
|
||||
padding_left = 8,
|
||||
padding_right = 4,
|
||||
}
|
||||
media_playback:set {
|
||||
background = {
|
||||
shadow = {
|
||||
distance = 4,
|
||||
},
|
||||
},
|
||||
y_offset = 0,
|
||||
padding_left = 4,
|
||||
padding_right = 8,
|
||||
}
|
||||
end)
|
||||
media_playback:set { popup = { drawing = "toggle" } }
|
||||
end)
|
71
darwin/sketchybar/config/items/menus.lua
Normal file
71
darwin/sketchybar/config/items/menus.lua
Normal file
@ -0,0 +1,71 @@
|
||||
local settings = require("settings")
|
||||
|
||||
local menu_watcher = sbar.add("item", {
|
||||
drawing = false,
|
||||
updates = false,
|
||||
})
|
||||
local space_menu_swap = 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, {
|
||||
drawing = false,
|
||||
icon = { drawing = false },
|
||||
background = { drawing = false },
|
||||
label = {
|
||||
font = {
|
||||
style = settings.font.style_map[i == 1 and "Heavy" or "Semibold"],
|
||||
},
|
||||
padding_left = 6,
|
||||
padding_right = 6,
|
||||
},
|
||||
click_script = "$CONFIG_DIR/lua/helpers/menus/bin/menus -s " .. i,
|
||||
})
|
||||
|
||||
menu_items[i] = menu
|
||||
end
|
||||
|
||||
sbar.add("bracket", { "/menu\\..*/" }, {})
|
||||
|
||||
local menu_padding = sbar.add("item", "menu.padding", {
|
||||
drawing = false,
|
||||
width = 5,
|
||||
})
|
||||
|
||||
local function update_menus(env)
|
||||
sbar.exec("$CONFIG_DIR/lua/helpers/menus/bin/menus -l", function(menus)
|
||||
sbar.set("/menu\\..*/", { drawing = false })
|
||||
menu_padding:set { drawing = true }
|
||||
Id = 1
|
||||
for menu in string.gmatch(menus, "[^\r\n]+") do
|
||||
if Id < max_items then
|
||||
menu_items[Id]:set { label = menu, drawing = true }
|
||||
else
|
||||
break
|
||||
end
|
||||
Id = Id + 1
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
menu_watcher:subscribe("front_app_switched", update_menus)
|
||||
|
||||
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 })
|
||||
else
|
||||
menu_watcher:set { updates = true }
|
||||
sbar.set("/space\\..*/", { drawing = false })
|
||||
update_menus()
|
||||
end
|
||||
end)
|
||||
|
||||
return menu_watcher
|
49
darwin/sketchybar/config/items/notifications.lua
Normal file
49
darwin/sketchybar/config/items/notifications.lua
Normal file
@ -0,0 +1,49 @@
|
||||
local notification = sbar.add("item", "notifications", {
|
||||
width = 0,
|
||||
position = "center",
|
||||
popup = {
|
||||
drawing = true,
|
||||
align = "center",
|
||||
y_offset = -80,
|
||||
},
|
||||
})
|
||||
|
||||
local notification_popup = sbar.add("item", {
|
||||
position = "popup." .. notification.name,
|
||||
width = "dynamic",
|
||||
icon = { drawing = false },
|
||||
background = { drawing = false },
|
||||
})
|
||||
|
||||
local function hide_notification()
|
||||
sbar.animate("sin", 30, function()
|
||||
notification:set({ popup = { y_offset = 2 } })
|
||||
notification:set({ popup = { y_offset = -80 } })
|
||||
end)
|
||||
end
|
||||
|
||||
local function show_notification(content, hold)
|
||||
hide_notification()
|
||||
|
||||
notification_popup:set({ label = { string = content } })
|
||||
|
||||
sbar.animate("sin", 30, function()
|
||||
notification:set({ popup = { y_offset = -80 } })
|
||||
notification:set({ popup = { y_offset = 2 } })
|
||||
end)
|
||||
|
||||
if hold == false then
|
||||
sbar.delay(5, function()
|
||||
if hold then return end
|
||||
hide_notification()
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
notification:subscribe("send_message", function(env)
|
||||
local content = env.MESSAGE
|
||||
local hold = env.HOLD ~= nil and env.HOLD == "true" or false
|
||||
show_notification(content, hold)
|
||||
end)
|
||||
|
||||
notification:subscribe("hide_message", hide_notification)
|
158
darwin/sketchybar/config/items/spaces.lua
Normal file
158
darwin/sketchybar/config/items/spaces.lua
Normal file
@ -0,0 +1,158 @@
|
||||
local colors = require("colors").sections.spaces
|
||||
local icons = require("icons")
|
||||
local icon_map = require("helpers.icon_map")
|
||||
|
||||
local function add_windows(space, space_name)
|
||||
sbar.exec("aerospace list-windows --format %{app-name} --workspace " .. space_name, function(windows)
|
||||
local icon_line = ""
|
||||
for app in windows:gmatch "[^\r\n]+" do
|
||||
local lookup = icon_map[app]
|
||||
local icon = ((lookup == nil) and icon_map["Default"] or lookup)
|
||||
icon_line = icon_line .. " " .. icon
|
||||
end
|
||||
|
||||
sbar.animate("tanh", 10, function()
|
||||
space:set {
|
||||
label = {
|
||||
string = icon_line == "" and "—" or icon_line,
|
||||
padding_right = icon_line == "" and 8 or 12,
|
||||
},
|
||||
}
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
sbar.exec("aerospace list-workspaces --all", function(spaces)
|
||||
for space_name in spaces:gmatch "[^\r\n]+" do
|
||||
local space = sbar.add("item", "space." .. space_name, {
|
||||
icon = {
|
||||
string = space_name,
|
||||
color = colors.icon.color,
|
||||
highlight_color = colors.icon.highlight,
|
||||
padding_left = 8,
|
||||
},
|
||||
label = {
|
||||
font = "sketchybar-app-font:Regular:14.0",
|
||||
string = "",
|
||||
color = colors.label.color,
|
||||
highlight_color = colors.label.highlight,
|
||||
y_offset = -1,
|
||||
},
|
||||
click_script = "aerospace workspace " .. space_name,
|
||||
padding_left = space_name == "1" and 0 or 4,
|
||||
})
|
||||
|
||||
add_windows(space, space_name)
|
||||
|
||||
space:subscribe("aerospace_workspace_change", function(env)
|
||||
local selected = env.FOCUSED_WORKSPACE == space_name
|
||||
space:set {
|
||||
icon = { highlight = selected },
|
||||
label = { highlight = selected },
|
||||
}
|
||||
|
||||
if selected then
|
||||
sbar.animate("tanh", 8, function()
|
||||
space:set {
|
||||
background = {
|
||||
shadow = {
|
||||
distance = 0,
|
||||
},
|
||||
},
|
||||
y_offset = -4,
|
||||
padding_left = 8,
|
||||
padding_right = 0,
|
||||
}
|
||||
space:set {
|
||||
background = {
|
||||
shadow = {
|
||||
distance = 4,
|
||||
},
|
||||
},
|
||||
y_offset = 0,
|
||||
padding_left = 4,
|
||||
padding_right = 4,
|
||||
}
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
space:subscribe("space_windows_change", function()
|
||||
add_windows(space, space_name)
|
||||
end)
|
||||
|
||||
space:subscribe("mouse.clicked", function()
|
||||
sbar.animate("tanh", 8, function()
|
||||
space:set {
|
||||
background = {
|
||||
shadow = {
|
||||
distance = 0,
|
||||
},
|
||||
},
|
||||
y_offset = -4,
|
||||
padding_left = 8,
|
||||
padding_right = 0,
|
||||
}
|
||||
space:set {
|
||||
background = {
|
||||
shadow = {
|
||||
distance = 4,
|
||||
},
|
||||
},
|
||||
y_offset = 0,
|
||||
padding_left = 4,
|
||||
padding_right = 4,
|
||||
}
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
local spaces_indicator = sbar.add("item", {
|
||||
icon = {
|
||||
padding_left = 8,
|
||||
padding_right = 9,
|
||||
string = icons.switch.on,
|
||||
color = colors.indicator,
|
||||
},
|
||||
label = {
|
||||
width = 0,
|
||||
padding_left = 0,
|
||||
padding_right = 8,
|
||||
},
|
||||
padding_right = 8,
|
||||
})
|
||||
|
||||
spaces_indicator:subscribe("swap_menus_and_spaces", function()
|
||||
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)
|
||||
|
||||
spaces_indicator:subscribe("mouse.clicked", function()
|
||||
sbar.animate("tanh", 8, function()
|
||||
spaces_indicator:set {
|
||||
background = {
|
||||
shadow = {
|
||||
distance = 0,
|
||||
},
|
||||
},
|
||||
y_offset = -4,
|
||||
padding_left = 8,
|
||||
padding_right = 4,
|
||||
}
|
||||
spaces_indicator:set {
|
||||
background = {
|
||||
shadow = {
|
||||
distance = 4,
|
||||
},
|
||||
},
|
||||
y_offset = 0,
|
||||
padding_left = 4,
|
||||
padding_right = 8,
|
||||
}
|
||||
end)
|
||||
|
||||
sbar.trigger("swap_menus_and_spaces")
|
||||
end)
|
83
darwin/sketchybar/config/items/widgets/battery.lua
Normal file
83
darwin/sketchybar/config/items/widgets/battery.lua
Normal file
@ -0,0 +1,83 @@
|
||||
local icons = require "icons"
|
||||
local colors = require("colors").sections.widgets.battery
|
||||
|
||||
local battery = sbar.add("item", "widgets.battery", {
|
||||
position = "right",
|
||||
icon = {},
|
||||
label = { drawing = false },
|
||||
background = { drawing = false },
|
||||
padding_left = 8,
|
||||
padding_right = 4,
|
||||
update_freq = 180,
|
||||
popup = { align = "center", y_offset = 4 },
|
||||
})
|
||||
|
||||
local remaining_time = sbar.add("item", {
|
||||
position = "popup." .. battery.name,
|
||||
icon = {
|
||||
string = "Time remaining:",
|
||||
width = 100,
|
||||
align = "left",
|
||||
},
|
||||
label = {
|
||||
string = "??:??h",
|
||||
width = 100,
|
||||
align = "right",
|
||||
},
|
||||
background = { drawing = false },
|
||||
})
|
||||
|
||||
battery:subscribe({ "routine", "power_source_change", "system_woke" }, function()
|
||||
sbar.exec("pmset -g batt", function(batt_info)
|
||||
local icon = "!"
|
||||
|
||||
local found, _, charge = batt_info:find "(%d+)%%"
|
||||
if found then
|
||||
charge = tonumber(charge)
|
||||
end
|
||||
|
||||
local color = colors.high
|
||||
local charging, _, _ = batt_info:find "AC Power"
|
||||
|
||||
if charging then
|
||||
icon = icons.battery.charging
|
||||
else
|
||||
if found and charge > 80 then
|
||||
icon = icons.battery._100
|
||||
elseif found and charge > 60 then
|
||||
icon = icons.battery._75
|
||||
elseif found and charge > 40 then
|
||||
icon = icons.battery._50
|
||||
elseif found and charge > 30 then
|
||||
icon = icons.battery._50
|
||||
color = colors.mid
|
||||
elseif found and charge > 20 then
|
||||
icon = icons.battery._25
|
||||
color = colors.mid
|
||||
else
|
||||
icon = icons.battery._0
|
||||
color = colors.low
|
||||
end
|
||||
end
|
||||
|
||||
battery:set {
|
||||
icon = {
|
||||
string = icon,
|
||||
color = color,
|
||||
},
|
||||
}
|
||||
end)
|
||||
end)
|
||||
|
||||
battery:subscribe("mouse.clicked", function()
|
||||
local drawing = battery:query().popup.drawing
|
||||
battery:set { popup = { drawing = "toggle" } }
|
||||
|
||||
if drawing == "off" then
|
||||
sbar.exec("pmset -g batt", function(batt_info)
|
||||
local found, _, remaining = batt_info:find " (%d+:%d+) remaining"
|
||||
local label = found and remaining .. "h" or "No estimate"
|
||||
remaining_time:set { label = label }
|
||||
end)
|
||||
end
|
||||
end)
|
9
darwin/sketchybar/config/items/widgets/init.lua
Normal file
9
darwin/sketchybar/config/items/widgets/init.lua
Normal file
@ -0,0 +1,9 @@
|
||||
-- require "items.widgets.messages"
|
||||
require("items.widgets.volume")
|
||||
require("items.widgets.battery")
|
||||
|
||||
sbar.add("bracket", { "/widgets\\..*/" }, {})
|
||||
|
||||
sbar.add("item", "widget.padding", {
|
||||
width = 16,
|
||||
})
|
41
darwin/sketchybar/config/items/widgets/messages.lua
Normal file
41
darwin/sketchybar/config/items/widgets/messages.lua
Normal file
@ -0,0 +1,41 @@
|
||||
local icons = require "icons"
|
||||
local colors = require("colors").sections.widgets.messages
|
||||
|
||||
local messages = sbar.add("item", "widgets.messages", {
|
||||
position = "right",
|
||||
icon = {
|
||||
color = colors.icon,
|
||||
string = icons.message,
|
||||
padding_right = 4,
|
||||
},
|
||||
label = { drawing = false },
|
||||
background = { drawing = false },
|
||||
update_freq = 30,
|
||||
padding_left = -4,
|
||||
})
|
||||
|
||||
messages:subscribe({ "routine", "front_app_changed", "space_change", "space_windows_change" }, function(env)
|
||||
sbar.exec(
|
||||
-- requires full disk access
|
||||
[[sqlite3 ~/Library/Messages/chat.db "SELECT COUNT(guid) FROM message WHERE NOT(is_read) AND NOT(is_from_me) AND text !=''"]],
|
||||
function(newmess)
|
||||
local mess = tonumber(newmess)
|
||||
local drawing = false
|
||||
|
||||
if mess > 0 then
|
||||
drawing = true
|
||||
end
|
||||
|
||||
messages:set {
|
||||
icon = {
|
||||
drawing = drawing,
|
||||
},
|
||||
padding_right = drawing and 4 or 0,
|
||||
}
|
||||
end
|
||||
)
|
||||
end)
|
||||
|
||||
messages:subscribe("mouse.clicked", function(env)
|
||||
sbar.exec "open -a 'Messages'"
|
||||
end)
|
142
darwin/sketchybar/config/items/widgets/volume.lua
Normal file
142
darwin/sketchybar/config/items/widgets/volume.lua
Normal file
@ -0,0 +1,142 @@
|
||||
local colors = require("colors").sections.widgets.volume
|
||||
local icons = require "icons"
|
||||
|
||||
local popup_width = 250
|
||||
|
||||
local volume_icon = sbar.add("item", "widgets.volume", {
|
||||
position = "right",
|
||||
icon = {
|
||||
color = colors.icon,
|
||||
},
|
||||
label = { drawing = false },
|
||||
background = { drawing = false },
|
||||
popup = {
|
||||
align = "center",
|
||||
y_offset = 2,
|
||||
},
|
||||
padding_right = 8,
|
||||
})
|
||||
|
||||
local volume_slider = sbar.add("slider", popup_width, {
|
||||
position = "popup." .. volume_icon.name,
|
||||
slider = {
|
||||
highlight_color = colors.slider.highlight,
|
||||
background = {
|
||||
height = 12,
|
||||
corner_radius = 6,
|
||||
color = colors.slider.bg,
|
||||
border_color = colors.slider.border,
|
||||
border_width = 2,
|
||||
},
|
||||
knob = {
|
||||
string = "",
|
||||
drawing = true,
|
||||
},
|
||||
},
|
||||
background = { color = colors.bg1, height = 2, y_offset = -20 },
|
||||
click_script = 'osascript -e "set volume output volume $PERCENTAGE"',
|
||||
})
|
||||
|
||||
volume_icon:subscribe("volume_change", function(env)
|
||||
local icon = icons.volume._0
|
||||
local volume = tonumber(env.INFO)
|
||||
sbar.exec("SwitchAudioSource -t output -c", function(result)
|
||||
if volume > 60 then
|
||||
icon = icons.volume._100
|
||||
elseif volume > 30 then
|
||||
icon = icons.volume._66
|
||||
elseif volume > 10 then
|
||||
icon = icons.volume._33
|
||||
elseif volume > 0 then
|
||||
icon = icons.volume._10
|
||||
end
|
||||
|
||||
volume_icon:set { icon = icon }
|
||||
volume_slider:set { slider = { percentage = volume } }
|
||||
end)
|
||||
end)
|
||||
|
||||
local function volume_collapse_details()
|
||||
local drawing = volume_icon:query().popup.drawing == "on"
|
||||
if not drawing then
|
||||
return
|
||||
end
|
||||
volume_icon:set { popup = { drawing = false } }
|
||||
sbar.remove "/volume.device\\.*/"
|
||||
end
|
||||
|
||||
local current_audio_device = "None"
|
||||
local function volume_toggle_details(env)
|
||||
if env.BUTTON == "right" then
|
||||
sbar.exec "open /System/Library/PreferencePanes/Sound.prefpane"
|
||||
return
|
||||
end
|
||||
|
||||
local should_draw = volume_icon:query().popup.drawing == "off"
|
||||
if should_draw then
|
||||
volume_icon:set { popup = { drawing = true } }
|
||||
sbar.exec("SwitchAudioSource -t output -c", function(result)
|
||||
current_audio_device = result:sub(1, -2)
|
||||
sbar.exec("SwitchAudioSource -a -t output", function(available)
|
||||
local current = current_audio_device
|
||||
local color = colors.popup.item
|
||||
local counter = 0
|
||||
|
||||
for device in string.gmatch(available, "[^\r\n]+") do
|
||||
if current == device then
|
||||
color = colors.popup.highlight
|
||||
end
|
||||
sbar.add("item", "volume.device." .. counter, {
|
||||
position = "popup." .. volume_icon.name,
|
||||
width = popup_width,
|
||||
align = "center",
|
||||
label = { string = device, color = color },
|
||||
background = { drawing = false },
|
||||
click_script = 'SwitchAudioSource -s "'
|
||||
.. device
|
||||
.. '" && sketchybar --set /volume.device\\.*/ label.color='
|
||||
.. colors.popup.item
|
||||
.. " --set $NAME label.color="
|
||||
.. colors.popup.highlight,
|
||||
})
|
||||
counter = counter + 1
|
||||
end
|
||||
end)
|
||||
end)
|
||||
else
|
||||
volume_collapse_details()
|
||||
end
|
||||
end
|
||||
|
||||
local function volume_scroll(env)
|
||||
local delta = env.SCROLL_DELTA
|
||||
sbar.exec('osascript -e "set volume output volume (output volume of (get volume settings) + ' .. delta .. ')"')
|
||||
end
|
||||
|
||||
volume_icon:subscribe("mouse.clicked", function(env)
|
||||
volume_toggle_details(env)
|
||||
-- sbar.animate("tanh", 8, function()
|
||||
-- volume_icon:set({
|
||||
-- background = {
|
||||
-- shadow = {
|
||||
-- distance = 0,
|
||||
-- },
|
||||
-- },
|
||||
-- y_offset = -4,
|
||||
-- padding_left = 8,
|
||||
-- padding_right = 0,
|
||||
-- })
|
||||
-- volume_icon:set({
|
||||
-- background = {
|
||||
-- shadow = {
|
||||
-- distance = 4,
|
||||
-- },
|
||||
-- },
|
||||
-- y_offset = 0,
|
||||
-- padding_left = 4,
|
||||
-- padding_right = 4,
|
||||
-- })
|
||||
-- end)
|
||||
end)
|
||||
|
||||
volume_icon:subscribe("mouse.scrolled", volume_scroll)
|
142
darwin/sketchybar/config/items/wifi.lua
Normal file
142
darwin/sketchybar/config/items/wifi.lua
Normal file
@ -0,0 +1,142 @@
|
||||
local icons = require "icons"
|
||||
local colors = require("colors").sections.widgets.wifi
|
||||
|
||||
sbar.exec(
|
||||
"killall network_load >/dev/null; $CONFIG_DIR/helpers/event_providers/network_load/bin/network_load en0 network_update 2.0"
|
||||
)
|
||||
|
||||
local popup_width = 250
|
||||
|
||||
local wifi = sbar.add("item", "widgets.wifi", {
|
||||
position = "right",
|
||||
padding_right = 8,
|
||||
padding_left = 0,
|
||||
icon = {
|
||||
color = colors.icon,
|
||||
padding_left = 8
|
||||
},
|
||||
label = {
|
||||
padding_right = 8,
|
||||
},
|
||||
popup = {
|
||||
align = "center",
|
||||
height = 30,
|
||||
y_offset = 2,
|
||||
},
|
||||
})
|
||||
|
||||
local ip = sbar.add("item", {
|
||||
position = "popup." .. wifi.name,
|
||||
icon = {
|
||||
align = "left",
|
||||
string = "IP:",
|
||||
width = popup_width / 2,
|
||||
},
|
||||
label = {
|
||||
string = "???.???.???.???",
|
||||
width = popup_width / 2,
|
||||
align = "right",
|
||||
},
|
||||
background = { drawing = false },
|
||||
})
|
||||
|
||||
local router = sbar.add("item", {
|
||||
position = "popup." .. wifi.name,
|
||||
icon = {
|
||||
align = "left",
|
||||
string = "Router:",
|
||||
width = popup_width / 2,
|
||||
},
|
||||
label = {
|
||||
string = "???.???.???.???",
|
||||
width = popup_width / 2,
|
||||
align = "right",
|
||||
},
|
||||
background = { drawing = false },
|
||||
})
|
||||
|
||||
wifi:subscribe({ "wifi_change", "system_woke", "forced" }, function()
|
||||
sbar.exec([[ipconfig getsummary en0 | awk -F ' SSID : ' '/ SSID : / {print $2}']], function(wifi_name)
|
||||
local is_connected = not (wifi_name == "")
|
||||
wifi:set {
|
||||
icon = {
|
||||
string = is_connected and icons.wifi.connected or icons.wifi.disconnected,
|
||||
},
|
||||
label = {
|
||||
string = is_connected and wifi_name or "",
|
||||
}
|
||||
}
|
||||
|
||||
sbar.exec([[sleep 2; scutil --nwi | grep -m1 'utun' | awk '{ print $1 }']], function(vpn)
|
||||
local is_vpn_connected = not (vpn == "")
|
||||
|
||||
if is_vpn_connected then
|
||||
wifi:set {
|
||||
icon = {
|
||||
string = icons.wifi.vpn,
|
||||
color = colors.green,
|
||||
},
|
||||
}
|
||||
end
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
||||
local function hide_details()
|
||||
wifi:set { popup = { drawing = false } }
|
||||
end
|
||||
|
||||
local function toggle_details()
|
||||
local should_draw = wifi:query().popup.drawing == "off"
|
||||
if should_draw then
|
||||
wifi:set { popup = { drawing = true } }
|
||||
sbar.exec("ipconfig getifaddr en0", function(result)
|
||||
ip:set { label = result }
|
||||
end)
|
||||
sbar.exec("networksetup -getinfo Wi-Fi | awk -F 'Router: ' '/^Router: / {print $2}'", function(result)
|
||||
router:set { label = result }
|
||||
end)
|
||||
else
|
||||
hide_details()
|
||||
end
|
||||
end
|
||||
|
||||
wifi:subscribe("mouse.clicked", function()
|
||||
sbar.animate("tanh", 8, function()
|
||||
wifi:set({
|
||||
background = {
|
||||
shadow = {
|
||||
distance = 0,
|
||||
},
|
||||
},
|
||||
y_offset = -4,
|
||||
padding_left = 4,
|
||||
padding_right = 4,
|
||||
})
|
||||
wifi:set({
|
||||
background = {
|
||||
shadow = {
|
||||
distance = 4,
|
||||
},
|
||||
},
|
||||
y_offset = 0,
|
||||
padding_left = 0,
|
||||
padding_right = 8,
|
||||
})
|
||||
end)
|
||||
toggle_details()
|
||||
end)
|
||||
|
||||
-- wifi:subscribe("mouse.exited.global", hide_details)
|
||||
|
||||
local function copy_label_to_clipboard(env)
|
||||
local label = sbar.query(env.NAME).label.value
|
||||
sbar.exec('echo "' .. label .. '" | pbcopy')
|
||||
sbar.set(env.NAME, { label = { string = icons.clipboard, align = "center" } })
|
||||
sbar.delay(1, function()
|
||||
sbar.set(env.NAME, { label = { string = label, align = "right" } })
|
||||
end)
|
||||
end
|
||||
|
||||
ip:subscribe("mouse.clicked", copy_label_to_clipboard)
|
||||
router:subscribe("mouse.clicked", copy_label_to_clipboard)
|
6
darwin/sketchybar/config/settings.lua
Normal file
6
darwin/sketchybar/config/settings.lua
Normal file
@ -0,0 +1,6 @@
|
||||
return {
|
||||
paddings = 2,
|
||||
group_paddings = 5,
|
||||
icons = "sf-symbols", -- alternatively available: NerdFont
|
||||
font = require "helpers.default_font",
|
||||
}
|
6
darwin/sketchybar/config/stylua.toml
Normal file
6
darwin/sketchybar/config/stylua.toml
Normal file
@ -0,0 +1,6 @@
|
||||
column_width = 120
|
||||
line_endings = "Unix"
|
||||
indent_type = "Spaces"
|
||||
indent_width = 2
|
||||
quote_style = "AutoPreferDouble"
|
||||
call_parentheses = "None"
|
22
darwin/sketchybar/default.nix
Normal file
22
darwin/sketchybar/default.nix
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkIf;
|
||||
cfg = config.my.sketchybar;
|
||||
in {
|
||||
options.my.sketchybar = {
|
||||
enable = mkEnableOption "sketchybar";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
services.sketchybar.enable = true;
|
||||
hm.my.sketchybar.enable = true;
|
||||
|
||||
fonts.packages = with pkgs; [
|
||||
sketchybar-app-font
|
||||
];
|
||||
};
|
||||
}
|
39
darwin/sketchybar/home.nix
Normal file
39
darwin/sketchybar/home.nix
Normal file
@ -0,0 +1,39 @@
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) mkEnableOption mkIf;
|
||||
cfg = config.my.sketchybar;
|
||||
luaBasePackage = pkgs.lua5_4;
|
||||
luaPackage = luaBasePackage.withPackages (ps:
|
||||
with ps; [
|
||||
(pkgs.sbarlua.override {lua = luaBasePackage;})
|
||||
luafilesystem
|
||||
]);
|
||||
in {
|
||||
options.my.sketchybar = {
|
||||
enable = mkEnableOption "sketchybar";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.file.".config/sketchybar/lua".source =
|
||||
config.lib.file.mkOutOfStoreSymlink
|
||||
"${config.home.homeDirectory}/Projects/nix-dots/darwin/sketchybar/config";
|
||||
|
||||
home.file.".config/sketchybar/sketchybarrc" = {
|
||||
text = ''
|
||||
#!${luaPackage}/bin/lua
|
||||
|
||||
local lfs = require("lfs")
|
||||
lfs.chdir("lua")
|
||||
|
||||
-- Load the sketchybar-package and prepare the helper binaries
|
||||
require("helpers")
|
||||
require("init")
|
||||
'';
|
||||
executable = true;
|
||||
};
|
||||
};
|
||||
}
|
@ -36,7 +36,6 @@ in {
|
||||
hm = import ../user/environments/mac/home.nix;
|
||||
}
|
||||
|
||||
../modules/yabai.nix
|
||||
../machines/mac/configuration.nix
|
||||
];
|
||||
};
|
||||
|
@ -37,6 +37,11 @@
|
||||
];
|
||||
};
|
||||
|
||||
my = {
|
||||
aerospace.enable = true;
|
||||
sketchybar.enable = true;
|
||||
};
|
||||
|
||||
programs = {
|
||||
zsh = {
|
||||
enable = true;
|
||||
|
@ -1,82 +0,0 @@
|
||||
{...}: {
|
||||
services.yabai = {
|
||||
enable = true;
|
||||
config = {
|
||||
mouse_follows_focus = "off";
|
||||
focus_follows_mouse = "off";
|
||||
window_origin_display = "default";
|
||||
window_placement = "second_child";
|
||||
window_zoom_persist = "on";
|
||||
window_shadow = "on";
|
||||
window_animation_duration = 0;
|
||||
window_animation_frame_rate = 120;
|
||||
window_opacity_duration = 0;
|
||||
active_window_opacity = 1;
|
||||
normal_window_opacity = 0;
|
||||
window_opacity = "off";
|
||||
insert_feedback_color = "0xffd75f5f";
|
||||
split_ratio = 0;
|
||||
split_type = "auto";
|
||||
auto_balance = "off";
|
||||
top_padding = 0;
|
||||
bottom_padding = 0;
|
||||
left_padding = 0;
|
||||
right_padding = 0;
|
||||
window_gap = 6;
|
||||
layout = "bsp";
|
||||
mouse_modifier = "fn";
|
||||
mouse_action1 = "move";
|
||||
mouse_action2 = "resize";
|
||||
mouse_drop_action = "swap";
|
||||
};
|
||||
};
|
||||
|
||||
services.skhd = {
|
||||
enable = true;
|
||||
skhdConfig = ''
|
||||
ctrl + alt - h: yabai -m window --focus west
|
||||
ctrl + alt - j: yabai -m window --focus south
|
||||
ctrl + alt - k: yabai -m window --focus north
|
||||
ctrl + alt - l: yabai -m window --focus east
|
||||
|
||||
cmd + ctrl + alt - h : yabai -m window --warp west
|
||||
cmd + ctrl + alt - j : yabai -m window --warp south
|
||||
cmd + ctrl + alt - k : yabai -m window --warp north
|
||||
cmd + ctrl + alt - l : yabai -m window --warp east
|
||||
|
||||
ctrl + alt - 1 : yabai -m space --focus 1
|
||||
ctrl + alt - 2 : yabai -m space --focus 2
|
||||
ctrl + alt - 3 : yabai -m space --focus 3
|
||||
ctrl + alt - 4 : yabai -m space --focus 4
|
||||
ctrl + alt - 5 : yabai -m space --focus 5
|
||||
ctrl + alt - 6 : yabai -m space --focus 6
|
||||
ctrl + alt - 7 : yabai -m space --focus 7
|
||||
ctrl + alt - 8 : yabai -m space --focus 8
|
||||
ctrl + alt - 9 : yabai -m space --focus 9
|
||||
|
||||
ctrl + alt - q: yabai -m window --close
|
||||
|
||||
## stack window
|
||||
# Note that this only works when the active window does *not* already belong to a stack
|
||||
shift + alt + cmd - left : yabai -m window west --stack $(yabai -m query --windows --window | jq -r '.id')
|
||||
shift + alt + cmd - right : yabai -m window east --stack $(yabai -m query --windows --window | jq -r '.id')
|
||||
|
||||
# 0x21 - [
|
||||
# 0x1E - ]
|
||||
ctrl + alt - 0x21 : yabai -m query --spaces --space \
|
||||
| jq -re ".index" \
|
||||
| xargs -I{} yabai -m query --windows --space {} \
|
||||
| jq -sre "add | map(select(.minimized != 1)) | sort_by(.display, .frame.y, .frame.y, .id) | nth(index(map(select(.focused == 1))) - 1).id" \
|
||||
| xargs -I{} yabai -m window --focus {}
|
||||
|
||||
ctrl + alt - 0x1E : yabai -m query --spaces --space \
|
||||
| jq -re ".index" \
|
||||
| xargs -I{} yabai -m query --windows --space {} \
|
||||
| jq -sre "add | map(select(.minimized != 1)) | sort_by(.display, .frame.y, .frame.x, .id) | reverse | nth(index(map(select(.focused == 1))) - 1).id" \
|
||||
| xargs -I{} yabai -m window --focus {}
|
||||
|
||||
# applications
|
||||
ctrl + alt - t: open -n -a 'Alacritty.app'
|
||||
'';
|
||||
};
|
||||
}
|
@ -2,4 +2,5 @@
|
||||
homer = pkgs.callPackage ./homer {};
|
||||
keycloak-theme-keywind = pkgs.callPackage ./keywind {};
|
||||
nvim-custom = import ./nvim/default.nix args;
|
||||
sbarlua = pkgs.callPackage ./sbarlua {};
|
||||
}
|
||||
|
@ -59,7 +59,7 @@
|
||||
# ./utils/hardtime.nix # hints to get better at vim
|
||||
# ./utils/harpoon.nix # better navigation between files & terminals
|
||||
./utils/illuminate.nix # highlight other uses of current word
|
||||
./utils/markdown-preview.nix
|
||||
# ./utils/markdown-preview.nix
|
||||
./utils/mini.nix # lots of utilities
|
||||
./utils/neoconf.nix
|
||||
# ./utils/neodev.nix # lua development
|
||||
|
@ -8,7 +8,7 @@
|
||||
icons = import ./config/icons.nix;
|
||||
pkgsMaster = inputs.master.legacyPackages.${system};
|
||||
nixvimModule = {
|
||||
pkgs = inputs.unstable.legacyPackages.${system};
|
||||
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
||||
module = import ./config;
|
||||
extraSpecialArgs = {inherit icons pkgsMaster;};
|
||||
};
|
||||
|
30
pkgs/sbarlua/default.nix
Normal file
30
pkgs/sbarlua/default.nix
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
clang,
|
||||
fetchFromGitHub,
|
||||
gcc,
|
||||
readline,
|
||||
lua,
|
||||
}:
|
||||
lua.pkgs.buildLuaPackage {
|
||||
pname = "SBarLua";
|
||||
version = "0-unstable-2024-08-12";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "FelixKratz";
|
||||
repo = "SbarLua";
|
||||
rev = "437bd2031da38ccda75827cb7548e7baa4aa9978";
|
||||
hash = "sha256-F0UfNxHM389GhiPQ6/GFbeKQq5EvpiqQdvyf7ygzkPg=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
clang
|
||||
gcc
|
||||
];
|
||||
|
||||
buildInputs = [readline];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/lib/lua/${lua.luaversion}/
|
||||
cp -r bin/* "$out/lib/lua/${lua.luaversion}/"
|
||||
'';
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
{
|
||||
pkgs,
|
||||
config,
|
||||
...
|
||||
}: {
|
||||
programs.neovim = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
programs.lazygit = {
|
||||
enable = true;
|
||||
};
|
||||
|
||||
# Copy Neovim config
|
||||
xdg.configFile.nvim.source =
|
||||
config.lib.file.mkOutOfStoreSymlink
|
||||
"${config.home.homeDirectory}/Projects/nix-dots/user/modules/nvim";
|
||||
|
||||
home.packages = with pkgs; [
|
||||
ripgrep
|
||||
gnumake
|
||||
gcc
|
||||
eslint_d
|
||||
prettierd
|
||||
];
|
||||
}
|
8
user/modules/nvim/.gitignore
vendored
8
user/modules/nvim/.gitignore
vendored
@ -1,8 +0,0 @@
|
||||
tt.*
|
||||
.tests
|
||||
doc/tags
|
||||
debug
|
||||
.repro
|
||||
foo.*
|
||||
*.log
|
||||
data
|
@ -1,15 +0,0 @@
|
||||
{
|
||||
"neodev": {
|
||||
"library": {
|
||||
"enabled": true,
|
||||
"plugins": true
|
||||
}
|
||||
},
|
||||
"neoconf": {
|
||||
"plugins": {
|
||||
"lua_ls": {
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,201 +0,0 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
@ -1,4 +0,0 @@
|
||||
# 💤 LazyVim
|
||||
|
||||
A starter template for [LazyVim](https://github.com/LazyVim/LazyVim).
|
||||
Refer to the [documentation](https://lazyvim.github.io/installation) to get started.
|
@ -1,2 +0,0 @@
|
||||
-- bootstrap lazy.nvim, LazyVim and your plugins
|
||||
require("config.lazy")
|
@ -1,60 +0,0 @@
|
||||
{
|
||||
"LazyVim": { "branch": "main", "commit": "53f4595b4e7ee980e9446a9248862a40701959c1" },
|
||||
"LuaSnip": { "branch": "master", "commit": "ba3ea5bcfd969679f38fefb1bc801cd45524045b" },
|
||||
"bufferline.nvim": { "branch": "main", "commit": "81820cac7c85e51e4cf179f8a66d13dbf7b032d9" },
|
||||
"catppuccin": { "branch": "main", "commit": "894efb557728e532aa98b98029d16907a214ec05" },
|
||||
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
|
||||
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
|
||||
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
|
||||
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
|
||||
"conform.nvim": { "branch": "master", "commit": "c26dadf8a47a547768d1048a0d698ecec33494ce" },
|
||||
"crates.nvim": { "branch": "main", "commit": "df9937e1d2352704b0b58087d41da199261f7fc3" },
|
||||
"dashboard-nvim": { "branch": "master", "commit": "69a4c935cc43d3d725ed0600c6d00593bc23d132" },
|
||||
"dressing.nvim": { "branch": "master", "commit": "6741f1062d3dc6e4755367a7e9b347b553623f04" },
|
||||
"flash.nvim": { "branch": "main", "commit": "43f67935d388fbb540f8b40e8cbfd80de54f978a" },
|
||||
"friendly-snippets": { "branch": "main", "commit": "682157939e57bd6a2c86277dfd4d6fbfce63dbac" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "fa42613096ebfa5fee1ea87d70f8625ab9685d01" },
|
||||
"gruvbox.nvim": { "branch": "main", "commit": "d4cde3853a172485961b515c36d51d757728d6e6" },
|
||||
"indent-blankline.nvim": { "branch": "master", "commit": "4288ce8128a52650e401dda42fd7651a6038f262" },
|
||||
"kdl.vim": { "branch": "main", "commit": "b84d7d3a15d8d30da016cf9e98e2cfbe35cddee5" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "20af3fcc4ef2fef0cb4021543c70410567fcf9aa" },
|
||||
"lazydev.nvim": { "branch": "main", "commit": "78d8a11fbd02ad4eafa07dd8a43a959a69fb3bf8" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
|
||||
"luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "37a336b653f8594df75c827ed589f1c91d91ff6c" },
|
||||
"mason-nvim-dap.nvim": { "branch": "main", "commit": "f5425eb1d0d794f0305d5eeebddabb74614683ff" },
|
||||
"mason.nvim": { "branch": "main", "commit": "0950b15060067f752fde13a779a994f59516ce3d" },
|
||||
"mini.ai": { "branch": "main", "commit": "ebf806de0292ef89b2756cfb0b55040901d1c441" },
|
||||
"mini.comment": { "branch": "main", "commit": "b8bd7ea58912bd6fa6cf984f2f702a771ce24c1f" },
|
||||
"mini.pairs": { "branch": "main", "commit": "18a2d9d7106d08d3560d07c03dcbf5680c8675cc" },
|
||||
"neo-tree.nvim": { "branch": "v3.x", "commit": "29f7c215332ba95e470811c380ddbce2cebe2af4" },
|
||||
"neodev.nvim": { "branch": "main", "commit": "02893eeb9d6e8503817bd52385e111cba9a90500" },
|
||||
"no-neck-pain.nvim": { "branch": "main", "commit": "741ad26c4acc45f2164a3933f7825b0e555b724d" },
|
||||
"noice.nvim": { "branch": "main", "commit": "cade1f972ba226e7753a7a113f3f1a942908e73c" },
|
||||
"nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" },
|
||||
"nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" },
|
||||
"nvim-dap": { "branch": "master", "commit": "6f79b822997f2e8a789c6034e147d42bc6706770" },
|
||||
"nvim-dap-ui": { "branch": "master", "commit": "b7267003ba4dd860350be86f75b9d9ea287cedca" },
|
||||
"nvim-dap-virtual-text": { "branch": "master", "commit": "d7c695ea39542f6da94ee4d66176f5d660ab0a77" },
|
||||
"nvim-lint": { "branch": "master", "commit": "efc6fc83f0772283e064c53a8f9fb5645bde0bc0" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "9c9eb07fecc578e25e28db8dc9002b43fff2ed79" },
|
||||
"nvim-nio": { "branch": "master", "commit": "7969e0a8ffabdf210edd7978ec954a47a737bbcc" },
|
||||
"nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" },
|
||||
"nvim-spectre": { "branch": "master", "commit": "49fae98ef2bfa8342522b337892992e3495065d5" },
|
||||
"nvim-treesitter": { "branch": "master", "commit": "53b32a6aa3e1de224e82f88cbdc08584c753adb7" },
|
||||
"nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" },
|
||||
"nvim-ts-autotag": { "branch": "main", "commit": "ddfccbf0df1b9349c2b9e9b17f4afa8f9b6c1ed1" },
|
||||
"nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" },
|
||||
"nvim-web-devicons": { "branch": "master", "commit": "c0cfc1738361b5da1cd0a962dd6f774cc444f856" },
|
||||
"persistence.nvim": { "branch": "main", "commit": "95d03ad5450389ad7dc2a0fab14ebb3d46bc2c96" },
|
||||
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
|
||||
"rustaceanvim": { "branch": "master", "commit": "d6d7620b66d74b3b16defcf85cbef7b3582795b3" },
|
||||
"telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" },
|
||||
"telescope.nvim": { "branch": "master", "commit": "61a4a615366c470a4e9ca8f8b45718b6b92af73f" },
|
||||
"todo-comments.nvim": { "branch": "main", "commit": "51e10f838e84b4756c16311d0b1ef0972c6482d2" },
|
||||
"tokyonight.nvim": { "branch": "main", "commit": "30d7be361a7fbf187a881f17e574e9213d5108ea" },
|
||||
"tree-sitter-asm": { "branch": "main", "commit": "b0306e9bb2ebe01c6562f1aef265cc42ccc53070" },
|
||||
"trouble.nvim": { "branch": "main", "commit": "88c3be40c061ce053ab326ce4fdcb973a1f785ff" },
|
||||
"vim-freemarker": { "branch": "master", "commit": "993bda23e72e4c074659970c1e777cb19d8cf93e" },
|
||||
"which-key.nvim": { "branch": "main", "commit": "0099511294f16b81c696004fa6a403b0ae61f7a0" }
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
{
|
||||
"extras": [
|
||||
"lazyvim.plugins.extras.dap.core",
|
||||
"lazyvim.plugins.extras.lsp.neoconf"
|
||||
],
|
||||
"news": {
|
||||
"NEWS.md": "6077"
|
||||
},
|
||||
"version": 6
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
-- Autocmds are automatically loaded on the VeryLazy event
|
||||
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
|
||||
-- Add any additional autocmds here
|
@ -1,8 +0,0 @@
|
||||
-- Keymaps are automatically loaded on the VeryLazy event
|
||||
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
|
||||
-- Add any additional keymaps here
|
||||
|
||||
local keymap = vim.keymap
|
||||
|
||||
-- Select all
|
||||
keymap.set("n", "<C-a>", "gg<S-v>G$")
|
@ -1,47 +0,0 @@
|
||||
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
-- bootstrap lazy.nvim
|
||||
-- stylua: ignore
|
||||
vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", "--branch=stable", lazypath })
|
||||
end
|
||||
vim.opt.rtp:prepend(vim.env.LAZY or lazypath)
|
||||
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
-- add LazyVim and import its plugins
|
||||
{ "LazyVim/LazyVim", import = "lazyvim.plugins", opts = { colorscheme = "gruvbox" } },
|
||||
-- import any extras modules here
|
||||
{ import = "lazyvim.plugins.extras.lang.typescript" },
|
||||
-- { import = "lazyvim.plugins.extras.lang.rust" },
|
||||
-- { import = "lazyvim.plugins.extras.lang.json" },
|
||||
-- { import = "lazyvim.plugins.extras.ui.mini-animate" },
|
||||
-- import/override with your plugins
|
||||
{ import = "plugins" },
|
||||
},
|
||||
defaults = {
|
||||
-- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup.
|
||||
-- If you know what you're doing, you can set this to `true` to have all your custom plugins lazy-loaded by default.
|
||||
lazy = false,
|
||||
-- It's recommended to leave version=false for now, since a lot the plugin that support versioning,
|
||||
-- have outdated releases, which may break your Neovim install.
|
||||
version = false, -- always use the latest git commit
|
||||
-- version = "*", -- try installing the latest stable version for plugins that support semver
|
||||
},
|
||||
install = { colorscheme = { "tokyonight", "habamax" } },
|
||||
checker = { enabled = true, notify = false }, -- automatically check for plugin updates
|
||||
performance = {
|
||||
rtp = {
|
||||
-- disable some rtp plugins
|
||||
disabled_plugins = {
|
||||
"gzip",
|
||||
-- "matchit",
|
||||
-- "matchparen",
|
||||
-- "netrwPlugin",
|
||||
"tarPlugin",
|
||||
"tohtml",
|
||||
-- "tutor",
|
||||
"zipPlugin",
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
@ -1,4 +0,0 @@
|
||||
-- Options are automatically loaded before lazy.nvim startup
|
||||
-- Default options that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/options.lua
|
||||
-- Add any additional options here
|
||||
vim.g.root_spec = { ".git", "cwd" }
|
@ -1,13 +0,0 @@
|
||||
return {
|
||||
{
|
||||
"ellisonleao/gruvbox.nvim",
|
||||
|
||||
priority = 1000,
|
||||
|
||||
config = true,
|
||||
|
||||
opts = {
|
||||
contrast = "",
|
||||
},
|
||||
},
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
return {
|
||||
{
|
||||
"nvimdev/dashboard-nvim",
|
||||
event = "VimEnter",
|
||||
opts = function(_, opts)
|
||||
local logo = [[
|
||||
███╗ ██╗███████╗ ██████╗ ██╗ ██╗██╗███╗ ███╗
|
||||
████╗ ██║██╔════╝██╔═══██╗██║ ██║██║████╗ ████║
|
||||
██╔██╗ ██║█████╗ ██║ ██║██║ ██║██║██╔████╔██║
|
||||
██║╚██╗██║██╔══╝ ██║ ██║╚██╗ ██╔╝██║██║╚██╔╝██║
|
||||
██║ ╚████║███████╗╚██████╔╝ ╚████╔╝ ██║██║ ╚═╝ ██║
|
||||
╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
|
||||
]]
|
||||
|
||||
logo = string.rep("\n", 8) .. logo .. "\n\n"
|
||||
|
||||
opts.config.header = vim.split(logo, "\n")
|
||||
end,
|
||||
},
|
||||
}
|
@ -1,266 +0,0 @@
|
||||
-- since this is just an example spec, don't actually load anything here and return an empty spec
|
||||
-- stylua: ignore
|
||||
if true then return {} end
|
||||
|
||||
-- every spec file under the "plugins" directory will be loaded automatically by lazy.nvim
|
||||
--
|
||||
-- In your plugin files, you can:
|
||||
-- * add extra plugins
|
||||
-- * disable/enabled LazyVim plugins
|
||||
-- * override the configuration of LazyVim plugins
|
||||
return {
|
||||
-- add gruvbox
|
||||
{ "ellisonleao/gruvbox.nvim" },
|
||||
|
||||
-- Configure LazyVim to load gruvbox
|
||||
{
|
||||
"LazyVim/LazyVim",
|
||||
opts = {
|
||||
colorscheme = "gruvbox",
|
||||
},
|
||||
},
|
||||
|
||||
-- change trouble config
|
||||
{
|
||||
"folke/trouble.nvim",
|
||||
-- opts will be merged with the parent spec
|
||||
opts = { use_diagnostic_signs = true },
|
||||
},
|
||||
|
||||
-- disable trouble
|
||||
{ "folke/trouble.nvim", enabled = false },
|
||||
|
||||
-- add symbols-outline
|
||||
{
|
||||
"simrat39/symbols-outline.nvim",
|
||||
cmd = "SymbolsOutline",
|
||||
keys = { { "<leader>cs", "<cmd>SymbolsOutline<cr>", desc = "Symbols Outline" } },
|
||||
config = true,
|
||||
},
|
||||
|
||||
-- override nvim-cmp and add cmp-emoji
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = { "hrsh7th/cmp-emoji" },
|
||||
---@param opts cmp.ConfigSchema
|
||||
opts = function(_, opts)
|
||||
local cmp = require("cmp")
|
||||
opts.sources = cmp.config.sources(vim.list_extend(opts.sources, { { name = "emoji" } }))
|
||||
end,
|
||||
},
|
||||
|
||||
-- change some telescope options and a keymap to browse plugin files
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
keys = {
|
||||
-- add a keymap to browse plugin files
|
||||
-- stylua: ignore
|
||||
{
|
||||
"<leader>fp",
|
||||
function() require("telescope.builtin").find_files({ cwd = require("lazy.core.config").options.root }) end,
|
||||
desc = "Find Plugin File",
|
||||
},
|
||||
},
|
||||
-- change some options
|
||||
opts = {
|
||||
defaults = {
|
||||
layout_strategy = "horizontal",
|
||||
layout_config = { prompt_position = "top" },
|
||||
sorting_strategy = "ascending",
|
||||
winblend = 0,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- add telescope-fzf-native
|
||||
{
|
||||
"telescope.nvim",
|
||||
dependencies = {
|
||||
"nvim-telescope/telescope-fzf-native.nvim",
|
||||
build = "make",
|
||||
config = function()
|
||||
require("telescope").load_extension("fzf")
|
||||
end,
|
||||
},
|
||||
},
|
||||
|
||||
-- add pyright to lspconfig
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
---@class PluginLspOpts
|
||||
opts = {
|
||||
---@type lspconfig.options
|
||||
servers = {
|
||||
-- pyright will be automatically installed with mason and loaded with lspconfig
|
||||
pyright = {},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- add tsserver and setup with typescript.nvim instead of lspconfig
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
dependencies = {
|
||||
"jose-elias-alvarez/typescript.nvim",
|
||||
init = function()
|
||||
require("lazyvim.util").on_attach(function(_, buffer)
|
||||
-- stylua: ignore
|
||||
vim.keymap.set( "n", "<leader>co", "TypescriptOrganizeImports", { buffer = buffer, desc = "Organize Imports" })
|
||||
vim.keymap.set("n", "<leader>cR", "TypescriptRenameFile", { desc = "Rename File", buffer = buffer })
|
||||
end)
|
||||
end,
|
||||
},
|
||||
---@class PluginLspOpts
|
||||
opts = {
|
||||
---@type lspconfig.options
|
||||
servers = {
|
||||
-- tsserver will be automatically installed with mason and loaded with lspconfig
|
||||
tsserver = {},
|
||||
},
|
||||
-- you can do any additional lsp server setup here
|
||||
-- return true if you don't want this server to be setup with lspconfig
|
||||
---@type table<string, fun(server:string, opts:_.lspconfig.options):boolean?>
|
||||
setup = {
|
||||
-- example to setup with typescript.nvim
|
||||
tsserver = function(_, opts)
|
||||
require("typescript").setup({ server = opts })
|
||||
return true
|
||||
end,
|
||||
-- Specify * to use this function as a fallback for any server
|
||||
-- ["*"] = function(server, opts) end,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- for typescript, LazyVim also includes extra specs to properly setup lspconfig,
|
||||
-- treesitter, mason and typescript.nvim. So instead of the above, you can use:
|
||||
{ import = "lazyvim.plugins.extras.lang.typescript" },
|
||||
|
||||
-- add more treesitter parsers
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"html",
|
||||
"javascript",
|
||||
"json",
|
||||
"lua",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"python",
|
||||
"query",
|
||||
"regex",
|
||||
"tsx",
|
||||
"typescript",
|
||||
"vim",
|
||||
"yaml",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- since `vim.tbl_deep_extend`, can only merge tables and not lists, the code above
|
||||
-- would overwrite `ensure_installed` with the new value.
|
||||
-- If you'd rather extend the default config, use the code below instead:
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = function(_, opts)
|
||||
-- add tsx and treesitter
|
||||
vim.list_extend(opts.ensure_installed, {
|
||||
"tsx",
|
||||
"typescript",
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- the opts function can also be used to change the default opts:
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.sections.lualine_x, "😄")
|
||||
end,
|
||||
},
|
||||
|
||||
-- or you can return new options to override all the defaults
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = function()
|
||||
return {
|
||||
--[[add your custom lualine config here]]
|
||||
}
|
||||
end,
|
||||
},
|
||||
|
||||
-- use mini.starter instead of alpha
|
||||
{ import = "lazyvim.plugins.extras.ui.mini-starter" },
|
||||
|
||||
-- add jsonls and schemastore packages, and setup treesitter for json, json5 and jsonc
|
||||
{ import = "lazyvim.plugins.extras.lang.json" },
|
||||
|
||||
-- add any tools you want to have installed below
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"stylua",
|
||||
"shellcheck",
|
||||
"shfmt",
|
||||
"flake8",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Use <tab> for completion and snippets (supertab)
|
||||
-- first: disable default <tab> and <s-tab> behavior in LuaSnip
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
keys = function()
|
||||
return {}
|
||||
end,
|
||||
},
|
||||
-- then: setup supertab in cmp
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-emoji",
|
||||
},
|
||||
---@param opts cmp.ConfigSchema
|
||||
opts = function(_, opts)
|
||||
local has_words_before = function()
|
||||
unpack = unpack or table.unpack
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
local luasnip = require("luasnip")
|
||||
local cmp = require("cmp")
|
||||
|
||||
opts.mapping = vim.tbl_extend("force", opts.mapping, {
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
|
||||
-- this way you will only jump inside the snippet region
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
return {
|
||||
{ "shortcuts/no-neck-pain.nvim", version = "*" },
|
||||
}
|
@ -1,97 +0,0 @@
|
||||
return {
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = {
|
||||
servers = {
|
||||
rust_analyzer = {},
|
||||
taplo = {
|
||||
keys = {
|
||||
{
|
||||
"K",
|
||||
function()
|
||||
if vim.fn.expand("%:t") == "Cargo.toml" and require("crates").popup_available() then
|
||||
require("crates").show_popup()
|
||||
else
|
||||
vim.lsp.buf.hover()
|
||||
end
|
||||
end,
|
||||
desc = "Show Crate Documentation",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
-- setup = {
|
||||
-- rust_analyzer = function()
|
||||
-- return true
|
||||
-- end,
|
||||
-- },
|
||||
},
|
||||
},
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
---@type TSConfig
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"c",
|
||||
"diff",
|
||||
"html",
|
||||
"javascript",
|
||||
"jsdoc",
|
||||
"json",
|
||||
"jsonc",
|
||||
"lua",
|
||||
"luadoc",
|
||||
"luap",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"python",
|
||||
"query",
|
||||
"regex",
|
||||
"toml",
|
||||
"tsx",
|
||||
"typescript",
|
||||
"vim",
|
||||
"vimdoc",
|
||||
"yaml",
|
||||
"nix",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"stevearc/conform.nvim",
|
||||
---@class ConformOpts
|
||||
opts = {
|
||||
---@type table<string, conform.FormatterUnit[]>
|
||||
formatters_by_ft = {
|
||||
nix = { "alejandra" },
|
||||
javascript = { { "prettierd", "prettier" } },
|
||||
javascriptreact = { { "prettierd", "prettier" } },
|
||||
typescript = { { "prettierd", "prettier" } },
|
||||
typescriptreact = { { "prettierd", "prettier" } },
|
||||
json = { { "prettierd", "prettier" } },
|
||||
yaml = { { "prettierd", "prettier" } },
|
||||
css = { { "prettierd", "prettier" } },
|
||||
markdown = { { "prettierd", "prettier" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"rush-rs/tree-sitter-asm",
|
||||
},
|
||||
{
|
||||
"imsnif/kdl.vim",
|
||||
},
|
||||
{
|
||||
"andreshazard/vim-freemarker",
|
||||
},
|
||||
{
|
||||
"mrcjkb/rustaceanvim",
|
||||
opts = {
|
||||
server = {
|
||||
load_vscode_settings = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
return {
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
event = "VeryLazy",
|
||||
opts = function(_, opts)
|
||||
opts.options.section_separators = ""
|
||||
opts.options.component_separators = { left = "·", right = "·" }
|
||||
end,
|
||||
},
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
indent_type = "Spaces"
|
||||
indent_width = 2
|
||||
column_width = 120
|
Loading…
x
Reference in New Issue
Block a user