From 16bba88c61d98bfe905b8dd1255989e7c65012ce Mon Sep 17 00:00:00 2001 From: Pavel Kirilin <win10@list.ru> Date: Thu, 30 Jul 2020 03:36:15 +0400 Subject: [PATCH] Added pre-commit. Signed-off-by: Pavel Kirilin <win10@list.ru> --- .gitignore | 5 +++++ .pre-commit-config.yaml | 7 +++++++ .pre-commit-hooks.yaml | 6 ++++++ dotfiles/.picom.conf | 4 +++- dotfiles/.xinitrc | 4 +++- dwm/config.h | 5 +++++ hooks/deps_sort.sh | 17 +++++++++++++++++ pacman.deps | 1 + 8 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml create mode 100644 .pre-commit-hooks.yaml create mode 100644 hooks/deps_sort.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8e6f916 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +dwm +drw.o +dwm.o +util.o +dwm-6.2.tar.gz diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..cf3953c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,7 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks +repos: +- repo: https://github.com/s3rius/dwm-autoconfig + rev: master + hooks: + - id: sort_deps diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml new file mode 100644 index 0000000..98aff20 --- /dev/null +++ b/.pre-commit-hooks.yaml @@ -0,0 +1,6 @@ +- id: sort_deps + name: Deps sorting + description: sort entries of a deps files. + language: script + entry: hooks/deps_sort.sh + files: *.deps diff --git a/dotfiles/.picom.conf b/dotfiles/.picom.conf index 03ad358..d9c3ae0 100644 --- a/dotfiles/.picom.conf +++ b/dotfiles/.picom.conf @@ -86,6 +86,7 @@ shadow-exclude = [ "name *= 'picom'", "name *= 'Chromium'", "name *= 'Chrome'", + "name *= 'maim'", "class_g = 'Firefox' && argb", "class_g = 'Conky'", "class_g = 'Kupfer'", @@ -123,7 +124,8 @@ blur-background = true; blur-background-fixed = false; blur-background-exclude = [ "window_type = 'dock'", - "window_type = 'desktop'" + "window_type = 'desktop'", + "name *= 'slop'" ]; ################################# diff --git a/dotfiles/.xinitrc b/dotfiles/.xinitrc index 63551e0..58acd5d 100644 --- a/dotfiles/.xinitrc +++ b/dotfiles/.xinitrc @@ -6,4 +6,6 @@ done & nitrogen --restore picom --config ~/.picom.conf -b -exec dwm +while true; do + dwm >/dev/null 2>&1 +done diff --git a/dwm/config.h b/dwm/config.h index c6f521d..e781567 100644 --- a/dwm/config.h +++ b/dwm/config.h @@ -59,10 +59,15 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn() static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL }; static const char *termcmd[] = { "konsole", NULL }; +/* helper for spawning shell commands in the pre dwm-5.0 fashion */ +#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } + static Key keys[] = { /* modifier key function argument */ { MODKEY, XK_d, spawn, {.v = dmenucmd } }, { MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd } }, + { 0, XK_Print, spawn, SHCMD("maim /dev/stdout | xclip -sel clip -t image/png") }, + { ShiftMask, XK_Print, spawn, SHCMD("maim -s /dev/stdout | xclip -sel clip -t image/png") }, { MODKEY, XK_b, togglebar, {0} }, { MODKEY, XK_j, focusstack, {.i = +1 } }, { MODKEY, XK_k, focusstack, {.i = -1 } }, diff --git a/hooks/deps_sort.sh b/hooks/deps_sort.sh new file mode 100644 index 0000000..0d4caed --- /dev/null +++ b/hooks/deps_sort.sh @@ -0,0 +1,17 @@ +#! /bin/bash +# Verifies that all dependencies are sorted. +set -e + +check_files() { + local all_files=( "$@" ) + has_error=0 + for file in "${all_files[@]}" ; do + if [[ -f "$file" ]]; then + sort -o "$file" "$file" + fi + done +} + +if ! check_files "$@" ; then + echo "To ignore, use --no-verify" +fi diff --git a/pacman.deps b/pacman.deps index fd7648a..f5637e5 100644 --- a/pacman.deps +++ b/pacman.deps @@ -1,3 +1,4 @@ +asp base-devel zsh dmenu -- GitLab