fetch: add sixel-query & update sixel files; update kgp-query with better timeout handling

This commit is contained in:
2026-02-06 22:33:41 +01:00
parent 53b33f6422
commit 0863da0f47
11 changed files with 106 additions and 59 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -36,7 +36,7 @@ binds {
Alt+Space { spawn-sh "pkill -x rofi || rofi -show drun"; } Alt+Space { spawn-sh "pkill -x rofi || rofi -show drun"; }
// Actions // Actions
Mod+V { spawn-sh "pkill -x rofi || rofi-cliphist"; } Mod+V { spawn "shorinclip-wrap"; }
Mod+Period { spawn-sh "pkill -x rofi || rofi-emoji"; } Mod+Period { spawn-sh "pkill -x rofi || rofi-emoji"; }
Ctrl+Alt+Delete { spawn-sh "pkill -x wlogout || wlogout -p layer-shell"; } Ctrl+Alt+Delete { spawn-sh "pkill -x wlogout || wlogout -p layer-shell"; }
Print { spawn "niri" "msg" "action" "screenshot-screen"; } Print { spawn "niri" "msg" "action" "screenshot-screen"; }
+1 -1
View File
@@ -1,7 +1,7 @@
screenshot-path "~/Pictures/Screenshots/niri_screenshot_%Y-%m-%d_%H-%M-%S.png" screenshot-path "~/Pictures/Screenshots/niri_screenshot_%Y-%m-%d_%H-%M-%S.png"
debug { debug {
render-drm-device "/dev/dri/renderD129" render-drm-device "/dev/dri/renderD128"
} }
// gestures { // gestures {
+4 -6
View File
@@ -19,18 +19,16 @@ FENCE_CODE=$(printf "\033[c")
# Set terminal to raw mode with timeout as 0.5s # Set terminal to raw mode with timeout as 0.5s
stty_orig=$(stty -g) stty_orig=$(stty -g)
trap 'stty "$stty_orig"' EXIT trap 'stty "$stty_orig"' EXIT
stty -echo -icanon min 0 time 5 stty -echo -icanon min 1 time 0
printf "%s%s" "$QUERY_CODE" "$FENCE_CODE" > /dev/tty printf "%s%s" "$QUERY_CODE" "$FENCE_CODE" > /dev/tty
response="" response=""
ret=1 ret=1
while true; do while true; do
char=$(dd bs=1 count=1 2>/dev/null) || break IFS= read -r -N 1 -t 0.3 char || {
[ -z "$char" ] && break
if [ -z "$char" ]; then }
break
fi
response+="$char" response+="$char"
+43 -42
View File
@@ -16,31 +16,31 @@
set -euo pipefail set -euo pipefail
[ "$(id -u)" -eq 0 ] && { [ "$(id -u)" -eq 0 ] && {
echo "[ERROR] Do not run this script in sudo mode." >&2 echo "[ERROR] Do not run this script in sudo mode." >&2
exit 1 exit 1
} }
find_luks_device() { find_luks_device() {
# Set $devices array to all LUKS devices # Set $devices array to all LUKS devices
# lsblk command explained - n: no headings, p: full path, o: output format, l: list format # lsblk command explained - n: no headings, p: full path, o: output format, l: list format
mapfile -t devices < <(lsblk -nplo NAME,FSTYPE | awk '$2 == "crypto_LUKS" {print $1}') mapfile -t devices < <(lsblk -nplo NAME,FSTYPE | awk '$2 == "crypto_LUKS" {print $1}')
if [ ${#devices[@]} -eq 0 ]; then if [ ${#devices[@]} -eq 0 ]; then
echo "[ERROR] No LUKS devices found." >&2 echo "[ERROR] No LUKS devices found." >&2
return 1 return 1
elif [ ${#devices[@]} -eq 1 ]; then elif [ ${#devices[@]} -eq 1 ]; then
echo "${devices[0]}" echo "${devices[0]}"
else else
# Multiple devices found # Multiple devices found
# Select one using fzf if available # Select one using fzf if available
if command -v fzf >/dev/null; then if command -v fzf >/dev/null; then
printf "%s\n" "${devices[@]}" | fzf --prompt="Select LUKS device: " printf "%s\n" "${devices[@]}" | fzf --prompt="Select LUKS device: "
else else
echo "[ERROR] Multiple LUKS devices found. Please set LUKS_PARTITION env var." >&2 echo "[ERROR] Multiple LUKS devices found. Please set LUKS_PARTITION env var." >&2
printf "%s\n" "${devices[@]}" >&2 printf "%s\n" "${devices[@]}" >&2
return 1 return 1
fi fi
fi fi
} }
LUKS_PARTITION="${LUKS_PARTITION:-$(find_luks_device)}" LUKS_PARTITION="${LUKS_PARTITION:-$(find_luks_device)}"
@@ -57,43 +57,44 @@ echo "[INFO] Mount: $LUKS_MOUNT_POINT" >&2
mount_point_created=0 mount_point_created=0
if [ ! -d "$LUKS_MOUNT_POINT" ]; then if [ ! -d "$LUKS_MOUNT_POINT" ]; then
sudo mkdir -p "$LUKS_MOUNT_POINT" sudo mkdir -p "$LUKS_MOUNT_POINT"
mount_point_created=1 mount_point_created=1
fi fi
if ! sudo cryptsetup open "$LUKS_PARTITION" "$LUKS_MAPPER_NAME"; then if ! sudo cryptsetup open "$LUKS_PARTITION" "$LUKS_MAPPER_NAME"; then
echo "[ERROR] Failed to open device." >&2 echo "[ERROR] Failed to open device." >&2
exit 1 exit 1
fi fi
cleanup() { cleanup() {
echo "[INFO] Cleaning up..." >&2 echo "[INFO] Cleaning up..." >&2
# Make sure we are not in the mount point when unmounting # Make sure we are not in the mount point when unmounting
cd "$HOME" || true cd "$HOME" || true
if mountpoint -q "$LUKS_MOUNT_POINT"; then if mountpoint -q "$LUKS_MOUNT_POINT"; then
sudo umount "$LUKS_MOUNT_POINT" || echo "[WARNING] Failed to unmount." >&2 sudo umount "$LUKS_MOUNT_POINT" || echo "[WARNING] Failed to unmount." >&2
fi fi
if [ -e "/dev/mapper/$LUKS_MAPPER_NAME" ]; then if [ -e "/dev/mapper/$LUKS_MAPPER_NAME" ]; then
sudo cryptsetup close "$LUKS_MAPPER_NAME" || echo "[WARNING] Failed to close LUKS mapper." >&2 sudo cryptsetup close "$LUKS_MAPPER_NAME" || echo "[WARNING] Failed to close LUKS mapper." >&2
fi fi
if [ $mount_point_created -eq 1 ] && [ -d "$LUKS_MOUNT_POINT" ]; then if [ $mount_point_created -eq 1 ] && [ -d "$LUKS_MOUNT_POINT" ]; then
sudo rmdir "$LUKS_MOUNT_POINT" || echo "[WARNING] Failed to remove mount point." >&2 sudo rmdir "$LUKS_MOUNT_POINT" || echo "[WARNING] Failed to remove mount point." >&2
fi fi
echo "[INFO] Done." >&2 echo "[INFO] Done." >&2
} }
trap cleanup EXIT INT TERM trap cleanup EXIT INT TERM
sudo mount "/dev/mapper/$LUKS_MAPPER_NAME" "$LUKS_MOUNT_POINT" sudo mount "/dev/mapper/$LUKS_MAPPER_NAME" "$LUKS_MOUNT_POINT"
sudo chown "$(whoami):$(whoami)" "$LUKS_MOUNT_POINT"
echo "[INFO] Successfully mounted at $LUKS_MOUNT_POINT." >&2 echo "[INFO] Successfully mounted at $LUKS_MOUNT_POINT." >&2
echo "[INFO] Exit this shell to unmount and close the LUKS volume." >&2 echo "[INFO] Exit this shell to unmount and close the LUKS volume." >&2
cd "$LUKS_MOUNT_POINT" cd "$LUKS_MOUNT_POINT"
USER_SHELL="${SHELL:-/bin/bash}" USER_SHELL="${SHELL:-/bin/bash}"
if [[ "$USER_SHELL" == *"/bash" ]]; then if [[ "$USER_SHELL" == *"/bash" ]]; then
"$USER_SHELL" --rcfile <(cat ~/.bashrc 2>/dev/null; printf '%s\n' 'PS1="\[\e[1;31m\][LUKS]\[\e[0m\][\u@\h \W]\$ "') -i "$USER_SHELL" --rcfile <(
cat ~/.bashrc 2>/dev/null
printf '%s\n' 'PS1="\[\e[1;31m\][LUKS]\[\e[0m\][\u@\h \W]\$ "'
) -i
else else
"$USER_SHELL" "$USER_SHELL"
fi fi
+3
View File
@@ -0,0 +1,3 @@
#!/bin/sh
pkill -f "ghostty -e shorinclip" || ghostty -e shorinclip
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env bash
set -euo pipefail
# Ensure in a interactive terminal
[ ! -t 0 ] && exit 1
# Construct query
QUERY_CODE=$(printf "\033[c")
# Set terminal to raw mode with timeout as 0.5s
stty_orig=$(stty -g)
trap 'stty "$stty_orig"' EXIT
stty -echo -icanon min 1 time 0
printf "%s" "$QUERY_CODE" >/dev/tty
response=""
while true; do
IFS= read -r -N 1 -t 0.3 char || {
[ -z "$char" ] && break
}
response+="$char"
if [[ "$char" = "c" ]]; then
break
fi
if [ ${#response} -gt 1024 ]; then
break
fi
done
if [[ "$response" =~ $'\x1b'\[\?([0-9;]*)c ]]; then
params="${BASH_REMATCH[1]}"
IFS=';' read -ra codes <<< "$params"
for code in "${codes[@]}"; do
if [[ "$code" == "4" ]]; then
exit 0
fi
done
fi
exit 1
@@ -1,7 +1,9 @@
if not set -q fetch_logo_type if not set -q fetch_logo_type
if type -q kgp-query; and kgp-query if type -q kgp-query; and kgp-query
set -g fetch_logo_type kitty set -g fetch_logo_type kitty
else if type -q kgp-query else if type -q sixel-query; and sixel-query
set -g fetch_logo_type sixel
else if type -q kgp-query; or type -q sixel-query
set -g fetch_logo_type logo set -g fetch_logo_type logo
else else
set -g fetch_logo_type auto set -g fetch_logo_type auto