| author | |
| committer | |
| log | fbad532ae9e5541455ffb0829262a4859ff1165d |
| tree | feec9d699b39acca4988b584d24d4a6eb540e297 |
| parent | 3ee04064c08e9504d2ffa4adabe7211f102f8ad7 |
| signature | Commit is signed but in an unrecognized format. |
34 files changed, 2049 insertions(+), 151 deletions(-)
.DS_Store deleted| Binary files a/.DS_Store and /dev/null differ | |||
files/sketchybar/executable_colors.sh created+26| ... | @@ -0,0 +1,26 @@ | ||
| 1 | #!/usr/bin/env sh | ||
| 2 | |||
| 3 | # Color Palette | ||
| 4 | export BLACK=0xff4c4f69 | ||
| 5 | export WHITE=0xffeff1f5 | ||
| 6 | export RED=0xffd20f39 | ||
| 7 | export GREEN=0xff40a02b | ||
| 8 | export BLUE=0xff1e66f5 | ||
| 9 | export YELLOW=0xffdf8e1d | ||
| 10 | export ORANGE=0xfffe640b | ||
| 11 | export MAGENTA=0xffea76cb | ||
| 12 | export GREY=0xff9ca0b0 | ||
| 13 | export TRANSPARENT=0xff000000 | ||
| 14 | export BLUE2=0xff7287fd | ||
| 15 | |||
| 16 | # General bar colors | ||
| 17 | export BAR_COLOR=0xeff1f5ff # Color of the bar | ||
| 18 | export ICON_COLOR=0xff4c4f69 | ||
| 19 | export LABEL_COLOR=0xff4c4f69 # Color of all labels | ||
| 20 | export BACKGROUND_1=0xffbcc0cc | ||
| 21 | export BACKGROUND_2=0xffbcc0cc | ||
| 22 | |||
| 23 | export POPUP_BACKGROUND_COLOR=$BLACK | ||
| 24 | export POPUP_BORDER_COLOR=$WHITE | ||
| 25 | |||
| 26 | export SHADOW_COLOR=$BLACK | ||
files/sketchybar/executable_icons.sh created+31| ... | @@ -0,0 +1,31 @@ | ||
| 1 | #!/usr/bin/env sh | ||
| 2 | |||
| 3 | # General Icons | ||
| 4 | LOADING= | ||
| 5 | APPLE= | ||
| 6 | PREFERENCES= | ||
| 7 | ACTIVITY= | ||
| 8 | LOCK= | ||
| 9 | BELL= | ||
| 10 | BELL_DOT= | ||
| 11 | |||
| 12 | # Git Icons | ||
| 13 | GIT_ISSUE= | ||
| 14 | GIT_DISCUSSION= | ||
| 15 | GIT_PULL_REQUEST= | ||
| 16 | GIT_COMMIT= | ||
| 17 | GIT_INDICATOR= | ||
| 18 | |||
| 19 | # Spotify Icons | ||
| 20 | SPOTIFY_BACK= | ||
| 21 | SPOTIFY_PLAY_PAUSE= | ||
| 22 | SPOTIFY_NEXT= | ||
| 23 | SPOTIFY_SHUFFLE= | ||
| 24 | SPOTIFY_REPEAT= | ||
| 25 | |||
| 26 | # Yabai Icons | ||
| 27 | YABAI_STACK= | ||
| 28 | YABAI_FULLSCREEN_ZOOM= | ||
| 29 | YABAI_PARENT_ZOOM= | ||
| 30 | YABAI_FLOAT= | ||
| 31 | YABAI_GRID= | ||
files/sketchybar/executable_sketchybarrc created+73| ... | @@ -0,0 +1,73 @@ | ||
| 1 | #!/usr/bin/env sh | ||
| 2 | |||
| 3 | source "$HOME/.config/sketchybar/colors.sh" # Loads all defined colors | ||
| 4 | source "$HOME/.config/sketchybar/icons.sh" # Loads all defined icons | ||
| 5 | |||
| 6 | ITEM_DIR="$HOME/.config/sketchybar/items" # Directory where the items are configured | ||
| 7 | PLUGIN_DIR="$HOME/.config/sketchybar/plugins" # Directory where all the plugin scripts are stored | ||
| 8 | |||
| 9 | FONT="SF Pro" # Needs to have Regular, Bold, Semibold, Heavy and Black variants | ||
| 10 | PADDINGS=3 # All paddings use this value (icon, label, background) | ||
| 11 | |||
| 12 | # Setting up and starting the helper process | ||
| 13 | HELPER=git.felix.helper | ||
| 14 | killall helper | ||
| 15 | cd $HOME/.config/sketchybar/helper && make | ||
| 16 | $HOME/.config/sketchybar/helper/helper $HELPER > /dev/null 2>&1 & | ||
| 17 | |||
| 18 | # Unload the macOS on screen indicator overlay for volume change | ||
| 19 | launchctl unload -F /System/Library/LaunchAgents/com.apple.OSDUIHelper.plist > /dev/null 2>&1 & | ||
| 20 | |||
| 21 | # Setting up the general bar appearance and default values | ||
| 22 | sketchybar --bar height=50 \ | ||
| 23 | color=$BAR_COLOR \ | ||
| 24 | shadow=off \ | ||
| 25 | position=top \ | ||
| 26 | sticky=on \ | ||
| 27 | padding_right=7 \ | ||
| 28 | padding_left=7 \ | ||
| 29 | corner_radius=12 \ | ||
| 30 | y_offset=20 \ | ||
| 31 | margin=40 \ | ||
| 32 | blur_radius=0 \ | ||
| 33 | notch_width=0 \ | ||
| 34 | \ | ||
| 35 | --default updates=when_shown \ | ||
| 36 | icon.font="$FONT:Bold:14.0" \ | ||
| 37 | icon.color=$ICON_COLOR \ | ||
| 38 | icon.padding_left=$PADDINGS \ | ||
| 39 | icon.padding_right=$PADDINGS \ | ||
| 40 | label.font="$FONT:Semibold:13.0" \ | ||
| 41 | label.color=$LABEL_COLOR \ | ||
| 42 | label.padding_left=$PADDINGS \ | ||
| 43 | label.padding_right=$PADDINGS \ | ||
| 44 | background.padding_right=$PADDINGS \ | ||
| 45 | background.padding_left=$PADDINGS \ | ||
| 46 | background.height=26 \ | ||
| 47 | background.corner_radius=9 \ | ||
| 48 | popup.background.border_width=2 \ | ||
| 49 | popup.background.corner_radius=11 \ | ||
| 50 | popup.background.border_color=$POPUP_BORDER_COLOR \ | ||
| 51 | popup.background.color=$POPUP_BACKGROUND_COLOR \ | ||
| 52 | popup.background.shadow.drawing=on | ||
| 53 | |||
| 54 | # Left | ||
| 55 | source "$ITEM_DIR/apple.sh" | ||
| 56 | source "$ITEM_DIR/spaces.sh" | ||
| 57 | source "$ITEM_DIR/front_app.sh" | ||
| 58 | |||
| 59 | # Center | ||
| 60 | # source "$ITEM_DIR/spotify.sh" | ||
| 61 | source "$ITEM_DIR/calendar.sh" | ||
| 62 | |||
| 63 | # Right | ||
| 64 | source "$ITEM_DIR/brew.sh" | ||
| 65 | # source "$ITEM_DIR/github.sh" | ||
| 66 | source "$ITEM_DIR/volume.sh" | ||
| 67 | source "$ITEM_DIR/divider.sh" | ||
| 68 | # source "$ITEM_DIR/cpu.sh" | ||
| 69 | |||
| 70 | # Forcing all item scripts to run (never do this outside of sketchybarrc) | ||
| 71 | sketchybar --update | ||
| 72 | |||
| 73 | echo "sketchybar configuation loaded.." | ||
files/sketchybar/helper/cpu.h created+120| ... | @@ -0,0 +1,120 @@ | ||
| 1 | #include <stdio.h> | ||
| 2 | #include <stdlib.h> | ||
| 3 | #include <unistd.h> | ||
| 4 | #include <mach/mach.h> | ||
| 5 | #include <stdbool.h> | ||
| 6 | #include <time.h> | ||
| 7 | |||
| 8 | static const char TOPPROC[32] = { "/bin/ps -Aceo pid,pcpu,comm -r" }; | ||
| 9 | static const char FILTER_PATTERN[16] = { "com.apple." }; | ||
| 10 | |||
| 11 | struct cpu { | ||
| 12 | host_t host; | ||
| 13 | mach_msg_type_number_t count; | ||
| 14 | host_cpu_load_info_data_t load; | ||
| 15 | host_cpu_load_info_data_t prev_load; | ||
| 16 | bool has_prev_load; | ||
| 17 | |||
| 18 | char command[256]; | ||
| 19 | }; | ||
| 20 | |||
| 21 | static inline void cpu_init(struct cpu* cpu) { | ||
| 22 | cpu->host = mach_host_self(); | ||
| 23 | cpu->count = HOST_CPU_LOAD_INFO_COUNT; | ||
| 24 | cpu->has_prev_load = false; | ||
| 25 | snprintf(cpu->command, 100, ""); | ||
| 26 | } | ||
| 27 | |||
| 28 | static inline void cpu_update(struct cpu* cpu) { | ||
| 29 | kern_return_t error = host_statistics(cpu->host, | ||
| 30 | HOST_CPU_LOAD_INFO, | ||
| 31 | (host_info_t)&cpu->load, | ||
| 32 | &cpu->count ); | ||
| 33 | |||
| 34 | if (error != KERN_SUCCESS) { | ||
| 35 | printf("Error: Could not read cpu host statistics.\n"); | ||
| 36 | return; | ||
| 37 | } | ||
| 38 | |||
| 39 | if (cpu->has_prev_load) { | ||
| 40 | uint32_t delta_user = cpu->load.cpu_ticks[CPU_STATE_USER] | ||
| 41 | - cpu->prev_load.cpu_ticks[CPU_STATE_USER]; | ||
| 42 | |||
| 43 | uint32_t delta_system = cpu->load.cpu_ticks[CPU_STATE_SYSTEM] | ||
| 44 | - cpu->prev_load.cpu_ticks[CPU_STATE_SYSTEM]; | ||
| 45 | |||
| 46 | uint32_t delta_idle = cpu->load.cpu_ticks[CPU_STATE_IDLE] | ||
| 47 | - cpu->prev_load.cpu_ticks[CPU_STATE_IDLE]; | ||
| 48 | |||
| 49 | double user_perc = (double)delta_user / (double)(delta_system | ||
| 50 | + delta_user | ||
| 51 | + delta_idle); | ||
| 52 | |||
| 53 | double sys_perc = (double)delta_system / (double)(delta_system | ||
| 54 | + delta_user | ||
| 55 | + delta_idle); | ||
| 56 | |||
| 57 | double total_perc = user_perc + sys_perc; | ||
| 58 | |||
| 59 | FILE* file; | ||
| 60 | char line[1024]; | ||
| 61 | |||
| 62 | file = popen(TOPPROC, "r"); | ||
| 63 | if (!file) { | ||
| 64 | printf("Error: TOPPROC command errored out...\n" ); | ||
| 65 | return; | ||
| 66 | } | ||
| 67 | |||
| 68 | fgets(line, sizeof(line), file); | ||
| 69 | fgets(line, sizeof(line), file); | ||
| 70 | |||
| 71 | char* start = strstr(line, FILTER_PATTERN); | ||
| 72 | char topproc[32]; | ||
| 73 | uint32_t caret = 0; | ||
| 74 | for (int i = 0; i < sizeof(line); i++) { | ||
| 75 | if (start && i == start - line) { | ||
| 76 | i+=9; | ||
| 77 | continue; | ||
| 78 | } | ||
| 79 | |||
| 80 | if (caret >= 28 && caret <= 30) { | ||
| 81 | topproc[caret++] = '.'; | ||
| 82 | continue; | ||
| 83 | } | ||
| 84 | if (caret > 30) break; | ||
| 85 | topproc[caret++] = line[i]; | ||
| 86 | if (line[i] == '\0') break; | ||
| 87 | } | ||
| 88 | |||
| 89 | topproc[31] = '\0'; | ||
| 90 | |||
| 91 | pclose(file); | ||
| 92 | |||
| 93 | char color[16]; | ||
| 94 | if (total_perc >= .7) { | ||
| 95 | snprintf(color, 16, "%s", getenv("RED")); | ||
| 96 | } else if (total_perc >= .3) { | ||
| 97 | snprintf(color, 16, "%s", getenv("ORANGE")); | ||
| 98 | } else if (total_perc >= .1) { | ||
| 99 | snprintf(color, 16, "%s", getenv("YELLOW")); | ||
| 100 | } else { | ||
| 101 | snprintf(color, 16, "%s", getenv("LABEL_COLOR")); | ||
| 102 | } | ||
| 103 | |||
| 104 | snprintf(cpu->command, 256, "--push cpu.sys %.2f " | ||
| 105 | "--push cpu.user %.2f " | ||
| 106 | "--set cpu.percent label=%.0f%% label.color=%s " | ||
| 107 | "--set cpu.top label=\"%s\"", | ||
| 108 | sys_perc, | ||
| 109 | user_perc, | ||
| 110 | total_perc*100., | ||
| 111 | color, | ||
| 112 | topproc ); | ||
| 113 | } | ||
| 114 | else { | ||
| 115 | snprintf(cpu->command, 256, ""); | ||
| 116 | } | ||
| 117 | |||
| 118 | cpu->prev_load = cpu->load; | ||
| 119 | cpu->has_prev_load = true; | ||
| 120 | } | ||
files/sketchybar/helper/executable_helper created| Binary files /dev/null and b/files/sketchybar/helper/executable_helper differ | |||
files/sketchybar/helper/helper.c created+32| ... | @@ -0,0 +1,32 @@ | ||
| 1 | #include "cpu.h" | ||
| 2 | #include "sketchybar.h" | ||
| 3 | |||
| 4 | struct cpu g_cpu; | ||
| 5 | |||
| 6 | void handler(env env) { | ||
| 7 | // Environment variables passed from sketchybar can be accessed as seen below | ||
| 8 | char* name = env_get_value_for_key(env, "NAME"); | ||
| 9 | char* sender = env_get_value_for_key(env, "SENDER"); | ||
| 10 | char* info = env_get_value_for_key(env, "INFO"); | ||
| 11 | char* selected = env_get_value_for_key(env, "SELECTED"); | ||
| 12 | |||
| 13 | if ((strcmp(sender, "routine") == 0) | ||
| 14 | || (strcmp(sender, "forced") == 0)) { | ||
| 15 | // CPU graph updates | ||
| 16 | cpu_update(&g_cpu); | ||
| 17 | |||
| 18 | if (strlen(g_cpu.command) > 0) sketchybar(g_cpu.command); | ||
| 19 | } | ||
| 20 | } | ||
| 21 | |||
| 22 | int main (int argc, char** argv) { | ||
| 23 | cpu_init(&g_cpu); | ||
| 24 | |||
| 25 | if (argc < 2) { | ||
| 26 | printf("Usage: provider \"<bootstrap name>\"\n"); | ||
| 27 | exit(1); | ||
| 28 | } | ||
| 29 | |||
| 30 | event_server_begin(handler, argv[1]); | ||
| 31 | return 0; | ||
| 32 | } | ||
files/sketchybar/helper/makefile created+3| ... | @@ -0,0 +1,3 @@ | ||
| 1 | |||
| 2 | helper: helper.c cpu.h sketchybar.h | ||
| 3 | 	clang -std=c99 -O3 helper.c -o helper | ||
files/sketchybar/helper/sketchybar.h created+227| ... | @@ -0,0 +1,227 @@ | ||
| 1 | #pragma once | ||
| 2 | |||
| 3 | #include <mach/mach.h> | ||
| 4 | #include <mach/message.h> | ||
| 5 | #include <bootstrap.h> | ||
| 6 | #include <stdlib.h> | ||
| 7 | #include <pthread.h> | ||
| 8 | #include <stdio.h> | ||
| 9 | |||
| 10 | typedef char* env; | ||
| 11 | |||
| 12 | #define MACH_HANDLER(name) void name(env env) | ||
| 13 | typedef MACH_HANDLER(mach_handler); | ||
| 14 | |||
| 15 | struct mach_message { | ||
| 16 | mach_msg_header_t header; | ||
| 17 | mach_msg_size_t msgh_descriptor_count; | ||
| 18 | mach_msg_ool_descriptor_t descriptor; | ||
| 19 | }; | ||
| 20 | |||
| 21 | struct mach_buffer { | ||
| 22 | struct mach_message message; | ||
| 23 | mach_msg_trailer_t trailer; | ||
| 24 | }; | ||
| 25 | |||
| 26 | struct mach_server { | ||
| 27 | bool is_running; | ||
| 28 | mach_port_name_t task; | ||
| 29 | mach_port_t port; | ||
| 30 | mach_port_t bs_port; | ||
| 31 | |||
| 32 | pthread_t thread; | ||
| 33 | mach_handler* handler; | ||
| 34 | }; | ||
| 35 | |||
| 36 | static struct mach_server g_mach_server; | ||
| 37 | static mach_port_t g_mach_port = 0; | ||
| 38 | |||
| 39 | static inline char* env_get_value_for_key(env env, char* key) { | ||
| 40 | uint32_t caret = 0; | ||
| 41 | for(;;) { | ||
| 42 | if (!env[caret]) break; | ||
| 43 | if (strcmp(&env[caret], key) == 0) | ||
| 44 | return &env[caret + strlen(&env[caret]) + 1]; | ||
| 45 | |||
| 46 | caret += strlen(&env[caret]) | ||
| 47 | + strlen(&env[caret + strlen(&env[caret]) + 1]) | ||
| 48 | + 2; | ||
| 49 | } | ||
| 50 | return (char*)""; | ||
| 51 | } | ||
| 52 | |||
| 53 | static inline mach_port_t mach_get_bs_port() { | ||
| 54 | mach_port_name_t task = mach_task_self(); | ||
| 55 | |||
| 56 | mach_port_t bs_port; | ||
| 57 | if (task_get_special_port(task, | ||
| 58 | TASK_BOOTSTRAP_PORT, | ||
| 59 | &bs_port ) != KERN_SUCCESS) { | ||
| 60 | return 0; | ||
| 61 | } | ||
| 62 | |||
| 63 | mach_port_t port; | ||
| 64 | if (bootstrap_look_up(bs_port, | ||
| 65 | "git.felix.sketchybar", | ||
| 66 | &port ) != KERN_SUCCESS) { | ||
| 67 | return 0; | ||
| 68 | } | ||
| 69 | |||
| 70 | return port; | ||
| 71 | } | ||
| 72 | |||
| 73 | static inline void mach_receive_message(mach_port_t port, struct mach_buffer* buffer, bool timeout) { | ||
| 74 | *buffer = (struct mach_buffer) { 0 }; | ||
| 75 | mach_msg_return_t msg_return; | ||
| 76 | if (timeout) | ||
| 77 | msg_return = mach_msg(&buffer->message.header, | ||
| 78 | MACH_RCV_MSG | MACH_RCV_TIMEOUT, | ||
| 79 | 0, | ||
| 80 | sizeof(struct mach_buffer), | ||
| 81 | port, | ||
| 82 | 100, | ||
| 83 | MACH_PORT_NULL ); | ||
| 84 | else | ||
| 85 | msg_return = mach_msg(&buffer->message.header, | ||
| 86 | MACH_RCV_MSG, | ||
| 87 | 0, | ||
| 88 | sizeof(struct mach_buffer), | ||
| 89 | port, | ||
| 90 | MACH_MSG_TIMEOUT_NONE, | ||
| 91 | MACH_PORT_NULL ); | ||
| 92 | |||
| 93 | if (msg_return != MACH_MSG_SUCCESS) { | ||
| 94 | buffer->message.descriptor.address = NULL; | ||
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | static inline char* mach_send_message(mach_port_t port, char* message, uint32_t len) { | ||
| 99 | if (!message || !port) { | ||
| 100 | return NULL; | ||
| 101 | } | ||
| 102 | |||
| 103 | mach_port_t response_port; | ||
| 104 | mach_port_name_t task = mach_task_self(); | ||
| 105 | if (mach_port_allocate(task, MACH_PORT_RIGHT_RECEIVE, | ||
| 106 | &response_port ) != KERN_SUCCESS) { | ||
| 107 | return NULL; | ||
| 108 | } | ||
| 109 | |||
| 110 | if (mach_port_insert_right(task, response_port, | ||
| 111 | response_port, | ||
| 112 | MACH_MSG_TYPE_MAKE_SEND)!= KERN_SUCCESS) { | ||
| 113 | return NULL; | ||
| 114 | } | ||
| 115 | |||
| 116 | struct mach_message msg = { 0 }; | ||
| 117 | msg.header.msgh_remote_port = port; | ||
| 118 | msg.header.msgh_local_port = response_port; | ||
| 119 | msg.header.msgh_id = response_port; | ||
| 120 | msg.header.msgh_bits = MACH_MSGH_BITS_SET(MACH_MSG_TYPE_COPY_SEND, | ||
| 121 | MACH_MSG_TYPE_MAKE_SEND, | ||
| 122 | 0, | ||
| 123 | MACH_MSGH_BITS_COMPLEX ); | ||
| 124 | |||
| 125 | msg.header.msgh_size = sizeof(struct mach_message); | ||
| 126 | msg.msgh_descriptor_count = 1; | ||
| 127 | msg.descriptor.address = message; | ||
| 128 | msg.descriptor.size = len * sizeof(char); | ||
| 129 | msg.descriptor.copy = MACH_MSG_VIRTUAL_COPY; | ||
| 130 | msg.descriptor.deallocate = false; | ||
| 131 | msg.descriptor.type = MACH_MSG_OOL_DESCRIPTOR; | ||
| 132 | |||
| 133 | mach_msg(&msg.header, | ||
| 134 | MACH_SEND_MSG, | ||
| 135 | sizeof(struct mach_message), | ||
| 136 | 0, | ||
| 137 | MACH_PORT_NULL, | ||
| 138 | MACH_MSG_TIMEOUT_NONE, | ||
| 139 | MACH_PORT_NULL ); | ||
| 140 | |||
| 141 | struct mach_buffer buffer = { 0 }; | ||
| 142 | mach_receive_message(response_port, &buffer, true); | ||
| 143 | if (buffer.message.descriptor.address) | ||
| 144 | return (char*)buffer.message.descriptor.address; | ||
| 145 | mach_msg_destroy(&buffer.message.header); | ||
| 146 | |||
| 147 | return NULL; | ||
| 148 | } | ||
| 149 | |||
| 150 | #pragma clang diagnostic push | ||
| 151 | #pragma clang diagnostic ignored "-Wdeprecated-declarations" | ||
| 152 | static inline bool mach_server_begin(struct mach_server* mach_server, mach_handler handler, char* bootstrap_name) { | ||
| 153 | mach_server->task = mach_task_self(); | ||
| 154 | |||
| 155 | if (mach_port_allocate(mach_server->task, | ||
| 156 | MACH_PORT_RIGHT_RECEIVE, | ||
| 157 | &mach_server->port ) != KERN_SUCCESS) { | ||
| 158 | return false; | ||
| 159 | } | ||
| 160 | |||
| 161 | if (mach_port_insert_right(mach_server->task, | ||
| 162 | mach_server->port, | ||
| 163 | mach_server->port, | ||
| 164 | MACH_MSG_TYPE_MAKE_SEND) != KERN_SUCCESS) { | ||
| 165 | return false; | ||
| 166 | } | ||
| 167 | |||
| 168 | if (task_get_special_port(mach_server->task, | ||
| 169 | TASK_BOOTSTRAP_PORT, | ||
| 170 | &mach_server->bs_port) != KERN_SUCCESS) { | ||
| 171 | return false; | ||
| 172 | } | ||
| 173 | |||
| 174 | if (bootstrap_register(mach_server->bs_port, | ||
| 175 | bootstrap_name, | ||
| 176 | mach_server->port ) != KERN_SUCCESS) { | ||
| 177 | return false; | ||
| 178 | } | ||
| 179 | |||
| 180 | mach_server->handler = handler; | ||
| 181 | mach_server->is_running = true; | ||
| 182 | while (mach_server->is_running) { | ||
| 183 | struct mach_buffer* buffer = (struct mach_buffer*)malloc(sizeof(struct mach_buffer)); | ||
| 184 | mach_receive_message(mach_server->port, buffer, false); | ||
| 185 | mach_server->handler((env)buffer->message.descriptor.address); | ||
| 186 | mach_msg_destroy(&buffer->message.header); | ||
| 187 | } | ||
| 188 | |||
| 189 | return true; | ||
| 190 | } | ||
| 191 | #pragma clang diagnostic pop | ||
| 192 | |||
| 193 | static inline char* sketchybar(char* message) { | ||
| 194 | uint32_t message_length = strlen(message) + 1; | ||
| 195 | char formatted_message[message_length + 1]; | ||
| 196 | |||
| 197 | char quote = '\0'; | ||
| 198 | uint32_t caret = 0; | ||
| 199 | for (int i = 0; i < message_length; ++i) { | ||
| 200 | if (message[i] == '"' || message[i] == '\'') { | ||
| 201 | if (quote == message[i]) quote = '\0'; | ||
| 202 | else quote = message[i]; | ||
| 203 | continue; | ||
| 204 | } | ||
| 205 | formatted_message[caret] = message[i]; | ||
| 206 | if (message[i] == ' ' && !quote) formatted_message[caret] = '\0'; | ||
| 207 | caret++; | ||
| 208 | } | ||
| 209 | |||
| 210 | if (caret > 0 && formatted_message[caret] == '\0' | ||
| 211 | && formatted_message[caret - 1] == '\0') { | ||
| 212 | caret--; | ||
| 213 | } | ||
| 214 | |||
| 215 | formatted_message[caret] = '\0'; | ||
| 216 | if (!g_mach_port) g_mach_port = mach_get_bs_port(); | ||
| 217 | char* response = mach_send_message(g_mach_port, | ||
| 218 | formatted_message, | ||
| 219 | caret + 1 ); | ||
| 220 | |||
| 221 | if (response) return response; | ||
| 222 | else return (char*)""; | ||
| 223 | } | ||
| 224 | |||
| 225 | static inline void event_server_begin(mach_handler event_handler, char* bootstrap_name) { | ||
| 226 | mach_server_begin(&g_mach_server, event_handler, bootstrap_name); | ||
| 227 | } | ||
files/sketchybar/items/executable_apple.sh created+31| ... | @@ -0,0 +1,31 @@ | ||
| 1 | #!/usr/bin/env sh | ||
| 2 | |||
| 3 | POPUP_OFF="sketchybar --set apple.logo popup.drawing=off" | ||
| 4 | POPUP_CLICK_SCRIPT="sketchybar --set \$NAME popup.drawing=toggle" | ||
| 5 | |||
| 6 | sketchybar --add item apple.logo left \ | ||
| 7 | \ | ||
| 8 | --set apple.logo icon=$APPLE \ | ||
| 9 | icon.font="$FONT:Black:16.0" \ | ||
| 10 | icon.color=$BLUE2 \ | ||
| 11 | background.padding_right=25 \ | ||
| 12 | label.drawing=off \ | ||
| 13 | click_script="$POPUP_CLICK_SCRIPT" \ | ||
| 14 | \ | ||
| 15 | --add item apple.prefs popup.apple.logo \ | ||
| 16 | --set apple.prefs icon=$PREFERENCES \ | ||
| 17 | label="Preferences" \ | ||
| 18 | click_script="open -a 'System Preferences'; | ||
| 19 | $POPUP_OFF" \ | ||
| 20 | \ | ||
| 21 | --add item apple.activity popup.apple.logo \ | ||
| 22 | --set apple.activity icon=$ACTIVITY \ | ||
| 23 | label="Activity" \ | ||
| 24 | click_script="open -a 'Activity Monitor'; | ||
| 25 | $POPUP_OFF"\ | ||
| 26 | \ | ||
| 27 | --add item apple.lock popup.apple.logo \ | ||
| 28 | --set apple.lock icon=$LOCK \ | ||
| 29 | label="Lock Screen" \ | ||
| 30 | click_script="pmset displaysleepnow; | ||
| 31 | $POPUP_OFF" | ||
files/sketchybar/items/executable_brew.sh created+14| ... | @@ -0,0 +1,14 @@ | ||
| 1 | #!/usr/bin/env sh | ||
| 2 | |||
| 3 | # Trigger the brew_udpate event when brew update or upgrade is run from cmdline | ||
| 4 | # e.g. via function in .zshrc | ||
| 5 | |||
| 6 | sketchybar --add event brew_update \ | ||
| 7 | --add item brew right \ | ||
| 8 | --set brew script="$PLUGIN_DIR/brew.sh" \ | ||
| 9 | icon= \ | ||
| 10 | label=? \ | ||
| 11 | label.color=$BLACK \ | ||
| 12 | background.padding_right=15 \ | ||
| 13 | --subscribe brew brew_update | ||
| 14 | |||
files/sketchybar/items/executable_calendar.sh created+12| ... | @@ -0,0 +1,12 @@ | ||
| 1 | #!/usr/bin/env sh | ||
| 2 | |||
| 3 | sketchybar --add item calendar center \ | ||
| 4 | --set calendar icon=cal \ | ||
| 5 | icon.font="$FONT:Black:12.0" \ | ||
| 6 | icon.padding_right=0 \ | ||
| 7 | label.width=50 \ | ||
| 8 | label.align=right \ | ||
| 9 | background.padding_left=15 \ | ||
| 10 | update_freq=30 \ | ||
| 11 | script="$PLUGIN_DIR/calendar.sh" \ | ||
| 12 | click_script="$PLUGIN_DIR/zen.sh" | ||
files/sketchybar/items/executable_cpu.sh created+37| ... | @@ -0,0 +1,37 @@ | ||
| 1 | #!/usr/bin/env sh | ||
| 2 | |||
| 3 | sketchybar --add item cpu.top right \ | ||
| 4 | --set cpu.top label.font="$FONT:Semibold:7" \ | ||
| 5 | label=CPU \ | ||
| 6 | icon.drawing=off \ | ||
| 7 | width=0 \ | ||
| 8 | y_offset=6 \ | ||
| 9 | \ | ||
| 10 | --add item cpu.percent right \ | ||
| 11 | --set cpu.percent label.font="$FONT:Heavy:12" \ | ||
| 12 | label=CPU \ | ||
| 13 | y_offset=-4 \ | ||
| 14 | width=40 \ | ||
| 15 | icon.drawing=off \ | ||
| 16 | update_freq=2 \ | ||
| 17 | mach_helper="$HELPER" \ | ||
| 18 | \ | ||
| 19 | --add graph cpu.sys right 100 \ | ||
| 20 | --set cpu.sys width=0 \ | ||
| 21 | graph.color=$RED \ | ||
| 22 | graph.fill_color=$RED \ | ||
| 23 | label.drawing=off \ | ||
| 24 | icon.drawing=off \ | ||
| 25 | background.padding_left=10 \ | ||
| 26 | background.height=30 \ | ||
| 27 | background.drawing=on \ | ||
| 28 | background.color=$TRANSPARENT \ | ||
| 29 | \ | ||
| 30 | --add graph cpu.user right 100 \ | ||
| 31 | --set cpu.user graph.color=$BLUE \ | ||
| 32 | label.drawing=off \ | ||
| 33 | icon.drawing=off \ | ||
| 34 | background.padding_left=10 \ | ||
| 35 | background.height=30 \ | ||
| 36 | background.drawing=on \ | ||
| 37 | background.color=$TRANSPARENT | ||
files/sketchybar/items/executable_divider.sh created+9| ... | @@ -0,0 +1,9 @@ | ||
| 1 | sketchybar --add bracket status brew volume volume_alias \ | ||
| 2 | --set status background.color=$WHITE | ||
| 3 | |||
| 4 | # sketchybar --add item divider right \ | ||
| 5 | # --set divider label.drawing=off \ | ||
| 6 | # icon= \ | ||
| 7 | # icon.font="$FONT:Black:22.0" \ | ||
| 8 | # background.padding_left=15 \ | ||
| 9 | # background.padding_right=20 | ||
files/sketchybar/items/executable_front_app.sh created+29| ... | @@ -0,0 +1,29 @@ | ||
| 1 | #!/usr/bin/env sh | ||
| 2 | |||
| 3 | FRONT_APP_SCRIPT='sketchybar --set $NAME label="$INFO"' | ||
| 4 | |||
| 5 | sketchybar --add event window_focus \ | ||
| 6 | --add event windows_on_spaces \ | ||
| 7 | --add item system.yabai left \ | ||
| 8 | --set system.yabai script="$PLUGIN_DIR/yabai.sh" \ | ||
| 9 | icon.font="$FONT:Bold:16.0" \ | ||
| 10 | label.drawing=off \ | ||
| 11 | icon.width=30 \ | ||
| 12 | icon=$YABAI_GRID \ | ||
| 13 | icon.color=$BLACK \ | ||
| 14 | updates=on \ | ||
| 15 | associated_display=active \ | ||
| 16 | --subscribe system.yabai window_focus \ | ||
| 17 | windows_on_spaces \ | ||
| 18 | mouse.clicked \ | ||
| 19 | \ | ||
| 20 | --add item front_app left \ | ||
| 21 | --set front_app script="$FRONT_APP_SCRIPT" \ | ||
| 22 | icon.drawing=off \ | ||
| 23 | background.padding_left=0 \ | ||
| 24 | background.padding_right=10 \ | ||
| 25 | label.color=$BLACK \ | ||
| 26 | label.font="$FONT:Black:12.0" \ | ||
| 27 | associated_display=active \ | ||
| 28 | --subscribe front_app front_app_switched | ||
| 29 | |||
files/sketchybar/items/executable_github.sh created+27| ... | @@ -0,0 +1,27 @@ | ||
| 1 | #!/usr/bin/env sh | ||
| 2 | |||
| 3 | POPUP_CLICK_SCRIPT="sketchybar --set \$NAME popup.drawing=toggle" | ||
| 4 | |||
| 5 | sketchybar --add item github.bell right \ | ||
| 6 | --set github.bell update_freq=180 \ | ||
| 7 | icon.font="$FONT:Bold:15.0" \ | ||
| 8 | icon=$BELL \ | ||
| 9 | icon.color=$BLUE \ | ||
| 10 | label=$LOADING \ | ||
| 11 | label.highlight_color=$BLUE \ | ||
| 12 | popup.align=right \ | ||
| 13 | script="$PLUGIN_DIR/github.sh" \ | ||
| 14 | click_script="$POPUP_CLICK_SCRIPT" \ | ||
| 15 | --subscribe github.bell mouse.entered \ | ||
| 16 | mouse.exited \ | ||
| 17 | mouse.exited.global \ | ||
| 18 | \ | ||
| 19 | --add item github.template popup.github.bell \ | ||
| 20 | --set github.template drawing=off \ | ||
| 21 | background.corner_radius=12 \ | ||
| 22 | background.padding_left=7 \ | ||
| 23 | background.padding_right=7 \ | ||
| 24 | background.color=$BLACK \ | ||
| 25 | background.drawing=off \ | ||
| 26 | icon.background.height=2 \ | ||
| 27 | icon.background.y_offset=-12 | ||
files/sketchybar/items/executable_spaces.sh.tmpl created+39| ... | @@ -0,0 +1,39 @@ | ||
| 1 | #!/usr/bin/env sh | ||
| 2 | |||
| 3 | SPACE_ICONS=("1" "2" "3" "4" "5" "6" "7" "8" "9" "10") | ||
| 4 | SPACE_CLICK_SCRIPT="yabai -m space --focus \$SID 2>/dev/null" | ||
| 5 | |||
| 6 | sid=0 | ||
| 7 | for i in "${!SPACE_ICONS[@]}" | ||
| 8 | do | ||
| 9 | sid=$(($i+1)) | ||
| 10 | sketchybar --add space space.$sid left \ | ||
| 11 | --set space.$sid associated_space=$sid \ | ||
| 12 | icon=${SPACE_ICONS[i]} \ | ||
| 13 | icon.padding_left=22 \ | ||
| 14 | icon.padding_right=22 \ | ||
| 15 | label.padding_right=33 \ | ||
| 16 | icon.highlight_color=$WHITE \ | ||
| 17 | icon.color=0xff4c566a \ | ||
| 18 | background.padding_left=-8 \ | ||
| 19 | background.padding_right=-8 \ | ||
| 20 | background.color=$BACKGROUND_1 \ | ||
| 21 | background.drawing=on \ | ||
| 22 | label.font="JetBrainsMono Nerd Font:Regular:16.0" \ | ||
| 23 | label.background.height=26 \ | ||
| 24 | label.background.drawing=on \ | ||
| 25 | label.background.color=$BACKGROUND_2 \ | ||
| 26 | label.background.corner_radius=9 \ | ||
| 27 | label.drawing=off \ | ||
| 28 | script="$PLUGIN_DIR/space.sh" \ | ||
| 29 | click_script="$SPACE_CLICK_SCRIPT" | ||
| 30 | done | ||
| 31 | |||
| 32 | sketchybar --add item separator left \ | ||
| 33 | --set separator icon= \ | ||
| 34 | icon.font="JetBrainsMono Nerd Font:Regular:16.0" \ | ||
| 35 | background.padding_left=26 \ | ||
| 36 | background.padding_right=15 \ | ||
| 37 | label.drawing=off \ | ||
| 38 | associated_display=active \ | ||
| 39 | icon.color=$GREEN | ||
files/sketchybar/items/executable_spotify.sh created+125| ... | @@ -0,0 +1,125 @@ | ||
| 1 | SPOTIFY_EVENT="com.spotify.client.PlaybackStateChanged" | ||
| 2 | POPUP_SCRIPT="sketchybar -m --set spotify.anchor popup.drawing=toggle" | ||
| 3 | |||
| 4 | sketchybar --add event spotify_change $SPOTIFY_EVENT \ | ||
| 5 | --add item spotify.anchor center \ | ||
| 6 | --set spotify.anchor script="$PLUGIN_DIR/spotify.sh" \ | ||
| 7 | click_script="$POPUP_SCRIPT" \ | ||
| 8 | background.padding_left=22 \ | ||
| 9 | popup.horizontal=on \ | ||
| 10 | popup.align=center \ | ||
| 11 | popup.height=120 \ | ||
| 12 | icon= \ | ||
| 13 | icon.font="$FONT:Regular:25.0" \ | ||
| 14 | icon.drawing=off \ | ||
| 15 | label.drawing=off \ | ||
| 16 | drawing=off \ | ||
| 17 | --subscribe spotify.anchor mouse.entered mouse.exited \ | ||
| 18 | mouse.exited.global \ | ||
| 19 | \ | ||
| 20 | --add item spotify.cover popup.spotify.anchor \ | ||
| 21 | --set spotify.cover script="$PLUGIN_DIR/spotify.sh" \ | ||
| 22 | label.drawing=off \ | ||
| 23 | icon.drawing=off \ | ||
| 24 | background.padding_left=12 \ | ||
| 25 | background.padding_right=10 \ | ||
| 26 | background.image.scale=0.15 \ | ||
| 27 | background.image.drawing=on \ | ||
| 28 | background.drawing=on \ | ||
| 29 | \ | ||
| 30 | --add item spotify.title popup.spotify.anchor \ | ||
| 31 | --set spotify.title icon.drawing=off \ | ||
| 32 | background.padding_left=0 \ | ||
| 33 | background.padding_right=0 \ | ||
| 34 | width=0 \ | ||
| 35 | label.font="$FONT:Heavy:14.0" \ | ||
| 36 | y_offset=40 \ | ||
| 37 | \ | ||
| 38 | --add item spotify.artist popup.spotify.anchor \ | ||
| 39 | --set spotify.artist icon.drawing=off \ | ||
| 40 | y_offset=20 \ | ||
| 41 | background.padding_left=0 \ | ||
| 42 | background.padding_right=0 \ | ||
| 43 | width=0 \ | ||
| 44 | \ | ||
| 45 | --add item spotify.album popup.spotify.anchor \ | ||
| 46 | --set spotify.album icon.drawing=off \ | ||
| 47 | background.padding_left=0 \ | ||
| 48 | background.padding_right=0 \ | ||
| 49 | y_offset=3 \ | ||
| 50 | width=0 \ | ||
| 51 | \ | ||
| 52 | --add item spotify.shuffle popup.spotify.anchor \ | ||
| 53 | --set spotify.shuffle icon= \ | ||
| 54 | icon.padding_left=5 \ | ||
| 55 | icon.padding_right=5 \ | ||
| 56 | icon.color=$BLACK \ | ||
| 57 | icon.highlight_color=$MAGENTA \ | ||
| 58 | label.drawing=off \ | ||
| 59 | script="$PLUGIN_DIR/spotify.sh" \ | ||
| 60 | y_offset=-30 \ | ||
| 61 | --subscribe spotify.shuffle mouse.clicked \ | ||
| 62 | \ | ||
| 63 | --add item spotify.back popup.spotify.anchor \ | ||
| 64 | --set spotify.back icon= \ | ||
| 65 | icon.padding_left=5 \ | ||
| 66 | icon.padding_right=5 \ | ||
| 67 | icon.color=$BLACK \ | ||
| 68 | script="$PLUGIN_DIR/spotify.sh" \ | ||
| 69 | label.drawing=off \ | ||
| 70 | y_offset=-30 \ | ||
| 71 | --subscribe spotify.back mouse.clicked \ | ||
| 72 | \ | ||
| 73 | --add item spotify.play popup.spotify.anchor \ | ||
| 74 | --set spotify.play icon= \ | ||
| 75 | background.height=40 \ | ||
| 76 | background.corner_radius=20 \ | ||
| 77 | width=40 \ | ||
| 78 | align=center \ | ||
| 79 | background.color=$BLACK \ | ||
| 80 | background.border_color=$WHITE \ | ||
| 81 | background.border_width=0 \ | ||
| 82 | background.drawing=on \ | ||
| 83 | icon.padding_left=4 \ | ||
| 84 | icon.padding_right=5 \ | ||
| 85 | icon.color=$WHITE \ | ||
| 86 | updates=on \ | ||
| 87 | label.drawing=off \ | ||
| 88 | script="$PLUGIN_DIR/spotify.sh" \ | ||
| 89 | y_offset=-30 \ | ||
| 90 | --subscribe spotify.play mouse.clicked spotify_change \ | ||
| 91 | \ | ||
| 92 | --add item spotify.next popup.spotify.anchor \ | ||
| 93 | --set spotify.next icon= \ | ||
| 94 | icon.padding_left=5 \ | ||
| 95 | icon.padding_right=10 \ | ||
| 96 | icon.color=$BLACK \ | ||
| 97 | label.drawing=off \ | ||
| 98 | script="$PLUGIN_DIR/spotify.sh" \ | ||
| 99 | y_offset=-30 \ | ||
| 100 | --subscribe spotify.next mouse.clicked \ | ||
| 101 | \ | ||
| 102 | --add item spotify.repeat popup.spotify.anchor \ | ||
| 103 | --set spotify.repeat icon= \ | ||
| 104 | icon.highlight_color=$MAGENTA \ | ||
| 105 | icon.padding_left=5 \ | ||
| 106 | icon.padding_right=10 \ | ||
| 107 | icon.color=$BLACK \ | ||
| 108 | label.drawing=off \ | ||
| 109 | script="$PLUGIN_DIR/spotify.sh" \ | ||
| 110 | y_offset=-30 \ | ||
| 111 | --subscribe spotify.repeat mouse.clicked \ | ||
| 112 | \ | ||
| 113 | --add item spotify.spacer popup.spotify.anchor \ | ||
| 114 | --set spotify.spacer width=5 \ | ||
| 115 | \ | ||
| 116 | --add bracket spotify spotify.shuffle \ | ||
| 117 | spotify.back \ | ||
| 118 | spotify.play \ | ||
| 119 | spotify.next \ | ||
| 120 | spotify.repeat \ | ||
| 121 | --set spotify background.color=$GREEN \ | ||
| 122 | background.corner_radius=11 \ | ||
| 123 | background.drawing=on \ | ||
| 124 | y_offset=-30 \ | ||
| 125 | drawing=off | ||
files/sketchybar/items/executable_volume.sh created+27| ... | @@ -0,0 +1,27 @@ | ||
| 1 | sketchybar --add item volume right \ | ||
| 2 | --set volume script="$PLUGIN_DIR/volume.sh" \ | ||
| 3 | updates=on \ | ||
| 4 | icon.background.drawing=on \ | ||
| 5 | icon.background.color=$GREEN \ | ||
| 6 | icon.background.height=8 \ | ||
| 7 | icon.background.corner_radius=3 \ | ||
| 8 | icon.width=0 \ | ||
| 9 | icon.align=right \ | ||
| 10 | label.drawing=off \ | ||
| 11 | background.drawing=on \ | ||
| 12 | background.color=$BACKGROUND_2 \ | ||
| 13 | background.height=8 \ | ||
| 14 | background.corner_radius=3 \ | ||
| 15 | align=left \ | ||
| 16 | --subscribe volume volume_change | ||
| 17 | |||
| 18 | sketchybar --add alias "Control Center,Sound" right \ | ||
| 19 | --rename "Control Center,Sound" volume_alias \ | ||
| 20 | --set volume_alias icon.drawing=off \ | ||
| 21 | label.drawing=off \ | ||
| 22 | alias.color=$WHITE \ | ||
| 23 | background.padding_right=0 \ | ||
| 24 | background.padding_left=5 \ | ||
| 25 | width=50 \ | ||
| 26 | align=right \ | ||
| 27 | click_script="$PLUGIN_DIR/volume_click.sh" | ||
files/sketchybar/plugins/executable_brew.sh created+21| ... | @@ -0,0 +1,21 @@ | ||
| 1 | #!/usr/bin/env sh | ||
| 2 | |||
| 3 | source "$HOME/.config/sketchybar/colors.sh" | ||
| 4 | |||
| 5 | COUNT=$(brew outdated | wc -l | tr -d ' ') | ||
| 6 | |||
| 7 | COLOR=$RED | ||
| 8 | |||
| 9 | case "$COUNT" in | ||
| 10 | [3-5][0-9]) COLOR=$ORANGE | ||
| 11 | ;; | ||
| 12 | [1-2][0-9]) COLOR=$YELLOW | ||
| 13 | ;; | ||
| 14 | [1-9]) COLOR=$BLACK | ||
| 15 | ;; | ||
| 16 | 0) COLOR=$GREEN | ||
| 17 | COUNT= | ||
| 18 | ;; | ||
| 19 | esac | ||
| 20 | |||
| 21 | sketchybar --set $NAME label=$COUNT icon.color=$COLOR | ||
files/sketchybar/plugins/executable_calendar.sh created+3| ... | @@ -0,0 +1,3 @@ | ||
| 1 | #!/usr/bin/env sh | ||
| 2 | |||
| 3 | sketchybar --set $NAME icon="$(date '+%a %d. %b')" label="$(date '+%H:%M')" | ||
files/sketchybar/plugins/executable_github.sh created+87| ... | @@ -0,0 +1,87 @@ | ||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | update() { | ||
| 4 | source "$HOME/.config/sketchybar/colors.sh" | ||
| 5 | source "$HOME/.config/sketchybar/icons.sh" | ||
| 6 | |||
| 7 | NOTIFICATIONS="$(gh api notifications)" | ||
| 8 | COUNT="$(echo "$NOTIFICATIONS" | jq 'length')" | ||
| 9 | args=() | ||
| 10 | if [ "$NOTIFICATIONS" = "[]" ]; then | ||
| 11 | args+=(--set $NAME icon=$BELL label="0") | ||
| 12 | else | ||
| 13 | args+=(--set $NAME icon=$BELL_DOT label="$COUNT") | ||
| 14 | fi | ||
| 15 | |||
| 16 | PREV_COUNT=$(sketchybar --query github.bell | jq -r .label.value) | ||
| 17 | # For sound to play around with: | ||
| 18 | # afplay /System/Library/Sounds/Morse.aiff | ||
| 19 | |||
| 20 | args+=(--remove '/github.notification\.*/') | ||
| 21 | |||
| 22 | COUNTER=0 | ||
| 23 | COLOR=$BLUE | ||
| 24 | args+=(--set github.bell icon.color=$COLOR) | ||
| 25 | |||
| 26 | while read -r repo url type title | ||
| 27 | do | ||
| 28 | COUNTER=$((COUNTER + 1)) | ||
| 29 | IMPORTANT="$(echo "$title" | egrep -i "(deprecat|break|broke)")" | ||
| 30 | COLOR=$BLUE | ||
| 31 | PADDING=0 | ||
| 32 | |||
| 33 | if [ "${repo}" = "" ] && [ "${title}" = "" ]; then | ||
| 34 | repo="Note" | ||
| 35 | title="No new notifications" | ||
| 36 | fi | ||
| 37 | case "${type}" in | ||
| 38 | "'Issue'") COLOR=$GREEN; ICON=$GIT_ISSUE; URL="$(gh api "$(echo "${url}" | sed -e "s/^'//" -e "s/'$//")" | jq .html_url)" | ||
| 39 | ;; | ||
| 40 | "'Discussion'") COLOR=$WHITE; ICON=$GIT_DISCUSSION; URL="https://www.github.com/notifications" | ||
| 41 | ;; | ||
| 42 | "'PullRequest'") COLOR=$MAGENTA; ICON=$GIT_PULL_REQUEST; URL="$(gh api "$(echo "${url}" | sed -e "s/^'//" -e "s/'$//")" | jq .html_url)" | ||
| 43 | ;; | ||
| 44 | "'Commit'") COLOR=$WHITE; ICON=$GIT_COMMIT; URL="$(gh api "$(echo "${url}" | sed -e "s/^'//" -e "s/'$//")" | jq .html_url)" | ||
| 45 | ;; | ||
| 46 | esac | ||
| 47 | |||
| 48 | if [ "$IMPORTANT" != "" ]; then | ||
| 49 | COLOR=$RED | ||
| 50 | ICON= | ||
| 51 | args+=(--set github.bell icon.color=$COLOR) | ||
| 52 | fi | ||
| 53 | |||
| 54 | args+=(--clone github.notification.$COUNTER github.template \ | ||
| 55 | --set github.notification.$COUNTER label="$(echo "$title" | sed -e "s/^'//" -e "s/'$//")" \ | ||
| 56 | icon="$ICON $(echo "$repo" | sed -e "s/^'//" -e "s/'$//"):" \ | ||
| 57 | icon.padding_left="$PADDING" \ | ||
| 58 | label.padding_right="$PADDING" \ | ||
| 59 | icon.color=$COLOR \ | ||
| 60 | position=popup.github.bell \ | ||
| 61 | icon.background.color=$COLOR \ | ||
| 62 | drawing=on \ | ||
| 63 | click_script="open $URL; | ||
| 64 | sketchybar --set github.bell popup.drawing=off") | ||
| 65 | done <<< "$(echo "$NOTIFICATIONS" | jq -r '.[] | [.repository.name, .subject.latest_comment_url, .subject.type, .subject.title] | @sh')" | ||
| 66 | |||
| 67 | sketchybar -m "${args[@]}" | ||
| 68 | |||
| 69 | if [ $COUNT -gt $PREV_COUNT ] 2>/dev/null || [ "$SENDER" = "forced" ]; then | ||
| 70 | sketchybar --animate tanh 15 --set github.bell label.y_offset=5 label.y_offset=0 | ||
| 71 | fi | ||
| 72 | } | ||
| 73 | |||
| 74 | popup() { | ||
| 75 | sketchybar --set $NAME popup.drawing=$1 | ||
| 76 | } | ||
| 77 | |||
| 78 | case "$SENDER" in | ||
| 79 | "routine"|"forced") update | ||
| 80 | ;; | ||
| 81 | "mouse.entered") popup on | ||
| 82 | ;; | ||
| 83 | "mouse.exited"|"mouse.exited.global") popup off | ||
| 84 | ;; | ||
| 85 | "mouse.clicked") popup toggle | ||
| 86 | ;; | ||
| 87 | esac | ||
files/sketchybar/plugins/executable_icon_map.sh created+381| ... | @@ -0,0 +1,381 @@ | ||
| 1 | case "$1" in | ||
| 2 | "Brave Browser") | ||
| 3 | icon_result=":brave_browser:" | ||
| 4 | ;; | ||
| 5 | "Keyboard Maestro") | ||
| 6 | icon_result=":keyboard_maestro:" | ||
| 7 | ;; | ||
| 8 | "Min") | ||
| 9 | icon_result=":min_browser:" | ||
| 10 | ;; | ||
| 11 | "Final Cut Pro") | ||
| 12 | icon_result=":final_cut_pro:" | ||
| 13 | ;; | ||
| 14 | "FaceTime") | ||
| 15 | icon_result=":face_time:" | ||
| 16 | ;; | ||
| 17 | "Affinity Publisher") | ||
| 18 | icon_result=":affinity_publisher:" | ||
| 19 | ;; | ||
| 20 | "Messages" | "Nachrichten") | ||
| 21 | icon_result=":messages:" | ||
| 22 | ;; | ||
| 23 | "Tweetbot" | "Twitter") | ||
| 24 | icon_result=":twitter:" | ||
| 25 | ;; | ||
| 26 | "ClickUp") | ||
| 27 | icon_result=":click_up:" | ||
| 28 | ;; | ||
| 29 | "KeePassXC") | ||
| 30 | icon_result=":kee_pass_x_c:" | ||
| 31 | ;; | ||
| 32 | "Microsoft Edge") | ||
| 33 | icon_result=":microsoft_edge:" | ||
| 34 | ;; | ||
| 35 | "VLC") | ||
| 36 | icon_result=":vlc:" | ||
| 37 | ;; | ||
| 38 | "Emacs") | ||
| 39 | icon_result=":emacs:" | ||
| 40 | ;; | ||
| 41 | "Thunderbird") | ||
| 42 | icon_result=":thunderbird:" | ||
| 43 | ;; | ||
| 44 | "Notes") | ||
| 45 | icon_result=":notes:" | ||
| 46 | ;; | ||
| 47 | "Caprine") | ||
| 48 | icon_result=":caprine:" | ||
| 49 | ;; | ||
| 50 | "Zulip") | ||
| 51 | icon_result=":zulip:" | ||
| 52 | ;; | ||
| 53 | "Spark") | ||
| 54 | icon_result=":spark:" | ||
| 55 | ;; | ||
| 56 | "Microsoft To Do" | "Things") | ||
| 57 | icon_result=":things:" | ||
| 58 | ;; | ||
| 59 | "DEVONthink 3") | ||
| 60 | icon_result=":devonthink3:" | ||
| 61 | ;; | ||
| 62 | "GitHub Desktop") | ||
| 63 | icon_result=":git_hub:" | ||
| 64 | ;; | ||
| 65 | "App Store") | ||
| 66 | icon_result=":app_store:" | ||
| 67 | ;; | ||
| 68 | "Chromium" | "Google Chrome" | "Google Chrome Canary") | ||
| 69 | icon_result=":google_chrome:" | ||
| 70 | ;; | ||
| 71 | "zoom.us") | ||
| 72 | icon_result=":zoom:" | ||
| 73 | ;; | ||
| 74 | "MoneyMoney") | ||
| 75 | icon_result=":bank:" | ||
| 76 | ;; | ||
| 77 | "Color Picker") | ||
| 78 | icon_result=":color_picker:" | ||
| 79 | ;; | ||
| 80 | "Microsoft Word") | ||
| 81 | icon_result=":microsoft_word:" | ||
| 82 | ;; | ||
| 83 | "Iris") | ||
| 84 | icon_result=":iris:" | ||
| 85 | ;; | ||
| 86 | "WebStorm") | ||
| 87 | icon_result=":web_storm:" | ||
| 88 | ;; | ||
| 89 | "Neovide" | "MacVim" | "Vim" | "VimR") | ||
| 90 | icon_result=":vim:" | ||
| 91 | ;; | ||
| 92 | "Sublime Text") | ||
| 93 | icon_result=":sublime_text:" | ||
| 94 | ;; | ||
| 95 | "PomoDone App") | ||
| 96 | icon_result=":pomodone:" | ||
| 97 | ;; | ||
| 98 | "Setapp") | ||
| 99 | icon_result=":setapp:" | ||
| 100 | ;; | ||
| 101 | "qutebrowser") | ||
| 102 | icon_result=":qute_browser:" | ||
| 103 | ;; | ||
| 104 | "Mattermost") | ||
| 105 | icon_result=":mattermost:" | ||
| 106 | ;; | ||
| 107 | "Notability") | ||
| 108 | icon_result=":notability:" | ||
| 109 | ;; | ||
| 110 | "WhatsApp") | ||
| 111 | icon_result=":whats_app:" | ||
| 112 | ;; | ||
| 113 | "OBS") | ||
| 114 | icon_result=":obsstudio:" | ||
| 115 | ;; | ||
| 116 | "Parallels Desktop") | ||
| 117 | icon_result=":parallels:" | ||
| 118 | ;; | ||
| 119 | "VMware Fusion") | ||
| 120 | icon_result=":vmware_fusion:" | ||
| 121 | ;; | ||
| 122 | "Pine") | ||
| 123 | icon_result=":pine:" | ||
| 124 | ;; | ||
| 125 | "Microsoft Excel") | ||
| 126 | icon_result=":microsoft_excel:" | ||
| 127 | ;; | ||
| 128 | "Microsoft PowerPoint") | ||
| 129 | icon_result=":microsoft_power_point:" | ||
| 130 | ;; | ||
| 131 | "Matlab") | ||
| 132 | icon_result=":matlab:" | ||
| 133 | ;; | ||
| 134 | "Numbers") | ||
| 135 | icon_result=":numbers:" | ||
| 136 | ;; | ||
| 137 | "Default") | ||
| 138 | icon_result=":default:" | ||
| 139 | ;; | ||
| 140 | "Element") | ||
| 141 | icon_result=":element:" | ||
| 142 | ;; | ||
| 143 | "Bear") | ||
| 144 | icon_result=":bear:" | ||
| 145 | ;; | ||
| 146 | "TeamSpeak 3") | ||
| 147 | icon_result=":team_speak:" | ||
| 148 | ;; | ||
| 149 | "Airmail") | ||
| 150 | icon_result=":airmail:" | ||
| 151 | ;; | ||
| 152 | "Firefox Developer Edition" | "Firefox Nightly") | ||
| 153 | icon_result=":firefox_developer_edition:" | ||
| 154 | ;; | ||
| 155 | "Trello") | ||
| 156 | icon_result=":trello:" | ||
| 157 | ;; | ||
| 158 | "TickTick") | ||
| 159 | icon_result=":tick_tick:" | ||
| 160 | ;; | ||
| 161 | "Notion") | ||
| 162 | icon_result=":notion:" | ||
| 163 | ;; | ||
| 164 | "Live") | ||
| 165 | icon_result=":ableton:" | ||
| 166 | ;; | ||
| 167 | "Evernote Legacy") | ||
| 168 | icon_result=":evernote_legacy:" | ||
| 169 | ;; | ||
| 170 | "Calendar" | "Fantastical") | ||
| 171 | icon_result=":calendar:" | ||
| 172 | ;; | ||
| 173 | "Android Studio") | ||
| 174 | icon_result=":android_studio:" | ||
| 175 | ;; | ||
| 176 | "Xcode") | ||
| 177 | icon_result=":xcode:" | ||
| 178 | ;; | ||
| 179 | "Slack") | ||
| 180 | icon_result=":slack:" | ||
| 181 | ;; | ||
| 182 | "Sequel Pro") | ||
| 183 | icon_result=":sequel_pro:" | ||
| 184 | ;; | ||
| 185 | "Bitwarden") | ||
| 186 | icon_result=":bit_warden:" | ||
| 187 | ;; | ||
| 188 | "System Preferences") | ||
| 189 | icon_result=":gear:" | ||
| 190 | ;; | ||
| 191 | "Discord" | "Discord Canary" | "Discord PTB") | ||
| 192 | icon_result=":discord:" | ||
| 193 | ;; | ||
| 194 | "Vivaldi") | ||
| 195 | icon_result=":vivaldi:" | ||
| 196 | ;; | ||
| 197 | "Firefox") | ||
| 198 | icon_result=":firefox:" | ||
| 199 | ;; | ||
| 200 | "Skype") | ||
| 201 | icon_result=":skype:" | ||
| 202 | ;; | ||
| 203 | "Dropbox") | ||
| 204 | icon_result=":dropbox:" | ||
| 205 | ;; | ||
| 206 | "微信") | ||
| 207 | icon_result=":wechat:" | ||
| 208 | ;; | ||
| 209 | "Typora") | ||
| 210 | icon_result=":text:" | ||
| 211 | ;; | ||
| 212 | "Blender") | ||
| 213 | icon_result=":blender:" | ||
| 214 | ;; | ||
| 215 | "Canary Mail" | "HEY" | "Mail" | "Mailspring" | "MailMate" | "邮件") | ||
| 216 | icon_result=":mail:" | ||
| 217 | ;; | ||
| 218 | "Safari" | "Safari Technology Preview") | ||
| 219 | icon_result=":safari:" | ||
| 220 | ;; | ||
| 221 | "Telegram") | ||
| 222 | icon_result=":telegram:" | ||
| 223 | ;; | ||
| 224 | "Keynote") | ||
| 225 | icon_result=":keynote:" | ||
| 226 | ;; | ||
| 227 | "Reeder") | ||
| 228 | icon_result=":reeder5:" | ||
| 229 | ;; | ||
| 230 | "Spotify") | ||
| 231 | icon_result=":spotify:" | ||
| 232 | ;; | ||
| 233 | "MAMP" | "MAMP PRO") | ||
| 234 | icon_result=":mamp:" | ||
| 235 | ;; | ||
| 236 | "Figma") | ||
| 237 | icon_result=":figma:" | ||
| 238 | ;; | ||
| 239 | "Joplin") | ||
| 240 | icon_result=":joplin:" | ||
| 241 | ;; | ||
| 242 | "Spotlight") | ||
| 243 | icon_result=":spotlight:" | ||
| 244 | ;; | ||
| 245 | "Music") | ||
| 246 | icon_result=":music:" | ||
| 247 | ;; | ||
| 248 | "Insomnia") | ||
| 249 | icon_result=":insomnia:" | ||
| 250 | ;; | ||
| 251 | "TIDAL") | ||
| 252 | icon_result=":tidal:" | ||
| 253 | ;; | ||
| 254 | "Alfred") | ||
| 255 | icon_result=":alfred:" | ||
| 256 | ;; | ||
| 257 | "Pages") | ||
| 258 | icon_result=":pages:" | ||
| 259 | ;; | ||
| 260 | "Folx") | ||
| 261 | icon_result=":folx:" | ||
| 262 | ;; | ||
| 263 | "Android Messages") | ||
| 264 | icon_result=":android_messages:" | ||
| 265 | ;; | ||
| 266 | "mpv") | ||
| 267 | icon_result=":mpv:" | ||
| 268 | ;; | ||
| 269 | "网易云音乐") | ||
| 270 | icon_result=":netease_music:" | ||
| 271 | ;; | ||
| 272 | "Transmit") | ||
| 273 | icon_result=":transmit:" | ||
| 274 | ;; | ||
| 275 | "Pi-hole Remote") | ||
| 276 | icon_result=":pihole:" | ||
| 277 | ;; | ||
| 278 | "Nova") | ||
| 279 | icon_result=":nova:" | ||
| 280 | ;; | ||
| 281 | "Affinity Designer") | ||
| 282 | icon_result=":affinity_designer:" | ||
| 283 | ;; | ||
| 284 | "IntelliJ IDEA") | ||
| 285 | icon_result=":idea:" | ||
| 286 | ;; | ||
| 287 | "Drafts") | ||
| 288 | icon_result=":drafts:" | ||
| 289 | ;; | ||
| 290 | "Audacity") | ||
| 291 | icon_result=":audacity:" | ||
| 292 | ;; | ||
| 293 | "Affinity Photo") | ||
| 294 | icon_result=":affinity_photo:" | ||
| 295 | ;; | ||
| 296 | "Atom") | ||
| 297 | icon_result=":atom:" | ||
| 298 | ;; | ||
| 299 | "Obsidian") | ||
| 300 | icon_result=":obsidian:" | ||
| 301 | ;; | ||
| 302 | "CleanMyMac X") | ||
| 303 | icon_result=":desktop:" | ||
| 304 | ;; | ||
| 305 | "Zotero") | ||
| 306 | icon_result=":zotero:" | ||
| 307 | ;; | ||
| 308 | "Todoist") | ||
| 309 | icon_result=":todoist:" | ||
| 310 | ;; | ||
| 311 | "LibreWolf") | ||
| 312 | icon_result=":libre_wolf:" | ||
| 313 | ;; | ||
| 314 | "Grammarly Editor") | ||
| 315 | icon_result=":grammarly:" | ||
| 316 | ;; | ||
| 317 | "OmniFocus") | ||
| 318 | icon_result=":omni_focus:" | ||
| 319 | ;; | ||
| 320 | "Reminders") | ||
| 321 | icon_result=":reminders:" | ||
| 322 | ;; | ||
| 323 | "Preview" | "Skim" | "zathura") | ||
| 324 | icon_result=":pdf:" | ||
| 325 | ;; | ||
| 326 | "1Password 7") | ||
| 327 | icon_result=":one_password:" | ||
| 328 | ;; | ||
| 329 | "Code" | "Code - Insiders") | ||
| 330 | icon_result=":code:" | ||
| 331 | ;; | ||
| 332 | "VSCodium") | ||
| 333 | icon_result=":vscodium:" | ||
| 334 | ;; | ||
| 335 | "Tower") | ||
| 336 | icon_result=":tower:" | ||
| 337 | ;; | ||
| 338 | "Calibre") | ||
| 339 | icon_result=":book:" | ||
| 340 | ;; | ||
| 341 | "Finder" | "访达") | ||
| 342 | icon_result=":finder:" | ||
| 343 | ;; | ||
| 344 | "Linear") | ||
| 345 | icon_result=":linear:" | ||
| 346 | ;; | ||
| 347 | "League of Legends") | ||
| 348 | icon_result=":league_of_legends:" | ||
| 349 | ;; | ||
| 350 | "Zeplin") | ||
| 351 | icon_result=":zeplin:" | ||
| 352 | ;; | ||
| 353 | "Signal") | ||
| 354 | icon_result=":signal:" | ||
| 355 | ;; | ||
| 356 | "Podcasts") | ||
| 357 | icon_result=":podcasts:" | ||
| 358 | ;; | ||
| 359 | "Alacritty" | "Hyper" | "iTerm2" | "kitty" | "Terminal" | "WezTerm") | ||
| 360 | icon_result=":terminal:" | ||
| 361 | ;; | ||
| 362 | "Tor Browser") | ||
| 363 | icon_result=":tor_browser:" | ||
| 364 | ;; | ||
| 365 | "Kakoune") | ||
| 366 | icon_result=":kakoune:" | ||
| 367 | ;; | ||
| 368 | "GrandTotal" | "Receipts") | ||
| 369 | icon_result=":dollar:" | ||
| 370 | ;; | ||
| 371 | "Sketch") | ||
| 372 | icon_result=":sketch:" | ||
| 373 | ;; | ||
| 374 | "Sequel Ace") | ||
| 375 | icon_result=":sequel_ace:" | ||
| 376 | ;; | ||
| 377 | *) | ||
| 378 | icon_result=":default:" | ||
| 379 | ;; | ||
| 380 | esac | ||
| 381 | echo $icon_result | ||
files/sketchybar/plugins/executable_space.sh created+8| ... | @@ -0,0 +1,8 @@ | ||
| 1 | #!/usr/bin/env sh | ||
| 2 | |||
| 3 | WIDTH="dynamic" | ||
| 4 | if [ "$SELECTED" = "true" ]; then | ||
| 5 | WIDTH="0" | ||
| 6 | fi | ||
| 7 | |||
| 8 | sketchybar --animate tanh 20 --set $NAME icon.highlight=$SELECTED label.width=$WIDTH | ||
files/sketchybar/plugins/executable_spotify.sh created+114| ... | @@ -0,0 +1,114 @@ | ||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | next () | ||
| 4 | { | ||
| 5 | osascript -e 'tell application "Spotify" to play next track' | ||
| 6 | } | ||
| 7 | |||
| 8 | back () | ||
| 9 | { | ||
| 10 | osascript -e 'tell application "Spotify" to play previous track' | ||
| 11 | } | ||
| 12 | |||
| 13 | play () | ||
| 14 | { | ||
| 15 | osascript -e 'tell application "Spotify" to playpause' | ||
| 16 | } | ||
| 17 | |||
| 18 | repeat () | ||
| 19 | { | ||
| 20 | REPEAT=$(osascript -e 'tell application "Spotify" to get repeating') | ||
| 21 | if [ "$REPEAT" = "false" ]; then | ||
| 22 | sketchybar -m --set spotify.repeat icon.highlight=on | ||
| 23 | osascript -e 'tell application "Spotify" to set repeating to true' | ||
| 24 | else | ||
| 25 | sketchybar -m --set spotify.repeat icon.highlight=off | ||
| 26 | osascript -e 'tell application "Spotify" to set repeating to false' | ||
| 27 | fi | ||
| 28 | } | ||
| 29 | |||
| 30 | shuffle () | ||
| 31 | { | ||
| 32 | SHUFFLE=$(osascript -e 'tell application "Spotify" to get shuffling') | ||
| 33 | if [ "$SHUFFLE" = "false" ]; then | ||
| 34 | sketchybar -m --set spotify.shuffle icon.highlight=on | ||
| 35 | osascript -e 'tell application "Spotify" to set shuffling to true' | ||
| 36 | else | ||
| 37 | sketchybar -m --set spotify.shuffle icon.highlight=off | ||
| 38 | osascript -e 'tell application "Spotify" to set shuffling to false' | ||
| 39 | fi | ||
| 40 | } | ||
| 41 | |||
| 42 | update () | ||
| 43 | { | ||
| 44 | PLAYING=1 | ||
| 45 | if [ "$(echo "$INFO" | jq -r '.["Player State"]')" = "Playing" ]; then | ||
| 46 | PLAYING=0 | ||
| 47 | TRACK="$(echo "$INFO" | jq -r .Name | sed 's/\(.\{20\}\).*/\1.../')" | ||
| 48 | ARTIST="$(echo "$INFO" | jq -r .Artist | sed 's/\(.\{20\}\).*/\1.../')" | ||
| 49 | ALBUM="$(echo "$INFO" | jq -r .Album | sed 's/\(.\{25\}\).*/\1.../')" | ||
| 50 | SHUFFLE=$(osascript -e 'tell application "Spotify" to get shuffling') | ||
| 51 | REPEAT=$(osascript -e 'tell application "Spotify" to get repeating') | ||
| 52 | COVER=$(osascript -e 'tell application "Spotify" to get artwork url of current track') | ||
| 53 | fi | ||
| 54 | |||
| 55 | args=() | ||
| 56 | if [ $PLAYING -eq 0 ]; then | ||
| 57 | curl -s --max-time 20 "$COVER" -o /tmp/cover.jpg | ||
| 58 | if [ "$ARTIST" == "" ]; then | ||
| 59 | args+=(--set spotify.title label="$TRACK" drawing=on \ | ||
| 60 | --set spotify.album label="Podcast" drawing=on \ | ||
| 61 | --set spotify.artist label="$ALBUM" drawing=on ) | ||
| 62 | else | ||
| 63 | args+=(--set spotify.title label="$TRACK" drawing=on \ | ||
| 64 | --set spotify.album label="$ALBUM" drawing=on \ | ||
| 65 | --set spotify.artist label="$ARTIST" drawing=on) | ||
| 66 | fi | ||
| 67 | args+=(--set spotify.play icon= \ | ||
| 68 | --set spotify.shuffle icon.highlight=$SHUFFLE \ | ||
| 69 | --set spotify.repeat icon.highlight=$REPEAT \ | ||
| 70 | --set spotify.cover background.image="/tmp/cover.jpg" \ | ||
| 71 | background.color=0x00000000 \ | ||
| 72 | --set spotify.anchor icon.drawing=on \ | ||
| 73 | drawing=on \ | ||
| 74 | --set spotify drawing=on ) | ||
| 75 | else | ||
| 76 | args+=(--set spotify.title drawing=off \ | ||
| 77 | --set spotify.artist drawing=off \ | ||
| 78 | --set spotify.anchor drawing=off popup.drawing=off \ | ||
| 79 | --set spotify.play icon= ) | ||
| 80 | fi | ||
| 81 | sketchybar -m "${args[@]}" | ||
| 82 | } | ||
| 83 | |||
| 84 | mouse_clicked () { | ||
| 85 | case "$NAME" in | ||
| 86 | "spotify.next") next | ||
| 87 | ;; | ||
| 88 | "spotify.back") back | ||
| 89 | ;; | ||
| 90 | "spotify.play") play | ||
| 91 | ;; | ||
| 92 | "spotify.shuffle") shuffle | ||
| 93 | ;; | ||
| 94 | "spotify.repeat") repeat | ||
| 95 | ;; | ||
| 96 | *) exit | ||
| 97 | ;; | ||
| 98 | esac | ||
| 99 | } | ||
| 100 | |||
| 101 | popup () { | ||
| 102 | sketchybar --set spotify.anchor popup.drawing=$1 | ||
| 103 | } | ||
| 104 | |||
| 105 | case "$SENDER" in | ||
| 106 | "mouse.clicked") mouse_clicked | ||
| 107 | ;; | ||
| 108 | "mouse.entered") popup on | ||
| 109 | ;; | ||
| 110 | "mouse.exited"|"mouse.exited.global") popup off | ||
| 111 | ;; | ||
| 112 | *) update | ||
| 113 | ;; | ||
| 114 | esac | ||
files/sketchybar/plugins/executable_volume.sh created+23| ... | @@ -0,0 +1,23 @@ | ||
| 1 | #!/usr/bin/env sh | ||
| 2 | |||
| 3 | WIDTH=100 | ||
| 4 | |||
| 5 | volume_change() { | ||
| 6 | INITIAL_WIDTH=$(sketchybar --query $NAME | jq ".icon.width") | ||
| 7 | if [ "$INITIAL_WIDTH" -eq "0" ]; then | ||
| 8 | sketchybar --animate tanh 30 --set $NAME width=$WIDTH icon.width=$INFO | ||
| 9 | else | ||
| 10 | sketchybar --set $NAME icon.width=$INFO width=$WIDTH | ||
| 11 | fi | ||
| 12 | |||
| 13 | sleep 5 | ||
| 14 | FINAL_WIDTH=$(sketchybar --query $NAME | jq ".icon.width") | ||
| 15 | if [ "$FINAL_WIDTH" -eq "$INFO" ]; then | ||
| 16 | sketchybar --animate tanh 30 --set $NAME width=0 icon.width=0 | ||
| 17 | fi | ||
| 18 | } | ||
| 19 | |||
| 20 | case "$SENDER" in | ||
| 21 | "volume_change") volume_change | ||
| 22 | ;; | ||
| 23 | esac | ||
files/sketchybar/plugins/executable_volume_click.sh created+9| ... | @@ -0,0 +1,9 @@ | ||
| 1 | #!/usr/bin/env sh | ||
| 2 | |||
| 3 | MUTED=$(osascript -e 'output muted of (get volume settings)') | ||
| 4 | |||
| 5 | if [ "$MUTED" = "false" ]; then | ||
| 6 | osascript -e 'set volume output muted true' | ||
| 7 | else | ||
| 8 | osascript -e 'set volume output muted false' | ||
| 9 | fi | ||
files/sketchybar/plugins/executable_yabai.sh created+76| ... | @@ -0,0 +1,76 @@ | ||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | window_state() { | ||
| 4 | source "$HOME/.config/sketchybar/colors.sh" | ||
| 5 | source "$HOME/.config/sketchybar/icons.sh" | ||
| 6 | |||
| 7 | WINDOW=$(yabai -m query --windows --window) | ||
| 8 | CURRENT=$(echo "$WINDOW" | jq '.["stack-index"]') | ||
| 9 | |||
| 10 | args=() | ||
| 11 | if [[ $CURRENT -gt 0 ]]; then | ||
| 12 | LAST=$(yabai -m query --windows --window stack.last | jq '.["stack-index"]') | ||
| 13 | args+=(--set $NAME icon=$YABAI_STACK icon.color=$RED label.drawing=on label=$(printf "[%s/%s]" "$CURRENT" "$LAST")) | ||
| 14 | yabai -m config active_window_border_color $RED > /dev/null 2>&1 & | ||
| 15 | |||
| 16 | else | ||
| 17 | args+=(--set $NAME label.drawing=off) | ||
| 18 | case "$(echo "$WINDOW" | jq '.["is-floating"]')" in | ||
| 19 | "false") | ||
| 20 | if [ "$(echo "$WINDOW" | jq '.["has-fullscreen-zoom"]')" = "true" ]; then | ||
| 21 | args+=(--set $NAME icon=$YABAI_FULLSCREEN_ZOOM icon.color=$GREEN) | ||
| 22 | yabai -m config active_window_border_color $GREEN > /dev/null 2>&1 & | ||
| 23 | elif [ "$(echo "$WINDOW" | jq '.["has-parent-zoom"]')" = "true" ]; then | ||
| 24 | args+=(--set $NAME icon=$YABAI_PARENT_ZOOM icon.color=$BLUE) | ||
| 25 | yabai -m config active_window_border_color $BLUE > /dev/null 2>&1 & | ||
| 26 | else | ||
| 27 | args+=(--set $NAME icon=$YABAI_GRID icon.color=$ORANGE) | ||
| 28 | yabai -m config active_window_border_color $WHITE > /dev/null 2>&1 & | ||
| 29 | fi | ||
| 30 | ;; | ||
| 31 | "true") | ||
| 32 | args+=(--set $NAME icon=$YABAI_FLOAT icon.color=$MAGENTA) | ||
| 33 | yabai -m config active_window_border_color $MAGENTA > /dev/null 2>&1 & | ||
| 34 | ;; | ||
| 35 | esac | ||
| 36 | fi | ||
| 37 | |||
| 38 | sketchybar -m "${args[@]}" | ||
| 39 | } | ||
| 40 | |||
| 41 | windows_on_spaces () { | ||
| 42 | CURRENT_SPACES="$(yabai -m query --displays | jq -r '.[].spaces | @sh')" | ||
| 43 | |||
| 44 | args=() | ||
| 45 | while read -r line | ||
| 46 | do | ||
| 47 | for space in $line | ||
| 48 | do | ||
| 49 | icon_strip=" " | ||
| 50 | apps=$(yabai -m query --windows --space $space | jq -r ".[].app") | ||
| 51 | for app in $apps | ||
| 52 | do | ||
| 53 | icon_strip+=" $($HOME/.config/sketchybar/plugins/icon_map.sh "$app")" | ||
| 54 | done | ||
| 55 | args+=(--set space.$space label="$icon_strip" label.drawing=on) | ||
| 56 | done | ||
| 57 | done <<< "$CURRENT_SPACES" | ||
| 58 | |||
| 59 | sketchybar -m "${args[@]}" | ||
| 60 | } | ||
| 61 | |||
| 62 | mouse_clicked() { | ||
| 63 | yabai -m window --toggle float | ||
| 64 | update | ||
| 65 | } | ||
| 66 | |||
| 67 | case "$SENDER" in | ||
| 68 | "mouse.clicked") mouse_clicked | ||
| 69 | ;; | ||
| 70 | "forced") exit 0 | ||
| 71 | ;; | ||
| 72 | "window_focus") window_state | ||
| 73 | ;; | ||
| 74 | "windows_on_spaces") windows_on_spaces | ||
| 75 | ;; | ||
| 76 | esac | ||
files/sketchybar/plugins/executable_zen.sh created+45| ... | @@ -0,0 +1,45 @@ | ||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | zen_on() { | ||
| 4 | sketchybar --set github.bell drawing=off \ | ||
| 5 | --set apple.logo drawing=off \ | ||
| 6 | --set '/cpu.*/' drawing=off \ | ||
| 7 | --set calendar icon.drawing=off \ | ||
| 8 | --set system.yabai drawing=off \ | ||
| 9 | --set separator drawing=off \ | ||
| 10 | --set front_app drawing=off \ | ||
| 11 | --set volume_alias drawing=off \ | ||
| 12 | --set spotify.anchor drawing=off \ | ||
| 13 | --set spotify.play updates=off \ | ||
| 14 | --set brew drawing=off \ | ||
| 15 | --set divider drawing=off \ | ||
| 16 | --bar padding_left=18 | ||
| 17 | } | ||
| 18 | |||
| 19 | zen_off() { | ||
| 20 | sketchybar --set github.bell drawing=on \ | ||
| 21 | --set apple.logo drawing=on \ | ||
| 22 | --set '/cpu.*/' drawing=on \ | ||
| 23 | --set calendar icon.drawing=on \ | ||
| 24 | --set separator drawing=on \ | ||
| 25 | --set front_app drawing=on \ | ||
| 26 | --set system.yabai drawing=on \ | ||
| 27 | --set volume_alias drawing=on \ | ||
| 28 | --set spotify.play updates=on \ | ||
| 29 | --set brew drawing=on \ | ||
| 30 | --set divider drawing=on \ | ||
| 31 | --bar padding_left=7 | ||
| 32 | } | ||
| 33 | |||
| 34 | if [ "$1" = "on" ]; then | ||
| 35 | zen_on | ||
| 36 | elif [ "$1" = "off" ]; then | ||
| 37 | zen_off | ||
| 38 | else | ||
| 39 | if [ "$(sketchybar --query apple.logo | jq -r ".geometry.drawing")" = "on" ]; then | ||
| 40 | zen_on | ||
| 41 | else | ||
| 42 | zen_off | ||
| 43 | fi | ||
| 44 | fi | ||
| 45 | |||
hosts/laptop/home.nix+16-5| ... | @@ -7,11 +7,14 @@ | ... | @@ -7,11 +7,14 @@ |
| 7 | systemSettings, | 7 | systemSettings, |
| 8 | ... | 8 | ... |
| 9 | }: { | 9 | }: { |
| 10 | imports = [ | 10 | imports = |
| 11 | inputs.nixvim.homeManagerModules.nixvim | 11 | [ |
| 12 | #set up nixvim | 12 | inputs.nixvim.homeManagerModules.nixvim |
| 13 | # ../../modules/nixvim | 13 | #set up nixvim |
| 14 | ]; | 14 | # ../../modules/nixvim |
| 15 | ] | ||
| 16 | ++ lib.optionals userSettings.darwinTiling [../../modules/macos/tiling/sketchybar-home.nix]; | ||
| 17 | |||
| 15 | programs = import ../../modules/shared/homeManagerPrograms.nix {inherit inputs config pkgs lib userSettings systemSettings;}; | 18 | programs = import ../../modules/shared/homeManagerPrograms.nix {inherit inputs config pkgs lib userSettings systemSettings;}; |
| 16 | 19 | ||
| 17 | home = { | 20 | home = { |
| ... | @@ -22,6 +25,14 @@ | ... | @@ -22,6 +25,14 @@ |
| 22 | 25 | ||
| 23 | packages = pkgs.callPackage ../../modules/shared/packages.nix {inherit systemSettings;}; | 26 | packages = pkgs.callPackage ../../modules/shared/packages.nix {inherit systemSettings;}; |
| 24 | 27 | ||
| 28 | # file = { | ||
| 29 | # ".config/sketchybar" = { | ||
| 30 | # source = ../../modules/macos/tiling/sketchybar; | ||
| 31 | # recursive = true; | ||
| 32 | # onChange = "${pkgs.sketchybar}/bin/sketchybar --reload"; | ||
| 33 | # }; | ||
| 34 | # }; | ||
| 35 | |||
| 25 | sessionPath = [ | 36 | sessionPath = [ |
| 26 | "$HOME/.emacs.d/bin" | 37 | "$HOME/.emacs.d/bin" |
| 27 | ]; | 38 | ]; |
modules/macos/system.nix+4| ... | @@ -21,6 +21,10 @@ | ... | @@ -21,6 +21,10 @@ |
| 21 | LSQuarantine = false; | 21 | LSQuarantine = false; |
| 22 | }; | 22 | }; |
| 23 | 23 | ||
| 24 | WindowManager = { | ||
| 25 | EnableStandardClickToShowDesktop = false; | ||
| 26 | }; | ||
| 27 | |||
| 24 | NSGlobalDomain = { | 28 | NSGlobalDomain = { |
| 25 | # Show extensions in finder | 29 | # Show extensions in finder |
| 26 | AppleShowAllExtensions = true; | 30 | AppleShowAllExtensions = true; |
modules/macos/tiling/aerospace.nix+1-1| ... | @@ -29,7 +29,7 @@ | ... | @@ -29,7 +29,7 @@ |
| 29 | outer = { | 29 | outer = { |
| 30 | left = 0; | 30 | left = 0; |
| 31 | bottom = 0; | 31 | bottom = 0; |
| 32 | top = 0; | 32 | top = 40; |
| 33 | right = 0; | 33 | right = 0; |
| 34 | }; | 34 | }; |
| 35 | }; | 35 | }; |
modules/macos/tiling/sketchybar-home.nix created+398| ... | @@ -0,0 +1,398 @@ | ||
| 1 | {pkgs, ...}: let | ||
| 2 | folder = "../../../files/sketchybar/"; | ||
| 3 | in { | ||
| 4 | home.file = { | ||
| 5 | sketchybarrc = { | ||
| 6 | executable = true; | ||
| 7 | target = ".config/sketchybar/sketchybarrc"; | ||
| 8 | text = '' | ||
| 9 | #!/usr/bin/env sh | ||
| 10 | |||
| 11 | source "$HOME/.config/sketchybar/colors.sh" # Loads all defined colors | ||
| 12 | source "$HOME/.config/sketchybar/icons.sh" # Loads all defined icons | ||
| 13 | |||
| 14 | ITEM_DIR="$HOME/.config/sketchybar/items" # Directory where the items are configured | ||
| 15 | PLUGIN_DIR="$HOME/.config/sketchybar/plugins" # Directory where all the plugin scripts are stored | ||
| 16 | |||
| 17 | FONT="SF Pro" # Needs to have Regular, Bold, Semibold, Heavy and Black variants | ||
| 18 | PADDINGS=3 # All paddings use this value (icon, label, background) | ||
| 19 | |||
| 20 | # Setting up and starting the helper process | ||
| 21 | HELPER=git.felix.helper | ||
| 22 | killall helper | ||
| 23 | cd $HOME/.config/sketchybar/helper && make | ||
| 24 | $HOME/.config/sketchybar/helper/helper $HELPER > /dev/null 2>&1 & | ||
| 25 | |||
| 26 | # Unload the macOS on screen indicator overlay for volume change | ||
| 27 | # launchctl unload -F /System/Library/LaunchAgents/com.apple.OSDUIHelper.plist > /dev/null 2>&1 & | ||
| 28 | |||
| 29 | # Setting up the general bar appearance and default values | ||
| 30 | ${pkgs.sketchybar}/bin/sketchybar --bar height=50 \ | ||
| 31 | color=$BAR_COLOR \ | ||
| 32 | shadow=off \ | ||
| 33 | position=top \ | ||
| 34 | sticky=on \ | ||
| 35 | padding_right=7 \ | ||
| 36 | padding_left=7 \ | ||
| 37 | corner_radius=12 \ | ||
| 38 | y_offset=20 \ | ||
| 39 | margin=40 \ | ||
| 40 | blur_radius=0 \ | ||
| 41 | notch_width=0 \ | ||
| 42 | --default updates=when_shown \ | ||
| 43 | icon.font="$FONT:Bold:14.0" \ | ||
| 44 | icon.color=$ICON_COLOR \ | ||
| 45 | icon.padding_left=$PADDINGS \ | ||
| 46 | icon.padding_right=$PADDINGS \ | ||
| 47 | label.font="$FONT:Semibold:13.0" \ | ||
| 48 | label.color=$LABEL_COLOR \ | ||
| 49 | label.padding_left=$PADDINGS \ | ||
| 50 | label.padding_right=$PADDINGS \ | ||
| 51 | background.padding_right=$PADDINGS \ | ||
| 52 | background.padding_left=$PADDINGS \ | ||
| 53 | background.height=26 \ | ||
| 54 | background.corner_radius=9 \ | ||
| 55 | popup.background.border_width=2 \ | ||
| 56 | popup.background.corner_radius=11 \ | ||
| 57 | popup.background.border_color=$POPUP_BORDER_COLOR \ | ||
| 58 | popup.background.color=$POPUP_BACKGROUND_COLOR \ | ||
| 59 | popup.background.shadow.drawing=on | ||
| 60 | |||
| 61 | # Left | ||
| 62 | source "$ITEM_DIR/apple.sh" | ||
| 63 | source "$ITEM_DIR/spaces.sh" | ||
| 64 | source "$ITEM_DIR/front_app.sh" | ||
| 65 | |||
| 66 | # Center | ||
| 67 | # source "$ITEM_DIR/spotify.sh" | ||
| 68 | source "$ITEM_DIR/calendar.sh" | ||
| 69 | |||
| 70 | # Right | ||
| 71 | # source "$ITEM_DIR/brew.sh" | ||
| 72 | # source "$ITEM_DIR/github.sh" | ||
| 73 | source "$ITEM_DIR/volume.sh" | ||
| 74 | # source "$ITEM_DIR/divider.sh" | ||
| 75 | # source "$ITEM_DIR/cpu.sh" | ||
| 76 | |||
| 77 | # Forcing all item scripts to run (never do this outside of sketchybarrc) | ||
| 78 | ${pkgs.sketchybar}/bin/sketchybar --update | ||
| 79 | |||
| 80 | echo "sketchybar configuation loaded.." | ||
| 81 | ''; | ||
| 82 | }; | ||
| 83 | icons = { | ||
| 84 | executable = true; | ||
| 85 | target = ".config/sketchybar/icons.sh"; | ||
| 86 | text = builtins.readFile "${folder}/executable_icons.sh"; | ||
| 87 | }; | ||
| 88 | colors = { | ||
| 89 | executable = true; | ||
| 90 | target = ".config/sketchybar/colors.sh"; | ||
| 91 | text = '' | ||
| 92 | #!/usr/bin/env sh | ||
| 93 | # Color Palette | ||
| 94 | export BLACK=0xff4c4f69 | ||
| 95 | export WHITE=0xffeff1f5 | ||
| 96 | export RED=0xffd20f39 | ||
| 97 | export GREEN=0xff40a02b | ||
| 98 | export BLUE=0xff1e66f5 | ||
| 99 | export YELLOW=0xffdf8e1d | ||
| 100 | export ORANGE=0xfffe640b | ||
| 101 | export MAGENTA=0xffea76cb | ||
| 102 | export GREY=0xff9ca0b0 | ||
| 103 | export TRANSPARENT=0xff000000 | ||
| 104 | export BLUE2=0xff7287fd | ||
| 105 | export FLAMINGO=0xffdd7878 | ||
| 106 | |||
| 107 | # General bar colors | ||
| 108 | export BAR_COLOR=0xeff1f5ff # Color of the bar | ||
| 109 | export ICON_COLOR=0xff4c4f69 | ||
| 110 | export LABEL_COLOR=0xff4c4f69 # Color of all labels | ||
| 111 | export BACKGROUND_1=0xffbcc0cc | ||
| 112 | export BACKGROUND_2=0xffbcc0cc | ||
| 113 | |||
| 114 | export POPUP_BACKGROUND_COLOR=$BLACK | ||
| 115 | export POPUP_BORDER_COLOR=$WHITE | ||
| 116 | |||
| 117 | export SHADOW_COLOR=$BLACK | ||
| 118 | ''; | ||
| 119 | }; | ||
| 120 | items_apple = { | ||
| 121 | executable = true; | ||
| 122 | target = ".config/sketchybar/items/apple.sh"; | ||
| 123 | text = builtins.readFile "${folder}/items/executable_apple.sh"; | ||
| 124 | }; | ||
| 125 | items_brew = { | ||
| 126 | executable = true; | ||
| 127 | target = ".config/sketchybar/items/brew.sh"; | ||
| 128 | text = builtins.readFile "${folder}/items/executable_brew.sh"; | ||
| 129 | }; | ||
| 130 | items_calendar = { | ||
| 131 | executable = true; | ||
| 132 | target = ".config/sketchybar/items/calendar.sh"; | ||
| 133 | text = '' | ||
| 134 | #!/usr/bin/env sh | ||
| 135 | |||
| 136 | sketchybar --add item calendar center \ | ||
| 137 | --set calendar icon=cal \ | ||
| 138 | display=1 \ | ||
| 139 | icon.font="$FONT:Black:12.0" \ | ||
| 140 | icon.padding_right=0 \ | ||
| 141 | label.width=50 \ | ||
| 142 | label.align=right \ | ||
| 143 | background.padding_left=15 \ | ||
| 144 | update_freq=30 \ | ||
| 145 | script="$PLUGIN_DIR/calendar.sh" \ | ||
| 146 | click_script="$PLUGIN_DIR/zen.sh" | ||
| 147 | ''; | ||
| 148 | }; | ||
| 149 | items_cpu = { | ||
| 150 | executable = true; | ||
| 151 | target = ".config/sketchybar/items/cpu.sh"; | ||
| 152 | text = builtins.readFile "${folder}/items/executable_cpu.sh"; | ||
| 153 | }; | ||
| 154 | items_divider = { | ||
| 155 | executable = true; | ||
| 156 | target = ".config/sketchybar/items/divider.sh"; | ||
| 157 | text = builtins.readFile "${folder}/items/executable_divider.sh"; | ||
| 158 | }; | ||
| 159 | items_front_app = { | ||
| 160 | executable = true; | ||
| 161 | target = ".config/sketchybar/items/front_app.sh"; | ||
| 162 | text = '' | ||
| 163 | #!/usr/bin/env sh | ||
| 164 | FRONT_APP_SCRIPT='sketchybar --set $NAME label="$INFO"' | ||
| 165 | sketchybar --add event window_focus \ | ||
| 166 | --add event windows_on_spaces \ | ||
| 167 | --add item system.aerospace left \ | ||
| 168 | --set system.aerospace script="$PLUGIN_DIR/yabai.sh" \ | ||
| 169 | icon.font="$FONT:Bold:16.0" \ | ||
| 170 | label.drawing=off \ | ||
| 171 | icon.width=30 \ | ||
| 172 | icon=$YABAI_GRID \ | ||
| 173 | icon.color=$BLACK \ | ||
| 174 | updates=on \ | ||
| 175 | display=active \ | ||
| 176 | --subscribe system.aerospace window_focus \ | ||
| 177 | windows_on_spaces \ | ||
| 178 | mouse.clicked \ | ||
| 179 | --add item front_app left \ | ||
| 180 | --set front_app script="$FRONT_APP_SCRIPT" \ | ||
| 181 | icon.drawing=off \ | ||
| 182 | background.padding_left=0 \ | ||
| 183 | background.padding_right=10 \ | ||
| 184 | label.color=$BLACK \ | ||
| 185 | label.font="$FONT:Black:12.0" \ | ||
| 186 | display=active \ | ||
| 187 | --subscribe front_app front_app_switched | ||
| 188 | ''; | ||
| 189 | }; | ||
| 190 | items_github = { | ||
| 191 | executable = true; | ||
| 192 | target = ".config/sketchybar/items/github.sh"; | ||
| 193 | text = builtins.readFile "${folder}/items/executable_github.sh"; | ||
| 194 | }; | ||
| 195 | items_spaces = { | ||
| 196 | executable = true; | ||
| 197 | target = ".config/sketchybar/items/spaces.sh"; | ||
| 198 | # label.background.color=$BACKGROUND_2 | ||
| 199 | text = '' | ||
| 200 | ${pkgs.sketchybar}/bin/sketchybar --add event aerospace_workspace_change | ||
| 201 | ${pkgs.sketchybar}/bin/sketchybar --add event aerospace_mode_change | ||
| 202 | for sid in $(${pkgs.aerospace}/bin/aerospace list-workspaces --all); do | ||
| 203 | ${pkgs.sketchybar}/bin/sketchybar --add item space.$sid left \ | ||
| 204 | --subscribe space.$sid aerospace_workspace_change \ | ||
| 205 | --subscribe space.$sid aerospace_mode_change \ | ||
| 206 | --set space.$sid \ | ||
| 207 | icon=$sid \ | ||
| 208 | icon.padding_left=22 \ | ||
| 209 | icon.padding_right=22 \ | ||
| 210 | icon.highlight_color=$WHITE \ | ||
| 211 | icon.highlight=off \ | ||
| 212 | icon.color=0xff4c566a \ | ||
| 213 | background.padding_left=-8 \ | ||
| 214 | background.padding_right=-8 \ | ||
| 215 | background.color=$BACKGROUND_1 \ | ||
| 216 | background.drawing=on \ | ||
| 217 | script="$PLUGIN_DIR/aerospace.sh $sid" \ | ||
| 218 | click_script="aerospace workspace $sid" \ | ||
| 219 | label.font="JetBrainsMono Nerd Font:Regular:16.0" \ | ||
| 220 | label.padding_right=33 \ | ||
| 221 | label.background.height=26 \ | ||
| 222 | label.background.drawing=on \ | ||
| 223 | label.background.corner_radius=9 \ | ||
| 224 | label.drawing=off | ||
| 225 | done | ||
| 226 | ${pkgs.sketchybar}/bin/sketchybar --add item separator left \ | ||
| 227 | --set separator icon= \ | ||
| 228 | icon.font="JetBrainsMono Nerd Font:Regular:16.0" \ | ||
| 229 | background.padding_left=26 \ | ||
| 230 | background.padding_right=15 \ | ||
| 231 | label.drawing=off \ | ||
| 232 | display=active \ | ||
| 233 | icon.color=$GREEN | ||
| 234 | ''; | ||
| 235 | }; | ||
| 236 | items_spotify = { | ||
| 237 | executable = true; | ||
| 238 | target = ".config/sketchybar/items/spotify.sh"; | ||
| 239 | text = builtins.readFile "${folder}/items/executable_spotify.sh"; | ||
| 240 | }; | ||
| 241 | items_volume = { | ||
| 242 | executable = true; | ||
| 243 | target = ".config/sketchybar/items/volume.sh"; | ||
| 244 | text = '' | ||
| 245 | INITIAL_WIDTH=$(osascript -e 'set ovol to output volume of (get volume settings)') | ||
| 246 | ${pkgs.sketchybar}/bin/sketchybar --add item volume right \ | ||
| 247 | --subscribe volume volume_change \ | ||
| 248 | --set volume script="$PLUGIN_DIR/volume.sh" \ | ||
| 249 | updates=on \ | ||
| 250 | icon.background.drawing=on \ | ||
| 251 | icon.background.color=$FLAMINGO \ | ||
| 252 | icon.background.height=8 \ | ||
| 253 | icon.background.corner_radius=3 \ | ||
| 254 | icon.width=$INITIAL_WIDTH \ | ||
| 255 | width=100 \ | ||
| 256 | icon.align=right \ | ||
| 257 | label.drawing=off \ | ||
| 258 | background.drawing=on \ | ||
| 259 | background.color=$BACKGROUND_2 \ | ||
| 260 | background.height=8 \ | ||
| 261 | background.corner_radius=3 \ | ||
| 262 | align=left | ||
| 263 | |||
| 264 | ${pkgs.sketchybar}/bin/sketchybar --add alias "Control Center,Sound" right \ | ||
| 265 | --rename "Control Center,Sound" volume_alias \ | ||
| 266 | --set volume_alias icon.drawing=off \ | ||
| 267 | label.drawing=off \ | ||
| 268 | alias.color=$BLUE2 \ | ||
| 269 | background.padding_right=0 \ | ||
| 270 | background.padding_left=5 \ | ||
| 271 | width=50 \ | ||
| 272 | align=right \ | ||
| 273 | click_script="$PLUGIN_DIR/volume_click.sh" | ||
| 274 | |||
| 275 | ''; | ||
| 276 | }; | ||
| 277 | plugins_brew = { | ||
| 278 | executable = true; | ||
| 279 | target = ".config/sketchybar/plugins/brew.sh"; | ||
| 280 | text = builtins.readFile "${folder}/plugins/executable_brew.sh"; | ||
| 281 | }; | ||
| 282 | plugins_calendar = { | ||
| 283 | executable = true; | ||
| 284 | target = ".config/sketchybar/plugins/calendar.sh"; | ||
| 285 | text = builtins.readFile "${folder}/plugins/executable_calendar.sh"; | ||
| 286 | }; | ||
| 287 | plugins_github = { | ||
| 288 | executable = true; | ||
| 289 | target = ".config/sketchybar/plugins/github.sh"; | ||
| 290 | text = builtins.readFile "${folder}/plugins/executable_github.sh"; | ||
| 291 | }; | ||
| 292 | plugins_icon_map = { | ||
| 293 | executable = true; | ||
| 294 | target = ".config/sketchybar/plugins/icon_map.sh"; | ||
| 295 | text = builtins.readFile "${folder}/plugins/executable_icon_map.sh"; | ||
| 296 | }; | ||
| 297 | plugins_space = { | ||
| 298 | executable = true; | ||
| 299 | target = ".config/sketchybar/plugins/space.sh"; | ||
| 300 | text = builtins.readFile "${folder}/plugins/executable_space.sh"; | ||
| 301 | }; | ||
| 302 | plugins_spotify = { | ||
| 303 | executable = true; | ||
| 304 | target = ".config/sketchybar/plugins/spotify.sh"; | ||
| 305 | text = builtins.readFile "${folder}/plugins/executable_spotify.sh"; | ||
| 306 | }; | ||
| 307 | plugins_volume = { | ||
| 308 | executable = true; | ||
| 309 | target = ".config/sketchybar/plugins/volume.sh"; | ||
| 310 | text = '' | ||
| 311 | #!/usr/bin/env sh | ||
| 312 | WIDTH=100 | ||
| 313 | |||
| 314 | volume_change() { | ||
| 315 | # INITIAL_WIDTH=$(${pkgs.sketchybar}/bin/sketchybar --query $NAME | ${pkgs.jq}/bin/jq ".icon.width") | ||
| 316 | # if [ "$INITIAL_WIDTH" -eq "0" ]; then | ||
| 317 | # ${pkgs.sketchybar}/bin/sketchybar --animate tanh 30 --set $NAME width=$WIDTH icon.width=$INFO | ||
| 318 | # else | ||
| 319 | # ${pkgs.sketchybar}/bin/sketchybar --set $NAME icon.width=$INFO width=$WIDTH | ||
| 320 | # fi | ||
| 321 | ${pkgs.sketchybar}/bin/sketchybar --set $NAME icon.width=$INFO | ||
| 322 | |||
| 323 | |||
| 324 | # sleep 5 | ||
| 325 | # FINAL_WIDTH=$(${pkgs.sketchybar}/bin/sketchybar --query $NAME | ${pkgs.jq}/bin/jq ".icon.width") | ||
| 326 | # if [ "$FINAL_WIDTH" -eq "$INFO" ]; then | ||
| 327 | # ${pkgs.sketchybar}/bin/sketchybar --animate tanh 30 --set $NAME width=0 icon.width=0 | ||
| 328 | # fi | ||
| 329 | } | ||
| 330 | |||
| 331 | case "$SENDER" in | ||
| 332 | "volume_change") volume_change | ||
| 333 | ;; | ||
| 334 | esac | ||
| 335 | ''; | ||
| 336 | }; | ||
| 337 | plugins_volume_click = { | ||
| 338 | executable = true; | ||
| 339 | target = ".config/sketchybar/plugins/volume_click.sh"; | ||
| 340 | text = '' | ||
| 341 | #!/usr/bin/env sh | ||
| 342 | MUTED=$(osascript -e 'output muted of (get volume settings)') | ||
| 343 | if [ "$MUTED" = "false" ]; then | ||
| 344 | osascript -e 'set volume output muted true' | ||
| 345 | else | ||
| 346 | osascript -e 'set volume output muted false' | ||
| 347 | fi | ||
| 348 | ''; | ||
| 349 | }; | ||
| 350 | plugins_yabai = { | ||
| 351 | executable = true; | ||
| 352 | target = ".config/sketchybar/plugins/yabai.sh"; | ||
| 353 | text = builtins.readFile "${folder}/plugins/executable_yabai.sh"; | ||
| 354 | }; | ||
| 355 | plugins_zen = { | ||
| 356 | executable = true; | ||
| 357 | target = ".config/sketchybar/plugins/zen.sh"; | ||
| 358 | text = builtins.readFile "${folder}/plugins/executable_zen.sh"; | ||
| 359 | }; | ||
| 360 | plugins_aerospace = { | ||
| 361 | executable = true; | ||
| 362 | target = ".config/sketchybar/plugins/aerospace.sh"; | ||
| 363 | text = '' | ||
| 364 | #!/usr/bin/env bash | ||
| 365 | source "$HOME/.config/sketchybar/colors.sh" # Loads all defined colors | ||
| 366 | |||
| 367 | highlight_focused_workspace() { | ||
| 368 | if [[ "$1" = "$FOCUSED_WORKSPACE" ]] | ||
| 369 | then | ||
| 370 | ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME icon.highlight=on label.width=0 | ||
| 371 | else | ||
| 372 | ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME icon.highlight=off label.width=dynamic | ||
| 373 | fi | ||
| 374 | } | ||
| 375 | |||
| 376 | illuminate_mode() { | ||
| 377 | if [[ "$mode" = "service" ]] | ||
| 378 | then | ||
| 379 | ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$ORANGE | ||
| 380 | elif [[ "$mode" = "resize" ]] | ||
| 381 | then | ||
| 382 | ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$GREEN | ||
| 383 | else | ||
| 384 | ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$BACKGROUND_1 | ||
| 385 | fi | ||
| 386 | } | ||
| 387 | case "$SENDER" in | ||
| 388 | "aerospace_workspace_change") | ||
| 389 | highlight_focused_workspace $1 | ||
| 390 | ;; | ||
| 391 | "aerospace_mode_change") | ||
| 392 | illuminate_mode | ||
| 393 | ;; | ||
| 394 | esac | ||
| 395 | ''; | ||
| 396 | }; | ||
| 397 | }; | ||
| 398 | } | ||
modules/macos/tiling/sketchybar.nix+1-145| ... | @@ -1,150 +1,6 @@ | ... | @@ -1,150 +1,6 @@ |
| 1 | {pkgs, ...}: { | 1 | {pkgs, ...}: { |
| 2 | services.sketchybar = { | 2 | services.sketchybar = { |
| 3 | enable = true; | 3 | enable = true; |
| 4 | config = '' | 4 | package = pkgs.sketchybar; |
| 5 | # This is a demo config to showcase some of the most important commands. | ||
| 6 | # It is meant to be changed and configured, as it is intentionally kept sparse. | ||
| 7 | # For a (much) more advanced configuration example see my dotfiles: | ||
| 8 | # https://github.com/FelixKratz/dotfiles | ||
| 9 | |||
| 10 | PLUGIN_DIR="$CONFIG_DIR/plugins" | ||
| 11 | |||
| 12 | ##### Bar Appearance ##### | ||
| 13 | # Configuring the general appearance of the bar. | ||
| 14 | # These are only some of the options available. For all options see: | ||
| 15 | # https://felixkratz.github.io/SketchyBar/config/bar | ||
| 16 | # If you are looking for other colors, see the color picker: | ||
| 17 | # https://felixkratz.github.io/SketchyBar/config/tricks#color-picker | ||
| 18 | |||
| 19 | sketchybar --bar position=top height=40 blur_radius=30 color=0x04313244 | ||
| 20 | |||
| 21 | # Colours | ||
| 22 | SURFACE=0xff313244 | ||
| 23 | |||
| 24 | ##### Changing Defaults ##### | ||
| 25 | # We now change some default values, which are applied to all further items. | ||
| 26 | # For a full list of all available item properties see: | ||
| 27 | # https://felixkratz.github.io/SketchyBar/config/items | ||
| 28 | |||
| 29 | default=( | ||
| 30 | padding_left=5 | ||
| 31 | padding_right=5 | ||
| 32 | icon.font="Hack Nerd Font:Bold:17.0" | ||
| 33 | label.font="Hack Nerd Font:Bold:14.0" | ||
| 34 | icon.color=0xffcdd6f4 | ||
| 35 | label.color=0xffcdd6f4 | ||
| 36 | icon.padding_left=8 | ||
| 37 | icon.padding_right=4 | ||
| 38 | label.padding_left=4 | ||
| 39 | label.padding_right=8 | ||
| 40 | background.padding_left=2 | ||
| 41 | background.padding_right=2 | ||
| 42 | background.color=$SURFACE \ | ||
| 43 | background.corner_radius=10 \ | ||
| 44 | background.height=30 \ | ||
| 45 | background.border_width=1 \ | ||
| 46 | ) | ||
| 47 | sketchybar --default "$\{default[@]}" | ||
| 48 | |||
| 49 | sketchybar --add event aerospace_workspace_change | ||
| 50 | |||
| 51 | for sid in $(aerospace list-workspaces --all); do | ||
| 52 | sketchybar --add item space.$sid left \ | ||
| 53 | --subscribe space.$sid aerospace_workspace_change \ | ||
| 54 | --set space.$sid \ | ||
| 55 | background.border_width=1 \ | ||
| 56 | background.border_color=0xffb4befe \ | ||
| 57 | background.corner_radius=5 \ | ||
| 58 | background.height=20 \ | ||
| 59 | icon.padding_left=0 \ | ||
| 60 | icon.padding_right=0 \ | ||
| 61 | label.padding_right=6 \ | ||
| 62 | label="$sid" \ | ||
| 63 | click_script="aerospace workspace $sid" \ | ||
| 64 | script="$CONFIG_DIR/plugins/aerospace.sh $sid" | ||
| 65 | done | ||
| 66 | |||
| 67 | ##### Adding Left Items ##### | ||
| 68 | # We add some regular items to the left side of the bar, where | ||
| 69 | # only the properties deviating from the current defaults need to be set | ||
| 70 | |||
| 71 | sketchybar --add item chevron left \ | ||
| 72 | --set chevron icon= label.drawing=off background.drawing=off \ | ||
| 73 | icon.color=0xfff5e0dc \ | ||
| 74 | --add item front_app left \ | ||
| 75 | --set front_app icon.drawing=off script="$PLUGIN_DIR/front_app.sh" \ | ||
| 76 | label.color=0xff94e2d5 \ | ||
| 77 | label.padding_left=8 \ | ||
| 78 | background.border_color=0xff94e2d5 \ | ||
| 79 | --subscribe front_app front_app_switched | ||
| 80 | |||
| 81 | ##### Adding Right Items ##### | ||
| 82 | # In the same way as the left items we can add items to the right side. | ||
| 83 | # Additional position (e.g. center) are available, see: | ||
| 84 | # https://felixkratz.github.io/SketchyBar/config/items#adding-items-to-sketchybar | ||
| 85 | |||
| 86 | # Some items refresh on a fixed cycle, e.g. the clock runs its script once | ||
| 87 | # every 10s. Other items respond to events they subscribe to, e.g. the | ||
| 88 | # volume.sh script is only executed once an actual change in system audio | ||
| 89 | # volume is registered. More info about the event system can be found here: | ||
| 90 | # https://felixkratz.github.io/SketchyBar/config/events | ||
| 91 | |||
| 92 | sketchybar --add item clock right \ | ||
| 93 | --set clock update_freq=10 icon= script="$PLUGIN_DIR/clock.sh" \ | ||
| 94 | icon.color=0xfffab387 \ | ||
| 95 | label.color=0xffcdd6f4 \ | ||
| 96 | background.color=$SURFACE \ | ||
| 97 | background.corner_radius=10 \ | ||
| 98 | background.height=30 \ | ||
| 99 | --add item volume right \ | ||
| 100 | --set volume script="$PLUGIN_DIR/volume.sh" \ | ||
| 101 | label.color=0xffcdd6f4 \ | ||
| 102 | background.color=$SURFACE \ | ||
| 103 | background.corner_radius=10 \ | ||
| 104 | background.height=30 \ | ||
| 105 | --subscribe volume volume_change \ | ||
| 106 | --add item battery right \ | ||
| 107 | --set battery update_freq=120 script="$PLUGIN_DIR/battery.sh" \ | ||
| 108 | label.color=0xffcdd6f4 \ | ||
| 109 | background.color=$SURFACE \ | ||
| 110 | background.corner_radius=10 \ | ||
| 111 | background.height=30 \ | ||
| 112 | --subscribe battery system_woke power_source_change | ||
| 113 | |||
| 114 | sketchybar -m --add item mullvad right \ | ||
| 115 | --set mullvad icon= \ | ||
| 116 | icon.color=0xfff38ba8 \ | ||
| 117 | background.color=$SURFACE \ | ||
| 118 | background.corner_radius=10 \ | ||
| 119 | background.height=30 \ | ||
| 120 | background.border_width=1 \ | ||
| 121 | background.border_color=0xfff38ba8 \ | ||
| 122 | label.padding_left=0 \ | ||
| 123 | label.padding_right=0 \ | ||
| 124 | icon.padding_left=6 \ | ||
| 125 | update_freq=5 \ | ||
| 126 | script="$PLUGIN_DIR/mullvad.sh" | ||
| 127 | |||
| 128 | # Add event | ||
| 129 | sketchybar -m --add event song_update com.apple.iTunes.playerInfo | ||
| 130 | |||
| 131 | # Add Music Item | ||
| 132 | sketchybar -m --add item music right \ | ||
| 133 | --set music script="$PLUGIN_DIR/music.sh" \ | ||
| 134 | click_script="$PLUGIN_DIR/music_click.sh" \ | ||
| 135 | label.padding_right=10 \ | ||
| 136 | label.color=0xffcdd6f4 \ | ||
| 137 | background.color=$SURFACE \ | ||
| 138 | background.corner_radius=10 \ | ||
| 139 | background.height=30 \ | ||
| 140 | background.border_width=1 \ | ||
| 141 | background.border_color=0xfff38ba8 \ | ||
| 142 | drawing=off \ | ||
| 143 | --subscribe music song_update | ||
| 144 | |||
| 145 | ##### Force all scripts to run the first time (never do this in a script) ##### | ||
| 146 | sketchybar --update | ||
| 147 | |||
| 148 | ''; | ||
| 149 | }; | 5 | }; |
| 150 | } | 6 | } |