style: add editorconfig & check hook

This commit is contained in:
winston 2023-02-10 09:13:56 +01:00
parent 8f4f64aa70
commit 9f906e0822
Signed by: winston
GPG key ID: 3786770EDBC2B481
8 changed files with 147 additions and 92 deletions

20
.ecrc Normal file
View file

@ -0,0 +1,20 @@
{
"Verbose": false,
"Debug": false,
"IgnoreDefaults": false,
"SpacesAftertabs": false,
"NoColor": false,
"Exclude": [
".gitsecret",
"lazy-lock.json",
"*.secret"
],
"AllowedContentTypes": [],
"PassedFiles": [],
"Disable": {
"EndOfLine": false,
"Indentation": false,
"InsertFinalNewline": false,
"TrimTrailingWhitespace": false
}
}

34
.editorconfig Normal file
View file

@ -0,0 +1,34 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# EditorConfig is awesome: https://EditorConfig.org
root = true
[*]
charset = utf-8
indent_size = 2
indent_style = space
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
# go
[*.go]
indent_style = tab
indent_size = 4
# python
[*.{ini,py,py.tpl,rst}]
indent_size = 4
# rust
[*.rs]
indent_size = 4
# documentation, utils
[*.{md,mdx,diff}]
trim_trailing_whitespace = false
# windows shell scripts
[*.{cmd,bat,ps1}]
end_of_line = crlf

View file

@ -1,6 +1,6 @@
keys: keys:
- &winston a476c39610e53a689a57bd0d0b89bc45007ee9cc - &winston a476c39610e53a689a57bd0d0b89bc45007ee9cc
creation_rules: creation_rules:
- key_groups: - key_groups:
- pgp: - pgp:
- *winston - *winston

View file

@ -4,17 +4,17 @@
dirname="$(dirname "$0")" dirname="$(dirname "$0")"
FLAVOURS=( FLAVOURS=(
"catppuccin-mocha" "catppuccin-mocha"
"catppuccin-macchiato" "catppuccin-macchiato"
"catppuccin-frappe" "catppuccin-frappe"
"catppuccin-latte" "catppuccin-latte"
) )
function to_json() { function to_json() {
gojq -nR '[ inputs | split(":") ][0] | map(. | split("=") | { (.[0]) : .[1] }) | add' </dev/stdin gojq -nR '[ inputs | split(":") ][0] | map(. | split("=") | { (.[0]) : .[1] }) | add' </dev/stdin
} }
for flavour in ${FLAVOURS[@]}; do for flavour in ${FLAVOURS[@]}; do
vivid generate $flavour | to_json >"$dirname/$flavour.json" vivid generate $flavour | to_json >"$dirname/$flavour.json"
vivid -m 8-bit generate $flavour | to_json >"$dirname/${flavour}-8bit.json" vivid -m 8-bit generate $flavour | to_json >"$dirname/${flavour}-8bit.json"
done done

View file

@ -7,6 +7,7 @@ in {
src = ./.; src = ./.;
hooks = { hooks = {
alejandra.enable = true; alejandra.enable = true;
editorconfig-checker.enable = true;
shellcheck.enable = true; shellcheck.enable = true;
stylua.enable = true; stylua.enable = true;
}; };

View file

@ -84,7 +84,7 @@ button {
padding: 10px; padding: 10px;
background-color: @bg-col-light; background-color: @bg-col-light;
text-color: @grey; text-color: @grey;
vertical-align: 0.5; vertical-align: 0.5;
horizontal-align: 0.5; horizontal-align: 0.5;
} }

View file

@ -1,27 +1,27 @@
#!/usr/bin/env sh #!/usr/bin/env sh
if pgrep -xq Music; then if pgrep -xq Music; then
STATE=$(osascript -e 'tell application "Music" to player state as string' 2>/dev/null || echo "") STATE=$(osascript -e 'tell application "Music" to player state as string' 2>/dev/null || echo "")
TRACK=$(osascript -e 'tell application "Music" to name of current track as string' 2>/dev/null || echo "") TRACK=$(osascript -e 'tell application "Music" to name of current track as string' 2>/dev/null || echo "")
ARTIST=$(osascript -e 'tell application "Music" to album artist of current track as string' 2>/dev/null || echo "") ARTIST=$(osascript -e 'tell application "Music" to album artist of current track as string' 2>/dev/null || echo "")
# fall back to artist, if album artist is unavailable, or generic # fall back to artist, if album artist is unavailable, or generic
if [ "$ARTIST" = "" ] || [ "$ARTIST" = "Various Artists" ]; then if [ "$ARTIST" = "" ] || [ "$ARTIST" = "Various Artists" ]; then
ARTIST=$(osascript -e 'tell application "Music" to artist of current track as string' 2>/dev/null || echo "") ARTIST=$(osascript -e 'tell application "Music" to artist of current track as string' 2>/dev/null || echo "")
fi fi
if [ "$STATE" = "playing" ]; then if [ "$STATE" = "playing" ]; then
ICON="" ICON=""
LABEL="$ARTIST - $TRACK" LABEL="$ARTIST - $TRACK"
else else
ICON="" ICON=""
if [ "$TRACK" = "" ] || [ "$ARTIST" = "" ]; then if [ "$TRACK" = "" ] || [ "$ARTIST" = "" ]; then
LABEL="paused" LABEL="paused"
else else
LABEL="$ARTIST - $TRACK" LABEL="$ARTIST - $TRACK"
fi fi
fi fi
sketchybar --set "$NAME" icon="$ICON" label="$LABEL" --add event "${NAME}-changed" sketchybar --set "$NAME" icon="$ICON" label="$LABEL" --add event "${NAME}-changed"
else else
sketchybar --set "$NAME" icon="" label="" --add event "${NAME}-changed" sketchybar --set "$NAME" icon="" label="" --add event "${NAME}-changed"
fi fi

View file

@ -4,85 +4,85 @@ PLUGIN_DIR="$HOME"/.config/sketchybar/plugins
## bar appearance {{{ ## bar appearance {{{
sketchybar --bar \ sketchybar --bar \
height=32 \ height=32 \
position=top \ position=top \
padding_left=0 \ padding_left=0 \
padding_right=0 \ padding_right=0 \
hidden=off \ hidden=off \
topmost=on topmost=on
# colors are managed seperately in the colordummy, # colors are managed seperately in the colordummy,
# which listens to theme_changed events, # which listens to theme_changed events,
# to swap between Catppuccin Mocha and Latte # to swap between Catppuccin Mocha and Latte
sketchybar -m --add event theme_changed AppleInterfaceThemeChangedNotification sketchybar -m --add event theme_changed AppleInterfaceThemeChangedNotification
sketchybar \ sketchybar \
--add item colordummy center \ --add item colordummy center \
--set colordummy \ --set colordummy \
drawing=off \ drawing=off \
script="$PLUGIN_DIR/colordummy.sh" \ script="$PLUGIN_DIR/colordummy.sh" \
--subscribe colordummy theme_changed --subscribe colordummy theme_changed
##### Changing Defaults ##### ##### Changing Defaults #####
sketchybar --default \ sketchybar --default \
updates=when_shown \ updates=when_shown \
drawing=on \ drawing=on \
icon.font="Symbols Nerd Font:2048-em:18.0" \ icon.font="Symbols Nerd Font:2048-em:18.0" \
label.font="SF Pro:Regular:16.0" \ label.font="SF Pro:Regular:16.0" \
label.padding_left=2 \ label.padding_left=2 \
label.padding_right=2 \ label.padding_right=2 \
icon.padding_left=2 \ icon.padding_left=2 \
icon.padding_right=2 icon.padding_right=2
# }}} # }}}
## left side of the bar {{{ ## left side of the bar {{{
# spaces for yabai wm # spaces for yabai wm
SPACE_ICONS=( SPACE_ICONS=(
"" ""
"Ⅱ" "Ⅱ"
"Ⅲ" "Ⅲ"
"Ⅳ" "Ⅳ"
"" ""
"Ⅵ" "Ⅵ"
"Ⅶ" "Ⅶ"
"Ⅷ" "Ⅷ"
"Ⅸ" "Ⅸ"
"" ""
) )
for i in "${!SPACE_ICONS[@]}"; do for i in "${!SPACE_ICONS[@]}"; do
sketchybar \ sketchybar \
--add space "space.$i" left \ --add space "space.$i" left \
--set "space.$i" associated_space=$((i + 1)) \ --set "space.$i" associated_space=$((i + 1)) \
icon="${SPACE_ICONS[i]}" \ icon="${SPACE_ICONS[i]}" \
icon.padding_left=8 \ icon.padding_left=8 \
icon.padding_right=8 \ icon.padding_right=8 \
background.padding_left=1 \ background.padding_left=1 \
background.padding_right=1 \ background.padding_right=1 \
background.height=32 \ background.height=32 \
label.drawing=off \ label.drawing=off \
script="$PLUGIN_DIR/space.sh" \ script="$PLUGIN_DIR/space.sh" \
click_script="yabai -m space --focus $((i + 1))" click_script="yabai -m space --focus $((i + 1))"
done done
sketchybar \ sketchybar \
--add item music center \ --add item music center \
--set music \ --set music \
script="$PLUGIN_DIR/music.sh" \ script="$PLUGIN_DIR/music.sh" \
--add item clock right \ --add item clock right \
--set clock \ --set clock \
script="$PLUGIN_DIR/clock.sh" \ script="$PLUGIN_DIR/clock.sh" \
update_freq=10 \ update_freq=10 \
background.padding_right=4 \ background.padding_right=4 \
--add alias "iStat Menus Status" right \ --add alias "iStat Menus Status" right \
icon.padding_left=0 \ icon.padding_left=0 \
icon.padding_right=0 \ icon.padding_right=0 \
--add alias "Little Snitch Agent" right \ --add alias "Little Snitch Agent" right \
icon.padding_left=0 \ icon.padding_left=0 \
icon.padding_right=0 \ icon.padding_right=0 \
--add alias "Control Centre,Battery" right \ --add alias "Control Centre,Battery" right \
icon.padding_left=0 \ icon.padding_left=0 \
icon.padding_right=0 \ icon.padding_right=0 \
--add alias "Mullvad VPN" right \ --add alias "Mullvad VPN" right \
icon.padding_left=0 \ icon.padding_left=0 \
icon.padding_right=0 icon.padding_right=0
sketchybar --update sketchybar --update