aboutsummaryrefslogtreecommitdiff
path: root/common/.config/sketchybar/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'common/.config/sketchybar/plugins')
-rwxr-xr-xcommon/.config/sketchybar/plugins/battery.sh.org46
-rwxr-xr-xcommon/.config/sketchybar/plugins/clock.sh.org7
-rwxr-xr-xcommon/.config/sketchybar/plugins/cpu.sh.org7
-rwxr-xr-xcommon/.config/sketchybar/plugins/front_app.sh.org9
-rwxr-xr-xcommon/.config/sketchybar/plugins/mem.sh.org16
-rwxr-xr-xcommon/.config/sketchybar/plugins/space.sh.org7
-rwxr-xr-xcommon/.config/sketchybar/plugins/volume.sh.org21
7 files changed, 113 insertions, 0 deletions
diff --git a/common/.config/sketchybar/plugins/battery.sh.org b/common/.config/sketchybar/plugins/battery.sh.org
new file mode 100755
index 0000000..d3918e2
--- /dev/null
+++ b/common/.config/sketchybar/plugins/battery.sh.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/common/.config/sketchybar/plugins/clock.sh.org b/common/.config/sketchybar/plugins/clock.sh.org
new file mode 100755
index 0000000..1ab5ec3
--- /dev/null
+++ b/common/.config/sketchybar/plugins/clock.sh.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/common/.config/sketchybar/plugins/cpu.sh.org b/common/.config/sketchybar/plugins/cpu.sh.org
new file mode 100755
index 0000000..199d89b
--- /dev/null
+++ b/common/.config/sketchybar/plugins/cpu.sh.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/common/.config/sketchybar/plugins/front_app.sh.org b/common/.config/sketchybar/plugins/front_app.sh.org
new file mode 100755
index 0000000..44917e4
--- /dev/null
+++ b/common/.config/sketchybar/plugins/front_app.sh.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/common/.config/sketchybar/plugins/mem.sh.org b/common/.config/sketchybar/plugins/mem.sh.org
new file mode 100755
index 0000000..ef3feef
--- /dev/null
+++ b/common/.config/sketchybar/plugins/mem.sh.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/common/.config/sketchybar/plugins/space.sh.org b/common/.config/sketchybar/plugins/space.sh.org
new file mode 100755
index 0000000..97581aa
--- /dev/null
+++ b/common/.config/sketchybar/plugins/space.sh.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/common/.config/sketchybar/plugins/volume.sh.org b/common/.config/sketchybar/plugins/volume.sh.org
new file mode 100755
index 0000000..c53b2a1
--- /dev/null
+++ b/common/.config/sketchybar/plugins/volume.sh.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