worf: Update yabay/sketchybar/alacritty config
This commit is contained in:
33
hosts/worf/sketchybar/plugins/battery.sh
Executable file
33
hosts/worf/sketchybar/plugins/battery.sh
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
source "$CONFIG_DIR/icons.sh"
|
||||
source "$CONFIG_DIR/colors.sh"
|
||||
|
||||
BATTERY_INFO="$(pmset -g batt)"
|
||||
PERCENTAGE=$(echo "$BATTERY_INFO" | /usr/bin/grep -Eo "\d+%" | cut -d% -f1)
|
||||
CHARGING=$(echo "$BATTERY_INFO" | grep 'AC Power')
|
||||
|
||||
if [ $PERCENTAGE = "" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
DRAWING=on
|
||||
COLOR=$WHITE
|
||||
case ${PERCENTAGE} in
|
||||
9[0-9]|100) ICON=$BATTERY_100; DRAWING=off
|
||||
;;
|
||||
[6-8][0-9]) ICON=$BATTERY_75; DRAWING=off
|
||||
;;
|
||||
[3-5][0-9]) ICON=$BATTERY_50
|
||||
;;
|
||||
[1-2][0-9]) ICON=$BATTERY_25; COLOR=$ORANGE
|
||||
;;
|
||||
*) ICON=$BATTERY_0; COLOR=$RED
|
||||
esac
|
||||
|
||||
if [[ $CHARGING != "" ]]; then
|
||||
ICON=$BATTERY_CHARGING
|
||||
DRAWING=off
|
||||
fi
|
||||
|
||||
sketchybar --set $NAME drawing=$DRAWING icon="$ICON" icon.color=$COLOR
|
||||
3
hosts/worf/sketchybar/plugins/calendar.sh
Executable file
3
hosts/worf/sketchybar/plugins/calendar.sh
Executable file
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
|
||||
sketchybar --set $NAME icon="$(date '+%a %d. %b')" label="$(date '+%H:%M')"
|
||||
5
hosts/worf/sketchybar/plugins/front_app.sh
Executable file
5
hosts/worf/sketchybar/plugins/front_app.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$SENDER" = "front_app_switched" ]; then
|
||||
sketchybar --set $NAME label="$INFO" icon.background.image="app.$INFO"
|
||||
fi
|
||||
414
hosts/worf/sketchybar/plugins/icon_map.sh
Executable file
414
hosts/worf/sketchybar/plugins/icon_map.sh
Executable file
@@ -0,0 +1,414 @@
|
||||
case "$1" in
|
||||
"WhatsApp")
|
||||
icon_result=":whats_app:"
|
||||
;;
|
||||
"Nova")
|
||||
icon_result=":nova:"
|
||||
;;
|
||||
"Signal")
|
||||
icon_result=":signal:"
|
||||
;;
|
||||
"Affinity Photo")
|
||||
icon_result=":affinity_photo:"
|
||||
;;
|
||||
"Sublime Text")
|
||||
icon_result=":sublime_text:"
|
||||
;;
|
||||
"Notion")
|
||||
icon_result=":notion:"
|
||||
;;
|
||||
"Pine")
|
||||
icon_result=":pine:"
|
||||
;;
|
||||
"Alacritty" | "Hyper" | "iTerm2" | "kitty" | "Terminal" | "终端" | "WezTerm")
|
||||
icon_result=":terminal:"
|
||||
;;
|
||||
"Podcasts" | "播客")
|
||||
icon_result=":podcasts:"
|
||||
;;
|
||||
"Spark Desktop")
|
||||
icon_result=":spark:"
|
||||
;;
|
||||
"Dropbox")
|
||||
icon_result=":dropbox:"
|
||||
;;
|
||||
"OmniFocus")
|
||||
icon_result=":omni_focus:"
|
||||
;;
|
||||
"TIDAL")
|
||||
icon_result=":tidal:"
|
||||
;;
|
||||
"Spotlight")
|
||||
icon_result=":spotlight:"
|
||||
;;
|
||||
"Affinity Publisher")
|
||||
icon_result=":affinity_publisher:"
|
||||
;;
|
||||
"Replit")
|
||||
icon_result=":replit:"
|
||||
;;
|
||||
"Kakoune")
|
||||
icon_result=":kakoune:"
|
||||
;;
|
||||
"Code" | "Code - Insiders")
|
||||
icon_result=":code:"
|
||||
;;
|
||||
"Microsoft Excel")
|
||||
icon_result=":microsoft_excel:"
|
||||
;;
|
||||
"League of Legends")
|
||||
icon_result=":league_of_legends:"
|
||||
;;
|
||||
"Obsidian")
|
||||
icon_result=":obsidian:"
|
||||
;;
|
||||
"Typora")
|
||||
icon_result=":text:"
|
||||
;;
|
||||
"Blender")
|
||||
icon_result=":blender:"
|
||||
;;
|
||||
"Microsoft Edge")
|
||||
icon_result=":microsoft_edge:"
|
||||
;;
|
||||
"Caprine")
|
||||
icon_result=":caprine:"
|
||||
;;
|
||||
"Figma")
|
||||
icon_result=":figma:"
|
||||
;;
|
||||
"Folx")
|
||||
icon_result=":folx:"
|
||||
;;
|
||||
"Arc")
|
||||
icon_result=":arc:"
|
||||
;;
|
||||
"TeamSpeak 3")
|
||||
icon_result=":team_speak:"
|
||||
;;
|
||||
"Drafts")
|
||||
icon_result=":drafts:"
|
||||
;;
|
||||
"Jellyfin Media Player")
|
||||
icon_result=":jellyfin:"
|
||||
;;
|
||||
"Element")
|
||||
icon_result=":element:"
|
||||
;;
|
||||
"Numbers" | "Numbers 表格")
|
||||
icon_result=":numbers:"
|
||||
;;
|
||||
"Airmail")
|
||||
icon_result=":airmail:"
|
||||
;;
|
||||
"Preview" | "预览" | "Skim" | "zathura")
|
||||
icon_result=":pdf:"
|
||||
;;
|
||||
"zoom.us")
|
||||
icon_result=":zoom:"
|
||||
;;
|
||||
"IntelliJ IDEA")
|
||||
icon_result=":idea:"
|
||||
;;
|
||||
"Music" | "音乐")
|
||||
icon_result=":music:"
|
||||
;;
|
||||
"Safari" | "Safari浏览器" | "Safari Technology Preview")
|
||||
icon_result=":safari:"
|
||||
;;
|
||||
"Finder" | "访达")
|
||||
icon_result=":finder:"
|
||||
;;
|
||||
"TickTick")
|
||||
icon_result=":tick_tick:"
|
||||
;;
|
||||
"Mattermost")
|
||||
icon_result=":mattermost:"
|
||||
;;
|
||||
"Calendar" | "日历" | "Fantastical" | "Cron" | "Amie")
|
||||
icon_result=":calendar:"
|
||||
;;
|
||||
"Todoist")
|
||||
icon_result=":todoist:"
|
||||
;;
|
||||
"Live")
|
||||
icon_result=":ableton:"
|
||||
;;
|
||||
"Logseq")
|
||||
icon_result=":logseq:"
|
||||
;;
|
||||
"Parallels Desktop")
|
||||
icon_result=":parallels:"
|
||||
;;
|
||||
"App Store")
|
||||
icon_result=":app_store:"
|
||||
;;
|
||||
"ClickUp")
|
||||
icon_result=":click_up:"
|
||||
;;
|
||||
"Docker" | "Docker Desktop")
|
||||
icon_result=":docker:"
|
||||
;;
|
||||
"Trello")
|
||||
icon_result=":trello:"
|
||||
;;
|
||||
"Microsoft To Do" | "Things")
|
||||
icon_result=":things:"
|
||||
;;
|
||||
"Notability")
|
||||
icon_result=":notability:"
|
||||
;;
|
||||
"Brave Browser")
|
||||
icon_result=":brave_browser:"
|
||||
;;
|
||||
"网易云音乐")
|
||||
icon_result=":netease_music:"
|
||||
;;
|
||||
"Messages" | "信息" | "Nachrichten")
|
||||
icon_result=":messages:"
|
||||
;;
|
||||
"DEVONthink 3")
|
||||
icon_result=":devonthink3:"
|
||||
;;
|
||||
"Bear")
|
||||
icon_result=":bear:"
|
||||
;;
|
||||
"Notes" | "备忘录")
|
||||
icon_result=":notes:"
|
||||
;;
|
||||
"GrandTotal" | "Receipts")
|
||||
icon_result=":dollar:"
|
||||
;;
|
||||
"Cypress")
|
||||
icon_result=":cypress:"
|
||||
;;
|
||||
"Sequel Pro")
|
||||
icon_result=":sequel_pro:"
|
||||
;;
|
||||
"Sequel Ace")
|
||||
icon_result=":sequel_ace:"
|
||||
;;
|
||||
"PomoDone App")
|
||||
icon_result=":pomodone:"
|
||||
;;
|
||||
"mpv")
|
||||
icon_result=":mpv:"
|
||||
;;
|
||||
"Orion" | "Orion RC")
|
||||
icon_result=":orion:"
|
||||
;;
|
||||
"System Preferences" | "系统设置")
|
||||
icon_result=":gear:"
|
||||
;;
|
||||
"Reminders" | "提醒事项")
|
||||
icon_result=":reminders:"
|
||||
;;
|
||||
"MoneyMoney")
|
||||
icon_result=":bank:"
|
||||
;;
|
||||
"MAMP" | "MAMP PRO")
|
||||
icon_result=":mamp:"
|
||||
;;
|
||||
"Final Cut Pro")
|
||||
icon_result=":final_cut_pro:"
|
||||
;;
|
||||
"Microsoft PowerPoint")
|
||||
icon_result=":microsoft_power_point:"
|
||||
;;
|
||||
"VLC")
|
||||
icon_result=":vlc:"
|
||||
;;
|
||||
"Chromium" | "Google Chrome" | "Google Chrome Canary")
|
||||
icon_result=":google_chrome:"
|
||||
;;
|
||||
"Xcode")
|
||||
icon_result=":xcode:"
|
||||
;;
|
||||
"Canary Mail" | "HEY" | "Mail" | "Mailspring" | "MailMate" | "邮件")
|
||||
icon_result=":mail:"
|
||||
;;
|
||||
"Vivaldi")
|
||||
icon_result=":vivaldi:"
|
||||
;;
|
||||
"Color Picker" | "数码测色计")
|
||||
icon_result=":color_picker:"
|
||||
;;
|
||||
"Audacity")
|
||||
icon_result=":audacity:"
|
||||
;;
|
||||
"WebStorm")
|
||||
icon_result=":web_storm:"
|
||||
;;
|
||||
"Emacs")
|
||||
icon_result=":emacs:"
|
||||
;;
|
||||
"GitHub Desktop")
|
||||
icon_result=":git_hub:"
|
||||
;;
|
||||
"Setapp")
|
||||
icon_result=":setapp:"
|
||||
;;
|
||||
"微信")
|
||||
icon_result=":wechat:"
|
||||
;;
|
||||
"Alfred")
|
||||
icon_result=":alfred:"
|
||||
;;
|
||||
"Tor Browser")
|
||||
icon_result=":tor_browser:"
|
||||
;;
|
||||
"Skype")
|
||||
icon_result=":skype:"
|
||||
;;
|
||||
"qutebrowser")
|
||||
icon_result=":qute_browser:"
|
||||
;;
|
||||
"Firefox Developer Edition" | "Firefox Nightly")
|
||||
icon_result=":firefox_developer_edition:"
|
||||
;;
|
||||
"Insomnia")
|
||||
icon_result=":insomnia:"
|
||||
;;
|
||||
"LibreWolf")
|
||||
icon_result=":libre_wolf:"
|
||||
;;
|
||||
"Tweetbot" | "Twitter")
|
||||
icon_result=":twitter:"
|
||||
;;
|
||||
"FaceTime" | "FaceTime 通话")
|
||||
icon_result=":face_time:"
|
||||
;;
|
||||
"Zotero")
|
||||
icon_result=":zotero:"
|
||||
;;
|
||||
"1Password 7")
|
||||
icon_result=":one_password:"
|
||||
;;
|
||||
"Slack")
|
||||
icon_result=":slack:"
|
||||
;;
|
||||
"Spotify")
|
||||
icon_result=":spotify:"
|
||||
;;
|
||||
"OBS")
|
||||
icon_result=":obsstudio:"
|
||||
;;
|
||||
"Min")
|
||||
icon_result=":min_browser:"
|
||||
;;
|
||||
"Default")
|
||||
icon_result=":default:"
|
||||
;;
|
||||
"Pi-hole Remote")
|
||||
icon_result=":pihole:"
|
||||
;;
|
||||
"VMware Fusion")
|
||||
icon_result=":vmware_fusion:"
|
||||
;;
|
||||
"CleanMyMac X")
|
||||
icon_result=":desktop:"
|
||||
;;
|
||||
"Telegram")
|
||||
icon_result=":telegram:"
|
||||
;;
|
||||
"Bitwarden")
|
||||
icon_result=":bit_warden:"
|
||||
;;
|
||||
"Iris")
|
||||
icon_result=":iris:"
|
||||
;;
|
||||
"Neovide" | "MacVim" | "Vim" | "VimR")
|
||||
icon_result=":vim:"
|
||||
;;
|
||||
"Warp")
|
||||
icon_result=":warp:"
|
||||
;;
|
||||
"Zulip")
|
||||
icon_result=":zulip:"
|
||||
;;
|
||||
"Thunderbird")
|
||||
icon_result=":thunderbird:"
|
||||
;;
|
||||
"Tower")
|
||||
icon_result=":tower:"
|
||||
;;
|
||||
"Matlab")
|
||||
icon_result=":matlab:"
|
||||
;;
|
||||
"Joplin")
|
||||
icon_result=":joplin:"
|
||||
;;
|
||||
"Android Studio")
|
||||
icon_result=":android_studio:"
|
||||
;;
|
||||
"Keynote" | "Keynote 讲演")
|
||||
icon_result=":keynote:"
|
||||
;;
|
||||
"Grammarly Editor")
|
||||
icon_result=":grammarly:"
|
||||
;;
|
||||
"Firefox")
|
||||
icon_result=":firefox:"
|
||||
;;
|
||||
"Zed")
|
||||
icon_result=":zed:"
|
||||
;;
|
||||
"Sketch")
|
||||
icon_result=":sketch:"
|
||||
;;
|
||||
"Discord" | "Discord Canary" | "Discord PTB")
|
||||
icon_result=":discord:"
|
||||
;;
|
||||
"Evernote Legacy")
|
||||
icon_result=":evernote_legacy:"
|
||||
;;
|
||||
"Zeplin")
|
||||
icon_result=":zeplin:"
|
||||
;;
|
||||
"KeePassXC")
|
||||
icon_result=":kee_pass_x_c:"
|
||||
;;
|
||||
"Microsoft Teams")
|
||||
icon_result=":microsoft_teams:"
|
||||
;;
|
||||
"카카오톡")
|
||||
icon_result=":kakaotalk:"
|
||||
;;
|
||||
"Linear")
|
||||
icon_result=":linear:"
|
||||
;;
|
||||
"Microsoft Word")
|
||||
icon_result=":microsoft_word:"
|
||||
;;
|
||||
"Atom")
|
||||
icon_result=":atom:"
|
||||
;;
|
||||
"Keyboard Maestro")
|
||||
icon_result=":keyboard_maestro:"
|
||||
;;
|
||||
"Transmit")
|
||||
icon_result=":transmit:"
|
||||
;;
|
||||
"Android Messages")
|
||||
icon_result=":android_messages:"
|
||||
;;
|
||||
"Pages" | "Pages 文稿")
|
||||
icon_result=":pages:"
|
||||
;;
|
||||
"Affinity Designer")
|
||||
icon_result=":affinity_designer:"
|
||||
;;
|
||||
"VSCodium")
|
||||
icon_result=":vscodium:"
|
||||
;;
|
||||
"Reeder")
|
||||
icon_result=":reeder5:"
|
||||
;;
|
||||
"Calibre")
|
||||
icon_result=":book:"
|
||||
;;
|
||||
*)
|
||||
icon_result=":default:"
|
||||
;;
|
||||
esac
|
||||
echo $icon_result
|
||||
18
hosts/worf/sketchybar/plugins/media.sh
Executable file
18
hosts/worf/sketchybar/plugins/media.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
update_media() {
|
||||
STATE="$(echo "$INFO" | jq -r '.state')"
|
||||
|
||||
if [ "$STATE" = "playing" ]; then
|
||||
APP=$(echo "$INFO" | jq -r '.app')
|
||||
MEDIA="$(echo "$INFO" | jq -r '.title + " - " + .artist')"
|
||||
sketchybar --set $NAME label="$MEDIA" drawing=on
|
||||
else
|
||||
sketchybar --set $NAME drawing=off
|
||||
fi
|
||||
}
|
||||
|
||||
case "$SENDER" in
|
||||
"media_change") update_media
|
||||
;;
|
||||
esac
|
||||
42
hosts/worf/sketchybar/plugins/space.sh
Executable file
42
hosts/worf/sketchybar/plugins/space.sh
Executable file
@@ -0,0 +1,42 @@
|
||||
#!/bin/bash
|
||||
|
||||
update() {
|
||||
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
|
||||
}
|
||||
|
||||
set_space_label() {
|
||||
sketchybar --set $NAME icon="$@"
|
||||
}
|
||||
|
||||
mouse_clicked() {
|
||||
if [ "$BUTTON" = "right" ]; then
|
||||
yabai -m space --destroy $SID
|
||||
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
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
case "$SENDER" in
|
||||
"mouse.clicked") mouse_clicked
|
||||
;;
|
||||
*) update
|
||||
;;
|
||||
esac
|
||||
21
hosts/worf/sketchybar/plugins/space_windows.sh
Executable file
21
hosts/worf/sketchybar/plugins/space_windows.sh
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$SENDER" = "space_windows_change" ]; then
|
||||
args=(--animate sin 10)
|
||||
|
||||
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.sh "$app")"
|
||||
done <<< "${apps}"
|
||||
else
|
||||
icon_strip=" —"
|
||||
fi
|
||||
args+=(--set space.$space label="$icon_strip")
|
||||
|
||||
sketchybar -m "${args[@]}"
|
||||
fi
|
||||
147
hosts/worf/sketchybar/plugins/spotify.sh
Executable file
147
hosts/worf/sketchybar/plugins/spotify.sh
Executable file
@@ -0,0 +1,147 @@
|
||||
#!/bin/bash
|
||||
|
||||
next ()
|
||||
{
|
||||
osascript -e 'tell application "Spotify" to play next track'
|
||||
}
|
||||
|
||||
back ()
|
||||
{
|
||||
osascript -e 'tell application "Spotify" to play previous track'
|
||||
}
|
||||
|
||||
play ()
|
||||
{
|
||||
osascript -e 'tell application "Spotify" to playpause'
|
||||
}
|
||||
|
||||
repeat ()
|
||||
{
|
||||
REPEAT=$(osascript -e 'tell application "Spotify" to get repeating')
|
||||
if [ "$REPEAT" = "false" ]; then
|
||||
sketchybar -m --set spotify.repeat icon.highlight=on
|
||||
osascript -e 'tell application "Spotify" to set repeating to true'
|
||||
else
|
||||
sketchybar -m --set spotify.repeat icon.highlight=off
|
||||
osascript -e 'tell application "Spotify" to set repeating to false'
|
||||
fi
|
||||
}
|
||||
|
||||
shuffle ()
|
||||
{
|
||||
SHUFFLE=$(osascript -e 'tell application "Spotify" to get shuffling')
|
||||
if [ "$SHUFFLE" = "false" ]; then
|
||||
sketchybar -m --set spotify.shuffle icon.highlight=on
|
||||
osascript -e 'tell application "Spotify" to set shuffling to true'
|
||||
else
|
||||
sketchybar -m --set spotify.shuffle icon.highlight=off
|
||||
osascript -e 'tell application "Spotify" to set shuffling to false'
|
||||
fi
|
||||
}
|
||||
|
||||
update ()
|
||||
{
|
||||
PLAYING=1
|
||||
if [ "$(echo "$INFO" | jq -r '.["Player State"]')" = "Playing" ]; then
|
||||
PLAYING=0
|
||||
TRACK="$(echo "$INFO" | jq -r .Name)"
|
||||
ARTIST="$(echo "$INFO" | jq -r .Artist)"
|
||||
ALBUM="$(echo "$INFO" | jq -r .Album)"
|
||||
SHUFFLE=$(osascript -e 'tell application "Spotify" to get shuffling')
|
||||
REPEAT=$(osascript -e 'tell application "Spotify" to get repeating')
|
||||
COVER=$(osascript -e 'tell application "Spotify" to get artwork url of current track')
|
||||
fi
|
||||
|
||||
args=()
|
||||
if [ $PLAYING -eq 0 ]; then
|
||||
curl -s --max-time 20 "$COVER" -o /tmp/cover.jpg
|
||||
if [ "$ARTIST" == "" ]; then
|
||||
args+=(--set spotify.title label="$TRACK"
|
||||
--set spotify.album label="Podcast"
|
||||
--set spotify.artist label="$ALBUM" )
|
||||
else
|
||||
args+=(--set spotify.title label="$TRACK"
|
||||
--set spotify.album label="$ALBUM"
|
||||
--set spotify.artist label="$ARTIST")
|
||||
fi
|
||||
args+=(--set spotify.play icon=
|
||||
--set spotify.shuffle icon.highlight=$SHUFFLE
|
||||
--set spotify.repeat icon.highlight=$REPEAT
|
||||
--set spotify.cover background.image="/tmp/cover.jpg"
|
||||
background.color=0x00000000
|
||||
--set spotify.anchor drawing=on )
|
||||
else
|
||||
args+=(--set spotify.anchor drawing=off popup.drawing=off
|
||||
--set spotify.play icon= )
|
||||
fi
|
||||
sketchybar -m "${args[@]}"
|
||||
}
|
||||
|
||||
scrubbing() {
|
||||
DURATION_MS=$(osascript -e 'tell application "Spotify" to get duration of current track')
|
||||
DURATION=$((DURATION_MS/1000))
|
||||
|
||||
TARGET=$((DURATION*PERCENTAGE/100))
|
||||
osascript -e "tell application \"Spotify\" to set player position to $TARGET"
|
||||
sketchybar --set spotify.state slider.percentage=$PERCENTAGE
|
||||
}
|
||||
|
||||
scroll() {
|
||||
DURATION_MS=$(osascript -e 'tell application "Spotify" to get duration of current track')
|
||||
DURATION=$((DURATION_MS/1000))
|
||||
|
||||
FLOAT="$(osascript -e 'tell application "Spotify" to get player position')"
|
||||
TIME=${FLOAT%.*}
|
||||
|
||||
sketchybar --animate linear 10 \
|
||||
--set spotify.state slider.percentage="$((TIME*100/DURATION))" \
|
||||
icon="$(date -r $TIME +'%M:%S')" \
|
||||
label="$(date -r $DURATION +'%M:%S')"
|
||||
}
|
||||
|
||||
mouse_clicked () {
|
||||
case "$NAME" in
|
||||
"spotify.next") next
|
||||
;;
|
||||
"spotify.back") back
|
||||
;;
|
||||
"spotify.play") play
|
||||
;;
|
||||
"spotify.shuffle") shuffle
|
||||
;;
|
||||
"spotify.repeat") repeat
|
||||
;;
|
||||
"spotify.state") scrubbing
|
||||
;;
|
||||
*) exit
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
popup () {
|
||||
sketchybar --set spotify.anchor popup.drawing=$1
|
||||
}
|
||||
|
||||
routine() {
|
||||
case "$NAME" in
|
||||
"spotify.state") scroll
|
||||
;;
|
||||
*) update
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
case "$SENDER" in
|
||||
"mouse.clicked") mouse_clicked
|
||||
;;
|
||||
"mouse.entered") popup on
|
||||
;;
|
||||
"mouse.exited"|"mouse.exited.global") popup off
|
||||
;;
|
||||
"routine") routine
|
||||
;;
|
||||
"forced") exit 0
|
||||
;;
|
||||
*) update
|
||||
;;
|
||||
esac
|
||||
44
hosts/worf/sketchybar/plugins/volume.sh
Executable file
44
hosts/worf/sketchybar/plugins/volume.sh
Executable file
@@ -0,0 +1,44 @@
|
||||
#!/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
|
||||
|
||||
sketchybar --set $NAME slider.percentage=$INFO \
|
||||
--animate tanh 30 --set $NAME slider.width=$WIDTH
|
||||
|
||||
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
|
||||
48
hosts/worf/sketchybar/plugins/volume_click.sh
Executable file
48
hosts/worf/sketchybar/plugins/volume_click.sh
Executable file
@@ -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
|
||||
28
hosts/worf/sketchybar/plugins/wifi.sh
Executable file
28
hosts/worf/sketchybar/plugins/wifi.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
|
||||
update() {
|
||||
source "$CONFIG_DIR/icons.sh"
|
||||
INFO="$(/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | awk -F ' SSID: ' '/ SSID: / {print $2}')"
|
||||
LABEL="$INFO ($(ipconfig getifaddr en0))"
|
||||
ICON="$([ -n "$INFO" ] && echo "$WIFI_CONNECTED" || echo "$WIFI_DISCONNECTED")"
|
||||
|
||||
sketchybar --set $NAME icon="$ICON" label="$LABEL"
|
||||
}
|
||||
|
||||
click() {
|
||||
CURRENT_WIDTH="$(sketchybar --query $NAME | jq -r .label.width)"
|
||||
|
||||
WIDTH=0
|
||||
if [ "$CURRENT_WIDTH" -eq "0" ]; then
|
||||
WIDTH=dynamic
|
||||
fi
|
||||
|
||||
sketchybar --animate sin 20 --set $NAME label.width="$WIDTH"
|
||||
}
|
||||
|
||||
case "$SENDER" in
|
||||
"wifi_change") update
|
||||
;;
|
||||
"mouse.clicked") click
|
||||
;;
|
||||
esac
|
||||
51
hosts/worf/sketchybar/plugins/yabai.sh
Executable file
51
hosts/worf/sketchybar/plugins/yabai.sh
Executable file
@@ -0,0 +1,51 @@
|
||||
#!/bin/bash
|
||||
|
||||
window_state() {
|
||||
source "$CONFIG_DIR/colors.sh"
|
||||
source "$CONFIG_DIR/icons.sh"
|
||||
|
||||
WINDOW=$(yabai -m query --windows --window)
|
||||
STACK_INDEX=$(echo "$WINDOW" | jq '.["stack-index"]')
|
||||
|
||||
COLOR=$BAR_BORDER_COLOR
|
||||
ICON=""
|
||||
|
||||
if [ "$(echo "$WINDOW" | jq '.["is-floating"]')" = "true" ]; then
|
||||
ICON+=$YABAI_FLOAT
|
||||
COLOR=$MAGENTA
|
||||
elif [ "$(echo "$WINDOW" | jq '.["has-fullscreen-zoom"]')" = "true" ]; then
|
||||
ICON+=$YABAI_FULLSCREEN_ZOOM
|
||||
COLOR=$GREEN
|
||||
elif [ "$(echo "$WINDOW" | jq '.["has-parent-zoom"]')" = "true" ]; then
|
||||
ICON+=$YABAI_PARENT_ZOOM
|
||||
COLOR=$BLUE
|
||||
elif [[ $STACK_INDEX -gt 0 ]]; then
|
||||
LAST_STACK_INDEX=$(yabai -m query --windows --window stack.last | jq '.["stack-index"]')
|
||||
ICON+=$YABAI_STACK
|
||||
LABEL="$(printf "[%s/%s]" "$STACK_INDEX" "$LAST_STACK_INDEX")"
|
||||
COLOR=$RED
|
||||
fi
|
||||
|
||||
args=(--bar border_color=$COLOR --animate sin 10 --set $NAME icon.color=$COLOR)
|
||||
|
||||
[ -z "$LABEL" ] && args+=(label.width=0) \
|
||||
|| args+=(label="$LABEL" label.width=40)
|
||||
|
||||
[ -z "$ICON" ] && args+=(icon.width=0) \
|
||||
|| args+=(icon="$ICON" icon.width=30)
|
||||
|
||||
sketchybar -m "${args[@]}"
|
||||
}
|
||||
|
||||
|
||||
mouse_clicked() {
|
||||
yabai -m window --toggle float
|
||||
window_state
|
||||
}
|
||||
|
||||
case "$SENDER" in
|
||||
"mouse.clicked") mouse_clicked
|
||||
;;
|
||||
"window_focus") window_state
|
||||
;;
|
||||
esac
|
||||
39
hosts/worf/sketchybar/plugins/zen.sh
Executable file
39
hosts/worf/sketchybar/plugins/zen.sh
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/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 volume 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 volume 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
|
||||
|
||||
Reference in New Issue
Block a user