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