From 9f906e0822b69f20bcd6ed113996844776f274d4 Mon Sep 17 00:00:00 2001 From: winston Date: Fri, 10 Feb 2023 09:13:56 +0100 Subject: [PATCH] style: add editorconfig & check hook --- .ecrc | 20 +++++ .editorconfig | 34 ++++++++ .sops.yaml | 6 +- catppuccin/dircolors/generate.sh | 14 ++-- default.nix | 1 + modules/rofi/theme.rasi | 2 +- modules/sketchybar/plugins/music.sh | 40 ++++----- modules/sketchybar/sketchybarrc | 122 ++++++++++++++-------------- 8 files changed, 147 insertions(+), 92 deletions(-) create mode 100644 .ecrc create mode 100644 .editorconfig diff --git a/.ecrc b/.ecrc new file mode 100644 index 0000000..ae9dadc --- /dev/null +++ b/.ecrc @@ -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 + } +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d86ac02 --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.sops.yaml b/.sops.yaml index 666f93a..a29a6d7 100644 --- a/.sops.yaml +++ b/.sops.yaml @@ -1,6 +1,6 @@ keys: - - &winston a476c39610e53a689a57bd0d0b89bc45007ee9cc + - &winston a476c39610e53a689a57bd0d0b89bc45007ee9cc creation_rules: - key_groups: - - pgp: - - *winston + - pgp: + - *winston diff --git a/catppuccin/dircolors/generate.sh b/catppuccin/dircolors/generate.sh index d00b6e0..8d5d423 100755 --- a/catppuccin/dircolors/generate.sh +++ b/catppuccin/dircolors/generate.sh @@ -4,17 +4,17 @@ dirname="$(dirname "$0")" FLAVOURS=( - "catppuccin-mocha" - "catppuccin-macchiato" - "catppuccin-frappe" - "catppuccin-latte" + "catppuccin-mocha" + "catppuccin-macchiato" + "catppuccin-frappe" + "catppuccin-latte" ) function to_json() { - gojq -nR '[ inputs | split(":") ][0] | map(. | split("=") | { (.[0]) : .[1] }) | add' "$dirname/${flavour}-8bit.json" + vivid generate $flavour | to_json >"$dirname/$flavour.json" + vivid -m 8-bit generate $flavour | to_json >"$dirname/${flavour}-8bit.json" done diff --git a/default.nix b/default.nix index 2962453..86139c3 100644 --- a/default.nix +++ b/default.nix @@ -7,6 +7,7 @@ in { src = ./.; hooks = { alejandra.enable = true; + editorconfig-checker.enable = true; shellcheck.enable = true; stylua.enable = true; }; diff --git a/modules/rofi/theme.rasi b/modules/rofi/theme.rasi index 55276d4..43ffc0a 100644 --- a/modules/rofi/theme.rasi +++ b/modules/rofi/theme.rasi @@ -84,7 +84,7 @@ button { padding: 10px; background-color: @bg-col-light; text-color: @grey; - vertical-align: 0.5; + vertical-align: 0.5; horizontal-align: 0.5; } diff --git a/modules/sketchybar/plugins/music.sh b/modules/sketchybar/plugins/music.sh index 1fd0866..1dcc961 100755 --- a/modules/sketchybar/plugins/music.sh +++ b/modules/sketchybar/plugins/music.sh @@ -1,27 +1,27 @@ #!/usr/bin/env sh if pgrep -xq Music; then - 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 "") - ARTIST=$(osascript -e 'tell application "Music" to album artist of current track 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 "") + 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 - if [ "$ARTIST" = "" ] || [ "$ARTIST" = "Various Artists" ]; then - ARTIST=$(osascript -e 'tell application "Music" to artist of current track as string' 2>/dev/null || echo "") - fi + # fall back to artist, if album artist is unavailable, or generic + if [ "$ARTIST" = "" ] || [ "$ARTIST" = "Various Artists" ]; then + ARTIST=$(osascript -e 'tell application "Music" to artist of current track as string' 2>/dev/null || echo "") + fi - if [ "$STATE" = "playing" ]; then - ICON="" - LABEL="$ARTIST - $TRACK" - else - ICON="" - if [ "$TRACK" = "" ] || [ "$ARTIST" = "" ]; then - LABEL="paused" - else - LABEL="$ARTIST - $TRACK" - fi - fi - sketchybar --set "$NAME" icon="$ICON" label="$LABEL" --add event "${NAME}-changed" + if [ "$STATE" = "playing" ]; then + ICON="" + LABEL="$ARTIST - $TRACK" + else + ICON="" + if [ "$TRACK" = "" ] || [ "$ARTIST" = "" ]; then + LABEL="paused" + else + LABEL="$ARTIST - $TRACK" + fi + fi + sketchybar --set "$NAME" icon="$ICON" label="$LABEL" --add event "${NAME}-changed" else - sketchybar --set "$NAME" icon="" label="" --add event "${NAME}-changed" + sketchybar --set "$NAME" icon="" label="" --add event "${NAME}-changed" fi diff --git a/modules/sketchybar/sketchybarrc b/modules/sketchybar/sketchybarrc index f5b527c..ad92ad3 100755 --- a/modules/sketchybar/sketchybarrc +++ b/modules/sketchybar/sketchybarrc @@ -4,85 +4,85 @@ PLUGIN_DIR="$HOME"/.config/sketchybar/plugins ## bar appearance {{{ sketchybar --bar \ - height=32 \ - position=top \ - padding_left=0 \ - padding_right=0 \ - hidden=off \ - topmost=on + height=32 \ + position=top \ + padding_left=0 \ + padding_right=0 \ + hidden=off \ + topmost=on # colors are managed seperately in the colordummy, # which listens to theme_changed events, # to swap between Catppuccin Mocha and Latte sketchybar -m --add event theme_changed AppleInterfaceThemeChangedNotification sketchybar \ - --add item colordummy center \ - --set colordummy \ - drawing=off \ - script="$PLUGIN_DIR/colordummy.sh" \ - --subscribe colordummy theme_changed + --add item colordummy center \ + --set colordummy \ + drawing=off \ + script="$PLUGIN_DIR/colordummy.sh" \ + --subscribe colordummy theme_changed ##### Changing Defaults ##### sketchybar --default \ - updates=when_shown \ - drawing=on \ - icon.font="Symbols Nerd Font:2048-em:18.0" \ - label.font="SF Pro:Regular:16.0" \ - label.padding_left=2 \ - label.padding_right=2 \ - icon.padding_left=2 \ - icon.padding_right=2 + updates=when_shown \ + drawing=on \ + icon.font="Symbols Nerd Font:2048-em:18.0" \ + label.font="SF Pro:Regular:16.0" \ + label.padding_left=2 \ + label.padding_right=2 \ + icon.padding_left=2 \ + icon.padding_right=2 # }}} ## left side of the bar {{{ # spaces for yabai wm SPACE_ICONS=( - "Ⅰ" - "Ⅱ" - "Ⅲ" - "Ⅳ" - "Ⅴ" - "Ⅵ" - "Ⅶ" - "Ⅷ" - "Ⅸ" - "Ⅹ" + "Ⅰ" + "Ⅱ" + "Ⅲ" + "Ⅳ" + "Ⅴ" + "Ⅵ" + "Ⅶ" + "Ⅷ" + "Ⅸ" + "Ⅹ" ) for i in "${!SPACE_ICONS[@]}"; do - sketchybar \ - --add space "space.$i" left \ - --set "space.$i" associated_space=$((i + 1)) \ - icon="${SPACE_ICONS[i]}" \ - icon.padding_left=8 \ - icon.padding_right=8 \ - background.padding_left=1 \ - background.padding_right=1 \ - background.height=32 \ - label.drawing=off \ - script="$PLUGIN_DIR/space.sh" \ - click_script="yabai -m space --focus $((i + 1))" + sketchybar \ + --add space "space.$i" left \ + --set "space.$i" associated_space=$((i + 1)) \ + icon="${SPACE_ICONS[i]}" \ + icon.padding_left=8 \ + icon.padding_right=8 \ + background.padding_left=1 \ + background.padding_right=1 \ + background.height=32 \ + label.drawing=off \ + script="$PLUGIN_DIR/space.sh" \ + click_script="yabai -m space --focus $((i + 1))" done sketchybar \ - --add item music center \ - --set music \ - script="$PLUGIN_DIR/music.sh" \ - --add item clock right \ - --set clock \ - script="$PLUGIN_DIR/clock.sh" \ - update_freq=10 \ - background.padding_right=4 \ - --add alias "iStat Menus Status" right \ - icon.padding_left=0 \ - icon.padding_right=0 \ - --add alias "Little Snitch Agent" right \ - icon.padding_left=0 \ - icon.padding_right=0 \ - --add alias "Control Centre,Battery" right \ - icon.padding_left=0 \ - icon.padding_right=0 \ - --add alias "Mullvad VPN" right \ - icon.padding_left=0 \ - icon.padding_right=0 + --add item music center \ + --set music \ + script="$PLUGIN_DIR/music.sh" \ + --add item clock right \ + --set clock \ + script="$PLUGIN_DIR/clock.sh" \ + update_freq=10 \ + background.padding_right=4 \ + --add alias "iStat Menus Status" right \ + icon.padding_left=0 \ + icon.padding_right=0 \ + --add alias "Little Snitch Agent" right \ + icon.padding_left=0 \ + icon.padding_right=0 \ + --add alias "Control Centre,Battery" right \ + icon.padding_left=0 \ + icon.padding_right=0 \ + --add alias "Mullvad VPN" right \ + icon.padding_left=0 \ + icon.padding_right=0 sketchybar --update