refactor(macos): refactor sketchybar config to use bash arrays
This commit is contained in:
parent
ba7247b545
commit
e92d9fb372
@ -4,34 +4,41 @@ source "$HOME/.config/sketchybar/variables.sh" # Loads all defined colors
|
||||
|
||||
# General bar and defaults
|
||||
|
||||
sketchybar --bar height=30 \
|
||||
color="$BAR_COLOR" \
|
||||
shadow="$SHADOW" \
|
||||
position=top \
|
||||
sticky=on \
|
||||
padding_right=0 \
|
||||
padding_left=3 \
|
||||
corner_radius="$CORNER_RADIUS" \
|
||||
y_offset=1 \
|
||||
margin=5 \
|
||||
blur_radius=20 \
|
||||
notch_width=200 \
|
||||
--default updates=when_shown \
|
||||
icon.font="$FONT:Bold:13.5" \
|
||||
icon.color="$ICON_COLOR" \
|
||||
icon.padding_left="$PADDINGS" \
|
||||
icon.padding_right="$PADDINGS" \
|
||||
label.font="$FONT:Bold:13.0" \
|
||||
label.color="$LABEL_COLOR" \
|
||||
label.padding_left="$PADDINGS" \
|
||||
label.padding_right="$PADDINGS" \
|
||||
background.padding_right="$PADDINGS" \
|
||||
background.padding_left="$PADDINGS" \
|
||||
popup.background.border_width=1 \
|
||||
popup.background.corner_radius=11 \
|
||||
popup.background.border_color="$POPUP_BORDER_COLOR" \
|
||||
popup.background.color="$POPUP_BACKGROUND_COLOR" \
|
||||
bar=(
|
||||
height=30
|
||||
color="$BAR_COLOR"
|
||||
shadow="$SHADOW"
|
||||
position=top
|
||||
sticky=on
|
||||
padding_right=0
|
||||
padding_left=3
|
||||
corner_radius="$CORNER_RADIUS"
|
||||
y_offset=1
|
||||
margin=5
|
||||
blur_radius=20
|
||||
notch_width=200
|
||||
)
|
||||
|
||||
defaults=(
|
||||
updates=when_shown
|
||||
icon.font="$FONT:Bold:13.5"
|
||||
icon.color="$ICON_COLOR"
|
||||
icon.padding_left="$PADDINGS"
|
||||
icon.padding_right="$PADDINGS"
|
||||
label.font="$FONT:Bold:13.0"
|
||||
label.color="$LABEL_COLOR"
|
||||
label.padding_left="$PADDINGS"
|
||||
label.padding_right="$PADDINGS"
|
||||
background.padding_right="$PADDINGS"
|
||||
background.padding_left="$PADDINGS"
|
||||
popup.background.border_width=1
|
||||
popup.background.corner_radius=11
|
||||
popup.background.border_color="$POPUP_BORDER_COLOR"
|
||||
popup.background.color="$POPUP_BACKGROUND_COLOR"
|
||||
popup.background.shadow.drawing="$SHADOW"
|
||||
)
|
||||
|
||||
sketchybar --bar "${bar[@]}" --default "${defaults[@]}"
|
||||
|
||||
# Left
|
||||
# source "$ITEM_DIR/apple.sh"
|
||||
@ -42,10 +49,12 @@ source "$ITEM_DIR/front_app.sh"
|
||||
source "$ITEM_DIR/spotify.sh"
|
||||
|
||||
# Right
|
||||
source "$ITEM_DIR/user.sh"
|
||||
source "$ITEM_DIR/clock.sh"
|
||||
source "$ITEM_DIR/calendar.sh"
|
||||
source "$ITEM_DIR/battery.sh"
|
||||
source "$ITEM_DIR/volume.sh"
|
||||
source "$ITEM_DIR/mem.sh"
|
||||
source "$ITEM_DIR/cpu.sh"
|
||||
|
||||
#################### Finalizing Setup ####################
|
||||
|
||||
@ -2,19 +2,24 @@
|
||||
|
||||
COLOR="$CYAN"
|
||||
|
||||
sketchybar --add item battery right \
|
||||
--set battery \
|
||||
update_freq=60 \
|
||||
icon.color="$COLOR" \
|
||||
icon.padding_left=10 \
|
||||
label.padding_right=10 \
|
||||
label.color="$COLOR" \
|
||||
background.height=26 \
|
||||
background.corner_radius="$CORNER_RADIUS" \
|
||||
background.padding_right=5 \
|
||||
background.border_width="$BORDER_WIDTH" \
|
||||
background.border_color="$COLOR" \
|
||||
background.color="$BAR_COLOR" \
|
||||
background.drawing=on \
|
||||
props=(
|
||||
update_freq=60
|
||||
icon.color="$COLOR"
|
||||
icon.padding_left=10
|
||||
label.padding_right=10
|
||||
label.color="$COLOR"
|
||||
background.height=26
|
||||
background.corner_radius="$CORNER_RADIUS"
|
||||
background.padding_right=5
|
||||
background.border_width="$BORDER_WIDTH"
|
||||
background.border_color="$COLOR"
|
||||
background.color="$BAR_COLOR"
|
||||
background.drawing=on
|
||||
script="$PLUGIN_DIR/power.sh" \
|
||||
--subscribe battery power_source_change
|
||||
)
|
||||
|
||||
sketchybar --add item battery right \
|
||||
--subscribe battery power_source_change \
|
||||
--set battery \
|
||||
${props[@]}
|
||||
|
||||
|
||||
@ -2,17 +2,22 @@
|
||||
|
||||
COLOR="$BLUE"
|
||||
|
||||
sketchybar --add item calendar right \
|
||||
--set calendar update_freq=15 \
|
||||
icon.color="$COLOR" \
|
||||
icon.padding_left=10 \
|
||||
label.color="$COLOR" \
|
||||
label.padding_right=10 \
|
||||
background.height=26 \
|
||||
background.corner_radius="$CORNER_RADIUS" \
|
||||
background.padding_right=5 \
|
||||
background.border_width="$BORDER_WIDTH" \
|
||||
background.border_color="$COLOR" \
|
||||
background.color="$BAR_COLOR" \
|
||||
background.drawing=on \
|
||||
props=(
|
||||
update_freq=15
|
||||
icon.color="$COLOR"
|
||||
icon.padding_left=10
|
||||
label.color="$COLOR"
|
||||
label.padding_right=10
|
||||
background.height=26
|
||||
background.corner_radius="$CORNER_RADIUS"
|
||||
background.padding_right=5
|
||||
background.border_width="$BORDER_WIDTH"
|
||||
background.border_color="$COLOR"
|
||||
background.color="$BAR_COLOR"
|
||||
background.drawing=on
|
||||
script="$PLUGIN_DIR/calendar.sh"
|
||||
)
|
||||
|
||||
sketchybar --add item calendar right \
|
||||
--set calendar "${props[@]}"\
|
||||
|
||||
|
||||
@ -2,20 +2,24 @@
|
||||
|
||||
COLOR="$MAGENTA"
|
||||
|
||||
sketchybar --add item clock right \
|
||||
--set clock update_freq=1 \
|
||||
icon.padding_left=10 \
|
||||
icon.color="$COLOR" \
|
||||
icon="" \
|
||||
label.color="$COLOR" \
|
||||
label.padding_right=5 \
|
||||
label.width=78 \
|
||||
align=center \
|
||||
background.height=26 \
|
||||
background.corner_radius="$CORNER_RADIUS" \
|
||||
background.padding_right=2 \
|
||||
background.border_width="$BORDER_WIDTH" \
|
||||
background.border_color="$COLOR" \
|
||||
background.color="$BAR_COLOR" \
|
||||
background.drawing=on \
|
||||
props=(
|
||||
update_freq=1
|
||||
icon.padding_left=10
|
||||
icon.color="$COLOR"
|
||||
icon=""
|
||||
label.color="$COLOR"
|
||||
label.padding_right=5
|
||||
label.width=78
|
||||
align=center
|
||||
background.height=26
|
||||
background.corner_radius="$CORNER_RADIUS"
|
||||
background.padding_right=2
|
||||
background.border_width="$BORDER_WIDTH"
|
||||
background.border_color="$COLOR"
|
||||
background.color="$BAR_COLOR"
|
||||
background.drawing=on
|
||||
script="$PLUGIN_DIR/clock.sh"
|
||||
)
|
||||
|
||||
sketchybar --add item clock right \
|
||||
--set clock "${props[@]}"
|
||||
|
||||
@ -2,18 +2,22 @@
|
||||
|
||||
COLOR="$YELLOW"
|
||||
|
||||
sketchybar --add item cpu right \
|
||||
--set cpu \
|
||||
update_freq=3 \
|
||||
icon.color="$COLOR" \
|
||||
icon.padding_left=10 \
|
||||
label.color="$COLOR" \
|
||||
label.padding_right=10 \
|
||||
background.height=26 \
|
||||
background.corner_radius="$CORNER_RADIUS" \
|
||||
background.padding_right=5 \
|
||||
background.border_width="$BORDER_WIDTH" \
|
||||
background.border_color="$COLOR" \
|
||||
background.color="$BAR_COLOR" \
|
||||
background.drawing=on \
|
||||
props=(
|
||||
update_freq=3
|
||||
icon.color="$COLOR"
|
||||
icon.padding_left=10
|
||||
label.color="$COLOR"
|
||||
label.padding_right=10
|
||||
background.height=26
|
||||
background.corner_radius="$CORNER_RADIUS"
|
||||
background.padding_right=5
|
||||
background.border_width="$BORDER_WIDTH"
|
||||
background.border_color="$COLOR"
|
||||
background.color="$BAR_COLOR"
|
||||
background.drawing=on
|
||||
script="$PLUGIN_DIR/cpu.sh"
|
||||
)
|
||||
|
||||
sketchybar --add item cpu right \
|
||||
--set cpu ${props[@]}\
|
||||
|
||||
|
||||
@ -2,19 +2,25 @@
|
||||
|
||||
COLOR="$WHITE"
|
||||
|
||||
props=(
|
||||
icon.drawing=off
|
||||
background.height=26
|
||||
background.padding_left=0
|
||||
background.padding_right=10
|
||||
background.border_width="$BORDER_WIDTH"
|
||||
background.border_color="$COLOR"
|
||||
background.corner_radius="$CORNER_RADIUS"
|
||||
background.color="$BAR_COLOR"
|
||||
label.color="$COLOR"
|
||||
label.padding_left=10
|
||||
label.padding_right=10
|
||||
associated_display=active
|
||||
script="$PLUGIN_DIR/front_app.sh"
|
||||
)
|
||||
|
||||
sketchybar \
|
||||
--add item front_app left \
|
||||
--set front_app script="$PLUGIN_DIR/front_app.sh" \
|
||||
icon.drawing=off \
|
||||
background.height=26 \
|
||||
background.padding_left=0 \
|
||||
background.padding_right=10 \
|
||||
background.border_width="$BORDER_WIDTH" \
|
||||
background.border_color="$COLOR" \
|
||||
background.corner_radius="$CORNER_RADIUS" \
|
||||
background.color="$BAR_COLOR" \
|
||||
label.color="$COLOR" \
|
||||
label.padding_left=10 \
|
||||
label.padding_right=10 \
|
||||
associated_display=active \
|
||||
--subscribe front_app front_app_switched
|
||||
--subscribe front_app front_app_switched \
|
||||
--set front_app \
|
||||
"${props[@]}" \
|
||||
|
||||
|
||||
23
private_dot_config/sketchybar/items/mem.sh
Normal file
23
private_dot_config/sketchybar/items/mem.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
COLOR="$ORANGE"
|
||||
|
||||
props=(
|
||||
update_freq=3
|
||||
icon.color="$COLOR"
|
||||
icon.padding_left=10
|
||||
label.color="$COLOR"
|
||||
label.padding_right=10
|
||||
background.height=26
|
||||
background.corner_radius="$CORNER_RADIUS"
|
||||
background.padding_right=5
|
||||
background.border_width="$BORDER_WIDTH"
|
||||
background.border_color="$COLOR"
|
||||
background.color="$BAR_COLOR"
|
||||
background.drawing=on
|
||||
script="$PLUGIN_DIR/mem.sh"
|
||||
)
|
||||
|
||||
sketchybar --add item mem right \
|
||||
--set mem \
|
||||
"${props[@]}"
|
||||
@ -3,22 +3,27 @@
|
||||
|
||||
MUSIC_EVENT="com.spotify.client.PlaybackStateChanged"
|
||||
COLOR="$GREEN"
|
||||
|
||||
props=(
|
||||
scroll_texts=on
|
||||
icon=
|
||||
icon.color="$COLOR"
|
||||
icon.padding_left=10
|
||||
background.color="$BAR_COLOR"
|
||||
background.height=26
|
||||
background.corner_radius="$CORNER_RADIUS"
|
||||
background.border_width="$BORDER_WIDTH"
|
||||
background.border_color="$COLOR"
|
||||
background.padding_right=-5
|
||||
background.drawing=on
|
||||
label.padding_right=10
|
||||
associated_display=active
|
||||
updates=on
|
||||
script="$PLUGIN_DIR/spotify.sh"
|
||||
)
|
||||
|
||||
sketchybar --add event music_change $MUSIC_EVENT \
|
||||
--add item music q \
|
||||
--set music ${bracket_defaults[@]}\
|
||||
scroll_texts=on \
|
||||
icon= \
|
||||
icon.color="$COLOR" \
|
||||
icon.padding_left=10 \
|
||||
background.color="$BAR_COLOR" \
|
||||
background.height=26 \
|
||||
background.corner_radius="$CORNER_RADIUS" \
|
||||
background.border_width="$BORDER_WIDTH" \
|
||||
background.border_color="$COLOR" \
|
||||
background.padding_right=-5 \
|
||||
background.drawing=on \
|
||||
label.padding_right=10 \
|
||||
associated_display=active \
|
||||
updates=on \
|
||||
script="$PLUGIN_DIR/spotify.sh" \
|
||||
--subscribe music music_change
|
||||
--subscribe music music_change \
|
||||
--set music ${bracket_defaults[@]} \
|
||||
"${props[@]}"
|
||||
25
private_dot_config/sketchybar/items/user.sh
Normal file
25
private_dot_config/sketchybar/items/user.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
COLOR="0xff565f89"
|
||||
|
||||
props=(
|
||||
update_freq=60
|
||||
icon.color="$COLOR"
|
||||
icon.padding_left=10
|
||||
label.padding_right=10
|
||||
label.color="$COLOR"
|
||||
background.height=26
|
||||
background.corner_radius="$CORNER_RADIUS"
|
||||
background.padding_right=5
|
||||
background.border_width="$BORDER_WIDTH"
|
||||
background.border_color="$COLOR"
|
||||
background.color="$BAR_COLOR"
|
||||
background.drawing=on
|
||||
script="$PLUGIN_DIR/user.sh"
|
||||
|
||||
)
|
||||
|
||||
sketchybar --add item user right \
|
||||
--set user \
|
||||
"${props[@]}"
|
||||
|
||||
@ -2,19 +2,24 @@
|
||||
|
||||
COLOR="$GREEN"
|
||||
|
||||
props=(
|
||||
icon.color="$COLOR"
|
||||
icon.padding_left=10
|
||||
label.color="$COLOR"
|
||||
label.padding_right=10
|
||||
background.height=26
|
||||
background.corner_radius="$CORNER_RADIUS"
|
||||
background.padding_right=5
|
||||
background.border_width="$BORDER_WIDTH"
|
||||
background.border_color="$COLOR"
|
||||
background.color="$BAR_COLOR"
|
||||
background.drawing=on
|
||||
script="$PLUGIN_DIR/sound.sh"
|
||||
)
|
||||
|
||||
sketchybar \
|
||||
--add item sound right \
|
||||
--subscribe sound volume_change \
|
||||
--set sound \
|
||||
icon.color="$COLOR" \
|
||||
icon.padding_left=10 \
|
||||
label.color="$COLOR" \
|
||||
label.padding_right=10 \
|
||||
background.height=26 \
|
||||
background.corner_radius="$CORNER_RADIUS" \
|
||||
background.padding_right=5 \
|
||||
background.border_width="$BORDER_WIDTH" \
|
||||
background.border_color="$COLOR" \
|
||||
background.color="$BAR_COLOR" \
|
||||
background.drawing=on \
|
||||
script="$PLUGIN_DIR/sound.sh" \
|
||||
--subscribe sound volume_change
|
||||
"${props[@]}"
|
||||
|
||||
|
||||
3
private_dot_config/sketchybar/plugins/executable_mem.sh
Normal file
3
private_dot_config/sketchybar/plugins/executable_mem.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
sketchybar --set "$NAME" icon="" label="$(ps -A -o %mem | awk '{s+=$1} END {s /= 8} END {printf "%.1f%%\n", s}')"
|
||||
@ -9,14 +9,15 @@ update() {
|
||||
TRACK="$(echo "$INFO" | jq -r .Name | cut -c1-40)"
|
||||
ARTIST="$(echo "$INFO" | jq -r .Artist | cut -c1-20)"
|
||||
ALBUM="$(echo "$INFO" | jq -r .Album | cut -c1-20)"
|
||||
FULL=$(echo "$ARTIST - $TRACK" | cut -c1-42)
|
||||
fi
|
||||
|
||||
args=()
|
||||
if [ $PLAYING -eq 0 ]; then
|
||||
if [ "$ARTIST" == "" ]; then
|
||||
args+=(--set music label="$ALBUM - $TRACK" drawing=on icon=)
|
||||
args+=(--set music label="$FULL" drawing=on icon=)
|
||||
else
|
||||
args+=(--set music label="$ARTIST - $TRACK" drawing=on icon=)
|
||||
args+=(--set music label="$FULL" drawing=on icon=)
|
||||
fi
|
||||
else
|
||||
args+=(--set music icon=)
|
||||
|
||||
3
private_dot_config/sketchybar/plugins/executable_user.sh
Normal file
3
private_dot_config/sketchybar/plugins/executable_user.sh
Normal file
@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
sketchybar --set "$NAME" icon="" label="$(whoami)"
|
||||
Loading…
Reference in New Issue
Block a user