mirror of
				https://gitlab.com/thebiblelover7/dotfiles.git
				synced 2025-10-30 06:03:49 +00:00 
			
		
		
		
	Clean up, update configs to be actually useful now...
This commit is contained in:
		
							
								
								
									
										33
									
								
								.config/sketchybar/plugins/battery.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										33
									
								
								.config/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" | 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 | ||||
							
								
								
									
										21
									
								
								.config/sketchybar/plugins/brew.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										21
									
								
								.config/sketchybar/plugins/brew.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,21 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| source "$CONFIG_DIR/colors.sh" | ||||
|  | ||||
| COUNT=$(brew outdated | wc -l | tr -d ' ') | ||||
|  | ||||
| COLOR=$RED | ||||
|  | ||||
| case "$COUNT" in | ||||
|   [3-5][0-9]) COLOR=$ORANGE | ||||
|   ;; | ||||
|   [1-2][0-9]) COLOR=$YELLOW | ||||
|   ;; | ||||
|   [1-9]) COLOR=$WHITE | ||||
|   ;; | ||||
|   0) COLOR=$GREEN | ||||
|      COUNT= | ||||
|   ;; | ||||
| esac | ||||
|  | ||||
| sketchybar --set $NAME label=$COUNT icon.color=$COLOR | ||||
							
								
								
									
										3
									
								
								.config/sketchybar/plugins/calendar.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										3
									
								
								.config/sketchybar/plugins/calendar.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,3 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| sketchybar --set $NAME icon="$(date '+%a, %d %b')" label="$(date '+%H:%M')" | ||||
							
								
								
									
										90
									
								
								.config/sketchybar/plugins/github.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										90
									
								
								.config/sketchybar/plugins/github.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,90 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| update() { | ||||
|   source "$CONFIG_DIR/colors.sh" | ||||
|   source "$CONFIG_DIR/icons.sh" | ||||
|  | ||||
|   NOTIFICATIONS="$(gh api notifications)" | ||||
|   COUNT="$(echo "$NOTIFICATIONS" | jq 'length')" | ||||
|   args=() | ||||
|   if [ "$NOTIFICATIONS" = "[]" ]; then | ||||
|     args+=(--set $NAME icon=$BELL label="0") | ||||
|   else | ||||
|     args+=(--set $NAME icon=$BELL_DOT label="$COUNT") | ||||
|   fi | ||||
|  | ||||
|   PREV_COUNT=$(sketchybar --query github.bell | jq -r .label.value) | ||||
|   # For sound to play around with: | ||||
|   # afplay /System/Library/Sounds/Morse.aiff | ||||
|  | ||||
|   args+=(--remove '/github.notification\.*/') | ||||
|  | ||||
|   COUNTER=0 | ||||
|   COLOR=$BLUE | ||||
|   args+=(--set github.bell icon.color=$COLOR) | ||||
|  | ||||
|   while read -r repo url type title  | ||||
|   do | ||||
|     COUNTER=$((COUNTER + 1)) | ||||
|     IMPORTANT="$(echo "$title" | egrep -i "(deprecat|break|broke)")" | ||||
|     COLOR=$BLUE | ||||
|     PADDING=0 | ||||
|  | ||||
|     if [ "${repo}" = "" ] && [ "${title}" = "" ]; then | ||||
|       repo="Note" | ||||
|       title="No new notifications" | ||||
|     fi  | ||||
|     case "${type}" in | ||||
|       "'Issue'") COLOR=$GREEN; ICON=$GIT_ISSUE; URL="$(gh api "$(echo "${url}" | sed -e "s/^'//" -e "s/'$//")" | jq .html_url)" | ||||
|       ;; | ||||
|       "'Discussion'") COLOR=$WHITE; ICON=$GIT_DISCUSSION; URL="https://www.github.com/notifications" | ||||
|       ;; | ||||
|       "'PullRequest'") COLOR=$MAGENTA; ICON=$GIT_PULL_REQUEST; URL="$(gh api "$(echo "${url}" | sed -e "s/^'//" -e "s/'$//")" | jq .html_url)" | ||||
|       ;; | ||||
|       "'Commit'") COLOR=$WHITE; ICON=$GIT_COMMIT; URL="$(gh api "$(echo "${url}" | sed -e "s/^'//" -e "s/'$//")" | jq .html_url)" | ||||
|       ;; | ||||
|     esac | ||||
|      | ||||
|     if [ "$IMPORTANT" != "" ]; then | ||||
|       COLOR=$RED | ||||
|       ICON= | ||||
|       args+=(--set github.bell icon.color=$COLOR) | ||||
|     fi | ||||
|      | ||||
|     notification=( | ||||
|       label="$(echo "$title" | sed -e "s/^'//" -e "s/'$//")" | ||||
|       icon="$ICON $(echo "$repo" | sed -e "s/^'//" -e "s/'$//"):" | ||||
|       icon.padding_left="$PADDING" | ||||
|       label.padding_right="$PADDING" | ||||
|       icon.color=$COLOR | ||||
|       position=popup.github.bell | ||||
|       icon.background.color=$COLOR | ||||
|       drawing=on | ||||
|       click_script="open $URL; sketchybar --set github.bell popup.drawing=off" | ||||
|     ) | ||||
|  | ||||
|     args+=(--clone github.notification.$COUNTER github.template \ | ||||
|            --set github.notification.$COUNTER "${notification[@]}") | ||||
|   done <<< "$(echo "$NOTIFICATIONS" | jq -r '.[] | [.repository.name, .subject.latest_comment_url, .subject.type, .subject.title] | @sh')" | ||||
|  | ||||
|   sketchybar -m "${args[@]}" > /dev/null | ||||
|  | ||||
|   if [ $COUNT -gt $PREV_COUNT ] 2>/dev/null || [ "$SENDER" = "forced" ]; then | ||||
|     sketchybar --animate tanh 15 --set github.bell label.y_offset=5 label.y_offset=0 | ||||
|   fi | ||||
| } | ||||
|  | ||||
| popup() { | ||||
|   sketchybar --set $NAME popup.drawing=$1 | ||||
| } | ||||
|  | ||||
| case "$SENDER" in | ||||
|   "routine"|"forced") update | ||||
|   ;; | ||||
|   "mouse.entered") popup on | ||||
|   ;; | ||||
|   "mouse.exited"|"mouse.exited.global") popup off | ||||
|   ;; | ||||
|   "mouse.clicked") popup toggle | ||||
|   ;; | ||||
| esac | ||||
							
								
								
									
										384
									
								
								.config/sketchybar/plugins/icon_map.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										384
									
								
								.config/sketchybar/plugins/icon_map.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,384 @@ | ||||
| case $@ in | ||||
| "Brave Browser") | ||||
|   icon_result=":brave_browser:" | ||||
|   ;; | ||||
| "Keyboard Maestro") | ||||
|   icon_result=":keyboard_maestro:" | ||||
|   ;; | ||||
| "Min") | ||||
|   icon_result=":min_browser:" | ||||
|   ;; | ||||
| "Final Cut Pro") | ||||
|   icon_result=":final_cut_pro:" | ||||
|   ;; | ||||
| "FaceTime") | ||||
|   icon_result=":face_time:" | ||||
|   ;; | ||||
| "Affinity Publisher") | ||||
|   icon_result=":affinity_publisher:" | ||||
|   ;; | ||||
| "Messages" | "Nachrichten") | ||||
|   icon_result=":messages:" | ||||
|   ;; | ||||
| "Tweetbot" | "Twitter") | ||||
|   icon_result=":twitter:" | ||||
|   ;; | ||||
| "ClickUp") | ||||
|   icon_result=":click_up:" | ||||
|   ;; | ||||
| "KeePassXC") | ||||
|   icon_result=":kee_pass_x_c:" | ||||
|   ;; | ||||
| "Microsoft Edge") | ||||
|   icon_result=":microsoft_edge:" | ||||
|   ;; | ||||
| "VLC") | ||||
|   icon_result=":vlc:" | ||||
|   ;; | ||||
| "Emacs") | ||||
|   icon_result=":emacs:" | ||||
|   ;; | ||||
| "Thunderbird") | ||||
|   icon_result=":thunderbird:" | ||||
|   ;; | ||||
| "Notes") | ||||
|   icon_result=":notes:" | ||||
|   ;; | ||||
| "Caprine") | ||||
|   icon_result=":caprine:" | ||||
|   ;; | ||||
| "Zulip") | ||||
|   icon_result=":zulip:" | ||||
|   ;; | ||||
| "Spark") | ||||
|   icon_result=":spark:" | ||||
|   ;; | ||||
| "Microsoft To Do" | "Things") | ||||
|   icon_result=":things:" | ||||
|   ;; | ||||
| "DEVONthink 3") | ||||
|   icon_result=":devonthink3:" | ||||
|   ;; | ||||
| "GitHub Desktop") | ||||
|   icon_result=":git_hub:" | ||||
|   ;; | ||||
| "App Store") | ||||
|   icon_result=":app_store:" | ||||
|   ;; | ||||
| "Chromium" | "Google Chrome" | "Google Chrome Canary") | ||||
|   icon_result=":google_chrome:" | ||||
|   ;; | ||||
| "zoom.us") | ||||
|   icon_result=":zoom:" | ||||
|   ;; | ||||
| "MoneyMoney") | ||||
|   icon_result=":bank:" | ||||
|   ;; | ||||
| "Color Picker") | ||||
|   icon_result=":color_picker:" | ||||
|   ;; | ||||
| "Microsoft Word") | ||||
|   icon_result=":microsoft_word:" | ||||
|   ;; | ||||
| "Microsoft Teams") | ||||
|   icon_result=":microsoft_teams:" | ||||
|   ;; | ||||
| "Iris") | ||||
|   icon_result=":iris:" | ||||
|   ;; | ||||
| "WebStorm") | ||||
|   icon_result=":web_storm:" | ||||
|   ;; | ||||
| "Neovide" | "MacVim" | "Vim" | "VimR") | ||||
|   icon_result=":vim:" | ||||
|   ;; | ||||
| "Sublime Text") | ||||
|   icon_result=":sublime_text:" | ||||
|   ;; | ||||
| "PomoDone App") | ||||
|   icon_result=":pomodone:" | ||||
|   ;; | ||||
| "Setapp") | ||||
|   icon_result=":setapp:" | ||||
|   ;; | ||||
| "qutebrowser") | ||||
|   icon_result=":qute_browser:" | ||||
|   ;; | ||||
| "Mattermost") | ||||
|   icon_result=":mattermost:" | ||||
|   ;; | ||||
| "Notability") | ||||
|   icon_result=":notability:" | ||||
|   ;; | ||||
| "WhatsApp") | ||||
|   icon_result=":whats_app:" | ||||
|   ;; | ||||
| "OBS") | ||||
|   icon_result=":obsstudio:" | ||||
|   ;; | ||||
| "Parallels Desktop") | ||||
|   icon_result=":parallels:" | ||||
|   ;; | ||||
| "VMware Fusion") | ||||
|   icon_result=":vmware_fusion:" | ||||
|   ;; | ||||
| "Pine") | ||||
|   icon_result=":pine:" | ||||
|   ;; | ||||
| "Microsoft Excel") | ||||
|   icon_result=":microsoft_excel:" | ||||
|   ;; | ||||
| "Microsoft PowerPoint") | ||||
|   icon_result=":microsoft_power_point:" | ||||
|   ;; | ||||
| "Matlab") | ||||
|   icon_result=":matlab:" | ||||
|   ;; | ||||
| "Numbers") | ||||
|   icon_result=":numbers:" | ||||
|   ;; | ||||
| "Default") | ||||
|   icon_result=":default:" | ||||
|   ;; | ||||
| "Element") | ||||
|   icon_result=":element:" | ||||
|   ;; | ||||
| "Bear") | ||||
|   icon_result=":bear:" | ||||
|   ;; | ||||
| "TeamSpeak 3") | ||||
|   icon_result=":team_speak:" | ||||
|   ;; | ||||
| "Airmail") | ||||
|   icon_result=":airmail:" | ||||
|   ;; | ||||
| "Firefox Developer Edition" | "Firefox Nightly") | ||||
|   icon_result=":firefox_developer_edition:" | ||||
|   ;; | ||||
| "Trello") | ||||
|   icon_result=":trello:" | ||||
|   ;; | ||||
| "TickTick") | ||||
|   icon_result=":tick_tick:" | ||||
|   ;; | ||||
| "Notion") | ||||
|   icon_result=":notion:" | ||||
|   ;; | ||||
| "Live") | ||||
|   icon_result=":ableton:" | ||||
|   ;; | ||||
| "Evernote Legacy") | ||||
|   icon_result=":evernote_legacy:" | ||||
|   ;; | ||||
| "Calendar" | "Fantastical") | ||||
|   icon_result=":calendar:" | ||||
|   ;; | ||||
| "Android Studio") | ||||
|   icon_result=":android_studio:" | ||||
|   ;; | ||||
| "Xcode") | ||||
|   icon_result=":xcode:" | ||||
|   ;; | ||||
| "Slack") | ||||
|   icon_result=":slack:" | ||||
|   ;; | ||||
| "Sequel Pro") | ||||
|   icon_result=":sequel_pro:" | ||||
|   ;; | ||||
| "Bitwarden") | ||||
|   icon_result=":bit_warden:" | ||||
|   ;; | ||||
| "System Preferences" | "System Settings") | ||||
|   icon_result=":gear:" | ||||
|   ;; | ||||
| "Discord" | "Discord Canary" | "Discord PTB") | ||||
|   icon_result=":discord:" | ||||
|   ;; | ||||
| "Vivaldi") | ||||
|   icon_result=":vivaldi:" | ||||
|   ;; | ||||
| "Firefox") | ||||
|   icon_result=":firefox:" | ||||
|   ;; | ||||
| "Skype") | ||||
|   icon_result=":skype:" | ||||
|   ;; | ||||
| "Dropbox") | ||||
|   icon_result=":dropbox:" | ||||
|   ;; | ||||
| "微信") | ||||
|   icon_result=":wechat:" | ||||
|   ;; | ||||
| "Typora") | ||||
|   icon_result=":text:" | ||||
|   ;; | ||||
| "Blender") | ||||
|   icon_result=":blender:" | ||||
|   ;; | ||||
| "Canary Mail" | "HEY" | "Mail" | "Mailspring" | "MailMate" | "邮件" | "Outlook") | ||||
|   icon_result=":mail:" | ||||
|   ;; | ||||
| "Safari" | "Safari Technology Preview") | ||||
|   icon_result=":safari:" | ||||
|   ;; | ||||
| "Telegram") | ||||
|   icon_result=":telegram:" | ||||
|   ;; | ||||
| "Keynote") | ||||
|   icon_result=":keynote:" | ||||
|   ;; | ||||
| "Reeder") | ||||
|   icon_result=":reeder5:" | ||||
|   ;; | ||||
| "Spotify") | ||||
|   icon_result=":spotify:" | ||||
|   ;; | ||||
| "MAMP" | "MAMP PRO") | ||||
|   icon_result=":mamp:" | ||||
|   ;; | ||||
| "Figma") | ||||
|   icon_result=":figma:" | ||||
|   ;; | ||||
| "Joplin") | ||||
|   icon_result=":joplin:" | ||||
|   ;; | ||||
| "Spotlight") | ||||
|   icon_result=":spotlight:" | ||||
|   ;; | ||||
| "Music") | ||||
|   icon_result=":music:" | ||||
|   ;; | ||||
| "Insomnia") | ||||
|   icon_result=":insomnia:" | ||||
|   ;; | ||||
| "TIDAL") | ||||
|   icon_result=":tidal:" | ||||
|   ;; | ||||
| "Alfred") | ||||
|   icon_result=":alfred:" | ||||
|   ;; | ||||
| "Pages") | ||||
|   icon_result=":pages:" | ||||
|   ;; | ||||
| "Folx") | ||||
|   icon_result=":folx:" | ||||
|   ;; | ||||
| "Android Messages") | ||||
|   icon_result=":android_messages:" | ||||
|   ;; | ||||
| "mpv") | ||||
|   icon_result=":mpv:" | ||||
|   ;; | ||||
| "网易云音乐") | ||||
|   icon_result=":netease_music:" | ||||
|   ;; | ||||
| "Transmit") | ||||
|   icon_result=":transmit:" | ||||
|   ;; | ||||
| "Pi-hole Remote") | ||||
|   icon_result=":pihole:" | ||||
|   ;; | ||||
| "Nova") | ||||
|   icon_result=":nova:" | ||||
|   ;; | ||||
| "Affinity Designer") | ||||
|   icon_result=":affinity_designer:" | ||||
|   ;; | ||||
| "IntelliJ IDEA") | ||||
|   icon_result=":idea:" | ||||
|   ;; | ||||
| "Drafts") | ||||
|   icon_result=":drafts:" | ||||
|   ;; | ||||
| "Audacity") | ||||
|   icon_result=":audacity:" | ||||
|   ;; | ||||
| "Affinity Photo") | ||||
|   icon_result=":affinity_photo:" | ||||
|   ;; | ||||
| "Atom") | ||||
|   icon_result=":atom:" | ||||
|   ;; | ||||
| "Obsidian") | ||||
|   icon_result=":obsidian:" | ||||
|   ;; | ||||
| "CleanMyMac X") | ||||
|   icon_result=":desktop:" | ||||
|   ;; | ||||
| "Zotero") | ||||
|   icon_result=":zotero:" | ||||
|   ;; | ||||
| "Todoist") | ||||
|   icon_result=":todoist:" | ||||
|   ;; | ||||
| "LibreWolf") | ||||
|   icon_result=":libre_wolf:" | ||||
|   ;; | ||||
| "Grammarly Editor") | ||||
|   icon_result=":grammarly:" | ||||
|   ;; | ||||
| "OmniFocus") | ||||
|   icon_result=":omni_focus:" | ||||
|   ;; | ||||
| "Reminders") | ||||
|   icon_result=":reminders:" | ||||
|   ;; | ||||
| "Preview" | "Skim" | "zathura") | ||||
|   icon_result=":pdf:" | ||||
|   ;; | ||||
| "1Password 7") | ||||
|   icon_result=":one_password:" | ||||
|   ;; | ||||
| "Code" | "Code - Insiders") | ||||
|   icon_result=":code:" | ||||
|   ;; | ||||
| "VSCodium") | ||||
|   icon_result=":vscodium:" | ||||
|   ;; | ||||
| "Tower") | ||||
|   icon_result=":tower:" | ||||
|   ;; | ||||
| "Calibre") | ||||
|   icon_result=":book:" | ||||
|   ;; | ||||
| "Finder" | "访达") | ||||
|   icon_result=":finder:" | ||||
|   ;; | ||||
| "Linear") | ||||
|   icon_result=":linear:" | ||||
|   ;; | ||||
| "League of Legends") | ||||
|   icon_result=":league_of_legends:" | ||||
|   ;; | ||||
| "Zeplin") | ||||
|   icon_result=":zeplin:" | ||||
|   ;; | ||||
| "Signal") | ||||
|   icon_result=":signal:" | ||||
|   ;; | ||||
| "Podcasts") | ||||
|   icon_result=":podcasts:" | ||||
|   ;; | ||||
| "Alacritty" | "Hyper" | "iTerm2" | "kitty" | "Terminal" | "WezTerm") | ||||
|   icon_result=":terminal:" | ||||
|   ;; | ||||
| "Tor Browser") | ||||
|   icon_result=":tor_browser:" | ||||
|   ;; | ||||
| "Kakoune") | ||||
|   icon_result=":kakoune:" | ||||
|   ;; | ||||
| "GrandTotal" | "Receipts") | ||||
|   icon_result=":dollar:" | ||||
|   ;; | ||||
| "Sketch") | ||||
|   icon_result=":sketch:" | ||||
|   ;; | ||||
| "Sequel Ace") | ||||
|   icon_result=":sequel_ace:" | ||||
|   ;; | ||||
| *) | ||||
|   icon_result=":default:" | ||||
|   ;; | ||||
| esac | ||||
| echo $icon_result | ||||
							
								
								
									
										28
									
								
								.config/sketchybar/plugins/space.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										28
									
								
								.config/sketchybar/plugins/space.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,28 @@ | ||||
| #!/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 | ||||
| } | ||||
|  | ||||
| mouse_clicked() { | ||||
|   if [ "$BUTTON" = "right" ]; then | ||||
|     yabai -m space --destroy $SID | ||||
|     sketchybar --trigger windows_on_spaces --trigger space_change | ||||
|   else | ||||
|     yabai -m space --focus $SID 2>/dev/null | ||||
|   fi | ||||
| } | ||||
|  | ||||
| case "$SENDER" in | ||||
|   "mouse.clicked") mouse_clicked | ||||
|   ;; | ||||
|   *) update | ||||
|   ;; | ||||
| esac | ||||
							
								
								
									
										147
									
								
								.config/sketchybar/plugins/spotify.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										147
									
								
								.config/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 | sed 's/\(.\{20\}\).*/\1.../')" | ||||
|     ARTIST="$(echo "$INFO" | jq -r .Artist | sed 's/\(.\{20\}\).*/\1.../')" | ||||
|     ALBUM="$(echo "$INFO" | jq -r .Album | sed 's/\(.\{25\}\).*/\1.../')" | ||||
|     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 | ||||
							
								
								
									
										56
									
								
								.config/sketchybar/plugins/volume.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										56
									
								
								.config/sketchybar/plugins/volume.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,56 @@ | ||||
| #!/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" | ||||
| } | ||||
|  | ||||
| mouse_entered() { | ||||
|   sketchybar --set $NAME slider.knob.drawing=on | ||||
| } | ||||
|  | ||||
| mouse_exited() { | ||||
|   sketchybar --set $NAME slider.knob.drawing=off | ||||
| } | ||||
|  | ||||
| case "$SENDER" in | ||||
|   "volume_change") volume_change | ||||
|   ;; | ||||
|   "mouse.clicked") mouse_clicked | ||||
|   ;; | ||||
|   "mouse.entered") mouse_entered | ||||
|   ;; | ||||
|   "mouse.exited") mouse_exited | ||||
|   ;; | ||||
| esac | ||||
							
								
								
									
										48
									
								
								.config/sketchybar/plugins/volume_click.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										48
									
								
								.config/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 | ||||
							
								
								
									
										80
									
								
								.config/sketchybar/plugins/yabai.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										80
									
								
								.config/sketchybar/plugins/yabai.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,80 @@ | ||||
| #!/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=(--animate sin 10 --bar border_color=$COLOR | ||||
|                          --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[@]}" | ||||
| } | ||||
|  | ||||
| windows_on_spaces () { | ||||
|   CURRENT_SPACES="$(yabai -m query --displays | jq -r '.[].spaces | @sh')" | ||||
|  | ||||
|   args=(--set spaces_bracket drawing=off | ||||
|         --set '/space\..*/' background.drawing=on | ||||
|         --animate sin 10) | ||||
|  | ||||
|   while read -r line | ||||
|   do | ||||
|     for space in $line | ||||
|     do | ||||
|       icon_strip=" " | ||||
|       apps=$(yabai -m query --windows --space $space | jq -r ".[].app") | ||||
|       if [ "$apps" != "" ]; then | ||||
|         while IFS= read -r app; do | ||||
|           icon_strip+=" $($CONFIG_DIR/plugins/icon_map.sh "$app")" | ||||
|         done <<< "$apps" | ||||
|       fi | ||||
|       args+=(--set space.$space label="$icon_strip" label.drawing=on) | ||||
|     done | ||||
|   done <<< "$CURRENT_SPACES" | ||||
|  | ||||
|   sketchybar -m "${args[@]}" | ||||
| } | ||||
|  | ||||
| mouse_clicked() { | ||||
|   yabai -m window --toggle float | ||||
|   window_state | ||||
| } | ||||
|  | ||||
| case "$SENDER" in | ||||
|   "mouse.clicked") mouse_clicked | ||||
|   ;; | ||||
|   "forced") exit 0 | ||||
|   ;; | ||||
|   "window_focus") window_state  | ||||
|   ;; | ||||
|   "windows_on_spaces") windows_on_spaces | ||||
|   ;; | ||||
| esac | ||||
							
								
								
									
										39
									
								
								.config/sketchybar/plugins/zen.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										39
									
								
								.config/sketchybar/plugins/zen.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| zen_on() { | ||||
|   sketchybar --set github.bell 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 | ||||
| } | ||||
|  | ||||
| zen_off() { | ||||
|   sketchybar --set github.bell 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 | ||||
| } | ||||
|  | ||||
| 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