diff options
author | Jacob Janzen <jacob.a.s.janzen@gmail.com> | 2024-08-14 10:43:27 -0500 |
---|---|---|
committer | Jacob Janzen <jacob.a.s.janzen@gmail.com> | 2024-08-14 10:43:27 -0500 |
commit | 418cf74ec16029d927271fbc255c061c2ed1ec4d (patch) | |
tree | d904b649ecc305f2e8551c360492cc2722a6a912 /macos | |
parent | aeb8600bf9480b73b025133e12fe25b19498c97d (diff) |
add sketchybar config
Diffstat (limited to 'macos')
-rw-r--r-- | macos/.config/sketchybar/plugins/battery.org | 46 | ||||
-rw-r--r-- | macos/.config/sketchybar/plugins/clock.org | 7 | ||||
-rw-r--r-- | macos/.config/sketchybar/plugins/cpu.org | 7 | ||||
-rw-r--r-- | macos/.config/sketchybar/plugins/front_app.org | 9 | ||||
-rw-r--r-- | macos/.config/sketchybar/plugins/mem.org | 16 | ||||
-rw-r--r-- | macos/.config/sketchybar/plugins/space.org | 7 | ||||
-rw-r--r-- | macos/.config/sketchybar/plugins/volume.org | 21 | ||||
-rw-r--r-- | macos/.config/sketchybar/sketchybarrc.org | 77 |
8 files changed, 190 insertions, 0 deletions
diff --git a/macos/.config/sketchybar/plugins/battery.org b/macos/.config/sketchybar/plugins/battery.org new file mode 100644 index 0000000..d3918e2 --- /dev/null +++ b/macos/.config/sketchybar/plugins/battery.org @@ -0,0 +1,46 @@ +#+title: SketchyBar Battery Plugin + +Get the percentage and charging status. +#+begin_src sh :tangle ~/.config/sketchybar/plugins/battery.sh :mkdirp yes :tangle-mode o755 + #!/bin/sh + PERCENTAGE="$(pmset -g batt | grep -Eo "\d+%" | cut -d% -f1)" + CHARGING="$(pmset -g batt | grep 'AC Power')" +#+end_src + +Exit if no percentage was reported. +#+begin_src sh :tangle ~/.config/sketchybar/plugins/battery.sh :mkdirp yes :tangle-mode o755 + if [ "$PERCENTAGE" = "" ]; then + exit 0 + fi +#+end_src + +Choose the icon based on the percentage. +#+begin_src sh :tangle ~/.config/sketchybar/plugins/battery.sh :mkdirp yes :tangle-mode o755 + if [[ "$CHARGING" != "" ]]; then + case "${PERCENTAGE}" in + 9[0-9]|100) ICON="" + ;; + [6-8][0-9]) ICON="" + ;; + [3-5][0-9]) ICON="" + ;; + [1-2][0-9]) ICON="" + ;; + ,*) ICON="" + esac + else + case "${PERCENTAGE}" in + 9[0-9]|100) ICON="" + ;; + [6-8][0-9]) ICON="" + ;; + [3-5][0-9]) ICON="" + ;; + [1-2][0-9]) ICON="" + ;; + ,*) ICON="" + esac + fi + + sketchybar --set "$NAME" icon="$ICON" label="${PERCENTAGE}%" +#+end_src diff --git a/macos/.config/sketchybar/plugins/clock.org b/macos/.config/sketchybar/plugins/clock.org new file mode 100644 index 0000000..1ab5ec3 --- /dev/null +++ b/macos/.config/sketchybar/plugins/clock.org @@ -0,0 +1,7 @@ +#+title: SketchyBar Clock Plugin + +Get the date and set it as the label. +#+begin_src sh :tangle ~/.config/sketchybar/plugins/clock.sh :mkdirp yes :tangle-mode o755 + #!/bin/sh + sketchybar --set "$NAME" label="$(date '+%Y-%m-%d %H:%M')" +#+end_src diff --git a/macos/.config/sketchybar/plugins/cpu.org b/macos/.config/sketchybar/plugins/cpu.org new file mode 100644 index 0000000..199d89b --- /dev/null +++ b/macos/.config/sketchybar/plugins/cpu.org @@ -0,0 +1,7 @@ +#+title: SketchyBar CPU Plugin + +Get the CPU percentage and display it. +#+begin_src sh :tangle ~/.config/sketchybar/plugins/cpu.sh :mkdirp yes :tangle-mode o755 + #!/bin/sh + sketchybar --set "$NAME" icon='' label="$(top -l 2 | grep -E "^CPU" | tail -1 | awk '{ print $3 + $5"%" }')" +#+end_src diff --git a/macos/.config/sketchybar/plugins/front_app.org b/macos/.config/sketchybar/plugins/front_app.org new file mode 100644 index 0000000..44917e4 --- /dev/null +++ b/macos/.config/sketchybar/plugins/front_app.org @@ -0,0 +1,9 @@ +#+title: SketchyBar Front App Plugin + +Get the name of the focused application. +#+begin_src sh :tangle ~/.config/sketchybar/plugins/front_app.sh :mkdirp yes :tangle-mode o755 + #!/bin/sh + if [ "$SENDER" = "front_app_switched" ]; then + sketchybar --set "$NAME" label="$INFO" + fi +#+end_src diff --git a/macos/.config/sketchybar/plugins/mem.org b/macos/.config/sketchybar/plugins/mem.org new file mode 100644 index 0000000..ef3feef --- /dev/null +++ b/macos/.config/sketchybar/plugins/mem.org @@ -0,0 +1,16 @@ +#+title: SketchyBar Memory Plugin + +Get the memory in use and return that as a percent. +#+begin_src sh :tangle ~/.config/sketchybar/plugins/mem.sh :mkdirp yes :tangle-mode o755 + #!/bin/sh + hw_pagesize="$(sysctl -n hw.pagesize)" + mem_total="$(($(sysctl -n hw.memsize) / 1024))" + pages_app="$(($(sysctl -n vm.page_pageable_internal_count) - $(sysctl -n vm.page_purgeable_count)))" + pages_wired="$(vm_stat | awk '/ wired/ { print $4 }')" + pages_compressed="$(vm_stat | awk '/ occupied/ { printf $5 }')" + pages_compressed="${pages_compressed:-0}" + mem_used="$(((pages_app + ${pages_wired//.} + ${pages_compressed//.}) * hw_pagesize / 1024))" + + mem_percent=$((mem_perc=$mem_used * 100 / $mem_total)) + sketchybar --set "$NAME" icon="" label="$mem_percent%" +#+end_src diff --git a/macos/.config/sketchybar/plugins/space.org b/macos/.config/sketchybar/plugins/space.org new file mode 100644 index 0000000..97581aa --- /dev/null +++ b/macos/.config/sketchybar/plugins/space.org @@ -0,0 +1,7 @@ +#+title: SketchyBar Space Plugin + +Get the current space. +#+begin_src sh :tangle ~/.config/sketchybar/plugins/space.sh :mkdirp yes :tangle-mode o755 + #!/bin/sh + sketchybar --set "$NAME" background.drawing="$SELECTED" +#+end_src diff --git a/macos/.config/sketchybar/plugins/volume.org b/macos/.config/sketchybar/plugins/volume.org new file mode 100644 index 0000000..c53b2a1 --- /dev/null +++ b/macos/.config/sketchybar/plugins/volume.org @@ -0,0 +1,21 @@ +#+title: SketchyBar Volume Plugin + +Set an icon based on the current volume and return the volume and the icon. +#+begin_src sh :tangle ~/.config/sketchybar/plugins/volume.sh :mkdirp yes :tangle-mode o755 + #!/bin/sh + if [ "$SENDER" = "volume_change" ]; then + VOLUME="$INFO" + + case "$VOLUME" in + [6-9][0-9]|100) ICON="" + ;; + [3-5][0-9]) ICON="" + ;; + [1-9]|[1-2][0-9]) ICON="" + ;; + ,*) ICON="" + esac + + sketchybar --set "$NAME" icon="$ICON" label="$VOLUME%" + fi +#+end_src diff --git a/macos/.config/sketchybar/sketchybarrc.org b/macos/.config/sketchybar/sketchybarrc.org new file mode 100644 index 0000000..316eaf3 --- /dev/null +++ b/macos/.config/sketchybar/sketchybarrc.org @@ -0,0 +1,77 @@ +#+title: SketchyBar Configuration + +Set the plugin directory. +#+begin_src sh :tangle ~/.config/sketchybar/sketchybarrc :mkdirp yes :tangle-mode o755 + PLUGIN_DIR="$CONFIG_DIR/plugins" +#+end_src + +Place the bar at the of the screen with full transparency. +#+begin_src sh :tangle ~/.config/sketchybar/sketchybarrc :mkdirp yes :tangle-mode o755 + sketchybar --bar position=top height=40 blur_radius=30 color=0x00000000 +#+end_src + +Add small padding to left and right, use Symbols font for icons and Source Code Pro for text. Make all text white and add padding on left and right for labels and icons. +#+begin_src sh :tangle ~/.config/sketchybar/sketchybarrc :mkdirp yes :tangle-mode o755 + default=( + padding_left=5 + padding_right=5 + icon.font="Symbols Nerd Font:Bold:17.0" + label.font="Sauce Code Pro Nerd Font:Bold:14.0" + icon.color=0xffffffff + label.color=0xffffffff + icon.padding_left=4 + icon.padding_right=4 + label.padding_left=4 + label.padding_right=4 + ) + sketchybar --default "${default[@]}" +#+end_src + +Add clickable space icons for 10 spaces. +#+begin_src sh :tangle ~/.config/sketchybar/sketchybarrc :mkdirp yes :tangle-mode o755 + SPACE_ICONS=("1" "2" "3" "4" "5" "6" "7" "8" "9" "10") + for i in "${!SPACE_ICONS[@]}" + do + sid="$(($i+1))" + space=( + space="$sid" + icon="${SPACE_ICONS[i]}" + icon.padding_left=7 + icon.padding_right=7 + background.color=0x40ffffff + background.corner_radius=5 + background.height=25 + label.drawing=off + script="$PLUGIN_DIR/space.sh" + click_script="yabai -m space --focus $sid" + ) + sketchybar --add space space."$sid" left --set space."$sid" "${space[@]}" + done +#+end_src + +Add a chevron before listing the open application. +#+begin_src sh :tangle ~/.config/sketchybar/sketchybarrc :mkdirp yes :tangle-mode o755 + sketchybar --add item chevron left \ + --set chevron icon= label.drawing=off \ + --add item front_app left \ + --set front_app icon.drawing=off script="$PLUGIN_DIR/front_app.sh" \ + --subscribe front_app front_app_switched +#+end_src + +Display a clock, volume, battery, CPU usage, and memory usage on the right. +#+begin_src sh :tangle ~/.config/sketchybar/sketchybarrc :mkdirp yes :tangle-mode o755 + sketchybar --add item clock right \ + --set clock update_freq=10 icon= script="$PLUGIN_DIR/clock.sh" \ + --add item volume right \ + --set volume script="$PLUGIN_DIR/volume.sh" \ + --subscribe volume volume_change \ + --add item battery right \ + --set battery update_freq=120 script="$PLUGIN_DIR/battery.sh" \ + --subscribe battery system_woke power_source_change \ + --add item cpu right \ + --set cpu update_freq=10 script="$PLUGIN_DIR/cpu.sh" \ + --add item mem right \ + --set mem update_freq=10 script="$PLUGIN_DIR/mem.sh" + + sketchybar --update +#+end_src |