Skip to content

Commit

Permalink
add proper svim support to sketchybar
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixKratz committed Nov 9, 2023
1 parent cab7d3d commit 80f938d
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 19 deletions.
7 changes: 7 additions & 0 deletions .config/sketchybar/icons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,10 @@ VOLUME_0=􀊣
# WiFi
WIFI_CONNECTED=􀙇
WIFI_DISCONNECTED=􀙈

# svim
MODE_NORMAL=􀂯
MODE_INSERT=􀂥
MODE_VISUAL=􀂿
MODE_CMD=􀂙
MODE_PENDING=􀈏
14 changes: 14 additions & 0 deletions .config/sketchybar/items/svim.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

svim=(
script="$PLUGIN_DIR/svim.sh"
icon=$INSERT_MODE
icon.font.size=20
updates=on
drawing=off
)

sketchybar --add event svim_update \
--add item svim right \
--set svim "${svim[@]}" \
--subscribe svim svim_update
30 changes: 30 additions & 0 deletions .config/sketchybar/plugins/svim.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/bin/bash

source "$CONFIG_DIR/icons.sh"
source "$CONFIG_DIR/colors.sh"

if [ "$SENDER" = "svim_update" ]; then
DRAWING=on
DRAW_CMD=off
COLOR=$WHITE
case "$MODE" in
"I") ICON="$MODE_INSERT" DRAWING=off
;;
"N") ICON="$MODE_NORMAL"
;;
"V") ICON="$MODE_VISUAL" COLOR=$YELLOW
;;
"C") ICON="$MODE_CMD" DRAW_CMD=on COLOR=$RED
;;
"_") ICON="$MODE_PENDING"
;;
*) DRAWING=off
;;
esac

sketchybar --set $NAME drawing="$DRAWING" \
label.drawing="$DRAW_CMD" \
icon="$ICON" \
icon.color="$COLOR" \
label="$CMDLINE"
fi
1 change: 1 addition & 0 deletions .config/sketchybar/sketchybarrc
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ source "$ITEM_DIR/wifi.sh"
source "$ITEM_DIR/battery.sh"
source "$ITEM_DIR/volume.sh"
source "$ITEM_DIR/cpu.sh"
source "$ITEM_DIR/svim.sh"

sketchybar --hotload on

Expand Down
6 changes: 5 additions & 1 deletion .config/svim/blacklist
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
WezTerm
kitty
Alacritty
iTerm2
WezTerm
MacVim
Neovide
JupyterApp
19 changes: 4 additions & 15 deletions .config/svim/svim.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
#!/usr/bin/env sh
#!/bin/bash

# This script is executed when either the mode changes,
# or the commandline changes

# if [ "$MODE" = "" ]; then
# MODE="-"
# fi
#
# DRAW_CMD="off"
# if [ "$CMDLINE" != "" ]; then
# DRAW_CMD="on"
# fi
#
# sketchybar --set system.svim label="[$MODE]" \
# label.drawing=$(if [ "$MODE" = "" ]; then echo "off"; else echo "on"; fi) \
# icon.highlight=$(if [ "$MODE" = "-" ]; then echo "off"; else echo "on"; fi) \
# popup.drawing=$DRAW_CMD \
# --set svim.cmdline label="$CMDLINE"
# Here I am simply passing the event to sketchybar, where an item handles it.

sketchybar --trigger svim_update MODE="$MODE" CMDLINE="$CMDLINE"
3 changes: 0 additions & 3 deletions .config/svim/svimrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ noremap k j
noremap l k
noremap ö l
noremap ß $
nmap <C-k> <Esc>:m .+1<CR>
nmap <C-l> <Esc>:m .-2<CR>

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ color scheme consistency across all configurations.

* [SketchyBar](https://github.com/FelixKratz/SketchyBar)
* [JankyBorders](https://github.com/FelixKratz/JankyBorders)
* [SketchyVim](https://github.com/FelixKratz/SketchyVim)
* [yabai](https://github.com/koekeishiya/yabai) (personal fork)
* [skhd](https://github.com/koekeishiya/skhd)
* [neovim](https://github.com/neovim/neovim)
Expand Down

0 comments on commit 80f938d

Please sign in to comment.