ci: format
This commit is contained in:
parent
310bd074e7
commit
25b821a4fd
8 changed files with 374 additions and 331 deletions
|
|
@ -226,12 +226,16 @@ return {
|
||||||
enabled_languages = { 'cpp', 'python' },
|
enabled_languages = { 'cpp', 'python' },
|
||||||
default_language = 'cpp',
|
default_language = 'cpp',
|
||||||
overrides = {
|
overrides = {
|
||||||
cpp = { template = '~/.config/nix/config/cp/template_single.cc' },
|
cpp = {
|
||||||
|
template = '~/.config/nix/config/cp/template_single.cc',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
cses = {
|
cses = {
|
||||||
overrides = {
|
overrides = {
|
||||||
cpp = { template = '~/.config/nix/config/cp/template_single.cc' },
|
cpp = {
|
||||||
|
template = '~/.config/nix/config/cp/template_single.cc',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -242,24 +246,39 @@ return {
|
||||||
hooks = {
|
hooks = {
|
||||||
setup = {
|
setup = {
|
||||||
contest = function(state)
|
contest = function(state)
|
||||||
local dir = vim.fn.fnamemodify(state.get_source_file(state.get_language()), ':h')
|
local dir = vim.fn.fnamemodify(
|
||||||
|
state.get_source_file(state.get_language()),
|
||||||
|
':h'
|
||||||
|
)
|
||||||
local path = dir .. '/.clang-format'
|
local path = dir .. '/.clang-format'
|
||||||
if vim.fn.filereadable(path) == 0 then
|
if vim.fn.filereadable(path) == 0 then
|
||||||
vim.fn.system({ 'cp', vim.fn.expand('~/.config/nix/config/cp/.clang-format'), path })
|
vim.fn.system({
|
||||||
|
'cp',
|
||||||
|
vim.fn.expand(
|
||||||
|
'~/.config/nix/config/cp/.clang-format'
|
||||||
|
),
|
||||||
|
path,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
code = function(_)
|
code = function(_)
|
||||||
vim.opt_local.foldlevel = 0
|
vim.opt_local.foldlevel = 0
|
||||||
vim.opt_local.foldmethod = 'marker'
|
vim.opt_local.foldmethod = 'marker'
|
||||||
vim.opt_local.foldmarker = '{{{,}}}'
|
vim.opt_local.foldmarker = '{{{,}}}'
|
||||||
vim.opt_local.foldtext = ''
|
vim.opt_local.foldtext = ''
|
||||||
vim.diagnostic.enable(false)
|
vim.diagnostic.enable(false)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
on = {
|
on = {
|
||||||
enter = function(_) vim.opt_local.winbar = '' end,
|
enter = function(_)
|
||||||
run = function(_) require('config.lsp').format() end,
|
vim.opt_local.winbar = ''
|
||||||
debug = function(_) require('config.lsp').format() end,
|
end,
|
||||||
|
run = function(_)
|
||||||
|
require('config.lsp').format()
|
||||||
|
end,
|
||||||
|
debug = function(_)
|
||||||
|
require('config.lsp').format()
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
filename = function(_, _, problem_id)
|
filename = function(_, _, problem_id)
|
||||||
|
|
@ -267,6 +286,9 @@ return {
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
|
after = function()
|
||||||
|
vim.cmd.packadd('fzf-lua')
|
||||||
|
end,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
'barrettruth/preview.nvim',
|
'barrettruth/preview.nvim',
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@ end
|
||||||
vim.api.nvim_create_autocmd('VimEnter', {
|
vim.api.nvim_create_autocmd('VimEnter', {
|
||||||
once = true,
|
once = true,
|
||||||
callback = function()
|
callback = function()
|
||||||
vim.o.statusline = ' %{v:lua._fugitive_stl()}' .. vim.o.statusline:sub(2)
|
vim.o.statusline = ' %{v:lua._fugitive_stl()}'
|
||||||
|
.. vim.o.statusline:sub(2)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,13 @@ in
|
||||||
configurationLimit = 5;
|
configurationLimit = 5;
|
||||||
gfxmodeEfi = "1920x1200,auto";
|
gfxmodeEfi = "1920x1200,auto";
|
||||||
fontSize = 36;
|
fontSize = 36;
|
||||||
mirroredBoots = [{
|
mirroredBoots = [
|
||||||
path = "/boot";
|
{
|
||||||
efiSysMountPoint = "/efi";
|
path = "/boot";
|
||||||
devices = [ "nodev" ];
|
efiSysMountPoint = "/efi";
|
||||||
}];
|
devices = [ "nodev" ];
|
||||||
|
}
|
||||||
|
];
|
||||||
};
|
};
|
||||||
boot.loader.efi.canTouchEfiVariables = true;
|
boot.loader.efi.canTouchEfiVariables = true;
|
||||||
boot.loader.efi.efiSysMountPoint = "/efi";
|
boot.loader.efi.efiSysMountPoint = "/efi";
|
||||||
|
|
|
||||||
81
scripts/ctl
81
scripts/ctl
|
|
@ -16,7 +16,7 @@ screenshot)
|
||||||
file="$dir/$(openssl rand -hex 10)-$(date +'%Y-%m-%d_%H-%M-%S').png"
|
file="$dir/$(openssl rand -hex 10)-$(date +'%Y-%m-%d_%H-%M-%S').png"
|
||||||
if [ "${XDG_SESSION_TYPE:-}" = "wayland" ]; then
|
if [ "${XDG_SESSION_TYPE:-}" = "wayland" ]; then
|
||||||
require grim slurp wl-copy
|
require grim slurp wl-copy
|
||||||
grim -g "$(slurp)" "$file" && wl-copy < "$file"
|
grim -g "$(slurp)" "$file" && wl-copy <"$file"
|
||||||
else
|
else
|
||||||
require maim xclip
|
require maim xclip
|
||||||
maim -s "$file" && xclip -selection clipboard -t image/png -i "$file" &
|
maim -s "$file" && xclip -selection clipboard -t image/png -i "$file" &
|
||||||
|
|
@ -48,13 +48,13 @@ keyboard)
|
||||||
colemak) current="Colemak" ;;
|
colemak) current="Colemak" ;;
|
||||||
*) current="QWERTY" ;;
|
*) current="QWERTY" ;;
|
||||||
esac
|
esac
|
||||||
choice=$(printf 'QWERTY\nDvorak\nColemak' | \
|
choice=$(printf 'QWERTY\nDvorak\nColemak' |
|
||||||
awk -v cur="$current" '{
|
awk -v cur="$current" '{
|
||||||
prefix = ($0 == cur) ? " > " : " "
|
prefix = ($0 == cur) ? " > " : " "
|
||||||
printf "%s%s\t%s\n", prefix, $0, $0
|
printf "%s%s\t%s\n", prefix, $0, $0
|
||||||
}' | \
|
}' |
|
||||||
fuzzel --dmenu --prompt="kbd: " --no-icons --lines=3 \
|
fuzzel --dmenu --prompt="kbd: " --no-icons --lines=3 \
|
||||||
--with-nth=1 --accept-nth=2 --width=24)
|
--with-nth=1 --accept-nth=2 --font="monospace:size=12" --width=23)
|
||||||
[ -z "$choice" ] && exit 0
|
[ -z "$choice" ] && exit 0
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
QWERTY) variant="" ;;
|
QWERTY) variant="" ;;
|
||||||
|
|
@ -76,7 +76,7 @@ keyboard)
|
||||||
audio)
|
audio)
|
||||||
require wpctl pw-dump jq fuzzel
|
require wpctl pw-dump jq fuzzel
|
||||||
case "$2" in
|
case "$2" in
|
||||||
sink|source)
|
sink | source)
|
||||||
if [ "$2" = sink ]; then
|
if [ "$2" = sink ]; then
|
||||||
class="Audio/Sink"
|
class="Audio/Sink"
|
||||||
prompt="sink: "
|
prompt="sink: "
|
||||||
|
|
@ -106,11 +106,11 @@ audio)
|
||||||
active_prefix=$(printf " >%$((pad - 3))s" "")
|
active_prefix=$(printf " >%$((pad - 3))s" "")
|
||||||
header=$(printf "%s%s\n%s%s" "$indent" "Device name" "$indent" "$sep")
|
header=$(printf "%s%s\n%s%s" "$indent" "Device name" "$indent" "$sep")
|
||||||
count=$(printf '%s\n' "$rows" | wc -l)
|
count=$(printf '%s\n' "$rows" | wc -l)
|
||||||
choice=$(printf '%s\n' "$rows" | \
|
choice=$(printf '%s\n' "$rows" |
|
||||||
awk -F'\t' -v w1="$w1" -v indent="$indent" -v active_prefix="$active_prefix" '{
|
awk -F'\t' -v w1="$w1" -v indent="$indent" -v active_prefix="$active_prefix" '{
|
||||||
prefix = ($3 == ">") ? active_prefix : indent
|
prefix = ($3 == ">") ? active_prefix : indent
|
||||||
printf "%s%-*s\t%s\n", prefix, w1, $2, $1
|
printf "%s%-*s\t%s\n", prefix, w1, $2, $1
|
||||||
}' | \
|
}' |
|
||||||
fuzzel --dmenu --prompt="$prompt" --no-icons --lines="$count" \
|
fuzzel --dmenu --prompt="$prompt" --no-icons --lines="$count" \
|
||||||
--with-nth=1 --accept-nth=2 \
|
--with-nth=1 --accept-nth=2 \
|
||||||
--mesg="$header" --mesg-mode=expand \
|
--mesg="$header" --mesg-mode=expand \
|
||||||
|
|
@ -130,14 +130,25 @@ brightness)
|
||||||
case "$2" in
|
case "$2" in
|
||||||
up) brightnessctl set "$BRIGHT_STEP"%+ ;;
|
up) brightnessctl set "$BRIGHT_STEP"%+ ;;
|
||||||
down) brightnessctl set "$BRIGHT_STEP"%- ;;
|
down) brightnessctl set "$BRIGHT_STEP"%- ;;
|
||||||
*) echo "Usage: ctl brightness {up|down}" >&2; exit 1 ;;
|
*)
|
||||||
|
echo "Usage: ctl brightness {up|down}" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
pct=$(awk -v cur="$(brightnessctl get)" -v max="$(brightnessctl max)" 'BEGIN { printf "%d", cur * 100 / max }')
|
pct=$(awk -v cur="$(brightnessctl get)" -v max="$(brightnessctl max)" 'BEGIN { printf "%d", cur * 100 / max }')
|
||||||
filled=$((pct / 5))
|
filled=$((pct / 5))
|
||||||
empty=$((20 - filled))
|
empty=$((20 - filled))
|
||||||
bar=""
|
bar=""
|
||||||
i=0; while [ "$i" -lt "$filled" ]; do bar="${bar}━"; i=$((i + 1)); done
|
i=0
|
||||||
i=0; while [ "$i" -lt "$empty" ]; do bar="${bar}─"; i=$((i + 1)); done
|
while [ "$i" -lt "$filled" ]; do
|
||||||
|
bar="${bar}━"
|
||||||
|
i=$((i + 1))
|
||||||
|
done
|
||||||
|
i=0
|
||||||
|
while [ "$i" -lt "$empty" ]; do
|
||||||
|
bar="${bar}─"
|
||||||
|
i=$((i + 1))
|
||||||
|
done
|
||||||
notify-send -a ctl -t 2500 -r 5555 " $bar"
|
notify-send -a ctl -t 2500 -r 5555 " $bar"
|
||||||
;;
|
;;
|
||||||
volume)
|
volume)
|
||||||
|
|
@ -149,14 +160,25 @@ volume)
|
||||||
up) wpctl set-volume "$SINK" "${VOL_STEP}%+" --limit 1.0 ;;
|
up) wpctl set-volume "$SINK" "${VOL_STEP}%+" --limit 1.0 ;;
|
||||||
down) wpctl set-volume "$SINK" "${VOL_STEP}%-" ;;
|
down) wpctl set-volume "$SINK" "${VOL_STEP}%-" ;;
|
||||||
toggle) wpctl set-mute "$SINK" toggle ;;
|
toggle) wpctl set-mute "$SINK" toggle ;;
|
||||||
*) echo "Usage: ctl volume {up|down|toggle}" >&2; exit 1 ;;
|
*)
|
||||||
|
echo "Usage: ctl volume {up|down|toggle}" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
vol=$(get_vol)
|
vol=$(get_vol)
|
||||||
filled=$((vol / 5))
|
filled=$((vol / 5))
|
||||||
empty=$((20 - filled))
|
empty=$((20 - filled))
|
||||||
bar=""
|
bar=""
|
||||||
i=0; while [ "$i" -lt "$filled" ]; do bar="${bar}━"; i=$((i + 1)); done
|
i=0
|
||||||
i=0; while [ "$i" -lt "$empty" ]; do bar="${bar}─"; i=$((i + 1)); done
|
while [ "$i" -lt "$filled" ]; do
|
||||||
|
bar="${bar}━"
|
||||||
|
i=$((i + 1))
|
||||||
|
done
|
||||||
|
i=0
|
||||||
|
while [ "$i" -lt "$empty" ]; do
|
||||||
|
bar="${bar}─"
|
||||||
|
i=$((i + 1))
|
||||||
|
done
|
||||||
if wpctl get-volume "$SINK" | grep -q MUTED; then
|
if wpctl get-volume "$SINK" | grep -q MUTED; then
|
||||||
icon=""
|
icon=""
|
||||||
elif [ "$vol" -le 33 ]; then
|
elif [ "$vol" -le 33 ]; then
|
||||||
|
|
@ -173,11 +195,14 @@ wifi)
|
||||||
pick)
|
pick)
|
||||||
require fuzzel
|
require fuzzel
|
||||||
station=$(iwctl device list 2>/dev/null | sed 's/\x1b\[[0-9;]*[a-zA-Z]//g' | awk '/station/{print $1}')
|
station=$(iwctl device list 2>/dev/null | sed 's/\x1b\[[0-9;]*[a-zA-Z]//g' | awk '/station/{print $1}')
|
||||||
[ -z "$station" ] && { echo "ctl: no wifi device found" >&2; exit 1; }
|
[ -z "$station" ] && {
|
||||||
|
echo "ctl: no wifi device found" >&2
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
while :; do
|
while :; do
|
||||||
networks=$(iwctl station "$station" get-networks 2>/dev/null | \
|
networks=$(iwctl station "$station" get-networks 2>/dev/null |
|
||||||
sed 's/\x1b\[[0-9;]*[a-zA-Z]//g' | \
|
sed 's/\x1b\[[0-9;]*[a-zA-Z]//g' |
|
||||||
awk 'NR>4 && /\S/ && !/^[[:space:]]*-/' | \
|
awk 'NR>4 && /\S/ && !/^[[:space:]]*-/' |
|
||||||
awk '{
|
awk '{
|
||||||
active = ($0 ~ /^[[:space:]]*>/) ? ">" : ""
|
active = ($0 ~ /^[[:space:]]*>/) ? ">" : ""
|
||||||
sub(/^[[:space:]>]*/, "")
|
sub(/^[[:space:]>]*/, "")
|
||||||
|
|
@ -210,11 +235,11 @@ wifi)
|
||||||
sep=$(awk -v n="$((w1 + w2 + w3 + 8))" 'BEGIN{for(i=0;i<n;i++)printf "─";print ""}')
|
sep=$(awk -v n="$((w1 + w2 + w3 + 8))" 'BEGIN{for(i=0;i<n;i++)printf "─";print ""}')
|
||||||
header=$(printf " %-*s %-*s %s\n %s" "$w1" "Network name" "$w2" "Security" "Signal" "$sep")
|
header=$(printf " %-*s %-*s %s\n %s" "$w1" "Network name" "$w2" "Security" "Signal" "$sep")
|
||||||
count=$(printf '%s\n' "$networks" | wc -l)
|
count=$(printf '%s\n' "$networks" | wc -l)
|
||||||
ssid=$(printf '%s\n' "$networks" | \
|
ssid=$(printf '%s\n' "$networks" |
|
||||||
awk -F'\t' -v w1="$w1" -v w2="$w2" '{
|
awk -F'\t' -v w1="$w1" -v w2="$w2" '{
|
||||||
prefix = ($4 == ">") ? " > " : " "
|
prefix = ($4 == ">") ? " > " : " "
|
||||||
printf "%s%-*s %-*s %s\t%s\n", prefix, w1, $1, w2, $2, $3, $1
|
printf "%s%-*s %-*s %s\t%s\n", prefix, w1, $1, w2, $2, $3, $1
|
||||||
}' | \
|
}' |
|
||||||
fuzzel --dmenu --prompt="wifi: " --no-icons --lines="$count" \
|
fuzzel --dmenu --prompt="wifi: " --no-icons --lines="$count" \
|
||||||
--with-nth=1 --accept-nth=2 \
|
--with-nth=1 --accept-nth=2 \
|
||||||
--mesg="$header" --mesg-mode=expand \
|
--mesg="$header" --mesg-mode=expand \
|
||||||
|
|
@ -266,33 +291,33 @@ media)
|
||||||
case "$chosen" in
|
case "$chosen" in
|
||||||
"$cap_desktop")
|
"$cap_desktop")
|
||||||
file="$ss_dir/$(date +'%Y-%m-%d_%H-%M-%S').png"
|
file="$ss_dir/$(date +'%Y-%m-%d_%H-%M-%S').png"
|
||||||
grim "$file" && wl-copy < "$file" && echo "$file" && notify-send -a ctl -t 2500 "Screenshot saved to ~${file#"$HOME"}"
|
grim "$file" && wl-copy <"$file" && echo "$file" && notify-send -a ctl -t 2500 "Screenshot saved to ~${file#"$HOME"}"
|
||||||
;;
|
;;
|
||||||
"$cap_area")
|
"$cap_area")
|
||||||
file="$ss_dir/$(date +'%Y-%m-%d_%H-%M-%S').png"
|
file="$ss_dir/$(date +'%Y-%m-%d_%H-%M-%S').png"
|
||||||
grim -g "$(slurp)" "$file" && wl-copy < "$file" && echo "$file" && notify-send -a ctl -t 2500 "Screenshot saved to ~${file#"$HOME"}"
|
grim -g "$(slurp)" "$file" && wl-copy <"$file" && echo "$file" && notify-send -a ctl -t 2500 "Screenshot saved to ~${file#"$HOME"}"
|
||||||
;;
|
;;
|
||||||
"$cap_window")
|
"$cap_window")
|
||||||
geom=$(hyprctl activewindow -j | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"')
|
geom=$(hyprctl activewindow -j | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"')
|
||||||
file="$ss_dir/$(date +'%Y-%m-%d_%H-%M-%S').png"
|
file="$ss_dir/$(date +'%Y-%m-%d_%H-%M-%S').png"
|
||||||
grim -g "$geom" "$file" && wl-copy < "$file" && echo "$file" && notify-send -a ctl -t 2500 "Screenshot saved to ~${file#"$HOME"}"
|
grim -g "$geom" "$file" && wl-copy <"$file" && echo "$file" && notify-send -a ctl -t 2500 "Screenshot saved to ~${file#"$HOME"}"
|
||||||
;;
|
;;
|
||||||
"$rec_desktop")
|
"$rec_desktop")
|
||||||
file="$rec_dir/$(date +'%Y-%m-%d_%H-%M-%S').mp4"
|
file="$rec_dir/$(date +'%Y-%m-%d_%H-%M-%S').mp4"
|
||||||
echo "$file" > "${XDG_RUNTIME_DIR:-/tmp}/ctl-recording"
|
echo "$file" >"${XDG_RUNTIME_DIR:-/tmp}/ctl-recording"
|
||||||
notify-send -a ctl -t 2500 "Recording started"
|
notify-send -a ctl -t 2500 "Recording started"
|
||||||
wf-recorder -f "$file" &
|
wf-recorder -f "$file" &
|
||||||
;;
|
;;
|
||||||
"$rec_area")
|
"$rec_area")
|
||||||
file="$rec_dir/$(date +'%Y-%m-%d_%H-%M-%S').mp4"
|
file="$rec_dir/$(date +'%Y-%m-%d_%H-%M-%S').mp4"
|
||||||
echo "$file" > "${XDG_RUNTIME_DIR:-/tmp}/ctl-recording"
|
echo "$file" >"${XDG_RUNTIME_DIR:-/tmp}/ctl-recording"
|
||||||
notify-send -a ctl -t 2500 "Recording started"
|
notify-send -a ctl -t 2500 "Recording started"
|
||||||
wf-recorder -g "$(slurp)" -f "$file" &
|
wf-recorder -g "$(slurp)" -f "$file" &
|
||||||
;;
|
;;
|
||||||
"$rec_window")
|
"$rec_window")
|
||||||
geom=$(hyprctl activewindow -j | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"')
|
geom=$(hyprctl activewindow -j | jq -r '"\(.at[0]),\(.at[1]) \(.size[0])x\(.size[1])"')
|
||||||
file="$rec_dir/$(date +'%Y-%m-%d_%H-%M-%S').mp4"
|
file="$rec_dir/$(date +'%Y-%m-%d_%H-%M-%S').mp4"
|
||||||
echo "$file" > "${XDG_RUNTIME_DIR:-/tmp}/ctl-recording"
|
echo "$file" >"${XDG_RUNTIME_DIR:-/tmp}/ctl-recording"
|
||||||
notify-send -a ctl -t 2500 "Recording started"
|
notify-send -a ctl -t 2500 "Recording started"
|
||||||
wf-recorder -g "$geom" -f "$file" &
|
wf-recorder -g "$geom" -f "$file" &
|
||||||
;;
|
;;
|
||||||
|
|
@ -306,7 +331,7 @@ media)
|
||||||
;;
|
;;
|
||||||
wallpaper)
|
wallpaper)
|
||||||
require python
|
require python
|
||||||
python - "$2" << 'PYTHON'
|
python - "$2" <<'PYTHON'
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ require tmux
|
||||||
get_scope() {
|
get_scope() {
|
||||||
_path=$(tmux display-message -p '#{pane_current_path}')
|
_path=$(tmux display-message -p '#{pane_current_path}')
|
||||||
case "$_path" in
|
case "$_path" in
|
||||||
"$HOME") printf '~' ;;
|
"$HOME") printf '~' ;;
|
||||||
*) basename "$_path" ;;
|
*) basename "$_path" ;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -61,7 +61,7 @@ pick_pane() {
|
||||||
sel=$({
|
sel=$({
|
||||||
printf 'target\tcommand\tpath\n'
|
printf 'target\tcommand\tpath\n'
|
||||||
tmux list-panes -a -F '#{window_index}.#{pane_index}:#{session_name} #{pane_current_command} #{pane_current_path}' |
|
tmux list-panes -a -F '#{window_index}.#{pane_index}:#{session_name} #{pane_current_command} #{pane_current_path}' |
|
||||||
sed "s|$HOME|~|g"
|
sed "s|$HOME|~|g"
|
||||||
} | column -t -s "$(printf '\t')" |
|
} | column -t -s "$(printf '\t')" |
|
||||||
fzf --reverse --header-lines 1 --prompt 'select-pane> ')
|
fzf --reverse --header-lines 1 --prompt 'select-pane> ')
|
||||||
sel="${sel%% *}"
|
sel="${sel%% *}"
|
||||||
|
|
@ -73,7 +73,7 @@ target_pane() {
|
||||||
sel=$({
|
sel=$({
|
||||||
printf 'target\tcommand\tpath\n'
|
printf 'target\tcommand\tpath\n'
|
||||||
tmux list-panes -a -F '#{window_index}.#{pane_index}:#{session_name} #{pane_current_command} #{pane_current_path}' |
|
tmux list-panes -a -F '#{window_index}.#{pane_index}:#{session_name} #{pane_current_command} #{pane_current_path}' |
|
||||||
sed "s|$HOME|~|g"
|
sed "s|$HOME|~|g"
|
||||||
} | column -t -s "$(printf '\t')" |
|
} | column -t -s "$(printf '\t')" |
|
||||||
fzf --reverse --header-lines 1 --prompt "$1> ")
|
fzf --reverse --header-lines 1 --prompt "$1> ")
|
||||||
sel="${sel%% *}"
|
sel="${sel%% *}"
|
||||||
|
|
|
||||||
551
scripts/pipes
551
scripts/pipes
|
|
@ -24,16 +24,15 @@
|
||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
VERSION=1.3.0
|
VERSION=1.3.0
|
||||||
|
|
||||||
M=32768 # Bash RANDOM maximum + 1
|
M=32768 # Bash RANDOM maximum + 1
|
||||||
p=1 # number of pipes
|
p=1 # number of pipes
|
||||||
f=75 # frame rate
|
f=75 # frame rate
|
||||||
s=13 # probability of straight fitting
|
s=13 # probability of straight fitting
|
||||||
r=2000 # characters limit
|
r=2000 # characters limit
|
||||||
t=0 # iteration counter for -r character limit
|
t=0 # iteration counter for -r character limit
|
||||||
w=80 # terminal size
|
w=80 # terminal size
|
||||||
h=24
|
h=24
|
||||||
|
|
||||||
# ab -> sets[][idx] = a*4 + b
|
# ab -> sets[][idx] = a*4 + b
|
||||||
|
|
@ -41,48 +40,47 @@ h=24
|
||||||
# 00 means going up , then going up -> ┃
|
# 00 means going up , then going up -> ┃
|
||||||
# 12 means going right, then going down -> ┓
|
# 12 means going right, then going down -> ┓
|
||||||
sets=(
|
sets=(
|
||||||
"┃┏ ┓┛━┓ ┗┃┛┗ ┏━"
|
"┃┏ ┓┛━┓ ┗┃┛┗ ┏━"
|
||||||
"│╭ ╮╯─╮ ╰│╯╰ ╭─"
|
"│╭ ╮╯─╮ ╰│╯╰ ╭─"
|
||||||
"│┌ ┐┘─┐ └│┘└ ┌─"
|
"│┌ ┐┘─┐ └│┘└ ┌─"
|
||||||
"║╔ ╗╝═╗ ╚║╝╚ ╔═"
|
"║╔ ╗╝═╗ ╚║╝╚ ╔═"
|
||||||
"|+ ++-+ +|++ +-"
|
"|+ ++-+ +|++ +-"
|
||||||
"|/ \/-\ \|/\ /-"
|
"|/ \/-\ \|/\ /-"
|
||||||
".. .... .... .."
|
".. .... .... .."
|
||||||
".o oo.o o.oo o."
|
".o oo.o o.oo o."
|
||||||
"-\ /\|/ /-\/ \|" # railway
|
"-\ /\|/ /-\/ \|" # railway
|
||||||
"╿┍ ┑┚╼┒ ┕╽┙┖ ┎╾" # knobby pipe
|
"╿┍ ┑┚╼┒ ┕╽┙┖ ┎╾" # knobby pipe
|
||||||
"████▀▀███▀█▀▀██▀"
|
"████▀▀███▀█▀▀██▀"
|
||||||
)
|
)
|
||||||
SETS=() # rearranged all pipe chars into individul elements for easier access
|
SETS=() # rearranged all pipe chars into individul elements for easier access
|
||||||
|
|
||||||
# pipes'
|
# pipes'
|
||||||
x=() # current position
|
x=() # current position
|
||||||
y=()
|
y=()
|
||||||
l=() # current directions
|
l=() # current directions
|
||||||
# 0: up, 1: right, 2: down, 3: left
|
# 0: up, 1: right, 2: down, 3: left
|
||||||
n=() # new directions
|
n=() # new directions
|
||||||
v=() # current types
|
v=() # current types
|
||||||
c=() # current escape codes
|
c=() # current escape codes
|
||||||
|
|
||||||
# selected pipes'
|
# selected pipes'
|
||||||
V=() # types (indexes to sets[])
|
V=() # types (indexes to sets[])
|
||||||
C=() # color indices for tput setaf
|
C=() # color indices for tput setaf
|
||||||
VN=0 # number of selected types
|
VN=0 # number of selected types
|
||||||
CN=0 # number of selected colors
|
CN=0 # number of selected colors
|
||||||
E=() # pre-generated escape codes from BOLD, NOCOLOR, and C
|
E=() # pre-generated escape codes from BOLD, NOCOLOR, and C
|
||||||
|
|
||||||
# switches
|
# switches
|
||||||
RNDSTART=0 # randomize starting position and direction
|
RNDSTART=0 # randomize starting position and direction
|
||||||
BOLD=1
|
BOLD=1
|
||||||
NOCOLOR=0
|
NOCOLOR=0
|
||||||
KEEPCT=0 # keep pipe color and type
|
KEEPCT=0 # keep pipe color and type
|
||||||
|
|
||||||
|
|
||||||
# print help message in 72-char width
|
# print help message in 72-char width
|
||||||
print_help() {
|
print_help() {
|
||||||
local cgap
|
local cgap
|
||||||
printf -v cgap '%*s' $((15 - ${#COLORS})) ''
|
printf -v cgap '%*s' $((15 - ${#COLORS})) ''
|
||||||
cat <<HELP
|
cat <<HELP
|
||||||
Usage: $(basename $0) [OPTION]...
|
Usage: $(basename $0) [OPTION]...
|
||||||
Animated pipes terminal screensaver.
|
Animated pipes terminal screensaver.
|
||||||
|
|
||||||
|
|
@ -106,281 +104,276 @@ Note: -t and -c can be used more than once.
|
||||||
HELP
|
HELP
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# parse command-line options
|
# parse command-line options
|
||||||
# It depends on a valid COLORS which is set by _CP_init_termcap_vars
|
# It depends on a valid COLORS which is set by _CP_init_termcap_vars
|
||||||
parse() {
|
parse() {
|
||||||
# test if $1 is a natural number in decimal, an integer >= 0
|
# test if $1 is a natural number in decimal, an integer >= 0
|
||||||
is_N() {
|
is_N() {
|
||||||
[[ -n $1 && -z ${1//[0-9]} ]]
|
[[ -n $1 && -z ${1//[0-9]/} ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# test if $1 is a hexadecimal string
|
||||||
|
is_hex() {
|
||||||
|
[[ -n $1 && -z ${1//[0-9A-Fa-f]/} ]]
|
||||||
|
}
|
||||||
|
|
||||||
# test if $1 is a hexadecimal string
|
# print error message for invalid argument to standard error, this
|
||||||
is_hex() {
|
# - mimics getopts error message
|
||||||
[[ -n $1 && -z ${1//[0-9A-Fa-f]} ]]
|
# - use all positional parameters as error message
|
||||||
}
|
# - has a newline appended
|
||||||
|
# $arg and $OPTARG are the option name and argument set by getopts.
|
||||||
|
pearg() {
|
||||||
|
printf "%s: -$arg invalid argument -- $OPTARG; %s\n" "$0" "$*" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
OPTIND=1
|
||||||
# print error message for invalid argument to standard error, this
|
while getopts "p:t:c:f:s:r:RBCKhv" arg; do
|
||||||
# - mimics getopts error message
|
|
||||||
# - use all positional parameters as error message
|
|
||||||
# - has a newline appended
|
|
||||||
# $arg and $OPTARG are the option name and argument set by getopts.
|
|
||||||
pearg() {
|
|
||||||
printf "%s: -$arg invalid argument -- $OPTARG; %s\n" "$0" "$*" >&2
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
OPTIND=1
|
|
||||||
while getopts "p:t:c:f:s:r:RBCKhv" arg; do
|
|
||||||
case $arg in
|
case $arg in
|
||||||
p)
|
p)
|
||||||
if is_N "$OPTARG" && ((OPTARG > 0)); then
|
if is_N "$OPTARG" && ((OPTARG > 0)); then
|
||||||
p=$OPTARG
|
p=$OPTARG
|
||||||
else
|
else
|
||||||
pearg 'must be an integer and greater than 0'
|
pearg 'must be an integer and greater than 0'
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
t)
|
|
||||||
if [[ "$OPTARG" = c???????????????? ]]; then
|
|
||||||
V+=(${#sets[@]})
|
|
||||||
sets+=("${OPTARG:1}")
|
|
||||||
elif is_N "$OPTARG" && ((OPTARG < ${#sets[@]})); then
|
|
||||||
V+=($OPTARG)
|
|
||||||
else
|
|
||||||
pearg 'must be an integer and from 0 to' \
|
|
||||||
"$((${#sets[@]} - 1)); or a custom type"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
c)
|
|
||||||
if [[ $OPTARG == '#'* ]]; then
|
|
||||||
if ! is_hex "${OPTARG:1}"; then
|
|
||||||
pearg 'unrecognized hexadecimal string'
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
if ((16$OPTARG >= COLORS)); then
|
|
||||||
pearg 'hexadecimal must be from #0 to' \
|
|
||||||
"#$(printf '%X' $((COLORS - 1)))"
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
C+=($((16$OPTARG)))
|
|
||||||
elif is_N "$OPTARG" && ((OPTARG < COLORS)); then
|
|
||||||
C+=($OPTARG)
|
|
||||||
else
|
|
||||||
pearg "must be an integer and from 0 to $((COLORS - 1));" \
|
|
||||||
'or a hexadecimal string with # prefix'
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
f)
|
|
||||||
if is_N "$OPTARG" && ((OPTARG >= 20 && OPTARG <= 100)); then
|
|
||||||
f=$OPTARG
|
|
||||||
else
|
|
||||||
pearg 'must be an integer and from 20 to 100'
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
s)
|
|
||||||
if is_N "$OPTARG" && ((OPTARG >= 5 && OPTARG <= 15)); then
|
|
||||||
s=$OPTARG
|
|
||||||
else
|
|
||||||
pearg 'must be an integer and from 5 to 15'
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
r)
|
|
||||||
if is_N "$OPTARG"; then
|
|
||||||
r=$OPTARG
|
|
||||||
else
|
|
||||||
pearg 'must be a non-negative integer'
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
;;
|
|
||||||
R) RNDSTART=1;;
|
|
||||||
B) BOLD=0;;
|
|
||||||
C) NOCOLOR=1;;
|
|
||||||
K) KEEPCT=1;;
|
|
||||||
h)
|
|
||||||
print_help
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
v) echo "$(basename -- "$0") $VERSION"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
return 1
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
shift $((OPTIND - 1))
|
|
||||||
if (($#)); then
|
|
||||||
printf "$0: illegal arguments -- $*; no arguments allowed\n" >&2
|
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
;;
|
||||||
|
t)
|
||||||
|
if [[ "$OPTARG" = c???????????????? ]]; then
|
||||||
|
V+=(${#sets[@]})
|
||||||
|
sets+=("${OPTARG:1}")
|
||||||
|
elif is_N "$OPTARG" && ((OPTARG < ${#sets[@]})); then
|
||||||
|
V+=($OPTARG)
|
||||||
|
else
|
||||||
|
pearg 'must be an integer and from 0 to' \
|
||||||
|
"$((${#sets[@]} - 1)); or a custom type"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
c)
|
||||||
|
if [[ $OPTARG == '#'* ]]; then
|
||||||
|
if ! is_hex "${OPTARG:1}"; then
|
||||||
|
pearg 'unrecognized hexadecimal string'
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if ((16$OPTARG >= COLORS)); then
|
||||||
|
pearg 'hexadecimal must be from #0 to' \
|
||||||
|
"#$(printf '%X' $((COLORS - 1)))"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
C+=($((16$OPTARG)))
|
||||||
|
elif is_N "$OPTARG" && ((OPTARG < COLORS)); then
|
||||||
|
C+=($OPTARG)
|
||||||
|
else
|
||||||
|
pearg "must be an integer and from 0 to $((COLORS - 1));" \
|
||||||
|
'or a hexadecimal string with # prefix'
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
f)
|
||||||
|
if is_N "$OPTARG" && ((OPTARG >= 20 && OPTARG <= 100)); then
|
||||||
|
f=$OPTARG
|
||||||
|
else
|
||||||
|
pearg 'must be an integer and from 20 to 100'
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
s)
|
||||||
|
if is_N "$OPTARG" && ((OPTARG >= 5 && OPTARG <= 15)); then
|
||||||
|
s=$OPTARG
|
||||||
|
else
|
||||||
|
pearg 'must be an integer and from 5 to 15'
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
r)
|
||||||
|
if is_N "$OPTARG"; then
|
||||||
|
r=$OPTARG
|
||||||
|
else
|
||||||
|
pearg 'must be a non-negative integer'
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
R) RNDSTART=1 ;;
|
||||||
|
B) BOLD=0 ;;
|
||||||
|
C) NOCOLOR=1 ;;
|
||||||
|
K) KEEPCT=1 ;;
|
||||||
|
h)
|
||||||
|
print_help
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
v)
|
||||||
|
echo "$(basename -- "$0") $VERSION"
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
if (($#)); then
|
||||||
|
printf "$0: illegal arguments -- $*; no arguments allowed\n" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
# clear out standard input
|
# clear out standard input
|
||||||
read -t 0.001 && cat </dev/stdin>/dev/null
|
read -t 0.001 && cat </dev/stdin >/dev/null
|
||||||
|
|
||||||
tput reset # fix for konsole, see pipeseroni/pipes.sh#43
|
tput reset # fix for konsole, see pipeseroni/pipes.sh#43
|
||||||
tput rmcup
|
tput rmcup
|
||||||
tput cnorm
|
tput cnorm
|
||||||
stty echo
|
stty echo
|
||||||
printf "$SGR0"
|
printf "$SGR0"
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
resize() {
|
resize() {
|
||||||
w=$(tput cols) h=$(tput lines)
|
w=$(tput cols) h=$(tput lines)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
init_pipes() {
|
init_pipes() {
|
||||||
# +_CP_init_pipes
|
# +_CP_init_pipes
|
||||||
local i
|
local i
|
||||||
|
|
||||||
ci=$((KEEPCT ? 0 : CN * RANDOM / M))
|
ci=$((KEEPCT ? 0 : CN * RANDOM / M))
|
||||||
vi=$((KEEPCT ? 0 : VN * RANDOM / M))
|
vi=$((KEEPCT ? 0 : VN * RANDOM / M))
|
||||||
for ((i = 0; i < p; i++)); do
|
for ((i = 0; i < p; i++)); do
|
||||||
((
|
((\
|
||||||
n[i] = 0,
|
n[i] = 0, \
|
||||||
l[i] = RNDSTART ? RANDOM % 4 : 0,
|
l[i] = RNDSTART ? RANDOM % 4 : 0, \
|
||||||
x[i] = RNDSTART ? w * RANDOM / M : w / 2,
|
x[i] = RNDSTART ? w * RANDOM / M : w / 2, \
|
||||||
y[i] = RNDSTART ? h * RANDOM / M : h / 2,
|
y[i] = RNDSTART ? h * RANDOM / M : h / 2, \
|
||||||
v[i] = V[vi]
|
v[i] = V[vi]))
|
||||||
))
|
|
||||||
c[i]=${E[ci]}
|
c[i]=${E[ci]}
|
||||||
((ci = (ci + 1) % CN, vi = (vi + 1) % VN))
|
((ci = (ci + 1) % CN, vi = (vi + 1) % VN))
|
||||||
done
|
done
|
||||||
# -_CP_init_pipes
|
# -_CP_init_pipes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
init_screen() {
|
init_screen() {
|
||||||
stty -echo
|
stty -echo
|
||||||
tput smcup
|
tput smcup
|
||||||
tput civis
|
tput civis
|
||||||
tput clear
|
tput clear
|
||||||
trap cleanup HUP TERM
|
trap cleanup HUP TERM
|
||||||
|
|
||||||
resize
|
resize
|
||||||
trap resize SIGWINCH
|
trap resize SIGWINCH
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
# simple pre-check of TERM, tput's error message should be enough
|
# simple pre-check of TERM, tput's error message should be enough
|
||||||
tput -T "$TERM" sgr0 >/dev/null || return $?
|
tput -T "$TERM" sgr0 >/dev/null || return $?
|
||||||
|
|
||||||
# +_CP_init_termcap_vars
|
# +_CP_init_termcap_vars
|
||||||
COLORS=$(tput colors) # COLORS - 1 == maximum color index for -c argument
|
COLORS=$(tput colors) # COLORS - 1 == maximum color index for -c argument
|
||||||
SGR0=$(tput sgr0)
|
SGR0=$(tput sgr0)
|
||||||
SGR_BOLD=$(tput bold)
|
SGR_BOLD=$(tput bold)
|
||||||
# -_CP_init_termcap_vars
|
# -_CP_init_termcap_vars
|
||||||
|
|
||||||
parse "$@" || return $?
|
parse "$@" || return $?
|
||||||
|
|
||||||
# +_CP_init_VC
|
# +_CP_init_VC
|
||||||
# set default values if not by options
|
# set default values if not by options
|
||||||
((${#V[@]})) || V=(0)
|
((${#V[@]})) || V=(0)
|
||||||
VN=${#V[@]}
|
VN=${#V[@]}
|
||||||
((${#C[@]})) || C=(1 2 3 4 5 6 7 0)
|
((${#C[@]})) || C=(1 2 3 4 5 6 7 0)
|
||||||
CN=${#C[@]}
|
CN=${#C[@]}
|
||||||
# -_CP_init_VC
|
# -_CP_init_VC
|
||||||
|
|
||||||
# +_CP_init_E
|
# +_CP_init_E
|
||||||
# generate E[] based on BOLD (SGR_BOLD), NOCOLOR, and C for each element in
|
# generate E[] based on BOLD (SGR_BOLD), NOCOLOR, and C for each element in
|
||||||
# C, a corresponding element in E[] =
|
# C, a corresponding element in E[] =
|
||||||
# SGR0
|
# SGR0
|
||||||
# + SGR_BOLD, if BOLD
|
# + SGR_BOLD, if BOLD
|
||||||
# + tput setaf C, if !NOCOLOR
|
# + tput setaf C, if !NOCOLOR
|
||||||
local i
|
local i
|
||||||
for ((i = 0; i < CN; i++)) {
|
for ((i = 0; i < CN; i++)); do
|
||||||
E[i]=$SGR0
|
E[i]=$SGR0
|
||||||
((BOLD)) && E[i]+=$SGR_BOLD
|
((BOLD)) && E[i]+=$SGR_BOLD
|
||||||
((NOCOLOR)) || E[i]+=$(tput setaf ${C[i]})
|
((NOCOLOR)) || E[i]+=$(tput setaf ${C[i]})
|
||||||
}
|
done
|
||||||
# -_CP_init_E
|
# -_CP_init_E
|
||||||
|
|
||||||
# +_CP_init_SETS
|
# +_CP_init_SETS
|
||||||
local i j
|
local i j
|
||||||
for ((i = 0; i < ${#sets[@]}; i++)) {
|
for ((i = 0; i < ${#sets[@]}; i++)); do
|
||||||
for ((j = 0; j < 16; j++)) {
|
for ((j = 0; j < 16; j++)); do
|
||||||
SETS+=("${sets[i]:j:1}")
|
SETS+=("${sets[i]:j:1}")
|
||||||
}
|
|
||||||
}
|
|
||||||
unset i j
|
|
||||||
# -_CP_init_SETS
|
|
||||||
|
|
||||||
init_screen
|
|
||||||
init_pipes
|
|
||||||
|
|
||||||
# any key press exits the loop and this script
|
|
||||||
trap 'break 2' INT
|
|
||||||
|
|
||||||
local i
|
|
||||||
while REPLY=; do
|
|
||||||
read -t 0.0$((1000 / f)) -n 1 2>/dev/null
|
|
||||||
case "$REPLY" in
|
|
||||||
P) ((s = s < 15 ? s + 1 : s));;
|
|
||||||
O) ((s = s > 3 ? s - 1 : s));;
|
|
||||||
F) ((f = f < 100 ? f + 1 : f));;
|
|
||||||
D) ((f = f > 20 ? f - 1 : f));;
|
|
||||||
B) ((BOLD = (BOLD + 1) % 2));;
|
|
||||||
C) ((NOCOLOR = (NOCOLOR + 1) % 2));;
|
|
||||||
K) ((KEEPCT = (KEEPCT + 1) % 2));;
|
|
||||||
?) break;;
|
|
||||||
esac
|
|
||||||
for ((i = 0; i < p; i++)); do
|
|
||||||
# New position:
|
|
||||||
# l[] direction = 0: up, 1: right, 2: down, 3: left
|
|
||||||
# +_CP_newpos
|
|
||||||
((l[i] % 2)) && ((x[i] += -l[i] + 2, 1)) || ((y[i] += l[i] - 1))
|
|
||||||
# -_CP_newpos
|
|
||||||
|
|
||||||
# Loop on edges (change color on loop):
|
|
||||||
# +_CP_warp
|
|
||||||
((!KEEPCT && (x[i] >= w || x[i] < 0 || y[i] >= h || y[i] < 0))) \
|
|
||||||
&& { c[i]=${E[CN * RANDOM / M]}; ((v[i] = V[VN * RANDOM / M])); }
|
|
||||||
((x[i] = (x[i] + w) % w,
|
|
||||||
y[i] = (y[i] + h) % h))
|
|
||||||
# -_CP_warp
|
|
||||||
|
|
||||||
# new turning direction:
|
|
||||||
# $((s - 1)) in $s, going straight, therefore n[i] == l[i];
|
|
||||||
# and 1 in $s that pipe makes a right or left turn
|
|
||||||
#
|
|
||||||
# s * RANDOM / M - 1 == 0
|
|
||||||
# n[i] == -1
|
|
||||||
# => n[i] == l[i] + 1 or l[i] - 1
|
|
||||||
# +_CP_newdir
|
|
||||||
((
|
|
||||||
n[i] = s * RANDOM / M - 1,
|
|
||||||
n[i] = n[i] >= 0 ? l[i] : l[i] + (2 * (RANDOM % 2) - 1),
|
|
||||||
n[i] = (n[i] + 4) % 4
|
|
||||||
))
|
|
||||||
# -_CP_newdir
|
|
||||||
|
|
||||||
# Print:
|
|
||||||
# +_CP_print
|
|
||||||
printf '\e[%d;%dH%s%s' \
|
|
||||||
$((y[i] + 1)) $((x[i] + 1)) ${c[i]} \
|
|
||||||
"${SETS[v[i] * 16 + l[i] * 4 + n[i]]}"
|
|
||||||
# -_CP_print
|
|
||||||
l[i]=${n[i]}
|
|
||||||
done
|
|
||||||
((r > 0 && t * p >= r)) && tput reset && tput civis && t=0 || ((t++))
|
|
||||||
done
|
done
|
||||||
|
done
|
||||||
|
unset i j
|
||||||
|
# -_CP_init_SETS
|
||||||
|
|
||||||
cleanup
|
init_screen
|
||||||
|
init_pipes
|
||||||
|
|
||||||
|
# any key press exits the loop and this script
|
||||||
|
trap 'break 2' INT
|
||||||
|
|
||||||
|
local i
|
||||||
|
while REPLY=; do
|
||||||
|
read -t 0.0$((1000 / f)) -n 1 2>/dev/null
|
||||||
|
case "$REPLY" in
|
||||||
|
P) ((s = s < 15 ? s + 1 : s)) ;;
|
||||||
|
O) ((s = s > 3 ? s - 1 : s)) ;;
|
||||||
|
F) ((f = f < 100 ? f + 1 : f)) ;;
|
||||||
|
D) ((f = f > 20 ? f - 1 : f)) ;;
|
||||||
|
B) ((BOLD = (BOLD + 1) % 2)) ;;
|
||||||
|
C) ((NOCOLOR = (NOCOLOR + 1) % 2)) ;;
|
||||||
|
K) ((KEEPCT = (KEEPCT + 1) % 2)) ;;
|
||||||
|
?) break ;;
|
||||||
|
esac
|
||||||
|
for ((i = 0; i < p; i++)); do
|
||||||
|
# New position:
|
||||||
|
# l[] direction = 0: up, 1: right, 2: down, 3: left
|
||||||
|
# +_CP_newpos
|
||||||
|
((l[i] % 2)) && ((x[i] += -l[i] + 2, 1)) || ((y[i] += l[i] - 1))
|
||||||
|
# -_CP_newpos
|
||||||
|
|
||||||
|
# Loop on edges (change color on loop):
|
||||||
|
# +_CP_warp
|
||||||
|
((!KEEPCT && (x[i] >= w || x[i] < 0 || y[i] >= h || y[i] < 0))) &&
|
||||||
|
{
|
||||||
|
c[i]=${E[CN * RANDOM / M]}
|
||||||
|
((v[i] = V[VN * RANDOM / M]))
|
||||||
|
}
|
||||||
|
((x[i] = (x[i] + w) % w, \
|
||||||
|
y[i] = (y[i] + h) % h))
|
||||||
|
# -_CP_warp
|
||||||
|
|
||||||
|
# new turning direction:
|
||||||
|
# $((s - 1)) in $s, going straight, therefore n[i] == l[i];
|
||||||
|
# and 1 in $s that pipe makes a right or left turn
|
||||||
|
#
|
||||||
|
# s * RANDOM / M - 1 == 0
|
||||||
|
# n[i] == -1
|
||||||
|
# => n[i] == l[i] + 1 or l[i] - 1
|
||||||
|
# +_CP_newdir
|
||||||
|
((\
|
||||||
|
n[i] = s * RANDOM / M - 1, \
|
||||||
|
n[i] = n[i] >= 0 ? l[i] : l[i] + (2 * (RANDOM % 2) - 1), \
|
||||||
|
n[i] = (n[i] + 4) % 4))
|
||||||
|
|
||||||
|
# -_CP_newdir
|
||||||
|
|
||||||
|
# Print:
|
||||||
|
# +_CP_print
|
||||||
|
printf '\e[%d;%dH%s%s' \
|
||||||
|
$((y[i] + 1)) $((x[i] + 1)) ${c[i]} \
|
||||||
|
"${SETS[v[i] * 16 + l[i] * 4 + n[i]]}"
|
||||||
|
# -_CP_print
|
||||||
|
l[i]=${n[i]}
|
||||||
|
done
|
||||||
|
((r > 0 && t * p >= r)) && tput reset && tput civis && t=0 || ((t++))
|
||||||
|
done
|
||||||
|
|
||||||
|
cleanup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# when being sourced, $0 == bash, only invoke main when they are the same
|
# when being sourced, $0 == bash, only invoke main when they are the same
|
||||||
[[ "$0" != "$BASH_SOURCE" ]] || main "$@"
|
[[ "$0" != "$BASH_SOURCE" ]] || main "$@"
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,7 @@ echo "$themes" | grep -Fxq "$theme" || exit 1
|
||||||
|
|
||||||
state_dir="${XDG_STATE_HOME:-$HOME/.local/state}"
|
state_dir="${XDG_STATE_HOME:-$HOME/.local/state}"
|
||||||
mkdir -p "$state_dir"
|
mkdir -p "$state_dir"
|
||||||
printf '%s\n' "$theme" > "$state_dir/theme"
|
printf '%s\n' "$theme" >"$state_dir/theme"
|
||||||
export THEME="$theme"
|
export THEME="$theme"
|
||||||
|
|
||||||
case "$(uname)" in
|
case "$(uname)" in
|
||||||
|
|
@ -81,7 +81,6 @@ Linux)
|
||||||
pkill -USR2 waybar
|
pkill -USR2 waybar
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
hypr_themes="$cfg/hypr/themes"
|
hypr_themes="$cfg/hypr/themes"
|
||||||
[ -f "$hypr_themes/$theme.conf" ] && {
|
[ -f "$hypr_themes/$theme.conf" ] && {
|
||||||
ln -sf "$hypr_themes/$theme.conf" "$hypr_themes/theme.conf"
|
ln -sf "$hypr_themes/$theme.conf" "$hypr_themes/theme.conf"
|
||||||
|
|
@ -132,8 +131,8 @@ if command -v claude >/dev/null 2>&1 && command -v jq >/dev/null 2>&1; then
|
||||||
daylight) claude_theme='light' ;;
|
daylight) claude_theme='light' ;;
|
||||||
esac
|
esac
|
||||||
[ -f "$CLAUDE_CONFIG" ] && {
|
[ -f "$CLAUDE_CONFIG" ] && {
|
||||||
jq ".theme=\"$claude_theme\"" "$CLAUDE_CONFIG" > "$CLAUDE_CONFIG.tmp" &&
|
jq ".theme=\"$claude_theme\"" "$CLAUDE_CONFIG" >"$CLAUDE_CONFIG.tmp" &&
|
||||||
mv "$CLAUDE_CONFIG.tmp" "$CLAUDE_CONFIG"
|
mv "$CLAUDE_CONFIG.tmp" "$CLAUDE_CONFIG"
|
||||||
}
|
}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ require() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd="$1"; shift
|
cmd="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
case "$cmd" in
|
case "$cmd" in
|
||||||
setup)
|
setup)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue