Added sketchybar config and updates to README

This commit is contained in:
josean-dev 2024-01-08 17:39:56 -04:00
parent 1bcf8bfd53
commit ee9f403039
18 changed files with 728 additions and 0 deletions

44
.config/sketchybar/colors.sh Executable file
View file

@ -0,0 +1,44 @@
#!/bin/bash
export WHITE=0xffffffff
# -- Teal Scheme --
export BAR_COLOR=0xff001f30
export ITEM_BG_COLOR=0xff003547
export ACCENT_COLOR=0xff2cf9ed
# -- Gray Scheme --
# export BAR_COLOR=0xff101314
# export ITEM_BG_COLOR=0xff353c3f
# export ACCENT_COLOR=0xffffffff
# -- Purple Scheme --
# export BAR_COLOR=0xff140c42
# export ITEM_BG_COLOR=0xff2b1c84
# export ACCENT_COLOR=0xffeb46f9
# -- Red Scheme ---
# export BAR_COLOR=0xff23090e
# export ITEM_BG_COLOR=0xff591221
# export ACCENT_COLOR=0xffff2453
# -- Blue Scheme ---
# export BAR_COLOR=0xff021254
# export ITEM_BG_COLOR=0xff093aa8
# export ACCENT_COLOR=0xff15bdf9
# -- Green Scheme --
# export BAR_COLOR=0xff003315
# export ITEM_BG_COLOR=0xff008c39
# export ACCENT_COLOR=0xff1dfca1
# -- Orange Scheme --
# export BAR_COLOR=0xff381c02
# export ITEM_BG_COLOR=0xff99440a
# export ACCENT_COLOR=0xfff97716
# -- Yellow Scheme --
# export BAR_COLOR=0xff2d2b02
# export ITEM_BG_COLOR=0xff8e7e0a
# export ACCENT_COLOR=0xfff7fc17

View file

@ -0,0 +1,6 @@
#!/bin/bash
sketchybar --add item battery right \
--set battery update_freq=120 \
script="$PLUGIN_DIR/battery.sh" \
--subscribe battery system_woke power_source_change

View file

@ -0,0 +1,6 @@
#!/bin/bash
sketchybar --add item calendar right \
--set calendar icon=􀧞 \
update_freq=30 \
script="$PLUGIN_DIR/calendar.sh"

View file

@ -0,0 +1,6 @@
#!/bin/bash
sketchybar --add item cpu right \
--set cpu update_freq=2 \
icon=􀧓 \
script="$PLUGIN_DIR/cpu.sh"

View file

@ -0,0 +1,9 @@
#!/bin/bash
sketchybar --add item front_app left \
--set front_app background.color=$ACCENT_COLOR \
icon.color=$BAR_COLOR \
icon.font="sketchybar-app-font:Regular:16.0" \
label.color=$BAR_COLOR \
script="$PLUGIN_DIR/front_app.sh" \
--subscribe front_app front_app_switched

View file

@ -0,0 +1,12 @@
#!/bin/bash
sketchybar --add item media e \
--set media label.color=$ACCENT_COLOR \
label.max_chars=20 \
icon.padding_left=0 \
scroll_texts=on \
icon=􀑪 \
icon.color=$ACCENT_COLOR \
background.drawing=off \
script="$PLUGIN_DIR/media.sh" \
--subscribe media media_change

View file

@ -0,0 +1,23 @@
#!/bin/bash
SPACE_SIDS=(1 2 3 4 5 6 7 8 9 10)
for sid in "${SPACE_SIDS[@]}"
do
sketchybar --add space space.$sid left \
--set space.$sid space=$sid \
icon=$sid \
label.font="sketchybar-app-font:Regular:16.0" \
label.padding_right=20 \
label.y_offset=-1 \
script="$PLUGIN_DIR/space.sh"
done
sketchybar --add item space_separator left \
--set space_separator icon="􀆊" \
icon.color=$ACCENT_COLOR \
icon.padding_left=4 \
label.drawing=off \
background.drawing=off \
script="$PLUGIN_DIR/space_windows.sh" \
--subscribe space_separator space_windows_change

View file

@ -0,0 +1,5 @@
#!/bin/bash
sketchybar --add item volume right \
--set volume script="$PLUGIN_DIR/volume.sh" \
--subscribe volume volume_change \

View file

@ -0,0 +1,28 @@
#!/bin/sh
PERCENTAGE=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)
CHARGING=$(pmset -g batt | grep 'AC Power')
if [ $PERCENTAGE = "" ]; then
exit 0
fi
case ${PERCENTAGE} in
9[0-9]|100) ICON="􀛨"
;;
[6-8][0-9]) ICON="􀺸"
;;
[3-5][0-9]) ICON="􀺶"
;;
[1-2][0-9]) ICON="􀛩"
;;
*) ICON="􀛪"
esac
if [[ $CHARGING != "" ]]; then
ICON="􀢋"
fi
# The item invoking this script (name $NAME) will get its icon and label
# updated with the current battery status
sketchybar --set $NAME icon="$ICON" label="${PERCENTAGE}%"

View file

@ -0,0 +1,3 @@
#!/bin/bash
sketchybar --set $NAME label="$(date +'%a %d %b %I:%M %p')"

View file

@ -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%"

View file

@ -0,0 +1,10 @@
#!/bin/sh
# Some events send additional information specific to the event in the $INFO
# variable. E.g. the front_app_switched event sends the name of the newly
# focused application in the $INFO variable:
# https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting
if [ "$SENDER" = "front_app_switched" ]; then
sketchybar --set $NAME label="$INFO" icon="$($CONFIG_DIR/plugins/icon_map_fn.sh "$INFO")"
fi

View file

@ -0,0 +1,436 @@
#!/bin/bash
function icon_map() {
case "$1" in
"Keynote" | "Keynote 讲演")
icon_result=":keynote:"
;;
"Figma")
icon_result=":figma:"
;;
"VMware Fusion")
icon_result=":vmware_fusion:"
;;
"Alacritty" | "Hyper" | "iTerm2" | "kitty" | "Terminal" | "终端" | "WezTerm")
icon_result=":terminal:"
;;
"Microsoft To Do" | "Things")
icon_result=":things:"
;;
"Keyboard Maestro")
icon_result=":keyboard_maestro:"
;;
"App Store")
icon_result=":app_store:"
;;
"CleanMyMac X")
icon_result=":desktop:"
;;
"Android Messages")
icon_result=":android_messages:"
;;
"Reeder")
icon_result=":reeder5:"
;;
"Joplin")
icon_result=":joplin:"
;;
"Discord" | "Discord Canary" | "Discord PTB")
icon_result=":discord:"
;;
"Logseq")
icon_result=":logseq:"
;;
"Microsoft Excel")
icon_result=":microsoft_excel:"
;;
"Microsoft PowerPoint")
icon_result=":microsoft_power_point:"
;;
"Telegram")
icon_result=":telegram:"
;;
"Transmit")
icon_result=":transmit:"
;;
"Pi-hole Remote")
icon_result=":pihole:"
;;
"League of Legends")
icon_result=":league_of_legends:"
;;
"Element")
icon_result=":element:"
;;
"Zulip")
icon_result=":zulip:"
;;
"Sequel Ace")
icon_result=":sequel_ace:"
;;
"Zed")
icon_result=":zed:"
;;
"TeamSpeak 3")
icon_result=":team_speak:"
;;
"1Password")
icon_result=":one_password:"
;;
"Caprine")
icon_result=":caprine:"
;;
"카카오톡")
icon_result=":kakaotalk:"
;;
"Dropbox")
icon_result=":dropbox:"
;;
"Kakoune")
icon_result=":kakoune:"
;;
"Rider" | "JetBrains Rider")
icon_result=":rider:"
;;
"Godot")
icon_result=":godot:"
;;
"qutebrowser")
icon_result=":qute_browser:"
;;
"Typora")
icon_result=":text:"
;;
"Sequel Pro")
icon_result=":sequel_pro:"
;;
"Reminders" | "提醒事项")
icon_result=":reminders:"
;;
"Setapp")
icon_result=":setapp:"
;;
"Finder" | "访达")
icon_result=":finder:"
;;
"Matlab")
icon_result=":matlab:"
;;
"LibreWolf")
icon_result=":libre_wolf:"
;;
"Notes" | "备忘录")
icon_result=":notes:"
;;
"Notion")
icon_result=":notion:"
;;
"Brave Browser")
icon_result=":brave_browser:"
;;
"Spotlight")
icon_result=":spotlight:"
;;
"Iris")
icon_result=":iris:"
;;
"Tower")
icon_result=":tower:"
;;
"Jellyfin Media Player")
icon_result=":jellyfin:"
;;
"Code" | "Code - Insiders")
icon_result=":code:"
;;
"Linear")
icon_result=":linear:"
;;
"Live")
icon_result=":ableton:"
;;
"Parallels Desktop")
icon_result=":parallels:"
;;
"Final Cut Pro")
icon_result=":final_cut_pro:"
;;
"Chromium" | "Google Chrome" | "Google Chrome Canary")
icon_result=":google_chrome:"
;;
"GitHub Desktop")
icon_result=":git_hub:"
;;
"Firefox")
icon_result=":firefox:"
;;
"Slack")
icon_result=":slack:"
;;
"Spotify")
icon_result=":spotify:"
;;
"Neovide" | "MacVim" | "Vim" | "VimR")
icon_result=":vim:"
;;
"KeePassXC")
icon_result=":kee_pass_x_c:"
;;
"PomoDone App")
icon_result=":pomodone:"
;;
"DEVONthink 3")
icon_result=":devonthink3:"
;;
"Color Picker" | "数码测色计")
icon_result=":color_picker:"
;;
"Tweetbot" | "Twitter")
icon_result=":twitter:"
;;
"Default")
icon_result=":default:"
;;
"Pages" | "Pages 文稿")
icon_result=":pages:"
;;
"Emacs")
icon_result=":emacs:"
;;
"MAMP" | "MAMP PRO")
icon_result=":mamp:"
;;
"Canary Mail" | "HEY" | "Mail" | "Mailspring" | "MailMate" | "邮件")
icon_result=":mail:"
;;
"WebStorm")
icon_result=":web_storm:"
;;
"TickTick")
icon_result=":tick_tick:"
;;
"TIDAL")
icon_result=":tidal:"
;;
"VLC")
icon_result=":vlc:"
;;
"Blender")
icon_result=":blender:"
;;
"Music" | "音乐")
icon_result=":music:"
;;
"Calendar" | "日历" | "Fantastical" | "Cron" | "Amie")
icon_result=":calendar:"
;;
"Evernote Legacy")
icon_result=":evernote_legacy:"
;;
"Microsoft Word")
icon_result=":microsoft_word:"
;;
"Safari" | "Safari浏览器" | "Safari Technology Preview")
icon_result=":safari:"
;;
"MoneyMoney")
icon_result=":bank:"
;;
"Xcode")
icon_result=":xcode:"
;;
"Numbers" | "Numbers 表格")
icon_result=":numbers:"
;;
"ClickUp")
icon_result=":click_up:"
;;
"Arc")
icon_result=":arc:"
;;
"Zeplin")
icon_result=":zeplin:"
;;
"Trello")
icon_result=":trello:"
;;
"Vivaldi")
icon_result=":vivaldi:"
;;
"Calibre")
icon_result=":book:"
;;
"Min")
icon_result=":min_browser:"
;;
"网易云音乐")
icon_result=":netease_music:"
;;
"GrandTotal" | "Receipts")
icon_result=":dollar:"
;;
"zoom.us")
icon_result=":zoom:"
;;
"Folx")
icon_result=":folx:"
;;
"微信")
icon_result=":wechat:"
;;
"Orion" | "Orion RC")
icon_result=":orion:"
;;
"Notability")
icon_result=":notability:"
;;
"Todoist")
icon_result=":todoist:"
;;
"Replit")
icon_result=":replit:"
;;
"Tor Browser")
icon_result=":tor_browser:"
;;
"Drafts")
icon_result=":drafts:"
;;
"Preview" | "预览" | "Skim" | "zathura")
icon_result=":pdf:"
;;
"PyCharm")
icon_result=":pycharm:"
;;
"Audacity")
icon_result=":audacity:"
;;
"Cypress")
icon_result=":cypress:"
;;
"VSCodium")
icon_result=":vscodium:"
;;
"Podcasts" | "播客")
icon_result=":podcasts:"
;;
"DingTalk" | "钉钉" | "阿里钉")
icon_result=":dingtalk:"
;;
"OBS")
icon_result=":obsstudio:"
;;
"Firefox Developer Edition" | "Firefox Nightly")
icon_result=":firefox_developer_edition:"
;;
"Alfred")
icon_result=":alfred:"
;;
"OmniFocus")
icon_result=":omni_focus:"
;;
"Skype")
icon_result=":skype:"
;;
"Spark Desktop")
icon_result=":spark:"
;;
"Docker" | "Docker Desktop")
icon_result=":docker:"
;;
"Signal")
icon_result=":signal:"
;;
"Pine")
icon_result=":pine:"
;;
"Insomnia")
icon_result=":insomnia:"
;;
"Microsoft Edge")
icon_result=":microsoft_edge:"
;;
"Affinity Photo")
icon_result=":affinity_photo:"
;;
"Sketch")
icon_result=":sketch:"
;;
"Android Studio")
icon_result=":android_studio:"
;;
"Bitwarden")
icon_result=":bit_warden:"
;;
"Affinity Publisher")
icon_result=":affinity_publisher:"
;;
"Zotero")
icon_result=":zotero:"
;;
"Sublime Text")
icon_result=":sublime_text:"
;;
"Warp")
icon_result=":warp:"
;;
"Messages" | "信息" | "Nachrichten")
icon_result=":messages:"
;;
"Obsidian")
icon_result=":obsidian:"
;;
"IntelliJ IDEA")
icon_result=":idea:"
;;
"Atom")
icon_result=":atom:"
;;
"FaceTime" | "FaceTime 通话")
icon_result=":face_time:"
;;
"Yuque" | "语雀")
icon_result=":yuque:"
;;
"Grammarly Editor")
icon_result=":grammarly:"
;;
"Mattermost")
icon_result=":mattermost:"
;;
"Affinity Designer")
icon_result=":affinity_designer:"
;;
"mpv")
icon_result=":mpv:"
;;
"Thunderbird")
icon_result=":thunderbird:"
;;
"Airmail")
icon_result=":airmail:"
;;
"Microsoft Teams")
icon_result=":microsoft_teams:"
;;
"Bear")
icon_result=":bear:"
;;
"System Preferences" | "System Settings" | "系统设置")
icon_result=":gear:"
;;
"Nova")
icon_result=":nova:"
;;
"WhatsApp")
icon_result=":whats_app:"
;;
*)
icon_result=":default:"
;;
esac
}
icon_map "$1"
echo "$icon_result"

View file

@ -0,0 +1,9 @@
#!/bin/bash
STATE="$(echo "$INFO" | jq -r '.state')"
if [ "$STATE" = "playing" ]; then
MEDIA="$(echo "$INFO" | jq -r '.title + " - " + .artist')"
sketchybar --set $NAME label="$MEDIA" drawing=on
else
sketchybar --set $NAME drawing=off
fi

View file

@ -0,0 +1,18 @@
#!/bin/sh
# The $SELECTED variable is available for space components and indicates if
# the space invoking this script (with name: $NAME) is currently selected:
# https://felixkratz.github.io/SketchyBar/config/components#space----associate-mission-control-spaces-with-an-item
source "$CONFIG_DIR/colors.sh" # Loads all defined colors
if [ $SELECTED = true ]; then
sketchybar --set $NAME background.drawing=on \
background.color=$ACCENT_COLOR \
label.color=$BAR_COLOR \
icon.color=$BAR_COLOR
else
sketchybar --set $NAME background.drawing=off \
label.color=$ACCENT_COLOR \
icon.color=$ACCENT_COLOR
fi

View file

@ -0,0 +1,18 @@
#!/bin/bash
if [ "$SENDER" = "space_windows_change" ]; then
space="$(echo "$INFO" | jq -r '.space')"
apps="$(echo "$INFO" | jq -r '.apps | keys[]')"
icon_strip=" "
if [ "${apps}" != "" ]; then
while read -r app
do
icon_strip+=" $($CONFIG_DIR/plugins/icon_map_fn.sh "$app")"
done <<< "${apps}"
else
icon_strip=" —"
fi
sketchybar --set space.$space label="$icon_strip"
fi

View file

@ -0,0 +1,20 @@
#!/bin/sh
# The volume_change event supplies a $INFO variable in which the current volume
# percentage is passed to the script.
if [ "$SENDER" = "volume_change" ]; then
VOLUME=$INFO
case $VOLUME in
[6-9][0-9]|100) ICON="􀊩"
;;
[3-5][0-9]) ICON="􀊥"
;;
[1-9]|[1-2][0-9]) ICON="􀊡"
;;
*) ICON="􀊣"
esac
sketchybar --set $NAME icon="$ICON" label="$VOLUME%"
fi

65
.config/sketchybar/sketchybarrc Executable file
View file

@ -0,0 +1,65 @@
#!/bin/bash
source "$CONFIG_DIR/colors.sh" # Loads all defined colors
# This is a demo config to show some of the most important commands more easily.
# This is meant to be changed and configured, as it is intentionally kept sparse.
# For a more advanced configuration example see my dotfiles:
# https://github.com/FelixKratz/dotfiles
PLUGIN_DIR="$CONFIG_DIR/plugins"
ITEM_DIR="$CONFIG_DIR/items"
##### Bar Appearance #####
# Configuring the general appearance of the bar, these are only some of the
# options available. For all options see:
# https://felixkratz.github.io/SketchyBar/config/bar
# If you are looking for other colors, see the color picker:
# https://felixkratz.github.io/SketchyBar/config/tricks#color-picker
sketchybar --bar height=37 \
blur_radius=30 \
position=top \
sticky=off \
padding_left=10 \
padding_right=10 \
color=$BAR_COLOR
##### Changing Defaults #####
# We now change some default values that are applied to all further items
# For a full list of all available item properties see:
# https://felixkratz.github.io/SketchyBar/config/items
sketchybar --default icon.font="SF Pro:Semibold:15.0" \
icon.color=$WHITE \
label.font="SF Pro:Semibold:15.0" \
label.color=$WHITE \
background.color=$ITEM_BG_COLOR \
background.corner_radius=5 \
background.height=24 \
padding_left=5 \
padding_right=5 \
label.padding_left=4 \
label.padding_right=10 \
icon.padding_left=10 \
icon.padding_right=4
# -- Left Side Items --
source $ITEM_DIR/spaces.sh
source $ITEM_DIR/front_app.sh
# -- Right Side Of Notch Items --
source $ITEM_DIR/media.sh
# -- Right Side Items --
source $ITEM_DIR/calendar.sh
source $ITEM_DIR/volume.sh
source $ITEM_DIR/battery.sh
source $ITEM_DIR/cpu.sh
##### Finalizing Setup #####
# The below command is only needed at the end of the initial configuration to
# force all scripts to run the first time, it should never be run in an item script.
sketchybar --update