| ... | ... | @@ -2,534 +2,538 @@ |
| 2 | 2 | pkgs, |
| 3 | 3 | lib, |
| 4 | 4 | config, |
| 5 | host, |
| 5 | 6 | ... |
| 6 | 7 | }: { |
| 7 | 8 | home.file = |
| 8 | | lib.attrsets.mapAttrs (file: value: ( |
| 9 | | lib.attrsets.overrideExisting value {enable = config.shared.darwin.tiling.enable;} |
| 10 | | )) { |
| 11 | | sketchybarrc = { |
| 12 | | executable = true; |
| 13 | | target = ".config/sketchybar/sketchybarrc"; |
| 14 | | text = '' |
| 15 | | #!/usr/bin/env sh |
| 16 | | |
| 17 | | source "$HOME/.config/sketchybar/colors.sh" # Loads all defined colors |
| 18 | | |
| 19 | | ITEM_DIR="$HOME/.config/sketchybar/items" # Directory where the items are configured |
| 20 | | PLUGIN_DIR="$HOME/.config/sketchybar/plugins" # Directory where all the plugin scripts are stored |
| 21 | | |
| 22 | | FONT="SF Pro" # Needs to have Regular, Bold, Semibold, Heavy and Black variants |
| 23 | | PADDINGS=3 # All paddings use this value (icon, label, background) |
| 24 | | |
| 25 | | |
| 26 | | # Setting up the general bar appearance and default values |
| 27 | | ${pkgs.sketchybar}/bin/sketchybar --bar height=40 \ |
| 28 | | blur_radius=30 \ |
| 29 | | position=top \ |
| 30 | | sticky=on \ |
| 31 | | padding_left=10 \ |
| 32 | | padding_right=10 |
| 33 | | |
| 34 | | |
| 35 | | ${pkgs.sketchybar}/bin/sketchybar --default icon.font="SF Pro:Semibold:12.0" \ |
| 36 | | icon.color=$ITEM_COLOR \ |
| 37 | | label.font="SF Pro:Semibold:12.0" \ |
| 38 | | label.color=$ITEM_COLOR \ |
| 39 | | background.color=$ACCENT_COLOR \ |
| 40 | | background.corner_radius=10 \ |
| 41 | | background.height=20 \ |
| 42 | | padding_left=4 \ |
| 43 | | padding_right=4 \ |
| 44 | | icon.padding_left=6 \ |
| 45 | | icon.padding_right=3 \ |
| 46 | | label.padding_left=3 \ |
| 47 | | label.padding_right=6 |
| 48 | | |
| 49 | | |
| 50 | | # Left |
| 51 | | # source "$ITEM_DIR/apple.sh" |
| 52 | | source "$ITEM_DIR/spaces.sh" |
| 53 | | source "$ITEM_DIR/front_app.sh" |
| 54 | | |
| 55 | | # Center |
| 56 | | # source "$ITEM_DIR/spotify.sh" |
| 57 | | source "$ITEM_DIR/calendar.sh" |
| 58 | | |
| 59 | | # Right |
| 60 | | source $ITEM_DIR/calendar.sh |
| 61 | | source $ITEM_DIR/wifi.sh |
| 62 | | source $ITEM_DIR/battery.sh |
| 63 | | source $ITEM_DIR/volume.sh |
| 64 | | |
| 65 | | # Forcing all item scripts to run (never do this outside of sketchybarrc) |
| 66 | | ${pkgs.sketchybar}/bin/sketchybar --update |
| 67 | | |
| 68 | | echo "sketchybar configuation loaded.." |
| 69 | | ''; |
| 70 | | }; |
| 71 | | icons = { |
| 72 | | executable = true; |
| 73 | | target = ".config/sketchybar/plugins/icons.sh"; |
| 74 | | text = '' |
| 75 | | #!/usr/bin/env sh |
| 76 | | |
| 77 | | # Source the icon map with all the application icons |
| 78 | | source ${pkgs.sketchybar-app-font}/bin/icon_map.sh |
| 79 | | |
| 80 | | # Create a cache directory if it doesn't exist |
| 81 | | CACHE_DIR="$HOME/.cache/sketchybar" |
| 82 | | mkdir -p "$CACHE_DIR" |
| 83 | | |
| 84 | | # Cache file for icon mappings |
| 85 | | ICON_CACHE="$CACHE_DIR/icon_cache.txt" |
| 86 | | |
| 87 | | # Create the cache file if it doesn't exist |
| 88 | | if [ ! -f "$ICON_CACHE" ]; then |
| 89 | | touch "$ICON_CACHE" |
| 90 | | fi |
| 91 | | |
| 92 | | # Check if the app is already in cache |
| 93 | | APP_NAME=$(if [ "$1" = "Zen" ]; then echo "Zen Browser"; else echo "$1"; fi) |
| 94 | | |
| 95 | | CACHED_ICON=$(grep "^$APP_NAME|" "$ICON_CACHE" | cut -d '|' -f2) |
| 96 | | |
| 97 | | if [ -n "$CACHED_ICON" ]; then |
| 98 | | # Cache hit, return the icon |
| 99 | | echo "$CACHED_ICON" |
| 100 | | exit 0 |
| 101 | | fi |
| 102 | | |
| 103 | | # Get icon from the mapping function |
| 104 | | __icon_map "$APP_NAME" |
| 105 | | |
| 106 | | if [ -n "$icon_result" ]; then |
| 107 | | echo "$APP_NAME|$icon_result" >>"$ICON_CACHE" |
| 108 | | fi |
| 109 | | |
| 110 | | echo "$icon_result" |
| 111 | | ''; |
| 112 | | }; |
| 113 | | colors = { |
| 114 | | executable = true; |
| 115 | | target = ".config/sketchybar/colors.sh"; |
| 116 | | text = '' |
| 117 | | |
| 118 | | export TRANSPARENT=0x00ffffff |
| 119 | | |
| 120 | | # -- Gray Scheme -- |
| 121 | | export ITEM_COLOR=0xff000000 |
| 122 | | export ACCENT_COLOR=0xffc3c6cb |
| 123 | | |
| 124 | | # -- White Scheme -- |
| 125 | | # export ITEM_COLOR=0xff000000 |
| 126 | | # export ACCENT_COLOR=0xffffffff |
| 127 | | |
| 128 | | # -- Teal Scheme -- |
| 129 | | # export ITEM_COLOR=0xff000000 |
| 130 | | # export ACCENT_COLOR=0xff2cf9ed |
| 131 | | |
| 132 | | # -- Purple Scheme -- |
| 133 | | # export ITEM_COLOR=0xff000000 |
| 134 | | # export ACCENT_COLOR=0xffeb46f9 |
| 135 | | |
| 136 | | # -- Red Scheme --- |
| 137 | | # export ITEM_COLOR=0xff000000 |
| 138 | | # export ACCENT_COLOR=0xffff2453 |
| 139 | | |
| 140 | | # -- Blue Scheme --- |
| 141 | | # export ITEM_COLOR=0xff000000 |
| 142 | | # export ACCENT_COLOR=0xff15bdf9 |
| 143 | | |
| 144 | | # -- Green Scheme -- |
| 145 | | # export ITEM_COLOR=0xff000000 |
| 146 | | # export ACCENT_COLOR=0xff1dfca1 |
| 147 | | |
| 148 | | # -- Orange Scheme -- |
| 149 | | # export ITEM_COLOR=0xffffffff |
| 150 | | # export ACCENT_COLOR=0xfff97716 |
| 151 | | |
| 152 | | # -- Yellow Scheme -- |
| 153 | | # export ITEM_COLOR=0xff000000 |
| 154 | | # export ACCENT_COLOR=0xfff7fc17 |
| 155 | | ''; |
| 156 | | }; |
| 157 | | items_wifi = { |
| 158 | | executable = true; |
| 159 | | target = ".config/sketchybar/items/wifi.sh"; |
| 160 | | text = '' |
| 161 | | #!/usr/bin/env/ sh |
| 162 | | |
| 163 | | sketchybar --add item wifi right \ |
| 164 | | --set wifi \ |
| 165 | | icon="" \ |
| 166 | | label="Updating..." \ |
| 167 | | script="$PLUGIN_DIR/wifi.sh" \ |
| 168 | | --subscribe wifi wifi_change |
| 169 | | ''; |
| 170 | | }; |
| 171 | | items_battery = { |
| 172 | | executable = true; |
| 173 | | target = ".config/sketchybar/items/battery.sh"; |
| 174 | | text = '' |
| 175 | | #!/usr/bin/env/ sh |
| 176 | | sketchybar --add item battery right \ |
| 177 | | --set battery update_freq=180 \ |
| 178 | | script="$PLUGIN_DIR/battery.sh" \ |
| 179 | | --subscribe battery system_woke power_source_change |
| 180 | | ''; |
| 181 | | }; |
| 182 | | items_calendar = { |
| 183 | | executable = true; |
| 184 | | target = ".config/sketchybar/items/calendar.sh"; |
| 185 | | text = '' |
| 186 | | #!/usr/bin/env sh |
| 187 | | sketchybar --add item calendar right \ |
| 188 | | --set calendar icon= \ |
| 189 | | update_freq=15 \ |
| 190 | | script="$PLUGIN_DIR/calendar.sh" |
| 191 | | ''; |
| 192 | | }; |
| 193 | | items_front_app = { |
| 194 | | executable = true; |
| 195 | | target = ".config/sketchybar/items/front_app.sh"; |
| 196 | | text = '' |
| 197 | | #!/usr/bin/env sh |
| 198 | | |
| 199 | | sketchybar --add item front_app left \ |
| 200 | | --set front_app background.color=$ACCENT_COLOR \ |
| 201 | | icon.color=$ITEM_COLOR \ |
| 202 | | label.color=$ITEM_COLOR \ |
| 203 | | icon.font="sketchybar-app-font:Regular:12.0" \ |
| 204 | | label.font="SF Pro:Semibold:12.0" \ |
| 205 | | script="$PLUGIN_DIR/front_app.sh" \ |
| 206 | | --subscribe front_app front_app_switched |
| 207 | | ''; |
| 208 | | }; |
| 209 | | items_spaces = { |
| 210 | | executable = true; |
| 211 | | target = ".config/sketchybar/items/spaces.sh"; |
| 212 | | text = '' |
| 213 | | sketchybar --add event aerospace_workspace_change |
| 214 | | |
| 215 | | sketchybar --add item aerospace_dummy left \ |
| 216 | | --set aerospace_dummy display=0 \ |
| 217 | | script="$PLUGIN_DIR/spaces.sh" \ |
| 218 | | --subscribe aerospace_dummy aerospace_workspace_change |
| 219 | | |
| 220 | | for m in $(aerospace list-monitors | awk '{print $1}'); do |
| 221 | | for sid in $(aerospace list-workspaces --monitor $m); do |
| 222 | | sketchybar --add space space.$sid left \ |
| 223 | | --set space.$sid space=$sid \ |
| 224 | | icon=$sid \ |
| 225 | | background.color=$TRANSPARENT \ |
| 226 | | label.color=$ACCENT_COLOR \ |
| 227 | | icon.color=$ACCENT_COLOR \ |
| 228 | | display=$m \ |
| 229 | | label.font="sketchybar-app-font:Regular:12.0" \ |
| 230 | | icon.font="SF Pro:Semibold:12.0" \ |
| 231 | | label.padding_right=10 \ |
| 232 | | label.y_offset=-1 \ |
| 233 | | click_script="$PLUGIN_DIR/space_click.sh $sid" |
| 234 | | |
| 235 | | apps=$(aerospace list-windows --monitor "$m" --workspace "$sid" | |
| 236 | | awk -F '|' '{gsub(/^ *| *$/, "", $2); if (!seen[$2]++) print $2}') |
| 9 | {} |
| 10 | // lib.optionalAttrs host.darwin ( |
| 11 | lib.attrsets.mapAttrs (file: value: ( |
| 12 | lib.attrsets.overrideExisting value {enable = config.shared.darwin.tiling.enable;} |
| 13 | )) { |
| 14 | sketchybarrc = { |
| 15 | executable = true; |
| 16 | target = ".config/sketchybar/sketchybarrc"; |
| 17 | text = '' |
| 18 | #!/usr/bin/env sh |
| 19 | |
| 20 | source "$HOME/.config/sketchybar/colors.sh" # Loads all defined colors |
| 21 | |
| 22 | ITEM_DIR="$HOME/.config/sketchybar/items" # Directory where the items are configured |
| 23 | PLUGIN_DIR="$HOME/.config/sketchybar/plugins" # Directory where all the plugin scripts are stored |
| 24 | |
| 25 | FONT="SF Pro" # Needs to have Regular, Bold, Semibold, Heavy and Black variants |
| 26 | PADDINGS=3 # All paddings use this value (icon, label, background) |
| 27 | |
| 28 | |
| 29 | # Setting up the general bar appearance and default values |
| 30 | ${pkgs.sketchybar}/bin/sketchybar --bar height=40 \ |
| 31 | blur_radius=30 \ |
| 32 | position=top \ |
| 33 | sticky=on \ |
| 34 | padding_left=10 \ |
| 35 | padding_right=10 |
| 36 | |
| 37 | |
| 38 | ${pkgs.sketchybar}/bin/sketchybar --default icon.font="SF Pro:Semibold:12.0" \ |
| 39 | icon.color=$ITEM_COLOR \ |
| 40 | label.font="SF Pro:Semibold:12.0" \ |
| 41 | label.color=$ITEM_COLOR \ |
| 42 | background.color=$ACCENT_COLOR \ |
| 43 | background.corner_radius=10 \ |
| 44 | background.height=20 \ |
| 45 | padding_left=4 \ |
| 46 | padding_right=4 \ |
| 47 | icon.padding_left=6 \ |
| 48 | icon.padding_right=3 \ |
| 49 | label.padding_left=3 \ |
| 50 | label.padding_right=6 |
| 51 | |
| 52 | |
| 53 | # Left |
| 54 | # source "$ITEM_DIR/apple.sh" |
| 55 | source "$ITEM_DIR/spaces.sh" |
| 56 | source "$ITEM_DIR/front_app.sh" |
| 57 | |
| 58 | # Center |
| 59 | # source "$ITEM_DIR/spotify.sh" |
| 60 | source "$ITEM_DIR/calendar.sh" |
| 61 | |
| 62 | # Right |
| 63 | source $ITEM_DIR/calendar.sh |
| 64 | source $ITEM_DIR/wifi.sh |
| 65 | source $ITEM_DIR/battery.sh |
| 66 | source $ITEM_DIR/volume.sh |
| 67 | |
| 68 | # Forcing all item scripts to run (never do this outside of sketchybarrc) |
| 69 | ${pkgs.sketchybar}/bin/sketchybar --update |
| 70 | |
| 71 | echo "sketchybar configuation loaded.." |
| 72 | ''; |
| 73 | }; |
| 74 | icons = { |
| 75 | executable = true; |
| 76 | target = ".config/sketchybar/plugins/icons.sh"; |
| 77 | text = '' |
| 78 | #!/usr/bin/env sh |
| 79 | |
| 80 | # Source the icon map with all the application icons |
| 81 | source ${pkgs.sketchybar-app-font}/bin/icon_map.sh |
| 82 | |
| 83 | # Create a cache directory if it doesn't exist |
| 84 | CACHE_DIR="$HOME/.cache/sketchybar" |
| 85 | mkdir -p "$CACHE_DIR" |
| 86 | |
| 87 | # Cache file for icon mappings |
| 88 | ICON_CACHE="$CACHE_DIR/icon_cache.txt" |
| 89 | |
| 90 | # Create the cache file if it doesn't exist |
| 91 | if [ ! -f "$ICON_CACHE" ]; then |
| 92 | touch "$ICON_CACHE" |
| 93 | fi |
| 237 | 94 | |
| 238 | | icon_strip="" |
| 239 | | if [ "''${apps}" != "" ]; then |
| 240 | | while read -r app; do |
| 241 | | icon_strip+=" $($PLUGIN_DIR/icons.sh "$app")" |
| 242 | | done <<<"''${apps}" |
| 243 | | else |
| 244 | | icon_strip=" —" |
| 245 | | fi |
| 95 | # Check if the app is already in cache |
| 96 | APP_NAME=$(if [ "$1" = "Zen" ]; then echo "Zen Browser"; else echo "$1"; fi) |
| 246 | 97 | |
| 247 | | sketchybar --set space.$sid label="$icon_strip" |
| 98 | CACHED_ICON=$(grep "^$APP_NAME|" "$ICON_CACHE" | cut -d '|' -f2) |
| 248 | 99 | |
| 249 | | done |
| 100 | if [ -n "$CACHED_ICON" ]; then |
| 101 | # Cache hit, return the icon |
| 102 | echo "$CACHED_ICON" |
| 103 | exit 0 |
| 104 | fi |
| 250 | 105 | |
| 251 | | for empty_space in $(aerospace list-workspaces --monitor $m --empty); do |
| 252 | | sketchybar --set space.$empty_space display=0 |
| 253 | | done |
| 254 | | for focus in $(aerospace list-workspaces --focused); do |
| 255 | | sketchybar --set space.$focus background.drawing=on \ |
| 256 | | background.color=$ACCENT_COLOR \ |
| 257 | | label.color=$ITEM_COLOR \ |
| 258 | | icon.color=$ITEM_COLOR |
| 259 | | done |
| 260 | | done |
| 261 | | ''; |
| 262 | | }; |
| 263 | | |
| 264 | | items_volume = { |
| 265 | | executable = true; |
| 266 | | target = ".config/sketchybar/items/volume.sh"; |
| 267 | | text = '' |
| 268 | | #/usr/bin/env sh |
| 269 | | |
| 270 | | sketchybar --add item volume right \ |
| 271 | | --set volume script="$PLUGIN_DIR/volume.sh" \ |
| 272 | | --subscribe volume volume_change |
| 273 | | ''; |
| 274 | | }; |
| 275 | | plugins_wifi = { |
| 276 | | executable = true; |
| 277 | | target = ".config/sketchybar/plugins/wifi.sh"; |
| 278 | | text = '' |
| 279 | | #/usr/bin/env sh |
| 280 | | |
| 281 | | SSID=$(system_profiler SPAirPortDataType | awk '/Current Network Information:/ { getline; print substr($0, 13, (length($0) - 13)); exit }') |
| 282 | | |
| 283 | | if [ "$SSID" = "" ]; then |
| 284 | | sketchybar --set $NAME icon="" label="Disconnected" |
| 285 | | else |
| 286 | | sketchybar --set $NAME icon="" label="$SSID" |
| 287 | | fi |
| 288 | | |
| 289 | | ''; |
| 290 | | }; |
| 291 | | plugins_calendar = { |
| 292 | | executable = true; |
| 293 | | target = ".config/sketchybar/plugins/calendar.sh"; |
| 294 | | |
| 295 | | text = '' |
| 296 | | #/usr/bin/env sh |
| 297 | | |
| 298 | | sketchybar --set $NAME label="$(date +'%a %d %b %I:%M %p')" |
| 299 | | ''; |
| 300 | | }; |
| 301 | | plugins_spaces = { |
| 302 | | executable = true; |
| 303 | | target = ".config/sketchybar/plugins/spaces.sh"; |
| 304 | | text = '' |
| 305 | | #!/usr/bin/env sh |
| 306 | | |
| 307 | | source "$CONFIG_DIR/colors.sh" |
| 308 | | |
| 309 | | update_workspace_appearance() { |
| 310 | | local sid=$1 |
| 311 | | local is_focused=$2 |
| 312 | | |
| 313 | | if [ "$is_focused" = "true" ]; then |
| 314 | | sketchybar --set space.$sid background.drawing=on \ |
| 315 | | background.color=$ACCENT_COLOR \ |
| 316 | | label.color=$ITEM_COLOR \ |
| 317 | | icon.color=$ITEM_COLOR |
| 318 | | else |
| 319 | | sketchybar --set space.$sid background.drawing=off \ |
| 320 | | label.color=$ACCENT_COLOR \ |
| 321 | | icon.color=$ACCENT_COLOR |
| 106 | # Get icon from the mapping function |
| 107 | __icon_map "$APP_NAME" |
| 108 | |
| 109 | if [ -n "$icon_result" ]; then |
| 110 | echo "$APP_NAME|$icon_result" >>"$ICON_CACHE" |
| 322 | 111 | fi |
| 323 | | } |
| 324 | 112 | |
| 325 | | update_icons() { |
| 326 | | m=$1 |
| 327 | | sid=$2 |
| 113 | echo "$icon_result" |
| 114 | ''; |
| 115 | }; |
| 116 | colors = { |
| 117 | executable = true; |
| 118 | target = ".config/sketchybar/colors.sh"; |
| 119 | text = '' |
| 120 | |
| 121 | export TRANSPARENT=0x00ffffff |
| 122 | |
| 123 | # -- Gray Scheme -- |
| 124 | export ITEM_COLOR=0xff000000 |
| 125 | export ACCENT_COLOR=0xffc3c6cb |
| 126 | |
| 127 | # -- White Scheme -- |
| 128 | # export ITEM_COLOR=0xff000000 |
| 129 | # export ACCENT_COLOR=0xffffffff |
| 130 | |
| 131 | # -- Teal Scheme -- |
| 132 | # export ITEM_COLOR=0xff000000 |
| 133 | # export ACCENT_COLOR=0xff2cf9ed |
| 134 | |
| 135 | # -- Purple Scheme -- |
| 136 | # export ITEM_COLOR=0xff000000 |
| 137 | # export ACCENT_COLOR=0xffeb46f9 |
| 138 | |
| 139 | # -- Red Scheme --- |
| 140 | # export ITEM_COLOR=0xff000000 |
| 141 | # export ACCENT_COLOR=0xffff2453 |
| 142 | |
| 143 | # -- Blue Scheme --- |
| 144 | # export ITEM_COLOR=0xff000000 |
| 145 | # export ACCENT_COLOR=0xff15bdf9 |
| 146 | |
| 147 | # -- Green Scheme -- |
| 148 | # export ITEM_COLOR=0xff000000 |
| 149 | # export ACCENT_COLOR=0xff1dfca1 |
| 150 | |
| 151 | # -- Orange Scheme -- |
| 152 | # export ITEM_COLOR=0xffffffff |
| 153 | # export ACCENT_COLOR=0xfff97716 |
| 154 | |
| 155 | # -- Yellow Scheme -- |
| 156 | # export ITEM_COLOR=0xff000000 |
| 157 | # export ACCENT_COLOR=0xfff7fc17 |
| 158 | ''; |
| 159 | }; |
| 160 | items_wifi = { |
| 161 | executable = true; |
| 162 | target = ".config/sketchybar/items/wifi.sh"; |
| 163 | text = '' |
| 164 | #!/usr/bin/env/ sh |
| 165 | |
| 166 | sketchybar --add item wifi right \ |
| 167 | --set wifi \ |
| 168 | icon="" \ |
| 169 | label="Updating..." \ |
| 170 | script="$PLUGIN_DIR/wifi.sh" \ |
| 171 | --subscribe wifi wifi_change |
| 172 | ''; |
| 173 | }; |
| 174 | items_battery = { |
| 175 | executable = true; |
| 176 | target = ".config/sketchybar/items/battery.sh"; |
| 177 | text = '' |
| 178 | #!/usr/bin/env/ sh |
| 179 | sketchybar --add item battery right \ |
| 180 | --set battery update_freq=180 \ |
| 181 | script="$PLUGIN_DIR/battery.sh" \ |
| 182 | --subscribe battery system_woke power_source_change |
| 183 | ''; |
| 184 | }; |
| 185 | items_calendar = { |
| 186 | executable = true; |
| 187 | target = ".config/sketchybar/items/calendar.sh"; |
| 188 | text = '' |
| 189 | #!/usr/bin/env sh |
| 190 | sketchybar --add item calendar right \ |
| 191 | --set calendar icon= \ |
| 192 | update_freq=15 \ |
| 193 | script="$PLUGIN_DIR/calendar.sh" |
| 194 | ''; |
| 195 | }; |
| 196 | items_front_app = { |
| 197 | executable = true; |
| 198 | target = ".config/sketchybar/items/front_app.sh"; |
| 199 | text = '' |
| 200 | #!/usr/bin/env sh |
| 201 | |
| 202 | sketchybar --add item front_app left \ |
| 203 | --set front_app background.color=$ACCENT_COLOR \ |
| 204 | icon.color=$ITEM_COLOR \ |
| 205 | label.color=$ITEM_COLOR \ |
| 206 | icon.font="sketchybar-app-font:Regular:12.0" \ |
| 207 | label.font="SF Pro:Semibold:12.0" \ |
| 208 | script="$PLUGIN_DIR/front_app.sh" \ |
| 209 | --subscribe front_app front_app_switched |
| 210 | ''; |
| 211 | }; |
| 212 | items_spaces = { |
| 213 | executable = true; |
| 214 | target = ".config/sketchybar/items/spaces.sh"; |
| 215 | text = '' |
| 216 | sketchybar --add event aerospace_workspace_change |
| 217 | |
| 218 | sketchybar --add item aerospace_dummy left \ |
| 219 | --set aerospace_dummy display=0 \ |
| 220 | script="$PLUGIN_DIR/spaces.sh" \ |
| 221 | --subscribe aerospace_dummy aerospace_workspace_change |
| 328 | 222 | |
| 329 | | apps=$(aerospace list-windows --monitor "$m" --workspace "$sid" \ |
| 330 | | | awk -F '|' '{gsub(/^ *| *$/, "", $2); if (!seen[$2]++) print $2}' \ |
| 331 | | | sort) |
| 223 | for m in $(aerospace list-monitors | awk '{print $1}'); do |
| 224 | for sid in $(aerospace list-workspaces --monitor $m); do |
| 225 | sketchybar --add space space.$sid left \ |
| 226 | --set space.$sid space=$sid \ |
| 227 | icon=$sid \ |
| 228 | background.color=$TRANSPARENT \ |
| 229 | label.color=$ACCENT_COLOR \ |
| 230 | icon.color=$ACCENT_COLOR \ |
| 231 | display=$m \ |
| 232 | label.font="sketchybar-app-font:Regular:12.0" \ |
| 233 | icon.font="SF Pro:Semibold:12.0" \ |
| 234 | label.padding_right=10 \ |
| 235 | label.y_offset=-1 \ |
| 236 | click_script="$PLUGIN_DIR/space_click.sh $sid" |
| 237 | |
| 238 | apps=$(aerospace list-windows --monitor "$m" --workspace "$sid" | |
| 239 | awk -F '|' '{gsub(/^ *| *$/, "", $2); if (!seen[$2]++) print $2}') |
| 332 | 240 | |
| 333 | | icon_strip="" |
| 334 | | if [ "''${apps}" != "" ]; then |
| 335 | | while read -r app; do |
| 336 | | icon_strip+=" $($CONFIG_DIR/plugins/icons.sh "$app")" |
| 337 | | done <<<"''${apps}" |
| 338 | | else |
| 339 | | icon_strip=" —" |
| 340 | | fi |
| 241 | icon_strip="" |
| 242 | if [ "''${apps}" != "" ]; then |
| 243 | while read -r app; do |
| 244 | icon_strip+=" $($PLUGIN_DIR/icons.sh "$app")" |
| 245 | done <<<"''${apps}" |
| 246 | else |
| 247 | icon_strip=" —" |
| 248 | fi |
| 341 | 249 | |
| 342 | | sketchybar --animate sin 10 --set space.$sid label="$icon_strip" |
| 343 | | } |
| 250 | sketchybar --set space.$sid label="$icon_strip" |
| 344 | 251 | |
| 345 | | update_workspace_appearance "$PREV_WORKSPACE" "false" |
| 346 | | update_workspace_appearance "$FOCUSED_WORKSPACE" "true" |
| 252 | done |
| 347 | 253 | |
| 348 | | for m in $(aerospace list-monitors | awk '{print $1}'); do |
| 349 | | for sid in $(aerospace list-workspaces --monitor $m --visible); do |
| 350 | | sketchybar --set space.$sid display=$m |
| 254 | for empty_space in $(aerospace list-workspaces --monitor $m --empty); do |
| 255 | sketchybar --set space.$empty_space display=0 |
| 256 | done |
| 257 | for focus in $(aerospace list-workspaces --focused); do |
| 258 | sketchybar --set space.$focus background.drawing=on \ |
| 259 | background.color=$ACCENT_COLOR \ |
| 260 | label.color=$ITEM_COLOR \ |
| 261 | icon.color=$ITEM_COLOR |
| 262 | done |
| 263 | done |
| 264 | ''; |
| 265 | }; |
| 266 | |
| 267 | items_volume = { |
| 268 | executable = true; |
| 269 | target = ".config/sketchybar/items/volume.sh"; |
| 270 | text = '' |
| 271 | #/usr/bin/env sh |
| 272 | |
| 273 | sketchybar --add item volume right \ |
| 274 | --set volume script="$PLUGIN_DIR/volume.sh" \ |
| 275 | --subscribe volume volume_change |
| 276 | ''; |
| 277 | }; |
| 278 | plugins_wifi = { |
| 279 | executable = true; |
| 280 | target = ".config/sketchybar/plugins/wifi.sh"; |
| 281 | text = '' |
| 282 | #/usr/bin/env sh |
| 283 | |
| 284 | SSID=$(system_profiler SPAirPortDataType | awk '/Current Network Information:/ { getline; print substr($0, 13, (length($0) - 13)); exit }') |
| 285 | |
| 286 | if [ "$SSID" = "" ]; then |
| 287 | sketchybar --set $NAME icon="" label="Disconnected" |
| 288 | else |
| 289 | sketchybar --set $NAME icon="" label="$SSID" |
| 290 | fi |
| 291 | |
| 292 | ''; |
| 293 | }; |
| 294 | plugins_calendar = { |
| 295 | executable = true; |
| 296 | target = ".config/sketchybar/plugins/calendar.sh"; |
| 297 | |
| 298 | text = '' |
| 299 | #/usr/bin/env sh |
| 300 | |
| 301 | sketchybar --set $NAME label="$(date +'%a %d %b %I:%M %p')" |
| 302 | ''; |
| 303 | }; |
| 304 | plugins_spaces = { |
| 305 | executable = true; |
| 306 | target = ".config/sketchybar/plugins/spaces.sh"; |
| 307 | text = '' |
| 308 | #!/usr/bin/env sh |
| 309 | |
| 310 | source "$CONFIG_DIR/colors.sh" |
| 311 | |
| 312 | update_workspace_appearance() { |
| 313 | local sid=$1 |
| 314 | local is_focused=$2 |
| 315 | |
| 316 | if [ "$is_focused" = "true" ]; then |
| 317 | sketchybar --set space.$sid background.drawing=on \ |
| 318 | background.color=$ACCENT_COLOR \ |
| 319 | label.color=$ITEM_COLOR \ |
| 320 | icon.color=$ITEM_COLOR |
| 321 | else |
| 322 | sketchybar --set space.$sid background.drawing=off \ |
| 323 | label.color=$ACCENT_COLOR \ |
| 324 | icon.color=$ACCENT_COLOR |
| 325 | fi |
| 326 | } |
| 351 | 327 | |
| 352 | | update_icons "$m" "$sid" |
| 328 | update_icons() { |
| 329 | m=$1 |
| 330 | sid=$2 |
| 353 | 331 | |
| 354 | | update_icons "$m" "$PREV_WORKSPACE" |
| 332 | apps=$(aerospace list-windows --monitor "$m" --workspace "$sid" \ |
| 333 | | awk -F '|' '{gsub(/^ *| *$/, "", $2); if (!seen[$2]++) print $2}' \ |
| 334 | | sort) |
| 355 | 335 | |
| 356 | | apps=$(aerospace list-windows --monitor "$m" --workspace "$sid" | wc -l) |
| 357 | | if [ "''${apps}" -eq 0 ]; then |
| 358 | | sketchybar --set space.$sid display=0 |
| 336 | icon_strip="" |
| 337 | if [ "''${apps}" != "" ]; then |
| 338 | while read -r app; do |
| 339 | icon_strip+=" $($CONFIG_DIR/plugins/icons.sh "$app")" |
| 340 | done <<<"''${apps}" |
| 341 | else |
| 342 | icon_strip=" —" |
| 359 | 343 | fi |
| 360 | | done |
| 361 | | done |
| 362 | | ''; |
| 363 | | }; |
| 364 | | |
| 365 | | plugins_space_click = { |
| 366 | | executable = true; |
| 367 | | target = ".config/sketchybar/plugins/space_click.sh"; |
| 368 | | text = '' |
| 369 | | #/usr/bin/env/ sh |
| 370 | | |
| 371 | | apps=$(aerospace list-windows --workspace $1 | awk -F '|' '{gsub(/^ *| *$/, "", $2); print $2}') |
| 372 | | focused=$(aerospace list-workspaces --focused) |
| 373 | | |
| 374 | | if [ "''${apps}" = "" ] && [ "''${focused}" != "$1" ]; then |
| 375 | | sketchybar --set space.$1 display=0 |
| 376 | | else |
| 377 | | aerospace workspace $1 |
| 378 | | fi |
| 379 | | ''; |
| 380 | | }; |
| 381 | | plugins_volume = { |
| 382 | | executable = true; |
| 383 | | target = ".config/sketchybar/plugins/volume.sh"; |
| 384 | | text = '' |
| 385 | | #!/usr/bin/env sh |
| 386 | | |
| 387 | | # The volume_change event supplies a $INFO variable in which the current volume |
| 388 | | # percentage is passed to the script. |
| 389 | | |
| 390 | | if [ "$SENDER" = "volume_change" ]; then |
| 391 | | |
| 392 | | VOLUME=$INFO |
| 393 | | |
| 394 | | case $VOLUME in |
| 395 | | [6-9][0-9] | 100) |
| 396 | | ICON="" |
| 397 | | ;; |
| 398 | | [3-5][0-9]) |
| 399 | | ICON="" |
| 400 | | ;; |
| 401 | | [1-9] | [1-2][0-9]) |
| 402 | | ICON="" |
| 403 | | ;; |
| 404 | | *) ICON="" ;; |
| 405 | | esac |
| 406 | 344 | |
| 407 | | sketchybar --set $NAME icon="$ICON" label="$VOLUME%" |
| 408 | | fi |
| 409 | | ''; |
| 410 | | }; |
| 411 | | plugins_front_app = { |
| 412 | | executable = true; |
| 413 | | target = ".config/sketchybar/plugins/front_app.sh"; |
| 414 | | text = '' |
| 415 | | # Some events send additional information specific to the event in the $INFO |
| 416 | | # variable. E.g. the front_app_switched event sends the name of the newly |
| 417 | | # focused application in the $INFO variable: |
| 418 | | # https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting |
| 419 | | |
| 420 | | app_switched() { |
| 345 | sketchybar --animate sin 10 --set space.$sid label="$icon_strip" |
| 346 | } |
| 347 | |
| 348 | update_workspace_appearance "$PREV_WORKSPACE" "false" |
| 349 | update_workspace_appearance "$FOCUSED_WORKSPACE" "true" |
| 350 | |
| 421 | 351 | for m in $(aerospace list-monitors | awk '{print $1}'); do |
| 422 | 352 | for sid in $(aerospace list-workspaces --monitor $m --visible); do |
| 353 | sketchybar --set space.$sid display=$m |
| 423 | 354 | |
| 424 | | apps=$( (echo "$INFO"; aerospace list-windows --monitor "$m" --workspace "$sid" \ |
| 425 | | | awk -F '|' '{gsub(/^ *| *$/, "", $2); print $2}') \ |
| 426 | | | awk '!seen[$0]++' | sort) |
| 355 | update_icons "$m" "$sid" |
| 427 | 356 | |
| 428 | | icon_strip="" |
| 429 | | if [ "''${apps}" != "" ]; then |
| 430 | | while read -r app; do |
| 431 | | icon_strip+=" $($CONFIG_DIR/plugins/icons.sh "$app")" |
| 432 | | done <<<"''${apps}" |
| 433 | | else |
| 434 | | icon_strip=" —" |
| 435 | | fi |
| 357 | update_icons "$m" "$PREV_WORKSPACE" |
| 436 | 358 | |
| 437 | | sketchybar --animate sin 10 --set space.$sid label="$icon_strip" |
| 359 | apps=$(aerospace list-windows --monitor "$m" --workspace "$sid" | wc -l) |
| 360 | if [ "''${apps}" -eq 0 ]; then |
| 361 | sketchybar --set space.$sid display=0 |
| 362 | fi |
| 438 | 363 | done |
| 439 | 364 | done |
| 440 | | } |
| 441 | | |
| 442 | | if [ "$SENDER" = "front_app_switched" ]; then |
| 443 | | |
| 444 | | sketchybar --set $NAME label="$INFO" icon="$($CONFIG_DIR/plugins/icons.sh "$INFO")" |
| 445 | | |
| 446 | | app_switched |
| 447 | | fi |
| 448 | | ''; |
| 449 | | }; |
| 450 | | plugins_battery = { |
| 451 | | executable = true; |
| 452 | | target = ".config/sketchybar/plugins/battery.sh"; |
| 453 | | text = '' |
| 454 | | #!/usr/bin/env sh |
| 455 | | source "$CONFIG_DIR/colors.sh" |
| 456 | | |
| 457 | | PERCENTAGE=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1) |
| 458 | | CHARGING=$(pmset -g batt | grep 'AC Power') |
| 459 | | |
| 460 | | if [ $PERCENTAGE = "" ]; then |
| 461 | | exit 0 |
| 462 | | fi |
| 463 | | |
| 464 | | case ''${PERCENTAGE} in |
| 465 | | 9[0-9] | 100) |
| 466 | | ICON="" |
| 467 | | COLOR=$ITEM_COLOR |
| 468 | | ;; |
| 469 | | [6-8][0-9]) |
| 470 | | ICON="" |
| 471 | | COLOR=$ITEM_COLOR |
| 472 | | ;; |
| 473 | | [3-5][0-9]) |
| 474 | | ICON="" |
| 475 | | COLOR="0xFFd97706" |
| 476 | | ;; |
| 477 | | [1-2][0-9]) |
| 478 | | ICON="" |
| 479 | | COLOR="0xFFf97316" |
| 480 | | ;; |
| 481 | | *) |
| 482 | | ICON="" |
| 483 | | COLOR="0xFFef4444" |
| 484 | | ;; |
| 485 | | esac |
| 486 | | |
| 487 | | if [[ $CHARGING != "" ]]; then |
| 488 | | ICON="" |
| 489 | | COLOR=$ITEM_COLOR |
| 490 | | fi |
| 491 | | |
| 492 | | # The item invoking this script (name $NAME) will get its icon and label |
| 493 | | # updated with the current battery status |
| 494 | | sketchybar --set $NAME icon="$ICON" label="''${PERCENTAGE}%" icon.color="$COLOR" |
| 495 | | ''; |
| 496 | | }; |
| 497 | | plugins_aerospace = { |
| 498 | | executable = true; |
| 499 | | target = ".config/sketchybar/plugins/aerospace.sh"; |
| 500 | | text = '' |
| 501 | | #!/usr/bin/env bash |
| 502 | | source "$HOME/.config/sketchybar/colors.sh" # Loads all defined colors |
| 503 | | |
| 504 | | highlight_focused_workspace() { |
| 505 | | if [[ "$1" = "$FOCUSED_WORKSPACE" ]] |
| 506 | | then |
| 507 | | ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME icon.highlight=on label.width=0 |
| 365 | ''; |
| 366 | }; |
| 367 | |
| 368 | plugins_space_click = { |
| 369 | executable = true; |
| 370 | target = ".config/sketchybar/plugins/space_click.sh"; |
| 371 | text = '' |
| 372 | #/usr/bin/env/ sh |
| 373 | |
| 374 | apps=$(aerospace list-windows --workspace $1 | awk -F '|' '{gsub(/^ *| *$/, "", $2); print $2}') |
| 375 | focused=$(aerospace list-workspaces --focused) |
| 376 | |
| 377 | if [ "''${apps}" = "" ] && [ "''${focused}" != "$1" ]; then |
| 378 | sketchybar --set space.$1 display=0 |
| 508 | 379 | else |
| 509 | | ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME icon.highlight=off label.width=dynamic |
| 380 | aerospace workspace $1 |
| 510 | 381 | fi |
| 511 | | } |
| 512 | | |
| 513 | | illuminate_mode() { |
| 514 | | if [[ "$mode" = "service" ]] |
| 515 | | then |
| 516 | | ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$ORANGE |
| 517 | | elif [[ "$mode" = "resize" ]] |
| 518 | | then |
| 519 | | ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$GREEN |
| 520 | | else |
| 521 | | ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$BACKGROUND_1 |
| 382 | ''; |
| 383 | }; |
| 384 | plugins_volume = { |
| 385 | executable = true; |
| 386 | target = ".config/sketchybar/plugins/volume.sh"; |
| 387 | text = '' |
| 388 | #!/usr/bin/env sh |
| 389 | |
| 390 | # The volume_change event supplies a $INFO variable in which the current volume |
| 391 | # percentage is passed to the script. |
| 392 | |
| 393 | if [ "$SENDER" = "volume_change" ]; then |
| 394 | |
| 395 | VOLUME=$INFO |
| 396 | |
| 397 | case $VOLUME in |
| 398 | [6-9][0-9] | 100) |
| 399 | ICON="" |
| 400 | ;; |
| 401 | [3-5][0-9]) |
| 402 | ICON="" |
| 403 | ;; |
| 404 | [1-9] | [1-2][0-9]) |
| 405 | ICON="" |
| 406 | ;; |
| 407 | *) ICON="" ;; |
| 408 | esac |
| 409 | |
| 410 | sketchybar --set $NAME icon="$ICON" label="$VOLUME%" |
| 522 | 411 | fi |
| 523 | | } |
| 524 | | case "$SENDER" in |
| 525 | | "aerospace_workspace_change") |
| 526 | | highlight_focused_workspace $1 |
| 412 | ''; |
| 413 | }; |
| 414 | plugins_front_app = { |
| 415 | executable = true; |
| 416 | target = ".config/sketchybar/plugins/front_app.sh"; |
| 417 | text = '' |
| 418 | # Some events send additional information specific to the event in the $INFO |
| 419 | # variable. E.g. the front_app_switched event sends the name of the newly |
| 420 | # focused application in the $INFO variable: |
| 421 | # https://felixkratz.github.io/SketchyBar/config/events#events-and-scripting |
| 422 | |
| 423 | app_switched() { |
| 424 | for m in $(aerospace list-monitors | awk '{print $1}'); do |
| 425 | for sid in $(aerospace list-workspaces --monitor $m --visible); do |
| 426 | |
| 427 | apps=$( (echo "$INFO"; aerospace list-windows --monitor "$m" --workspace "$sid" \ |
| 428 | | awk -F '|' '{gsub(/^ *| *$/, "", $2); print $2}') \ |
| 429 | | awk '!seen[$0]++' | sort) |
| 430 | |
| 431 | icon_strip="" |
| 432 | if [ "''${apps}" != "" ]; then |
| 433 | while read -r app; do |
| 434 | icon_strip+=" $($CONFIG_DIR/plugins/icons.sh "$app")" |
| 435 | done <<<"''${apps}" |
| 436 | else |
| 437 | icon_strip=" —" |
| 438 | fi |
| 439 | |
| 440 | sketchybar --animate sin 10 --set space.$sid label="$icon_strip" |
| 441 | done |
| 442 | done |
| 443 | } |
| 444 | |
| 445 | if [ "$SENDER" = "front_app_switched" ]; then |
| 446 | |
| 447 | sketchybar --set $NAME label="$INFO" icon="$($CONFIG_DIR/plugins/icons.sh "$INFO")" |
| 448 | |
| 449 | app_switched |
| 450 | fi |
| 451 | ''; |
| 452 | }; |
| 453 | plugins_battery = { |
| 454 | executable = true; |
| 455 | target = ".config/sketchybar/plugins/battery.sh"; |
| 456 | text = '' |
| 457 | #!/usr/bin/env sh |
| 458 | source "$CONFIG_DIR/colors.sh" |
| 459 | |
| 460 | PERCENTAGE=$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1) |
| 461 | CHARGING=$(pmset -g batt | grep 'AC Power') |
| 462 | |
| 463 | if [ $PERCENTAGE = "" ]; then |
| 464 | exit 0 |
| 465 | fi |
| 466 | |
| 467 | case ''${PERCENTAGE} in |
| 468 | 9[0-9] | 100) |
| 469 | ICON="" |
| 470 | COLOR=$ITEM_COLOR |
| 471 | ;; |
| 472 | [6-8][0-9]) |
| 473 | ICON="" |
| 474 | COLOR=$ITEM_COLOR |
| 475 | ;; |
| 476 | [3-5][0-9]) |
| 477 | ICON="" |
| 478 | COLOR="0xFFd97706" |
| 479 | ;; |
| 480 | [1-2][0-9]) |
| 481 | ICON="" |
| 482 | COLOR="0xFFf97316" |
| 527 | 483 | ;; |
| 528 | | "aerospace_mode_change") |
| 529 | | illuminate_mode |
| 484 | *) |
| 485 | ICON="" |
| 486 | COLOR="0xFFef4444" |
| 530 | 487 | ;; |
| 531 | | esac |
| 532 | | ''; |
| 533 | | }; |
| 534 | | }; |
| 488 | esac |
| 489 | |
| 490 | if [[ $CHARGING != "" ]]; then |
| 491 | ICON="" |
| 492 | COLOR=$ITEM_COLOR |
| 493 | fi |
| 494 | |
| 495 | # The item invoking this script (name $NAME) will get its icon and label |
| 496 | # updated with the current battery status |
| 497 | sketchybar --set $NAME icon="$ICON" label="''${PERCENTAGE}%" icon.color="$COLOR" |
| 498 | ''; |
| 499 | }; |
| 500 | plugins_aerospace = { |
| 501 | executable = true; |
| 502 | target = ".config/sketchybar/plugins/aerospace.sh"; |
| 503 | text = '' |
| 504 | #!/usr/bin/env bash |
| 505 | source "$HOME/.config/sketchybar/colors.sh" # Loads all defined colors |
| 506 | |
| 507 | highlight_focused_workspace() { |
| 508 | if [[ "$1" = "$FOCUSED_WORKSPACE" ]] |
| 509 | then |
| 510 | ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME icon.highlight=on label.width=0 |
| 511 | else |
| 512 | ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME icon.highlight=off label.width=dynamic |
| 513 | fi |
| 514 | } |
| 515 | |
| 516 | illuminate_mode() { |
| 517 | if [[ "$mode" = "service" ]] |
| 518 | then |
| 519 | ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$ORANGE |
| 520 | elif [[ "$mode" = "resize" ]] |
| 521 | then |
| 522 | ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$GREEN |
| 523 | else |
| 524 | ${pkgs.sketchybar}/bin/sketchybar --animate tanh 20 --set $NAME background.color=$BACKGROUND_1 |
| 525 | fi |
| 526 | } |
| 527 | case "$SENDER" in |
| 528 | "aerospace_workspace_change") |
| 529 | highlight_focused_workspace $1 |
| 530 | ;; |
| 531 | "aerospace_mode_change") |
| 532 | illuminate_mode |
| 533 | ;; |
| 534 | esac |
| 535 | ''; |
| 536 | }; |
| 537 | } |
| 538 | ); |
| 535 | 539 | } |