the GREAT CONFIG MIGRATION; (scwrypts v5 and some neat new config stuffs)

This commit is contained in:
2025-02-19 21:56:37 -07:00
parent 623828461e
commit 1b70e44700
114 changed files with 330 additions and 328 deletions

View File

@@ -0,0 +1,38 @@
#!/usr/bin/env zsh
command -v /usr/bin/rankmirrors &>/dev/null || {
echo "missing 'rankmirrors'; trying to install..." >&2
yay -S pacman-contrib
}
command -v /usr/bin/rankmirrors &>/dev/null || {
echo "cannot rank mirrors without 'rankmirrors' from pacman-contrib; aborting" >&2
return 1
}
echo 'ranking mirrors; this may take a few minutes...' >&2
{
echo "# mirrors ranked on $(date)"
curl -s 'https://archlinux.org/mirrorlist/?country=US&country=CA&protocol=https&use_mirror_status=on' \
| sed 's/^#Server/Server/; /^#/d'
} | /usr/bin/rankmirrors -n 7 - > "${HOME}/mirrorlist.ranked"
[ -f ~/mirrorlist.ranked ] || {
echo 'failed to rank mirrors :c'
return 1
}
echo "
finished ranking mirrors!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" >&2
diff --side-by-side --color /etc/pacman.d/mirrorlist "${HOME}/mirrorlist.ranked" >&2
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
updated list is currently at ~/mirrorlist.ranked; please review the new list
and backup existing list; once you're ready to save them, you can run:
" >&2
echo "sudo mv ~/mirrorlist.ranked /etc/pacman.d/mirrorlist && yay -Syyu"

61
config/bin/i3-utils Executable file
View File

@@ -0,0 +1,61 @@
#!/bin/zsh
[ "${DOTWRYN}" ] || {
notify-send 'I3 UTILS' 'cannot determine $DOTWRYN for utility execution'
return 1
}
command -v scwrypts &>/dev/null || {
scwrypts() { "${DOTWRYN}/zsh/plugins/scwrypts/scwrypts" $@; }
}
export CI=true
export DESKTOP__SFX_PATH="${HOME}/Media/sfx"
export SCWRYPTS_LOG_LEVEL=0
#####################################################################
case $1 in
( next | previous | play-pause ) playerctl $1 ;;
( fastforward ) playerctl position 5+ ;;
( rewind ) playerctl position 5- ;;
( volumedown ) scwrypts media pulseaudio volume -- sink down ;;
( volumeup ) scwrypts media pulseaudio volume -- sink up ;;
( volumemute ) scwrypts media pulseaudio volume -- sink mute ;;
( micmute ) scwrypts media pulseaudio volume -- source mute ;;
( backlightup ) scwrypts desktop backlight -- up ;;
( backlightdown ) scwrypts desktop backlight -- down ;;
( lock ) scwrypts desktop lock i3 -- ;;
( bgrandomize ) scwrypts desktop set i3 background -- random ;;
( logout ) scwrypts desktop i3 logout -- ;;
( launch )
local PROGRAM
local ARGS=()
case $2 in
messages ) PROGRAM=slack ARGS+=(-c Slack --has-statusbar-icon) ;;
voice ) PROGRAM=google-voice-desktop ;;
ytmusic ) PROGRAM=youtubemusic-nativefier ;;
1pass ) PROGRAM=1password ARGS+=(-c 1Password) ;;
discord ) PROGRAM=discord ARGS+=(--has-statusbar-icon) ;;
obs ) PROGRAM=obs ARGS+=(-c '^obs' -n -l --has-statusbar-icon) ;;
pavuctrl ) PROGRAM=pavucontrol ARGS+=(-s 0.5 -c '^Pavucontrol') ;;
scrcpy ) PROGRAM=scrcpy ARGS+=(-n -l) ;;
spotify ) PROGRAM=spotify ARGS+=(-c Spotify) ;;
* ) PROGRAM=$2 ;;
esac
scwrypts i3 launch or show -- $PROGRAM ${ARGS[@]}
;;
( screenshot )
command -v flameshot || notify-send "I3 UTILS" "screenshot application 'flameshot' not available"
flameshot gui
;;
esac

33
config/bin/media Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/zsh
#####################################################################
USAGE="$0 (next|prev|playpause)"
function ERROR() {
local ERROR_CODE=$1
local MESSAGE="$2"
echo -e "$MESSAGE\n\nUSAGE : $USAGE\n" >&2
notify-send "YouTube media controller" "$MESSAGE"
exit $ERROR_CODE
}
#####################################################################
COMMAND="$1"
case $COMMAND in
next ) COMMAND_KEY='j';;
prev ) COMMAND_KEY='k';;
play ) COMMAND_KEY='space';;
* ) ERROR 1 "unsupported command '$COMMAND'" ;;
esac
xdotool search --name 'YouTube Music' windowactivate \
|| ERROR 2 "YouTube Music is not running"
# Chrome / YouTube only accepts keypresses when window is active
xdotool search --name 'YouTube Music' windowactivate
sleep 0.3
xdotool key --clearmodifiers "$COMMAND_KEY"

8
config/bin/polybar Executable file
View File

@@ -0,0 +1,8 @@
#!/usr/bin/env sh
command -v /usr/bin/polybar || return 0
killall -q polybar
while pgrep -x polybar &>/dev/null; do sleep 0.1; done
/usr/bin/polybar i3 &

22
config/bin/vim Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/sh
#####################################################################
VIM_ARGS=(-p)
BUILD_PREFERENCE=(
/usr/local/bin/vim # source build
/usr/bin/vim # package manager build
)
for V in ${BUILD_PREFERENCE[@]}
do
[ -f $V ] && VIM=$V && break
done
[ -f $VIM ] || {
echo "unable to find a build for vim; is it installed?" >&2
exit 1
}
#####################################################################
exec $VIM ${VIM_ARGS[@]} "$@"

View File

@@ -0,0 +1,20 @@
#!/bin/zsh
LAYOUT="$DOTWRYN/bin/$(hostnamectl --static)/default"
until xrandr -q >/dev/null 2>&1; do sleep .1; done
[ -f "$LAYOUT" ] \
&& XRANDR_LAYOUT_MODE=manual \
|| XRANDR_LAYOUT_MODE=auto \
;
case $XRANDR_LAYOUT_MODE in
manual )
"$LAYOUT"
;;
auto )
xrandr --auto
;;
esac
unset XRANDR_LAYOUT_MODE
true