diff options
Diffstat (limited to 'mac/.config/sketchybar.allapp')
38 files changed, 2014 insertions, 0 deletions
diff --git a/mac/.config/sketchybar.allapp/colors.sh b/mac/.config/sketchybar.allapp/colors.sh new file mode 100755 index 0000000..78f1369 --- /dev/null +++ b/mac/.config/sketchybar.allapp/colors.sh @@ -0,0 +1,49 @@ +#!/bin/bash + +### Sonokai +# export BLACK=0xff181819 +# export WHITE=0xffe2e2e3 +# export RED=0xfffc5d7c +# export GREEN=0xff9ed072 +# export BLUE=0xff76cce0 +# export YELLOW=0xffe7c664 +# export ORANGE=0xfff39660 +# export MAGENTA=0xffb39df3 +# export GREY=0xff7f8490 +# export TRANSPARENT=0x00000000 +# export BG0=0xff2c2e34 +# export BG1=0xff363944 +# export BG2=0xff414550 + +### Catppuccin +export BLACK=0xff181926 +export WHITE=0xffcad3f5 +export RED=0xffed8796 +export GREEN=0xffa6da95 +export BLUE=0xff8aadf4 +export YELLOW=0xffeed49f +export ORANGE=0xfff5a97f +export MAGENTA=0xffc6a0f6 +export GREY=0xff939ab7 +export TRANSPARENT=0x00000000 +export BG0=0xff1e1e2e +export BG1=0x603c3e4f +export BG2=0x60494d64 + +export BATTERY_1=0xffa6da95 +export BATTERY_2=0xffeed49f +export BATTERY_3=0xfff5a97f +export BATTERY_4=0xffee99a0 +export BATTERY_5=0xffed8796 + +# General bar colors +export BAR_COLOR=$BG0 +export BAR_BORDER_COLOR=$BG2 +export BACKGROUND_1=$BG1 +export BACKGROUND_2=$BG2 +export ICON_COLOR=$WHITE # Color of all icons +export LABEL_COLOR=$WHITE # Color of all labels +export POPUP_BACKGROUND_COLOR=$BAR_COLOR +export POPUP_BORDER_COLOR=$WHITE +export SHADOW_COLOR=$BLACK + diff --git a/mac/.config/sketchybar.allapp/helper/cpu.h b/mac/.config/sketchybar.allapp/helper/cpu.h new file mode 100644 index 0000000..c350ae3 --- /dev/null +++ b/mac/.config/sketchybar.allapp/helper/cpu.h @@ -0,0 +1,122 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <mach/mach.h> +#include <stdbool.h> +#include <time.h> + +#define MAX_TOPPROC_LEN 28 + +static const char TOPPROC[] = { "/bin/ps -Aceo pid,pcpu,comm -r" }; +static const char FILTER_PATTERN[] = { "com.apple." }; + +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; + + char command[256]; +}; + +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; + snprintf(cpu->command, 100, ""); +} + +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]; + + double user_perc = (double)delta_user / (double)(delta_system + + delta_user + + delta_idle); + + double sys_perc = (double)delta_system / (double)(delta_system + + delta_user + + delta_idle); + + double total_perc = user_perc + sys_perc; + + FILE* file; + char line[1024]; + + file = popen(TOPPROC, "r"); + if (!file) { + printf("Error: TOPPROC command errored out...\n" ); + return; + } + + fgets(line, sizeof(line), file); + fgets(line, sizeof(line), file); + + char* start = strstr(line, FILTER_PATTERN); + char topproc[MAX_TOPPROC_LEN + 4]; + uint32_t caret = 0; + for (int i = 0; i < sizeof(line); i++) { + if (start && i == start - line) { + i+=9; + continue; + } + + if (caret >= MAX_TOPPROC_LEN && caret <= MAX_TOPPROC_LEN + 2) { + topproc[caret++] = '.'; + continue; + } + if (caret > MAX_TOPPROC_LEN + 2) break; + topproc[caret++] = line[i]; + if (line[i] == '\0') break; + } + + topproc[MAX_TOPPROC_LEN + 3] = '\0'; + + pclose(file); + + char color[16]; + if (total_perc >= .7) { + snprintf(color, 16, "%s", getenv("RED")); + } else if (total_perc >= .3) { + snprintf(color, 16, "%s", getenv("ORANGE")); + } else if (total_perc >= .1) { + snprintf(color, 16, "%s", getenv("YELLOW")); + } else { + snprintf(color, 16, "%s", getenv("LABEL_COLOR")); + } + + snprintf(cpu->command, 256, "--push cpu.sys %.2f " + "--push cpu.user %.2f " + "--set cpu.top label='%s' " + "--set cpu.percent label=%.0f%% label.color=%s ", + sys_perc, + user_perc, + topproc, + total_perc*100., + color ); + } + else { + snprintf(cpu->command, 256, ""); + } + + cpu->prev_load = cpu->load; + cpu->has_prev_load = true; +} diff --git a/mac/.config/sketchybar.allapp/helper/helper b/mac/.config/sketchybar.allapp/helper/helper Binary files differnew file mode 100755 index 0000000..ef12d02 --- /dev/null +++ b/mac/.config/sketchybar.allapp/helper/helper diff --git a/mac/.config/sketchybar.allapp/helper/helper.c b/mac/.config/sketchybar.allapp/helper/helper.c new file mode 100644 index 0000000..71c3038 --- /dev/null +++ b/mac/.config/sketchybar.allapp/helper/helper.c @@ -0,0 +1,31 @@ +#include "cpu.h" +#include "sketchybar.h" + +struct cpu g_cpu; + +void handler(env env) { + // Environment variables passed from sketchybar can be accessed as seen below + char* name = env_get_value_for_key(env, "NAME"); + char* sender = env_get_value_for_key(env, "SENDER"); + char* info = env_get_value_for_key(env, "INFO"); + char* selected = env_get_value_for_key(env, "SELECTED"); + + if ((strcmp(name, "cpu.percent") == 0)) { + // CPU graph updates + cpu_update(&g_cpu); + + if (strlen(g_cpu.command) > 0) sketchybar(g_cpu.command); + } +} + +int main (int argc, char** argv) { + cpu_init(&g_cpu); + + if (argc < 2) { + printf("Usage: helper \"<bootstrap name>\"\n"); + exit(1); + } + + event_server_begin(handler, argv[1]); + return 0; +} diff --git a/mac/.config/sketchybar.allapp/helper/makefile b/mac/.config/sketchybar.allapp/helper/makefile new file mode 100644 index 0000000..ac8721a --- /dev/null +++ b/mac/.config/sketchybar.allapp/helper/makefile @@ -0,0 +1,3 @@ + +helper: helper.c cpu.h sketchybar.h + clang -std=c99 -O3 helper.c -o helper diff --git a/mac/.config/sketchybar.allapp/helper/sketchybar.h b/mac/.config/sketchybar.allapp/helper/sketchybar.h new file mode 100644 index 0000000..2ab4c39 --- /dev/null +++ b/mac/.config/sketchybar.allapp/helper/sketchybar.h @@ -0,0 +1,209 @@ +#pragma once + +#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; +}; + +struct mach_server { + bool is_running; + mach_port_name_t task; + mach_port_t port; + mach_port_t bs_port; + + pthread_t thread; + mach_handler* handler; +}; + +static struct mach_server g_mach_server; +static mach_port_t g_mach_port = 0; + +static inline char* env_get_value_for_key(env env, char* key) { + uint32_t caret = 0; + for(;;) { + if (!env[caret]) break; + if (strcmp(&env[caret], key) == 0) + return &env[caret + strlen(&env[caret]) + 1]; + + caret += strlen(&env[caret]) + + strlen(&env[caret + strlen(&env[caret]) + 1]) + + 2; + } + return (char*)""; +} + +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; + } + + mach_port_t port; + if (bootstrap_look_up(bs_port, + "git.felix.sketchybar", + &port ) != KERN_SUCCESS) { + return 0; + } + + return port; +} + +static inline void mach_receive_message(mach_port_t port, struct mach_buffer* buffer, bool timeout) { + *buffer = (struct mach_buffer) { 0 }; + mach_msg_return_t msg_return; + if (timeout) + msg_return = mach_msg(&buffer->message.header, + MACH_RCV_MSG | MACH_RCV_TIMEOUT, + 0, + sizeof(struct mach_buffer), + port, + 100, + MACH_PORT_NULL ); + else + msg_return = mach_msg(&buffer->message.header, + MACH_RCV_MSG, + 0, + sizeof(struct mach_buffer), + port, + MACH_MSG_TIMEOUT_NONE, + MACH_PORT_NULL ); + + if (msg_return != MACH_MSG_SUCCESS) { + buffer->message.descriptor.address = NULL; + } +} + +static inline char* mach_send_message(mach_port_t port, char* message, uint32_t len) { + if (!message || !port) { + return NULL; + } + + 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; + + mach_msg(&msg.header, + MACH_SEND_MSG, + sizeof(struct mach_message), + 0, + MACH_PORT_NULL, + MACH_MSG_TIMEOUT_NONE, + MACH_PORT_NULL ); + + return NULL; +} + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" +static inline bool mach_server_begin(struct mach_server* mach_server, mach_handler handler, char* bootstrap_name) { + mach_server->task = mach_task_self(); + + if (mach_port_allocate(mach_server->task, + MACH_PORT_RIGHT_RECEIVE, + &mach_server->port ) != KERN_SUCCESS) { + return false; + } + + if (mach_port_insert_right(mach_server->task, + mach_server->port, + mach_server->port, + MACH_MSG_TYPE_MAKE_SEND) != KERN_SUCCESS) { + return false; + } + + if (task_get_special_port(mach_server->task, + TASK_BOOTSTRAP_PORT, + &mach_server->bs_port) != KERN_SUCCESS) { + return false; + } + + if (bootstrap_register(mach_server->bs_port, + bootstrap_name, + mach_server->port ) != KERN_SUCCESS) { + return false; + } + + mach_server->handler = handler; + mach_server->is_running = true; + struct mach_buffer buffer; + while (mach_server->is_running) { + mach_receive_message(mach_server->port, &buffer, false); + mach_server->handler((env)buffer.message.descriptor.address); + mach_msg_destroy(&buffer.message.header); + } + + return true; +} +#pragma clang diagnostic pop + +static inline char* sketchybar(char* message) { + uint32_t message_length = strlen(message) + 1; + char formatted_message[message_length + 1]; + + char quote = '\0'; + uint32_t caret = 0; + for (int i = 0; i < message_length; ++i) { + if (message[i] == '"' || message[i] == '\'') { + if (quote == message[i]) quote = '\0'; + else quote = message[i]; + continue; + } + formatted_message[caret] = message[i]; + if (message[i] == ' ' && !quote) formatted_message[caret] = '\0'; + caret++; + } + + if (caret > 0 && formatted_message[caret] == '\0' + && formatted_message[caret - 1] == '\0') { + caret--; + } + + formatted_message[caret] = '\0'; + if (!g_mach_port) g_mach_port = mach_get_bs_port(); + char* response = mach_send_message(g_mach_port, + formatted_message, + caret + 1 ); + + if (response) return response; + else return (char*)""; +} + +static inline void event_server_begin(mach_handler event_handler, char* bootstrap_name) { + mach_server_begin(&g_mach_server, event_handler, bootstrap_name); +} diff --git a/mac/.config/sketchybar.allapp/helpers/event_providers/cpu_load/bin/cpu_load b/mac/.config/sketchybar.allapp/helpers/event_providers/cpu_load/bin/cpu_load Binary files differnew file mode 100755 index 0000000..1c37f5f --- /dev/null +++ b/mac/.config/sketchybar.allapp/helpers/event_providers/cpu_load/bin/cpu_load diff --git a/mac/.config/sketchybar.allapp/helpers/event_providers/network_load/bin/network_load b/mac/.config/sketchybar.allapp/helpers/event_providers/network_load/bin/network_load Binary files differnew file mode 100755 index 0000000..3075243 --- /dev/null +++ b/mac/.config/sketchybar.allapp/helpers/event_providers/network_load/bin/network_load diff --git a/mac/.config/sketchybar.allapp/helpers/menus/bin/menus b/mac/.config/sketchybar.allapp/helpers/menus/bin/menus Binary files differnew file mode 100755 index 0000000..dda2cc1 --- /dev/null +++ b/mac/.config/sketchybar.allapp/helpers/menus/bin/menus diff --git a/mac/.config/sketchybar.allapp/icons.sh b/mac/.config/sketchybar.allapp/icons.sh new file mode 100755 index 0000000..bee0dad --- /dev/null +++ b/mac/.config/sketchybar.allapp/icons.sh @@ -0,0 +1,57 @@ +#!/bin/bash + +# General Icons +LOADING= +APPLE= +PREFERENCES= +ACTIVITY= +LOCK= +BELL= +BELL_DOT= + +# Git Icons +GIT_ISSUE= +GIT_DISCUSSION= +GIT_PULL_REQUEST= +GIT_COMMIT= +GIT_INDICATOR= + +# Spotify Icons +SPOTIFY_BACK= +SPOTIFY_PLAY_PAUSE= +SPOTIFY_NEXT= +SPOTIFY_SHUFFLE= +SPOTIFY_REPEAT= + +# Yabai Icons +YABAI_STACK= +YABAI_FULLSCREEN_ZOOM= +YABAI_PARENT_ZOOM= +YABAI_FLOAT= +YABAI_GRID= + +# Battery Icons +BATTERY_100= +BATTERY_75= +BATTERY_50= +BATTERY_25= +BATTERY_0= +BATTERY_CHARGING= + +# Volume Icons +VOLUME_100= +VOLUME_66= +VOLUME_33= +VOLUME_10= +VOLUME_0= + +# WiFi +WIFI_CONNECTED= +WIFI_DISCONNECTED= + +# svim +MODE_NORMAL= +MODE_INSERT= +MODE_VISUAL= +MODE_CMD= +MODE_PENDING= diff --git a/mac/.config/sketchybar.allapp/items/apple.sh b/mac/.config/sketchybar.allapp/items/apple.sh new file mode 100755 index 0000000..fde05b4 --- /dev/null +++ b/mac/.config/sketchybar.allapp/items/apple.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +POPUP_OFF='sketchybar --set apple.logo popup.drawing=off' +POPUP_CLICK_SCRIPT='sketchybar --set $NAME popup.drawing=toggle' + +apple_logo=( + icon=$APPLE + icon.font="$FONT:Black:16.0" + icon.color=$WHITE + padding_right=15 + label.drawing=off + click_script="$POPUP_CLICK_SCRIPT" + popup.height=35 +) + +apple_prefs=( + icon=$PREFERENCES + label="Preferences" + click_script="open -a 'System Preferences'; $POPUP_OFF" +) + +apple_activity=( + icon=$ACTIVITY + label="Activity" + click_script="open -a 'Activity Monitor'; $POPUP_OFF" +) + +apple_lock=( + icon=$LOCK + label="Lock Screen" + click_script="pmset displaysleepnow; $POPUP_OFF" +) + +sketchybar --add item apple.logo left \ + --set apple.logo "${apple_logo[@]}" \ + \ + --add item apple.prefs popup.apple.logo \ + --set apple.prefs "${apple_prefs[@]}" \ + \ + --add item apple.activity popup.apple.logo \ + --set apple.activity "${apple_activity[@]}" \ + \ + --add item apple.lock popup.apple.logo \ + --set apple.lock "${apple_lock[@]}" diff --git a/mac/.config/sketchybar.allapp/items/battery.sh b/mac/.config/sketchybar.allapp/items/battery.sh new file mode 100755 index 0000000..7955060 --- /dev/null +++ b/mac/.config/sketchybar.allapp/items/battery.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +battery=( + script="$PLUGIN_DIR/battery.sh" + icon.font="$FONT:Regular:19.0" + padding_right=3 + padding_left=0 + label.drawing=off + update_freq=120 + updates=on +) +sketchybar --add item battery right \ + --set battery "${battery[@]}"\ + icon.font.size=15 update_freq=120 script="$PLUGIN_DIR/battery.sh" \ + --subscribe battery power_source_change system_woke + diff --git a/mac/.config/sketchybar.allapp/items/calendar.sh b/mac/.config/sketchybar.allapp/items/calendar.sh new file mode 100755 index 0000000..62aadc8 --- /dev/null +++ b/mac/.config/sketchybar.allapp/items/calendar.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +calendar=( + icon= + icon.font="$FONT:Black:12.0" + icon.padding_right=0 + label.align=right + padding_left=15 + update_freq=30 + script="$PLUGIN_DIR/calendar.sh" + click_script="$PLUGIN_DIR/zen.sh" +) + +sketchybar --add item calendar right \ + --set calendar "${calendar[@]}" \ + --subscribe calendar system_woke diff --git a/mac/.config/sketchybar.allapp/items/cpu.sh b/mac/.config/sketchybar.allapp/items/cpu.sh new file mode 100755 index 0000000..249595d --- /dev/null +++ b/mac/.config/sketchybar.allapp/items/cpu.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +cpu_top=( + label.font="$FONT:Semibold:7" + label=CPU + icon.drawing=off + width=0 + padding_right=15 + y_offset=6 +) + +cpu_percent=( + label.font="$FONT:Heavy:12" + label=CPU + y_offset=-4 + padding_right=15 + width=55 + icon.drawing=off + update_freq=4 + mach_helper="$HELPER" +) + +cpu_sys=( + width=0 + graph.color=$RED + graph.fill_color=$RED + label.drawing=off + icon.drawing=off + background.height=30 + background.drawing=on + background.color=$TRANSPARENT +) + +cpu_user=( + graph.color=$BLUE + label.drawing=off + icon.drawing=off + background.height=30 + background.drawing=on + background.color=$TRANSPARENT +) + +sketchybar --add item cpu.top right \ + --set cpu.top "${cpu_top[@]}" \ + \ + --add item cpu.percent right \ + --set cpu.percent "${cpu_percent[@]}" \ + \ + --add graph cpu.sys right 75 \ + --set cpu.sys "${cpu_sys[@]}" \ + \ + --add graph cpu.user right 75 \ + --set cpu.user "${cpu_user[@]}" diff --git a/mac/.config/sketchybar.allapp/items/front_app.sh b/mac/.config/sketchybar.allapp/items/front_app.sh new file mode 100755 index 0000000..77f79ff --- /dev/null +++ b/mac/.config/sketchybar.allapp/items/front_app.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +front_app=( + label.font="$FONT:Black:12.0" + icon.background.drawing=on + display=active + script="$PLUGIN_DIR/front_app.sh" + click_script="open -a 'Mission Control'" +) +sketchybar --add item front_app left \ + --set front_app "${front_app[@]}" \ + --subscribe front_app front_app_switched + diff --git a/mac/.config/sketchybar.allapp/items/input_source.sh b/mac/.config/sketchybar.allapp/items/input_source.sh new file mode 100755 index 0000000..c72f38f --- /dev/null +++ b/mac/.config/sketchybar.allapp/items/input_source.sh @@ -0,0 +1,10 @@ +#!/bin/sh + +sketchybar --add item input_source right +sketchybar --set input_source \ + icon.font="$FONT:Regular:20.0" \ + script="$PLUGIN_DIR/get_input_source.sh" \ + icon.color=0xffffffff \ + update_freq=1 + + diff --git a/mac/.config/sketchybar.allapp/items/spaces.sh b/mac/.config/sketchybar.allapp/items/spaces.sh new file mode 100755 index 0000000..2d4a517 --- /dev/null +++ b/mac/.config/sketchybar.allapp/items/spaces.sh @@ -0,0 +1,81 @@ +#!/bin/sh + +#SPACE_ICONS=("1" "2" "3" "4") + +# Destroy space on right click, focus space on left click. +# New space by left clicking separator (>) + +sketchybar --add event aerospace_workspace_change +#echo $(aerospace list-workspaces --monitor 1 --visible no --empty no) >> ~/aaaa + +for m in $(aerospace list-monitors | awk '{print $1}'); do + for i in $(aerospace list-workspaces --monitor $m); do + sid=$i + space=( + space="$sid" + icon="$sid" + icon.highlight_color=$RED + icon.padding_left=10 + icon.padding_right=10 + display=$m + padding_left=2 + padding_right=2 + label.padding_right=20 + label.color=$GREY + label.highlight_color=$WHITE + label.font="sketchybar-app-font:Regular:16.0" + label.y_offset=-1 + background.color=$BACKGROUND_1 + background.border_color=$BACKGROUND_2 + script="$PLUGIN_DIR/space.sh" + ) + + sketchybar --add space space.$sid left \ + --set space.$sid "${space[@]}" \ + --subscribe space.$sid mouse.clicked + + apps=$(aerospace list-windows --workspace $sid | awk -F'|' '{gsub(/^ *| *$/, "", $2); print $2}') + + icon_strip=" " + if [ "${apps}" != "" ]; then + while read -r app + do + icon_strip+=" $($CONFIG_DIR/plugins/icon_map.sh "$app")" + done <<< "${apps}" + else + icon_strip=" —" + fi + + sketchybar --set space.$sid label="$icon_strip" + done + + for i in $(aerospace list-workspaces --monitor $m --empty); do + sketchybar --set space.$i display=0 + done + +done + + +space_creator=( + icon= + icon.font="$FONT:Heavy:16.0" + padding_left=10 + padding_right=8 + label.drawing=off + display=active + #click_script='yabai -m space --create' + script="$PLUGIN_DIR/space_windows.sh" + #script="$PLUGIN_DIR/aerospace.sh" + icon.color=$WHITE +) + +# sketchybar --add item space_creator left \ +# --set space_creator "${space_creator[@]}" \ +# --subscribe space_creator space_windows_change +sketchybar --add item space_creator left \ + --set space_creator "${space_creator[@]}" \ + --subscribe space_creator aerospace_workspace_change + +# sketchybar --add item change_windows left \ +# --set change_windows script="$PLUGIN_DIR/change_windows.sh" \ +# --subscribe change_windows space_changes diff --git a/mac/.config/sketchybar.allapp/items/volume.sh b/mac/.config/sketchybar.allapp/items/volume.sh new file mode 100755 index 0000000..bc9466d --- /dev/null +++ b/mac/.config/sketchybar.allapp/items/volume.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +volume_slider=( + script="$PLUGIN_DIR/volume.sh" + updates=on + label.drawing=off + icon.drawing=off + slider.highlight_color=$BLUE + slider.background.height=5 + slider.background.corner_radius=3 + slider.background.color=$BACKGROUND_2 + slider.knob= + slider.knob.drawing=on +) + +volume_icon=( + click_script="$PLUGIN_DIR/volume_click.sh" + padding_left=10 + icon=$VOLUME_100 + icon.width=0 + icon.align=left + icon.color=$GREY + icon.font="$FONT:Regular:14.0" + label.width=25 + label.align=left + label.font="$FONT:Regular:14.0" +) + +status_bracket=( + background.color=$BACKGROUND_1 + background.border_color=$BACKGROUND_2 +) + +sketchybar --add slider volume right \ + --set volume "${volume_slider[@]}" \ + --subscribe volume volume_change \ + mouse.clicked \ + --add item volume_icon right \ + --set volume_icon "${volume_icon[@]}" + +sketchybar --add bracket status brew github.bell wifi volume_icon \ + --set status "${status_bracket[@]}" + diff --git a/mac/.config/sketchybar.allapp/items/weather.sh b/mac/.config/sketchybar.allapp/items/weather.sh new file mode 100755 index 0000000..2b1f608 --- /dev/null +++ b/mac/.config/sketchybar.allapp/items/weather.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +sketchybar --add item weather right \ + --set weather \ + icon= \ + script="$PLUGIN_DIR/weather.sh" \ + update_freq=1500 \ + --subscribe weather mouse.clicked + diff --git a/mac/.config/sketchybar.allapp/plugins/aerospace.sh b/mac/.config/sketchybar.allapp/plugins/aerospace.sh new file mode 100755 index 0000000..68c739a --- /dev/null +++ b/mac/.config/sketchybar.allapp/plugins/aerospace.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash + +echo \$FOCUSED_WORKSPACE: $FOCUSED_WORKSPACE, \$NAME: $NAME \$1: $1 >> ~/aaaa + +if [ "$1" = "$FOCUSED_WORKSPACE" ]; then + sketchybar --set $NAME background.drawing=on +else + sketchybar --set $NAME background.drawing=off +fi + + + +# MAIN_COLOR=0xffa17fa7 +# ACCENT_COLOR=0xffe19286 +# +# echo $NAME > ~/debug_skekychybar +# +# if [ "$1" = "change-focused-window" ]; then +# echo "change-focused-window" +# focused_window_info=$(aerospace list-windows --focused) +# focused_window_id=$(echo $focused_window_info | awk -F ' \\| ' '{print $1}') +# if [ "$2" = "$focused_window_id" ]; then +# sketchybar --set $NAME icon.color=$ACCENT_COLOR +# else +# sketchybar --set $NAME icon.color=$MAIN_COLOR +# fi +# fi +# +# if [ "$1" = "change-focused-workspace" ]; then +# echo "change-focused-workspace" +# focused_workspace=$(aerospace list-workspaces --focused) +# if [ "$2" = "$focused_workspace" ]; then +# sketchybar --set $NAME label.color=$ACCENT_COLOR +# else +# sketchybar --set $NAME label.color=$MAIN_COLOR +# fi +# fi +# +# if [ "$1" = "move-window-within-workspace" ]; then +# echo "move-window-within-workspace" +# focused_workspace=$(aerospace list-workspaces --focused) +# if [ "$2" = "$focused_workspace" ]; then +# sketchybar --set $NAME label.color=$ACCENT_COLOR +# else +# sketchybar --set $NAME label.color=$MAIN_COLOR +# fi +# fi diff --git a/mac/.config/sketchybar.allapp/plugins/apple.sh b/mac/.config/sketchybar.allapp/plugins/apple.sh new file mode 100755 index 0000000..066d709 --- /dev/null +++ b/mac/.config/sketchybar.allapp/plugins/apple.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +POPUP_OFF='sketchybar --set apple.logo popup.drawing=off' +POPUP_CLICK_SCRIPT='sketchybar --set $NAME popup.drawing=toggle' + +apple_logo=( + icon=$APPLE + icon.font="$FONT:Black:16.0" + icon.color=$GREEN + padding_right=15 + label.drawing=off + click_script="$POPUP_CLICK_SCRIPT" + popup.height=35 +) + +apple_prefs=( + icon=$PREFERENCES + label="Preferences" + click_script="open -a 'System Preferences'; $POPUP_OFF" +) + +apple_activity=( + icon=$ACTIVITY + label="Activity" + click_script="open -a 'Activity Monitor'; $POPUP_OFF" +) + +apple_lock=( + icon=$LOCK + label="Lock Screen" + click_script="pmset displaysleepnow; $POPUP_OFF" +) + +sketchybar --add item apple.logo left \ + --set apple.logo "${apple_logo[@]}" \ + \ + --add item apple.prefs popup.apple.logo \ + --set apple.prefs "${apple_prefs[@]}" \ + \ + --add item apple.activity popup.apple.logo \ + --set apple.activity "${apple_activity[@]}" \ + \ + --add item apple.lock popup.apple.logo \ + --set apple.lock "${apple_lock[@]}" diff --git a/mac/.config/sketchybar.allapp/plugins/battery.sh b/mac/.config/sketchybar.allapp/plugins/battery.sh new file mode 100755 index 0000000..7487662 --- /dev/null +++ b/mac/.config/sketchybar.allapp/plugins/battery.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +source "$CONFIG_DIR/colors.sh" + +PERCENTAGE="$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)" +CHARGING="$(pmset -g batt | grep 'AC Power')" + +if [ "$PERCENTAGE" = "" ]; then + exit 0 +fi + +case ${PERCENTAGE} in + [8-9][0-9] | 100) + ICON="" + ICON_COLOR=$BATTERY_1 + ;; + 7[0-9]) + ICON="" + ICON_COLOR=$BATTERY_2 + ;; + [4-6][0-9]) + ICON="" + ICON_COLOR=$BATTERY_3 + ;; + [1-3][0-9]) + ICON="" + ICON_COLOR=$BATTERY_4 + ;; + [0-9]) + ICON="" + ICON_COLOR=$BATTERY_5 + ;; +esac + +if [[ "$CHARGING" != "" ]]; then + ICON="" + ICON_COLOR=$YELLOW +fi + +# The item invoking this script (name $NAME) will get its icon and label +# updated with the current battery status +sketchybar --set "$NAME" icon="$ICON" label="${PERCENTAGE}%" icon.color=${ICON_COLOR} diff --git a/mac/.config/sketchybar.allapp/plugins/calendar.sh b/mac/.config/sketchybar.allapp/plugins/calendar.sh new file mode 100755 index 0000000..4bc2b8d --- /dev/null +++ b/mac/.config/sketchybar.allapp/plugins/calendar.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +#sketchybar --set $NAME icon="$(date '+%a %d. %b')" label="$(date '+%H:%M')" +sketchybar --set "$NAME" label="$(date '+%m/%d %H:%M')" diff --git a/mac/.config/sketchybar.allapp/plugins/change_windows.sh b/mac/.config/sketchybar.allapp/plugins/change_windows.sh new file mode 100755 index 0000000..69364b8 --- /dev/null +++ b/mac/.config/sketchybar.allapp/plugins/change_windows.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +echo change_windows.sh NAME: $NAME, SENDER: $SENDER >> ~/aaaa diff --git a/mac/.config/sketchybar.allapp/plugins/clock.sh b/mac/.config/sketchybar.allapp/plugins/clock.sh new file mode 100755 index 0000000..d24d6af --- /dev/null +++ b/mac/.config/sketchybar.allapp/plugins/clock.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# The $NAME variable is passed from sketchybar and holds the name of +# the item invoking this script: +# https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting + +# sketchybar --set "$NAME" label="$(date '+%m/%d %H:%M')" +sketchybar --set "$NAME" label="$(date '+%m/%d %H:%M')" + diff --git a/mac/.config/sketchybar.allapp/plugins/cpu.sh b/mac/.config/sketchybar.allapp/plugins/cpu.sh new file mode 100755 index 0000000..c27af35 --- /dev/null +++ b/mac/.config/sketchybar.allapp/plugins/cpu.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +CORE_COUNT=$(sysctl -n machdep.cpu.thread_count) +CPU_INFO=$(ps -eo pcpu,user) +CPU_SYS=$(echo "$CPU_INFO" | grep -v $(whoami) | sed "s/[^ 0-9\.]//g" | awk "{sum+=\$1} END {print sum/(100.0 * $CORE_COUNT)}") +CPU_USER=$(echo "$CPU_INFO" | grep $(whoami) | sed "s/[^ 0-9\.]//g" | awk "{sum+=\$1} END {print sum/(100.0 * $CORE_COUNT)}") + +CPU_PERCENT="$(echo "$CPU_SYS $CPU_USER" | awk '{printf "%.0f\n", ($1 + $2)*100}')" + +sketchybar --set $NAME label="$CPU_PERCENT%" diff --git a/mac/.config/sketchybar.allapp/plugins/front_app.sh b/mac/.config/sketchybar.allapp/plugins/front_app.sh new file mode 100755 index 0000000..2426503 --- /dev/null +++ b/mac/.config/sketchybar.allapp/plugins/front_app.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# Some events send additional information specific to the event in the $INFO +# variable. E.g. the front_app_switched event sends the name of the newly +# focused application in the $INFO variable: +# https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting + +AEROSPACE_FOCUSED_MONITOR_NO=$(aerospace list-workspaces --focused) +AEROSPACE_LIST_OF_WINDOWS_IN_FOCUSED_MONITOR=$(aerospace list-windows --workspace $AEROSPACE_FOCUSED_MONITOR_NO | awk -F'|' '{gsub(/^ *| *$/, "", $2); print $2}') + +if [ "$SENDER" = "front_app_switched" ]; then + #echo name:$NAME INFO: $INFO SENDER: $SENDER, SID: $SID >> ~/aaaa + sketchybar --set "$NAME" label="$INFO" icon.background.image="app.$INFO" icon.background.image.scale=0.8 + + apps=$AEROSPACE_LIST_OF_WINDOWS_IN_FOCUSED_MONITOR + icon_strip=" " + if [ "${apps}" != "" ]; then + while read -r app + do + icon_strip+=" $($CONFIG_DIR/plugins/icon_map.sh "$app")" + done <<< "${apps}" + else + icon_strip=" —" + fi + sketchybar --set space.$AEROSPACE_FOCUSED_MONITOR_NO label="$icon_strip" +fi diff --git a/mac/.config/sketchybar.allapp/plugins/get_input_source.sh b/mac/.config/sketchybar.allapp/plugins/get_input_source.sh new file mode 100755 index 0000000..89dab2b --- /dev/null +++ b/mac/.config/sketchybar.allapp/plugins/get_input_source.sh @@ -0,0 +1,13 @@ +#!/bin/sh + +# hangul and english item + +# Read the plist data +plist_data=$(defaults read ~/Library/Preferences/com.apple.HIToolbox.plist AppleSelectedInputSources) +current_input_source=$(echo "$plist_data" | plutil -convert xml1 -o - - | grep -A1 'KeyboardLayout Name' | tail -n1 | cut -d '>' -f2 | cut -d '<' -f1) + +if [ "$current_input_source" = "ABC" ]; then + sketchybar --set input_source icon="" +else + sketchybar --set input_source icon="" +fi diff --git a/mac/.config/sketchybar.allapp/plugins/icon_map.sh b/mac/.config/sketchybar.allapp/plugins/icon_map.sh new file mode 100755 index 0000000..e23f8d0 --- /dev/null +++ b/mac/.config/sketchybar.allapp/plugins/icon_map.sh @@ -0,0 +1,637 @@ +#!/usr/bin/env bash + +### START-OF-ICON-MAP +function __icon_map() { + case "$1" in + "Live") + icon_result=":ableton:" + ;; + "Adobe Bridge"*) + icon_result=":adobe_bridge:" + ;; + "Affinity Designer") + icon_result=":affinity_designer:" + ;; + "Affinity Designer 2") + icon_result=":affinity_designer_2:" + ;; + "Affinity Photo") + icon_result=":affinity_photo:" + ;; + "Affinity Photo 2") + icon_result=":affinity_photo_2:" + ;; + "Affinity Publisher") + icon_result=":affinity_publisher:" + ;; + "Affinity Publisher 2") + icon_result=":affinity_publisher_2:" + ;; + "Airmail") + icon_result=":airmail:" + ;; + "Alacritty") + icon_result=":alacritty:" + ;; + "Alfred") + icon_result=":alfred:" + ;; + "Android Messages") + icon_result=":android_messages:" + ;; + "Android Studio") + icon_result=":android_studio:" + ;; + "Anytype") + icon_result=":anytype:" + ;; + "App Eraser") + icon_result=":app_eraser:" + ;; + "App Store") + icon_result=":app_store:" + ;; + "Arc") + icon_result=":arc:" + ;; + "Atom") + icon_result=":atom:" + ;; + "Audacity") + icon_result=":audacity:" + ;; + "Bambu Studio") + icon_result=":bambu_studio:" + ;; + "MoneyMoney") + icon_result=":bank:" + ;; + "Battle.net") + icon_result=":battle_net:" + ;; + "Bear") + icon_result=":bear:" + ;; + "BetterTouchTool") + icon_result=":bettertouchtool:" + ;; + "Bilibili" | "哔哩哔哩") + icon_result=":bilibili:" + ;; + "Bitwarden") + icon_result=":bit_warden:" + ;; + "Blender") + icon_result=":blender:" + ;; + "BluOS Controller") + icon_result=":bluos_controller:" + ;; + "Calibre") + icon_result=":book:" + ;; + "Brave Browser") + icon_result=":brave_browser:" + ;; + "Calculator" | "Calculette") + icon_result=":calculator:" + ;; + "Calendar" | "日历" | "Fantastical" | "Cron" | "Amie" | "Calendrier" | "Notion Calendar") + icon_result=":calendar:" + ;; + "Caprine") + icon_result=":caprine:" + ;; + "Citrix Workspace" | "Citrix Viewer") + icon_result=":citrix:" + ;; + "ClickUp") + icon_result=":click_up:" + ;; + "Code" | "Code - Insiders") + icon_result=":code:" + ;; + "Color Picker" | "数码测色计") + icon_result=":color_picker:" + ;; + "CotEditor") + icon_result=":coteditor:" + ;; + "Creative Cloud") + icon_result=":creative_cloud:" + ;; + "Cypress") + icon_result=":cypress:" + ;; + "DataGrip") + icon_result=":datagrip:" + ;; + "DataSpell") + icon_result=":dataspell:" + ;; + "DaVinci Resolve") + icon_result=":davinciresolve:" + ;; + "Default") + icon_result=":default:" + ;; + "CleanMyMac X") + icon_result=":desktop:" + ;; + "DEVONthink 3") + icon_result=":devonthink3:" + ;; + "DingTalk" | "钉钉" | "阿里钉") + icon_result=":dingtalk:" + ;; + "Discord" | "Discord Canary" | "Discord PTB") + icon_result=":discord:" + ;; + "Docker" | "Docker Desktop") + icon_result=":docker:" + ;; + "GrandTotal" | "Receipts") + icon_result=":dollar:" + ;; + "Double Commander") + icon_result=":doublecmd:" + ;; + "Drafts") + icon_result=":drafts:" + ;; + "Dropbox") + icon_result=":dropbox:" + ;; + "Element") + icon_result=":element:" + ;; + "Emacs") + icon_result=":emacs:" + ;; + "Evernote Legacy") + icon_result=":evernote_legacy:" + ;; + "FaceTime" | "FaceTime 通话") + icon_result=":face_time:" + ;; + "Figma") + icon_result=":figma:" + ;; + "Final Cut Pro") + icon_result=":final_cut_pro:" + ;; + "Finder" | "访达") + icon_result=":finder:" + ;; + "Firefox") + icon_result=":firefox:" + ;; + "Firefox Developer Edition" | "Firefox Nightly") + icon_result=":firefox_developer_edition:" + ;; + "Folx") + icon_result=":folx:" + ;; + "Fusion") + icon_result=":fusion:" + ;; + "System Preferences" | "System Settings" | "系统设置" | "Réglages Système") + icon_result=":gear:" + ;; + "GitHub Desktop") + icon_result=":git_hub:" + ;; + "Godot") + icon_result=":godot:" + ;; + "GoLand") + icon_result=":goland:" + ;; + "Chromium" | "Google Chrome" | "Google Chrome Canary") + icon_result=":google_chrome:" + ;; + "Grammarly Editor") + icon_result=":grammarly:" + ;; + "Home Assistant") + icon_result=":home_assistant:" + ;; + "Hyper") + icon_result=":hyper:" + ;; + "IntelliJ IDEA") + icon_result=":idea:" + ;; + "Inkdrop") + icon_result=":inkdrop:" + ;; + "Inkscape") + icon_result=":inkscape:" + ;; + "Insomnia") + icon_result=":insomnia:" + ;; + "Iris") + icon_result=":iris:" + ;; + "iTerm" | "iTerm2") + icon_result=":iterm:" + ;; + "Jellyfin Media Player") + icon_result=":jellyfin:" + ;; + "Joplin") + icon_result=":joplin:" + ;; + "카카오톡" | "KakaoTalk") + icon_result=":kakaotalk:" + ;; + "Kakoune") + icon_result=":kakoune:" + ;; + "KeePassXC") + icon_result=":kee_pass_x_c:" + ;; + "Keyboard Maestro") + icon_result=":keyboard_maestro:" + ;; + "Keynote" | "Keynote 讲演") + icon_result=":keynote:" + ;; + "kitty") + icon_result=":kitty:" + ;; + "League of Legends") + icon_result=":league_of_legends:" + ;; + "LibreWolf") + icon_result=":libre_wolf:" + ;; + "Adobe Lightroom") + icon_result=":lightroom:" + ;; + "Lightroom Classic") + icon_result=":lightroomclassic:" + ;; + "LINE") + icon_result=":line:" + ;; + "Linear") + icon_result=":linear:" + ;; + "LM Studio") + icon_result=":lm_studio:" + ;; + "LocalSend") + icon_result=":localsend:" + ;; + "Logic Pro") + icon_result=":logicpro:" + ;; + "Logseq") + icon_result=":logseq:" + ;; + "Canary Mail" | "HEY" | "Mail" | "Mailspring" | "MailMate" | "Superhuman" | "Spark" | "邮件") + icon_result=":mail:" + ;; + "MAMP" | "MAMP PRO") + icon_result=":mamp:" + ;; + "Maps" | "Google Maps") + icon_result=":maps:" + ;; + "Matlab") + icon_result=":matlab:" + ;; + "Mattermost") + icon_result=":mattermost:" + ;; + "Messages" | "信息" | "Nachrichten") + icon_result=":messages:" + ;; + "Messenger") + icon_result=":messenger:" + ;; + "Microsoft Edge") + icon_result=":microsoft_edge:" + ;; + "Microsoft Excel") + icon_result=":microsoft_excel:" + ;; + "Microsoft Outlook") + icon_result=":microsoft_outlook:" + ;; + "Microsoft PowerPoint") + icon_result=":microsoft_power_point:" + ;; + "Microsoft Remote Desktop") + icon_result=":microsoft_remote_desktop:" + ;; + "Microsoft Teams" | "Microsoft Teams (work or school)") + icon_result=":microsoft_teams:" + ;; + "Microsoft Word") + icon_result=":microsoft_word:" + ;; + "Min") + icon_result=":min_browser:" + ;; + "Miro") + icon_result=":miro:" + ;; + "MongoDB Compass"*) + icon_result=":mongodb:" + ;; + "mpv") + icon_result=":mpv:" + ;; + "Mullvad Browser") + icon_result=":mullvad_browser:" + ;; + "Music" | "音乐" | "Musique") + icon_result=":music:" + ;; + "Neovide" | "neovide") + icon_result=":neovide:" + ;; + "Neovim" | "neovim" | "nvim") + icon_result=":neovim:" + ;; + "网易云音乐") + icon_result=":netease_music:" + ;; + "Noodl" | "Noodl Editor") + icon_result=":noodl:" + ;; + "NordVPN") + icon_result=":nord_vpn:" + ;; + "Notability") + icon_result=":notability:" + ;; + "Notes" | "备忘录") + icon_result=":notes:" + ;; + "Notion") + icon_result=":notion:" + ;; + "Nova") + icon_result=":nova:" + ;; + "Numbers" | "Numbers 表格") + icon_result=":numbers:" + ;; + "Obsidian") + icon_result=":obsidian:" + ;; + "OBS") + icon_result=":obsstudio:" + ;; + "OmniFocus") + icon_result=":omni_focus:" + ;; + "1Password") + icon_result=":one_password:" + ;; + "ChatGPT") + icon_result=":openai:" + ;; + "OpenVPN Connect") + icon_result=":openvpn_connect:" + ;; + "Opera") + icon_result=":opera:" + ;; + "OrcaSlicer") + icon_result=":orcaslicer:" + ;; + "Orion" | "Orion RC") + icon_result=":orion:" + ;; + "Pages" | "Pages 文稿") + icon_result=":pages:" + ;; + "Parallels Desktop") + icon_result=":parallels:" + ;; + "Parsec") + icon_result=":parsec:" + ;; + "Preview" | "预览" | "Skim" | "zathura" | "Aperçu") + icon_result=":pdf:" + ;; + "PDF Expert") + icon_result=":pdf_expert:" + ;; + "Adobe Photoshop"*) + icon_result=":photoshop:" + ;; + "PhpStorm") + icon_result=":php_storm:" + ;; + "Pi-hole Remote") + icon_result=":pihole:" + ;; + "Pine") + icon_result=":pine:" + ;; + "Podcasts" | "播客") + icon_result=":podcasts:" + ;; + "PomoDone App") + icon_result=":pomodone:" + ;; + "Postman") + icon_result=":postman:" + ;; + "Proton Mail" | "Proton Mail Bridge") + icon_result=":proton_mail:" + ;; + "PrusaSlicer" | "SuperSlicer") + icon_result=":prusaslicer:" + ;; + "PyCharm") + icon_result=":pycharm:" + ;; + "QQ") + icon_result=":qq:" + ;; + "QQ音乐" | "QQMusic") + icon_result=":qqmusic:" + ;; + "Quantumult X") + icon_result=":quantumult_x:" + ;; + "qutebrowser") + icon_result=":qute_browser:" + ;; + "Raindrop.io") + icon_result=":raindrop_io:" + ;; + "Reeder") + icon_result=":reeder5:" + ;; + "Reminders" | "提醒事项" | "Rappels") + icon_result=":reminders:" + ;; + "Replit") + icon_result=":replit:" + ;; + "Rider" | "JetBrains Rider") + icon_result=":rider:" + ;; + "Safari" | "Safari浏览器" | "Safari Technology Preview") + icon_result=":safari:" + ;; + "Sequel Ace") + icon_result=":sequel_ace:" + ;; + "Sequel Pro") + icon_result=":sequel_pro:" + ;; + "Setapp") + icon_result=":setapp:" + ;; + "SF Symbols") + icon_result=":sf_symbols:" + ;; + "Signal") + icon_result=":signal:" + ;; + "Sketch") + icon_result=":sketch:" + ;; + "Skype") + icon_result=":skype:" + ;; + "Slack") + icon_result=":slack:" + ;; + "Spark Desktop") + icon_result=":spark:" + ;; + "Spotify") + icon_result=":spotify:" + ;; + "Spotlight") + icon_result=":spotlight:" + ;; + "Sublime Text") + icon_result=":sublime_text:" + ;; + "Tana") + icon_result=":tana:" + ;; + "TeamSpeak 3") + icon_result=":team_speak:" + ;; + "Telegram") + icon_result=":telegram:" + ;; + "Terminal" | "终端") + icon_result=":terminal:" + ;; + "Typora") + icon_result=":text:" + ;; + "Microsoft To Do" | "Things") + icon_result=":things:" + ;; + "Thunderbird") + icon_result=":thunderbird:" + ;; + "TickTick") + icon_result=":tick_tick:" + ;; + "TIDAL") + icon_result=":tidal:" + ;; + "Tiny RDM") + icon_result=":tinyrdm:" + ;; + "Todoist") + icon_result=":todoist:" + ;; + "Toggl Track") + icon_result=":toggl_track:" + ;; + "Tor Browser") + icon_result=":tor_browser:" + ;; + "Tower") + icon_result=":tower:" + ;; + "Transmit") + icon_result=":transmit:" + ;; + "Trello") + icon_result=":trello:" + ;; + "Tweetbot" | "Twitter") + icon_result=":twitter:" + ;; + "MacVim" | "Vim" | "VimR") + icon_result=":vim:" + ;; + "Vivaldi") + icon_result=":vivaldi:" + ;; + "VLC") + icon_result=":vlc:" + ;; + "VMware Fusion") + icon_result=":vmware_fusion:" + ;; + "VSCodium") + icon_result=":vscodium:" + ;; + "Warp") + icon_result=":warp:" + ;; + "WebStorm") + icon_result=":web_storm:" + ;; + "微信" | "WeChat") + icon_result=":wechat:" + ;; + "企业微信" | "WeCom") + icon_result=":wecom:" + ;; + "WezTerm") + icon_result=":wezterm:" + ;; + "WhatsApp" | "WhatsApp") + icon_result=":whats_app:" + ;; + "Xcode") + icon_result=":xcode:" + ;; + "Яндекс Музыка") + icon_result=":yandex_music:" + ;; + "Yuque" | "语雀") + icon_result=":yuque:" + ;; + "Zed") + icon_result=":zed:" + ;; + "Zeplin") + icon_result=":zeplin:" + ;; + "zoom.us") + icon_result=":zoom:" + ;; + "Zotero") + icon_result=":zotero:" + ;; + "Zulip") + icon_result=":zulip:" + ;; + *) + icon_result=":default:" + ;; + esac +} +### END-OF-ICON-MAP +__icon_map "$1" +echo "$icon_result" diff --git a/mac/.config/sketchybar.allapp/plugins/space.sh b/mac/.config/sketchybar.allapp/plugins/space.sh new file mode 100755 index 0000000..978fc38 --- /dev/null +++ b/mac/.config/sketchybar.allapp/plugins/space.sh @@ -0,0 +1,58 @@ +#!/bin/bash + +#echo space.sh $'FOCUSED_WORKSPACE': $FOCUSED_WORKSPACE, $'SELECTED': $SELECTED, NAME: $NAME, SENDER: $SENDER >> ~/aaaa + +update() { + # 처음 시작에만 작동하기 위해서 + # 현재 forced, space_change 이벤트가 동시에 발생하고 있다. + if [ "$SENDER" = "space_change" ]; then + #echo space.sh $'FOCUSED_WORKSPACE': $FOCUSED_WORKSPACE, $'SELECTED': $SELECTED, NAME: $NAME, SENDER: $SENDER, INFO: $INFO >> ~/aaaa + #echo $(aerospace list-workspaces --focused) >> ~/aaaa + source "$CONFIG_DIR/colors.sh" + COLOR=$BACKGROUND_2 + if [ "$SELECTED" = "true" ]; then + COLOR=$GREY + fi + # sketchybar --set $NAME icon.highlight=$SELECTED \ + # label.highlight=$SELECTED \ + # background.border_color=$COLOR + + sketchybar --set space.$(aerospace list-workspaces --focused) icon.highlight=true \ + label.highlight=true \ + background.border_color=$GREY + fi +} + +set_space_label() { + sketchybar --set $NAME icon="$@" +} + +mouse_clicked() { + if [ "$BUTTON" = "right" ]; then + # yabai -m space --destroy $SID + echo '' + else + if [ "$MODIFIER" = "shift" ]; then + SPACE_LABEL="$(osascript -e "return (text returned of (display dialog \"Give a name to space $NAME:\" default answer \"\" with icon note buttons {\"Cancel\", \"Continue\"} default button \"Continue\"))")" + if [ $? -eq 0 ]; then + if [ "$SPACE_LABEL" = "" ]; then + set_space_label "${NAME:6}" + else + set_space_label "${NAME:6} ($SPACE_LABEL)" + fi + fi + else + #yabai -m space --focus $SID 2>/dev/null + #echo space.sh BUTTON: $BUTTON, $'SELECTED': $SELECTED, MODIFIER: $MODIFIER, NAME: $NAME, SENDER: $SENDER, INFO: $INFO, TEST: ${NAME#*.}, ${NAME:6} >> ~/aaaa + aerospace workspace ${NAME#*.} + fi + fi +} + +# echo plugin_space.sh $SENDER >> ~/aaaa +case "$SENDER" in + "mouse.clicked") mouse_clicked + ;; + *) update + ;; +esac diff --git a/mac/.config/sketchybar.allapp/plugins/space_windows.sh b/mac/.config/sketchybar.allapp/plugins/space_windows.sh new file mode 100755 index 0000000..c8996cb --- /dev/null +++ b/mac/.config/sketchybar.allapp/plugins/space_windows.sh @@ -0,0 +1,87 @@ +#!/usr/bin/env bash + +echo AEROSPACE_PREV_WORKSPACE: $AEROSPACE_PREV_WORKSPACE, \ + AEROSPACE_FOCUSED_WORKSPACE: $AEROSPACE_FOCUSED_WORKSPACE \ + SELECTED: $SELECTED \ + BG2: $BG2 \ + INFO: $INFO \ + SENDER: $SENDER \ + NAME: $NAME \ + >> ~/aaaa + +source "$CONFIG_DIR/colors.sh" + +AEROSPACE_FOCUSED_MONITOR=$(aerospace list-monitors --focused | awk '{print $1}') +AEROSAPCE_WORKSPACE_FOCUSED_MONITOR=$(aerospace list-workspaces --monitor focused --empty no) +AEROSPACE_EMPTY_WORKESPACE=$(aerospace list-workspaces --monitor focused --empty) + +reload_workspace_icon() { + # echo reload_workspace_icon "$@" >> ~/aaaa + apps=$(aerospace list-windows --workspace "$@" | awk -F'|' '{gsub(/^ *| *$/, "", $2); print $2}') + + icon_strip=" " + if [ "${apps}" != "" ]; then + while read -r app + do + icon_strip+=" $($CONFIG_DIR/plugins/icon_map.sh "$app")" + done <<< "${apps}" + else + icon_strip=" —" + fi + + sketchybar --animate sin 10 --set space.$@ label="$icon_strip" +} + +if [ "$SENDER" = "aerospace_workspace_change" ]; then + + # if [ $i = "$FOCUSED_WORKSPACE" ]; then + # sketchybar --set space.$FOCUSED_WORKSPACE background.drawing=on + # else + # sketchybar --set space.$FOCUSED_WORKSPACE background.drawing=off + # fi + #echo 'space_windows_change: '$AEROSPACE_FOCUSED_WORKSPACE >> ~/aaaa + #echo space: $space >> ~/aaaa + #space="$(echo "$INFO" | jq -r '.space')" + #apps="$(echo "$INFO" | jq -r '.apps | keys[]')" + # apps=$(aerospace list-windows --workspace $AEROSPACE_FOCUSED_WORKSPACE | awk -F'|' '{gsub(/^ *| *$/, "", $2); print $2}') + # + # icon_strip=" " + # if [ "${apps}" != "" ]; then + # while read -r app + # do + # icon_strip+=" $($CONFIG_DIR/plugins/icon_map.sh "$app")" + # done <<< "${apps}" + # else + # icon_strip=" —" + # fi + + reload_workspace_icon "$AEROSPACE_PREV_WORKSPACE" + reload_workspace_icon "$AEROSPACE_FOCUSED_WORKSPACE" + + #sketchybar --animate sin 10 --set space.$space label="$icon_strip" + + # current workspace space border color + sketchybar --set space.$AEROSPACE_FOCUSED_WORKSPACE icon.highlight=true \ + label.highlight=true \ + background.border_color=$GREY + + # prev workspace space border color + sketchybar --set space.$AEROSPACE_PREV_WORKSPACE icon.highlight=false \ + label.highlight=false \ + background.border_color=$BACKGROUND_2 + + # if [ "$AEROSPACE_FOCUSED_WORKSPACE" -gt 3 ]; then + # sketchybar --animate sin 10 --set space.$AEROSPACE_FOCUSED_WORKSPACE display=1 + # fi + ## focused 된 모니터에 space 상태 보이게 설정 + for i in $AEROSAPCE_WORKSPACE_FOCUSED_MONITOR; do + sketchybar --set space.$i display=$AEROSPACE_FOCUSED_MONITOR + done + + for i in $AEROSPACE_EMPTY_WORKESPACE; do + sketchybar --set space.$i display=0 + done + + sketchybar --set space.$AEROSPACE_FOCUSED_WORKSPACE display=$AEROSPACE_FOCUSED_MONITOR + +fi diff --git a/mac/.config/sketchybar.allapp/plugins/volume.sh b/mac/.config/sketchybar.allapp/plugins/volume.sh new file mode 100755 index 0000000..1ee75a0 --- /dev/null +++ b/mac/.config/sketchybar.allapp/plugins/volume.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +WIDTH=100 + +volume_change() { + source "$CONFIG_DIR/icons.sh" + case $INFO in + [6-9][0-9]|100) ICON=$VOLUME_100 + ;; + [3-5][0-9]) ICON=$VOLUME_66 + ;; + [1-2][0-9]) ICON=$VOLUME_33 + ;; + [1-9]) ICON=$VOLUME_10 + ;; + 0) ICON=$VOLUME_0 + ;; + *) ICON=$VOLUME_100 + esac + + sketchybar --set volume_icon label=$ICON \ + --set $NAME slider.percentage=$INFO + + INITIAL_WIDTH="$(sketchybar --query $NAME | jq -r ".slider.width")" + if [ "$INITIAL_WIDTH" -eq "0" ]; then + sketchybar --animate tanh 30 --set $NAME slider.width=$WIDTH + fi + + sleep 2 + + # Check wether the volume was changed another time while sleeping + FINAL_PERCENTAGE="$(sketchybar --query $NAME | jq -r ".slider.percentage")" + if [ "$FINAL_PERCENTAGE" -eq "$INFO" ]; then + sketchybar --animate tanh 30 --set $NAME slider.width=0 + fi +} + +mouse_clicked() { + osascript -e "set volume output volume $PERCENTAGE" +} + +case "$SENDER" in + "volume_change") volume_change + ;; + "mouse.clicked") mouse_clicked + ;; +esac diff --git a/mac/.config/sketchybar.allapp/plugins/volume_click.sh b/mac/.config/sketchybar.allapp/plugins/volume_click.sh new file mode 100755 index 0000000..5c2a365 --- /dev/null +++ b/mac/.config/sketchybar.allapp/plugins/volume_click.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +WIDTH=100 + +detail_on() { + sketchybar --animate tanh 30 --set volume slider.width=$WIDTH +} + +detail_off() { + sketchybar --animate tanh 30 --set volume slider.width=0 +} + +toggle_detail() { + INITIAL_WIDTH=$(sketchybar --query volume | jq -r ".slider.width") + if [ "$INITIAL_WIDTH" -eq "0" ]; then + detail_on + else + detail_off + fi +} + +toggle_devices() { + which SwitchAudioSource >/dev/null || exit 0 + source "$CONFIG_DIR/colors.sh" + + args=(--remove '/volume.device\.*/' --set "$NAME" popup.drawing=toggle) + COUNTER=0 + CURRENT="$(SwitchAudioSource -t output -c)" + while IFS= read -r device; do + COLOR=$GREY + if [ "${device}" = "$CURRENT" ]; then + COLOR=$WHITE + fi + args+=(--add item volume.device.$COUNTER popup."$NAME" \ + --set volume.device.$COUNTER label="${device}" \ + label.color="$COLOR" \ + click_script="SwitchAudioSource -s \"${device}\" && sketchybar --set /volume.device\.*/ label.color=$GREY --set \$NAME label.color=$WHITE --set $NAME popup.drawing=off") + COUNTER=$((COUNTER+1)) + done <<< "$(SwitchAudioSource -a -t output)" + + sketchybar -m "${args[@]}" > /dev/null +} + +if [ "$BUTTON" = "right" ] || [ "$MODIFIER" = "shift" ]; then + toggle_devices +else + toggle_detail +fi diff --git a/mac/.config/sketchybar.allapp/plugins/weather.sh b/mac/.config/sketchybar.allapp/plugins/weather.sh new file mode 100755 index 0000000..9b9ba29 --- /dev/null +++ b/mac/.config/sketchybar.allapp/plugins/weather.sh @@ -0,0 +1,25 @@ +sketchybar --set $NAME \ + label="Loading..." \ + icon.color=0xff5edaff + +# fetch weather data +LOCATION="Seoul" +REGION="" +LANG="ko" + +# Line below replaces spaces with + +LOCATION_ESCAPED="${LOCATION// /+}+${REGION// /+}" +WEATHER_JSON=$(curl -s "https://wttr.in/$LOCATION_ESCAPED?0pq&format=j1&lang=$LANG") + +# Fallback if empty +if [ -z $WEATHER_JSON ]; then + sketchybar --set $NAME label="$LOCATION" + return +fi + +TEMPERATURE=$(echo $WEATHER_JSON | jq '.current_condition[0].temp_C' | tr -d '"') +#WEATHER_DESCRIPTION=$(echo $WEATHER_JSON | jq '.current_condition[0].weatherDesc[0].value' | tr -d '"' | sed 's/\(.\{16\}\).*/\1.../') +WEATHER_DESCRIPTION=$(echo $WEATHER_JSON | jq '.current_condition[0].lang_ko[0].value' | tr -d '"' | sed 's/\(.\{16\}\).*/\1.../') + +sketchybar --set $NAME \ + label="$TEMPERATURE$(echo '°')C • $WEATHER_DESCRIPTION" diff --git a/mac/.config/sketchybar.allapp/plugins/wifi.sh b/mac/.config/sketchybar.allapp/plugins/wifi.sh new file mode 100755 index 0000000..8a6db10 --- /dev/null +++ b/mac/.config/sketchybar.allapp/plugins/wifi.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +SSID=$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | awk -F: '($1 ~ "^ *SSID$"){print $2}' | cut -c 2-) + +sketchybar --set wifi \ + icon= icon.color=0xff58d1fc \ + label="$SSID" diff --git a/mac/.config/sketchybar.allapp/plugins/zen.sh b/mac/.config/sketchybar.allapp/plugins/zen.sh new file mode 100755 index 0000000..38f2291 --- /dev/null +++ b/mac/.config/sketchybar.allapp/plugins/zen.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +zen_on() { + sketchybar --set wifi drawing=off \ + --set apple.logo drawing=off \ + --set '/cpu.*/' drawing=off \ + --set calendar icon.drawing=off \ + --set separator drawing=off \ + --set front_app drawing=off \ + --set volume_icon drawing=off \ + --set spotify.anchor drawing=off \ + --set spotify.play updates=off \ + --set brew drawing=off \ + --set volume drawing=off \ + --set github.bell drawing=off +} + +zen_off() { + sketchybar --set wifi drawing=on \ + --set apple.logo drawing=on \ + --set '/cpu.*/' drawing=on \ + --set calendar icon.drawing=on \ + --set separator drawing=on \ + --set front_app drawing=on \ + --set volume_icon drawing=on \ + --set spotify.play updates=on \ + --set brew drawing=on \ + --set volume drawing=on \ + --set github.bell drawing=on +} + +if [ "$1" = "on" ]; then + zen_on +elif [ "$1" = "off" ]; then + zen_off +else + if [ "$(sketchybar --query apple.logo | jq -r ".geometry.drawing")" = "on" ]; then + zen_on + else + zen_off + fi +fi + diff --git a/mac/.config/sketchybar.allapp/reference.md b/mac/.config/sketchybar.allapp/reference.md new file mode 100644 index 0000000..9ba5418 --- /dev/null +++ b/mac/.config/sketchybar.allapp/reference.md @@ -0,0 +1,3 @@ +# Reference link +https://github.com/hbthen3rd/dotfiles/tree/master/.config/sketchybar + diff --git a/mac/.config/sketchybar.allapp/sketchybarrc b/mac/.config/sketchybar.allapp/sketchybarrc new file mode 100755 index 0000000..cd46900 --- /dev/null +++ b/mac/.config/sketchybar.allapp/sketchybarrc @@ -0,0 +1,105 @@ +#!/bin/bash + +source "$CONFIG_DIR/colors.sh" # Loads all defined colors +source "$CONFIG_DIR/icons.sh" # Loads all defined icons + +ITEM_DIR="$CONFIG_DIR/items" # Directory where the items are configured +PLUGIN_DIR="$CONFIG_DIR/plugins" # Directory where all the plugin scripts are stored + +FONT="SF Pro" # Needs to have Regular, Bold, Semibold, Heavy and Black variants +PADDINGS=3 # All paddings use this value (icon, label, background) + +# aerospace setting +AEROSPACE_FOCUSED_MONITOR_NO=$(aerospace list-workspaces --focused) +AEROSPACE_LIST_OF_WINDOWS_IN_FOCUSED_MONITOR=$(aerospace list-windows --workspace $AEROSPACE_FOCUSED_MONITOR_NO | awk -F'|' '{gsub(/^ *| *$/, "", $2); print $2}') + +# Setting up and starting the helper process +HELPER=git.felix.helper +killall helper +(cd $CONFIG_DIR/helper && make) +$CONFIG_DIR/helper/helper $HELPER > /dev/null 2>&1 & + +# Unload the macOS on screen indicator overlay for volume change +launchctl unload -F /System/Library/LaunchAgents/com.apple.OSDUIHelper.plist > /dev/null 2>&1 & + +# Setting up the general bar appearance of the bar +bar=( + height=45 + color=$BAR_COLOR + border_width=2 + border_color=$BAR_BORDER_COLOR + shadow=off + position=top + sticky=on + padding_right=10 + padding_left=10 + y_offset=-5 + margin=-2 + topmost=window + color=0x00000000 + border_color=0x00000000 +) + +sketchybar --bar "${bar[@]}" + +# Setting up default values +defaults=( + updates=when_shown + icon.font="$FONT:Regular:14.0" + icon.color=$ICON_COLOR + icon.padding_left=$PADDINS + icon.padding_right=$PADDINGS + label.font="$FONT:Semibold:13.0" + label.color=$LABEL_COLOR + label.padding_left=$PADDINGS + label.padding_right=$PADDINGS + label.shadow.drawing=on + label.shadow.distance=2 + label.shadow.color=0xff000000 + padding_right=$PADDINGS + padding_left=$PADDINGS + background.height=26 + background.corner_radius=9 + background.border_width=2 + popup.background.border_width=2 + popup.background.corner_radius=9 + popup.background.border_color=$POPUP_BORDER_COLOR + popup.background.color=$POPUP_BACKGROUND_COLOR + popup.blur_radius=20 + popup.background.shadow.drawing=on + scroll_texts=on + +) + +sketchybar --default "${defaults[@]}" + + +# Left +source "$ITEM_DIR/apple.sh" +source "$ITEM_DIR/spaces.sh" +source "$ITEM_DIR/front_app.sh" +#source "$ITEM_DIR/yabai.sh" + +# Center +# source "$ITEM_DIR/spotify.sh" +# source "$ITEM_DIR/media.sh" + +# Right +source "$ITEM_DIR/calendar.sh" +source "$ITEM_DIR/input_source.sh" +source "$ITEM_DIR/battery.sh" +#source "$ITEM_DIR/brew.sh" +#source "$ITEM_DIR/github.sh" +source "$ITEM_DIR/wifi.sh" +source "$ITEM_DIR/volume.sh" +source "$ITEM_DIR/svim.sh" + +source "$ITEM_DIR/cpu.sh" +source "$ITEM_DIR/weather.sh" + +sketchybar --hotload on + +# Forcing all item scripts to run (never do this outside of sketchybarrc) +sketchybar --update + +echo "sketchybar configuation loaded.." |
