From 817ee5a9f678c99afdc68dd6e7fb0ce9c454f739 Mon Sep 17 00:00:00 2001 From: Overxwise Date: Sun, 10 Jul 2022 10:26:43 +0300 Subject: [PATCH] Add another bunch of stuff --- .scripts/alxrcs | 115 +++++++++++++++++++++++++++++++++++++++++++ .scripts/rallwalls | 5 ++ .scripts/refwalls | 2 + .scripts/setwalle | 4 ++ .scripts/zsh/exports | 12 +++++ .scripts/zsh/hotkeys | 53 ++++++++++++++++++++ 6 files changed, 191 insertions(+) create mode 100755 .scripts/alxrcs create mode 100755 .scripts/rallwalls create mode 100755 .scripts/refwalls create mode 100755 .scripts/setwalle create mode 100755 .scripts/zsh/exports create mode 100755 .scripts/zsh/hotkeys diff --git a/.scripts/alxrcs b/.scripts/alxrcs new file mode 100755 index 0000000..9097c3f --- /dev/null +++ b/.scripts/alxrcs @@ -0,0 +1,115 @@ +#!/bin/sh +# Alacritty Color Export +# Version 0.1.1 +# github.com/egeesin +# +# Exports generated Wal colors to Alacritty config +# WARNING: Don't forget to backup your Alacritty config +# before execute this script! +# +# Dependencies: grep, sed +# Usage: ./script.sh +# ./script.sh + +# Function to display error and quit +die() { + printf "ERR: %s\n" "$1" >&2 + exit 1 +} + +DEFAULT_MACOS_CONFIG="$HOME"/.config/alacritty/alacritty.yml + +# Wal generates a shell script that defines color0..color15 +SRC="$HOME"/.cache/wal/colors.sh + +[ -e "$SRC" ] || die "Wal colors not found, exiting script. Have you executed Wal before?" +printf "Colors found, source ready.\n" + +READLINK=$( command -v greadlink || command -v readlink ) + +# Get config file +if [ -n "$1" ]; then + [ -e "$1" ] || die "Selected config doesn't exist, exiting script." + printf "Config found, destination ready.\n" + CFG=$1 + [ -L "$1" ] && { + printf "Following symlink to config...\n" + CFG=$($READLINK -f "$1") + } +else + # Default config path in Mac systems + [ -e "$DEFAULT_MACOS_CONFIG" ] || die "Alacritty config not found, exiting script." + + CFG="$DEFAULT_MACOS_CONFIG" + [ -L "$DEFAULT_MACOS_CONFIG" ] && { + printf "Following symlink to config...\n" + CFG=$($READLINK -f "$DEFAULT_MACOS_CONFIG") + } +fi + +# Get hex colors from Wal cache +# No need for shellcheck to check this, it comes from pywal +# shellcheck disable=SC1090 +. "$SRC" + +# Create temp file for sed results +tempfile=$(mktemp) +trap 'rm $tempfile' INT TERM EXIT + +# Delete existing color declarations generated by this script +# If begin comment exists +if rg -q '^# BEGIN ACE' "$CFG"; then + # And if end comment exists + if rg -q '^# END ACE' "$CFG"; then + # Delete contents of the block + printf "Existing generated colors found, replacing new colors...\n" + sed '/^# BEGIN ACE/,/^# END ACE/ { + /^# BEGIN ACE/! { /^# END ACE/!d; } + }' "$CFG" > "$tempfile" \ + && cat "$tempfile" > "$CFG" + # If no end comment, don't do anything + else + die "No '# END ACE' comment found, please ensure it is present." + fi +# If no begin comment found +else + # Don't do anything and notify user if there's an end comment in the file + ! rg -q '^# END ACE' "$CFG" || die "Found '# END ACE' comment, but no '# BEGIN ACE' comment found. Please ensure it is present." + printf "There's no existing 'generated' colors, adding comments...\n"; + printf '# BEGIN ACE\n# END ACE' >> "$CFG"; +fi + +# Write new color definitions +# We know $colorX is unset, we set it by sourcing above +# shellcheck disable=SC2154 +{ sed "/^# BEGIN ACE/ r /dev/stdin" "$CFG" > "$tempfile" < "$CFG" \ + && rm "$tempfile" +trap - INT TERM EXIT +printf "'%s' exported to '%s'\n" "$SRC" "$CFG" diff --git a/.scripts/rallwalls b/.scripts/rallwalls new file mode 100755 index 0000000..3e458ae --- /dev/null +++ b/.scripts/rallwalls @@ -0,0 +1,5 @@ +#!/bin/sh +rm $HOME/.config/wpg/wallpapers/* +rm $HOME/.config/wpg/samples/* +rm $HOME/.config/wpg/schemes/* +wpg -a ~/Nextcloud/Картинки/walls/* diff --git a/.scripts/refwalls b/.scripts/refwalls new file mode 100755 index 0000000..b40396c --- /dev/null +++ b/.scripts/refwalls @@ -0,0 +1,2 @@ +#!/bin/sh +wpg -a $HOME/Nextcloud/Картинки/walls/* diff --git a/.scripts/setwalle b/.scripts/setwalle new file mode 100755 index 0000000..b940643 --- /dev/null +++ b/.scripts/setwalle @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +alxrcs & +pywalfox update & +feh --no-fehbg --bg-scale $HOME/.config/wpg/.current & diff --git a/.scripts/zsh/exports b/.scripts/zsh/exports new file mode 100755 index 0000000..0526912 --- /dev/null +++ b/.scripts/zsh/exports @@ -0,0 +1,12 @@ +export PATH=$PATH:$HOME/.scripts + +export XDG_DATA_HOME=$HOME/.local/share +export XDG_CONFIG_HOME=$HOME/.config +export XDG_STATE_HOME=$HOME/.local/state +export XDG_CACHE_HOME=$HOME/.cache + +export CUDA_CACHE_PATH="$XDG_CACHE_HOME"/nv +export ICEAUTHORITY="$XDG_CACHE_HOME"/ICEauthority +export _JAVA_OPTIONS=-Djava.util.prefs.userRoot="$XDG_CONFIG_HOME"/java + +compinit -d $XDG_CACHE_HOME/zsh/zcompdump-$ZSH_VERSION diff --git a/.scripts/zsh/hotkeys b/.scripts/zsh/hotkeys new file mode 100755 index 0000000..072ab7c --- /dev/null +++ b/.scripts/zsh/hotkeys @@ -0,0 +1,53 @@ +# create a zkbd compatible hash; +# to add other keys to this hash, see: man 5 terminfo +typeset -g -A key + +key[Home]="${terminfo[khome]}" +key[End]="${terminfo[kend]}" +key[Insert]="${terminfo[kich1]}" +key[Backspace]="${terminfo[kbs]}" +key[Delete]="${terminfo[kdch1]}" +key[Up]="${terminfo[kcuu1]}" +key[Down]="${terminfo[kcud1]}" +key[Left]="${terminfo[kcub1]}" +key[Right]="${terminfo[kcuf1]}" +key[PageUp]="${terminfo[kpp]}" +key[PageDown]="${terminfo[knp]}" +key[Shift-Tab]="${terminfo[kcbt]}" + +# setup key accordingly +[[ -n "${key[Home]}" ]] && bindkey -- "${key[Home]}" beginning-of-line +[[ -n "${key[End]}" ]] && bindkey -- "${key[End]}" end-of-line +[[ -n "${key[Insert]}" ]] && bindkey -- "${key[Insert]}" overwrite-mode +[[ -n "${key[Backspace]}" ]] && bindkey -- "${key[Backspace]}" backward-delete-char +[[ -n "${key[Delete]}" ]] && bindkey -- "${key[Delete]}" delete-char +[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-history +[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-history +[[ -n "${key[Left]}" ]] && bindkey -- "${key[Left]}" backward-char +[[ -n "${key[Right]}" ]] && bindkey -- "${key[Right]}" forward-char +[[ -n "${key[PageUp]}" ]] && bindkey -- "${key[PageUp]}" beginning-of-buffer-or-history +[[ -n "${key[PageDown]}" ]] && bindkey -- "${key[PageDown]}" end-of-buffer-or-history +[[ -n "${key[Shift-Tab]}" ]] && bindkey -- "${key[Shift-Tab]}" reverse-menu-complete + +# Finally, make sure the terminal is in application mode, when zle is +# active. Only then are the values from $terminfo valid. +if (( ${+terminfo[smkx]} && ${+terminfo[rmkx]} )); then + autoload -Uz add-zle-hook-widget + function zle_application_mode_start { echoti smkx } + function zle_application_mode_stop { echoti rmkx } + add-zle-hook-widget -Uz zle-line-init zle_application_mode_start + add-zle-hook-widget -Uz zle-line-finish zle_application_mode_stop +fi + +autoload -Uz up-line-or-beginning-search down-line-or-beginning-search +zle -N up-line-or-beginning-search +zle -N down-line-or-beginning-search + +[[ -n "${key[Up]}" ]] && bindkey -- "${key[Up]}" up-line-or-beginning-search +[[ -n "${key[Down]}" ]] && bindkey -- "${key[Down]}" down-line-or-beginning-search + +key[Control-Left]="${terminfo[kLFT5]}" +key[Control-Right]="${terminfo[kRIT5]}" + +[[ -n "${key[Control-Left]}" ]] && bindkey -- "${key[Control-Left]}" backward-word +[[ -n "${key[Control-Right]}" ]] && bindkey -- "${key[Control-Right]}" forward-word