fix: kitty #9416
This commit is contained in:
@@ -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/renderD128"
|
render-drm-device "/dev/dri/renderD129"
|
||||||
}
|
}
|
||||||
|
|
||||||
// gestures {
|
// gestures {
|
||||||
|
|||||||
@@ -3,17 +3,17 @@
|
|||||||
|
|
||||||
# Description:
|
# Description:
|
||||||
# View and manage clipboard history using fzf, with support for
|
# View and manage clipboard history using fzf, with support for
|
||||||
# image previews in compatible terminals.
|
# image preview in compatible terminals.
|
||||||
# Requirements:
|
# Requirements:
|
||||||
# - cliphist
|
# - cliphist
|
||||||
# - wl-clipboard
|
# - wl-clipboard
|
||||||
# - fzf
|
# - fzf
|
||||||
# - sixel-query & kgp-query from this repository
|
# - sixel-query, kgp-query, iterm2-query from this repository
|
||||||
# - chafa (for image previews)
|
# - chafa (for image preview)
|
||||||
# - ffmpegthumbnailer (optional, for video thumbnails)
|
# - ffmpegthumbnailer (optional, for video thumbnails)
|
||||||
# Credits:
|
# Credits:
|
||||||
# - Original idea and some code adapted from https://github.com/SHORiN-KiWATA/shorinclip
|
# - Original idea and some code adapted from https://github.com/SHORiN-KiWATA/shorinclip
|
||||||
# LICENSE:
|
# License:
|
||||||
# # MIT License
|
# # MIT License
|
||||||
# #
|
# #
|
||||||
# # Copyright (c) 2026 shorinkiwata
|
# # Copyright (c) 2026 shorinkiwata
|
||||||
@@ -50,26 +50,26 @@ export C_RESET='\x1b[0m'
|
|||||||
# Check for terminal graphics support and set environment variables accordingly
|
# Check for terminal graphics support and set environment variables accordingly
|
||||||
|
|
||||||
_check_kitty_icat() {
|
_check_kitty_icat() {
|
||||||
# workaround for WezTerm
|
# workaround for WezTerm
|
||||||
if [ -n "${WEZTERM_EXECUTABLE:-}" ]; then
|
if [ -n "${WEZTERM_EXECUTABLE:-}" ]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
kgp-query
|
kgp-query
|
||||||
}
|
}
|
||||||
|
|
||||||
_check_sixel() {
|
_check_sixel() {
|
||||||
# workaround for Zellij
|
# workaround for Zellij
|
||||||
if [ -n "${ZELLIJ_SESSION_NAME:-}" ]; then
|
if [ -n "${ZELLIJ_SESSION_NAME:-}" ]; then
|
||||||
return 1
|
return 1
|
||||||
# same for tmux, unless otherwise configured
|
# same for tmux, unless otherwise configured
|
||||||
elif [ -n "${TMUX:-}" ]; then
|
elif [ -n "${TMUX:-}" ]; then
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
sixel-query
|
sixel-query
|
||||||
}
|
}
|
||||||
|
|
||||||
_check_iterm2() {
|
_check_iterm2() {
|
||||||
iterm2-query
|
iterm2-query
|
||||||
}
|
}
|
||||||
|
|
||||||
ENABLE_ICAT=0
|
ENABLE_ICAT=0
|
||||||
@@ -78,11 +78,11 @@ ENABLE_ITERM2=0
|
|||||||
|
|
||||||
# Priority: KGP > sixel > iterm2
|
# Priority: KGP > sixel > iterm2
|
||||||
if _check_kitty_icat; then
|
if _check_kitty_icat; then
|
||||||
export ENABLE_ICAT=1
|
export ENABLE_ICAT=1
|
||||||
elif _check_sixel; then
|
elif _check_sixel; then
|
||||||
export ENABLE_SIXEL=1
|
export ENABLE_SIXEL=1
|
||||||
elif _check_iterm2; then
|
elif _check_iterm2; then
|
||||||
export ENABLE_ITERM2=1
|
export ENABLE_ITERM2=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export ENABLE_ICAT
|
export ENABLE_ICAT
|
||||||
@@ -92,170 +92,170 @@ export ENABLE_ITERM2
|
|||||||
# Preview functions
|
# Preview functions
|
||||||
|
|
||||||
_preview_image() {
|
_preview_image() {
|
||||||
local file="$1"
|
local file="$1"
|
||||||
if [ "$ENABLE_ICAT" -eq 1 ]; then
|
if [ "$ENABLE_ICAT" -eq 1 ]; then
|
||||||
printf "\x1b_Ga=d\x1b\\"
|
printf "\x1b_Ga=d\x1b\\"
|
||||||
chafa -f kitty --animate=off --size="${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" "$file"
|
chafa -f kitty --size="${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" "$file"
|
||||||
elif [ "$ENABLE_SIXEL" -eq 1 ]; then
|
elif [ "$ENABLE_SIXEL" -eq 1 ]; then
|
||||||
chafa -f sixels --animate=off --size="${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" "$file"
|
chafa -f sixels --size="${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" "$file"
|
||||||
elif [ "$ENABLE_ITERM2" -eq 1 ]; then
|
elif [ "$ENABLE_ITERM2" -eq 1 ]; then
|
||||||
chafa -f iterm2 --animate=off --size="${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" "$file"
|
chafa -f iterm2 -size="${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" "$file"
|
||||||
else
|
else
|
||||||
chafa -f symbols --animate=off --size="${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" "$file"
|
chafa -f symbols --size="${FZF_PREVIEW_COLUMNS}x${FZF_PREVIEW_LINES}" "$file"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
export -f _preview_image
|
export -f _preview_image
|
||||||
|
|
||||||
_preview_text() {
|
_preview_text() {
|
||||||
local content="$1"
|
local content="$1"
|
||||||
if [ "$ENABLE_ICAT" -eq 1 ]; then
|
if [ "$ENABLE_ICAT" -eq 1 ]; then
|
||||||
printf "\x1b_Ga=d\x1b\\"
|
printf "\x1b_Ga=d\x1b\\"
|
||||||
fi
|
fi
|
||||||
echo "$content" | head -n 100
|
echo "$content" | head -n 100
|
||||||
}
|
}
|
||||||
export -f _preview_text
|
export -f _preview_text
|
||||||
|
|
||||||
_preview_file() {
|
_preview_file() {
|
||||||
path="$1"
|
path="$1"
|
||||||
path_mime=$(file -b --mime-type "$path")
|
path_mime=$(file -b --mime-type "$path")
|
||||||
if [[ $path_mime =~ image ]]; then
|
if [[ $path_mime =~ image ]]; then
|
||||||
_preview_image "$path"
|
_preview_image "$path"
|
||||||
elif [[ "$path_mime" =~ video ]]; then
|
elif [[ "$path_mime" =~ video ]]; then
|
||||||
video_hash=$(echo "$path" | md5sum | cut -d" " -f1)
|
video_hash=$(echo "$path" | md5sum | cut -d" " -f1)
|
||||||
thumb_file="$CACHE_DIR/$video_hash.png"
|
thumb_file="$CACHE_DIR/$video_hash.png"
|
||||||
if [ ! -f "$thumb_file" ]; then
|
if [ ! -f "$thumb_file" ]; then
|
||||||
if command -v ffmpegthumbnailer &>/dev/null;then
|
if command -v ffmpegthumbnailer &>/dev/null; then
|
||||||
ffmpegthumbnailer -i "$path" -o "$thumb_file" -s 480 -t 0 >/dev/null 2>&1
|
ffmpegthumbnailer -i "$path" -o "$thumb_file" -s 480 -t 0 >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
_preview_text "ffmpegthumbnailer not installed, cannot generate thumbnail for video."
|
_preview_text "ffmpegthumbnailer not installed, cannot generate thumbnail for video."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -s "$thumb_file" ]; then
|
if [ -s "$thumb_file" ]; then
|
||||||
_preview_image "$thumb_file"
|
_preview_image "$thumb_file"
|
||||||
else
|
else
|
||||||
_preview_text "Video: $path (No thumbnail)"
|
_preview_text "Video: $path (No thumbnail)"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
_preview_text "$path"
|
_preview_text "$path"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
export -f _preview_file
|
export -f _preview_file
|
||||||
|
|
||||||
preview() {
|
preview() {
|
||||||
entry="$1"
|
entry="$1"
|
||||||
|
|
||||||
content=$(echo "$entry" | cut -f2-)
|
content=$(echo "$entry" | cut -f2-)
|
||||||
mimeType=$(echo "$entry" | cliphist decode | file -b --mime-type -)
|
mimeType=$(echo "$entry" | cliphist decode | file -b --mime-type -)
|
||||||
ext=$(echo "$mimeType" | awk -F"/" "{print \$2}")
|
ext=$(echo "$mimeType" | awk -F"/" "{print \$2}")
|
||||||
|
|
||||||
if [[ $mimeType =~ image ]]; then
|
if [[ $mimeType =~ image ]]; then
|
||||||
img_hash=$(echo "$entry" | cliphist decode | md5sum | cut -d" " -f1)
|
img_hash=$(echo "$entry" | cliphist decode | md5sum | cut -d" " -f1)
|
||||||
cache_file="$CACHE_DIR/$img_hash.$ext"
|
cache_file="$CACHE_DIR/$img_hash.$ext"
|
||||||
[ -f "$cache_file" ] || echo "$entry" | cliphist decode > "$cache_file"
|
[ -f "$cache_file" ] || echo "$entry" | cliphist decode >"$cache_file"
|
||||||
_preview_image "$cache_file"
|
_preview_image "$cache_file"
|
||||||
|
|
||||||
elif [ "$mimeType" = "text/html" ] && echo "$content" | grep -q QQ; then
|
elif [ "$mimeType" = "text/html" ] && echo "$content" | grep -q QQ; then
|
||||||
qq_img_file=$(echo "$entry" | cliphist decode | grep -oP "^<img src=\"file://\K[^\"]+")
|
qq_img_file=$(echo "$entry" | cliphist decode | grep -oP "^<img src=\"file://\K[^\"]+")
|
||||||
#qq_ext="${qq_img_file##*.}"
|
#qq_ext="${qq_img_file##*.}"
|
||||||
#qq_img_cache_file=$CACHE_DIR/$id.$qq_ext
|
#qq_img_cache_file=$CACHE_DIR/$id.$qq_ext
|
||||||
#cp $qq_img_file $qq_img_cache_file
|
#cp $qq_img_file $qq_img_cache_file
|
||||||
if [ -f "$qq_img_file" ]; then
|
if [ -f "$qq_img_file" ]; then
|
||||||
_preview_image "$qq_img_file"
|
_preview_image "$qq_img_file"
|
||||||
else
|
else
|
||||||
_preview_text "$qq_img_file does not exist."
|
_preview_text "$qq_img_file does not exist."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elif path=$(echo "$entry" | cliphist decode) && [[ "$path" == /* ]]; then
|
elif path=$(echo "$entry" | cliphist decode) && [[ "$path" == /* ]]; then
|
||||||
if [ -e "$path" ]; then
|
if [ -e "$path" ]; then
|
||||||
_preview_file "$path"
|
_preview_file "$path"
|
||||||
else
|
else
|
||||||
_preview_text "$path does not exist."
|
_preview_text "$path does not exist."
|
||||||
fi
|
fi
|
||||||
elif decoded=$(echo "$entry" | cliphist decode) && [[ "$decoded" == file://* ]]; then
|
elif decoded=$(echo "$entry" | cliphist decode) && [[ "$decoded" == file://* ]]; then
|
||||||
raw_path="${decoded#file://}"
|
raw_path="${decoded#file://}"
|
||||||
raw_path=$(echo "$raw_path" | python -c "import sys, urllib.parse; print(urllib.parse.unquote(sys.stdin.read().strip()))")
|
raw_path=$(echo "$raw_path" | python -c "import sys, urllib.parse; print(urllib.parse.unquote(sys.stdin.read().strip()))")
|
||||||
if [ -e "$raw_path" ]; then
|
if [ -e "$raw_path" ]; then
|
||||||
_preview_file "$raw_path"
|
_preview_file "$raw_path"
|
||||||
else
|
else
|
||||||
_preview_text "$raw_path does not exist."
|
_preview_text "$raw_path does not exist."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ "$ENABLE_ICAT" = 1 ]; then
|
if [ "$ENABLE_ICAT" = 1 ]; then
|
||||||
printf "\x1b_Ga=d\x1b\\"
|
printf "\x1b_Ga=d\x1b\\"
|
||||||
fi
|
fi
|
||||||
_preview_text "$(echo "$entry" | cliphist decode)"
|
_preview_text "$(echo "$entry" | cliphist decode)"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
export -f preview
|
export -f preview
|
||||||
|
|
||||||
# Optimize entry formatting
|
# Optimize entry formatting
|
||||||
|
|
||||||
format_clip_list() {
|
format_clip_list() {
|
||||||
sed -E \
|
sed -E \
|
||||||
-e "s/(\t).*\.(mp4|mkv|webm|avi|mov|flv|wmv)$/\1${C_TERTIARY}[VIDEO]File.\2${C_RESET}/" \
|
-e "s/(\t).*\.(mp4|mkv|webm|avi|mov|flv|wmv)$/\1${C_TERTIARY}[VIDEO]File.\2${C_RESET}/" \
|
||||||
-e "s/(\t)file:\/\/.*\.(mp4|mkv|webm|avi|mov|flv|wmv)$/\1${C_TERTIARY}[VIDEO]Url.\2${C_RESET}/" \
|
-e "s/(\t)file:\/\/.*\.(mp4|mkv|webm|avi|mov|flv|wmv)$/\1${C_TERTIARY}[VIDEO]Url.\2${C_RESET}/" \
|
||||||
-e "s/(\t).*src=\"file:\/\/.*[qQ][qQ].*/\1${C_PRIMARY}[IMG_HTML]QQ${C_RESET}/" \
|
-e "s/(\t).*src=\"file:\/\/.*[qQ][qQ].*/\1${C_PRIMARY}[IMG_HTML]QQ${C_RESET}/" \
|
||||||
-e "s/(\t)file:\/\/.*xwechat.*temp.*/\1${C_PRIMARY}[IMG]WeChat${C_RESET}/" \
|
-e "s/(\t)file:\/\/.*xwechat.*temp.*/\1${C_PRIMARY}[IMG]WeChat${C_RESET}/" \
|
||||||
-e "s/(\t)file:\/\/.*\.gif$/\1${C_PRIMARY}[IMG]Url.gif${C_RESET}/" \
|
-e "s/(\t)file:\/\/.*\.gif$/\1${C_PRIMARY}[IMG]Url.gif${C_RESET}/" \
|
||||||
-e "s/(\t)file:\/\/.*\.(png|jpg|jpeg|webp|bmp)$/\1${C_TERTIARY}[IMG]Url.\2${C_RESET}/" \
|
-e "s/(\t)file:\/\/.*\.(png|jpg|jpeg|webp|bmp)$/\1${C_TERTIARY}[IMG]Url.\2${C_RESET}/" \
|
||||||
-e "s/(\t)file:\/\/.*/\1${C_CYAN}[URL]File${C_RESET}/" \
|
-e "s/(\t)file:\/\/.*/\1${C_CYAN}[URL]File${C_RESET}/" \
|
||||||
-e "s/(\t)\/.*\.gif$/\1${C_PRIMARY}[IMG]Path.gif${C_RESET}/" \
|
-e "s/(\t)\/.*\.gif$/\1${C_PRIMARY}[IMG]Path.gif${C_RESET}/" \
|
||||||
-e "s/(\t)\/.*\.(png|jpg|jpeg|webp|bmp)$/\1${C_TERTIARY}[IMG]Path.\2${C_RESET}/" \
|
-e "s/(\t)\/.*\.(png|jpg|jpeg|webp|bmp)$/\1${C_TERTIARY}[IMG]Path.\2${C_RESET}/" \
|
||||||
-e "s/\[\[ binary data .* (png|jpg|jpeg|gif|webp) .*\]\]/${C_TERTIARY}[IMG]Bin.\1${C_RESET}/" \
|
-e "s/\[\[ binary data .* (png|jpg|jpeg|gif|webp) .*\]\]/${C_TERTIARY}[IMG]Bin.\1${C_RESET}/" \
|
||||||
-e "s/\[\[ binary data .* \]\]/${C_CYAN}[BINARY]${C_RESET}/"
|
-e "s/\[\[ binary data .* \]\]/${C_CYAN}[BINARY]${C_RESET}/"
|
||||||
}
|
}
|
||||||
export -f format_clip_list
|
export -f format_clip_list
|
||||||
|
|
||||||
add_num() {
|
add_num() {
|
||||||
awk -F '\t' '{printf "%s\t\x1b[90m%-2d \x1b[0m%s\n", $1, NR, $2}'
|
awk -F '\t' '{printf "%s\t\x1b[90m%-2d \x1b[0m%s\n", $1, NR, $2}'
|
||||||
}
|
}
|
||||||
export -f add_num
|
export -f add_num
|
||||||
|
|
||||||
# Action when confirmed
|
# Action when confirmed
|
||||||
|
|
||||||
copy_selection() {
|
copy_selection() {
|
||||||
local input="$1"
|
local input="$1"
|
||||||
local decoded
|
local decoded
|
||||||
decoded=$(echo "$input" | cliphist decode)
|
decoded=$(echo "$input" | cliphist decode)
|
||||||
local mime
|
local mime
|
||||||
mime=$(echo "$decoded" | file -b --mime-type -)
|
mime=$(echo "$decoded" | file -b --mime-type -)
|
||||||
|
|
||||||
url_encode() {
|
url_encode() {
|
||||||
python -c "import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1]))" "$1"
|
python -c "import sys, urllib.parse; print(urllib.parse.quote(sys.argv[1]))" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Image
|
# Image
|
||||||
if [[ "$mime" =~ image ]]; then
|
if [[ "$mime" =~ image ]]; then
|
||||||
echo "$decoded" | wl-copy
|
echo "$decoded" | wl-copy
|
||||||
|
|
||||||
# HTML with QQ image
|
# HTML with QQ image
|
||||||
elif [ "$mime" = "text/html" ]; then
|
elif [ "$mime" = "text/html" ]; then
|
||||||
local qq_src
|
local qq_src
|
||||||
qq_src=$(echo "$decoded" | grep -oP "^<img src=\"file://\K[^\"]+")
|
qq_src=$(echo "$decoded" | grep -oP "^<img src=\"file://\K[^\"]+")
|
||||||
|
|
||||||
if [ -f "$qq_src" ]; then
|
if [ -f "$qq_src" ]; then
|
||||||
local encoded_path
|
local encoded_path
|
||||||
encoded_path=$(url_encode "$qq_src")
|
encoded_path=$(url_encode "$qq_src")
|
||||||
|
|
||||||
echo "file://$encoded_path" | wl-copy --type text/uri-list
|
echo "file://$encoded_path" | wl-copy --type text/uri-list
|
||||||
else
|
else
|
||||||
echo "$decoded" | wl-copy
|
echo "$decoded" | wl-copy
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# URL starting with file://
|
# URL starting with file://
|
||||||
elif [[ "$decoded" == file://* ]]; then
|
elif [[ "$decoded" == file://* ]]; then
|
||||||
echo "$decoded" | wl-copy --type text/uri-list
|
echo "$decoded" | wl-copy --type text/uri-list
|
||||||
|
|
||||||
# file path
|
# file path
|
||||||
elif [[ "$decoded" == /* ]] && [ -e "$decoded" ]; then
|
elif [[ "$decoded" == /* ]] && [ -e "$decoded" ]; then
|
||||||
local encoded_path
|
local encoded_path
|
||||||
encoded_path=$(url_encode "$decoded")
|
encoded_path=$(url_encode "$decoded")
|
||||||
echo "file://$encoded_path" | wl-copy --type text/uri-list
|
echo "file://$encoded_path" | wl-copy --type text/uri-list
|
||||||
|
|
||||||
# Other data, just copy
|
# Other data, just copy
|
||||||
else
|
else
|
||||||
echo "$decoded" | wl-copy
|
echo "$decoded" | wl-copy
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
export -f copy_selection
|
export -f copy_selection
|
||||||
|
|
||||||
@@ -271,26 +271,25 @@ trap 'rm -rf "$CACHE_DIR"; kill $WATCH_PID 2>/dev/null' EXIT
|
|||||||
|
|
||||||
wait_timeout=50
|
wait_timeout=50
|
||||||
while [[ $(tput cols) -lt 35 || $(tput lines) -lt 25 ]]; do
|
while [[ $(tput cols) -lt 35 || $(tput lines) -lt 25 ]]; do
|
||||||
printf "\rWaiting for terminal size at least 35x25... %d" "$wait_timeout"
|
printf "\rWaiting for terminal size at least 35x25... %d" "$wait_timeout"
|
||||||
sleep 1
|
sleep 1
|
||||||
((wait_timeout--))
|
((wait_timeout--))
|
||||||
[ "$wait_timeout" -eq 0 ] && exit 1
|
[ "$wait_timeout" -eq 0 ] && exit 1
|
||||||
done
|
done
|
||||||
|
|
||||||
cliphist list | format_clip_list | add_num | fzf \
|
cliphist list | format_clip_list | add_num | fzf \
|
||||||
--ansi \
|
--ansi \
|
||||||
--listen "$FZF_PORT" \
|
--listen "$FZF_PORT" \
|
||||||
--bind "ctrl-r:reload($RELOAD_CMD)" \
|
--bind "ctrl-r:reload($RELOAD_CMD)" \
|
||||||
--bind "ctrl-x:execute-silent(bash -c 'cliphist delete <<< \"\$1\"' -- {})+reload($RELOAD_CMD)" \
|
--bind "ctrl-x:execute-silent(bash -c 'cliphist delete <<< \"\$1\"' -- {})+reload($RELOAD_CMD)" \
|
||||||
--prompt=" > " \
|
--prompt=" > " \
|
||||||
--header='CTRL-X: Delete | CTRL-R: Reload | ENTER: Paste' \
|
--header='CTRL-X: Delete | CTRL-R: Reload | ENTER: Paste' \
|
||||||
--color='header:italic:yellow,prompt:blue,pointer:blue' \
|
--color='header:italic:yellow,prompt:blue,pointer:blue' \
|
||||||
--info=hidden \
|
--info=hidden \
|
||||||
--no-sort \
|
--no-sort \
|
||||||
--layout=reverse \
|
--layout=reverse \
|
||||||
--with-nth 2.. \
|
--with-nth 2.. \
|
||||||
--delimiter '\t' \
|
--delimiter '\t' \
|
||||||
--preview-window=down:60%,wrap \
|
--preview-window=down:60%,wrap \
|
||||||
--preview "preview {}" \
|
--preview "preview {}" \
|
||||||
--bind "enter:execute-silent(bash -c 'copy_selection \"\$1\"' -- {})+accept"
|
--bind "enter:execute-silent(bash -c 'copy_selection \"\$1\"' -- {})+accept"
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,20 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Description:
|
# Description:
|
||||||
# Query terminal capabilities for graphics support, including:
|
# Query terminal capabilities for graphics support using escape sequences,
|
||||||
# - Kitty Graphics Protocol (KGP)
|
# without relying on environment variables or external tools.
|
||||||
# - iTerm2 inline images
|
|
||||||
# - Sixel graphics
|
|
||||||
# This script will print three lines of output:
|
|
||||||
# SUPPORT_KGP=1 or 0
|
|
||||||
# SUPPORT_ITERM2=1 or 0
|
|
||||||
# SUPPORT_SIXEL=1 or 0
|
|
||||||
#
|
#
|
||||||
# Usage:
|
# Usage:
|
||||||
|
# This script will print 1 or more of the following strings to stdout, depending
|
||||||
|
# on the detected capabilities:
|
||||||
|
# - "kitty" if Kitty's terminal Graphics Protocol is supported
|
||||||
|
# - "iterm" if iTerm2's inline image support is detected
|
||||||
|
# - "sixels" if Sixel graphics support is detected
|
||||||
# Do NOT source this script directly, as it will modify the terminal state
|
# Do NOT source this script directly, as it will modify the terminal state
|
||||||
# and print its result directly to stdout.
|
# and print its result directly to stdout.
|
||||||
# Instead, use command substitution to capture the output, for example:
|
|
||||||
# eval "$(graphics-query)"
|
|
||||||
# or parse the output manually.
|
|
||||||
#
|
#
|
||||||
# See also:
|
# See also:
|
||||||
# - kgp-query: specifically checks for Kitty Graphics Protocol support
|
# - kgp-query: specifically checks for Kitty's terminal Graphics Protocol support
|
||||||
# - iterm2-query: specifically checks for iTerm2 inline image support
|
# - iterm2-query: specifically checks for iTerm2 inline image support
|
||||||
# - sixel-query: specifically checks for Sixel graphics support
|
# - sixel-query: specifically checks for Sixel graphics support
|
||||||
|
|
||||||
@@ -43,9 +39,11 @@ stty -echo -icanon min 1 time 0
|
|||||||
|
|
||||||
printf "%s%s%s" "$ITERM2_QUERY_CODE" "$KGP_QUERY_CODE" "$FENCE_CODE" > /dev/tty
|
printf "%s%s%s" "$ITERM2_QUERY_CODE" "$KGP_QUERY_CODE" "$FENCE_CODE" > /dev/tty
|
||||||
|
|
||||||
response=""
|
|
||||||
support_kgp=0
|
support_kgp=0
|
||||||
support_iterm2=0
|
support_iterm2=0
|
||||||
|
support_sixel=0
|
||||||
|
|
||||||
|
response=""
|
||||||
while true; do
|
while true; do
|
||||||
IFS= read -r -N 1 -t 0.3 char || {
|
IFS= read -r -N 1 -t 0.3 char || {
|
||||||
[ -z "$char" ] && break
|
[ -z "$char" ] && break
|
||||||
@@ -70,7 +68,6 @@ while true; do
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
support_sixel=0
|
|
||||||
if [[ "$response" =~ $'\x1b'\[\?([0-9;]*)c ]]; then
|
if [[ "$response" =~ $'\x1b'\[\?([0-9;]*)c ]]; then
|
||||||
params="${BASH_REMATCH[1]}"
|
params="${BASH_REMATCH[1]}"
|
||||||
|
|
||||||
@@ -85,19 +82,13 @@ if [[ "$response" =~ $'\x1b'\[\?([0-9;]*)c ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$support_kgp" -eq 1 ]; then
|
if [ "$support_kgp" -eq 1 ]; then
|
||||||
echo "SUPPORT_KGP=1"
|
echo "kitty"
|
||||||
else
|
|
||||||
echo "SUPPORT_KGP=0"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$support_iterm2" -eq 1 ]; then
|
if [ "$support_iterm2" -eq 1 ]; then
|
||||||
echo "SUPPORT_ITERM2=1"
|
echo "iterm"
|
||||||
else
|
|
||||||
echo "SUPPORT_ITERM2=0"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$support_sixel" -eq 1 ]; then
|
if [ "$support_sixel" -eq 1 ]; then
|
||||||
echo "SUPPORT_SIXEL=1"
|
echo "sixels"
|
||||||
else
|
|
||||||
echo "SUPPORT_SIXEL=0"
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,43 +0,0 @@
|
|||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
# Description:
|
|
||||||
# Adjust the SDR brightness setting in Hyprland's monitor configuration file.
|
|
||||||
# Useful for adjusting brightness when HDR is enabled.
|
|
||||||
|
|
||||||
import sys
|
|
||||||
import os
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
if len(sys.argv) != 2:
|
|
||||||
new_brightness = 1
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
new_brightness = float(sys.argv[1])
|
|
||||||
if new_brightness < 1 or new_brightness > 1.5:
|
|
||||||
raise ValueError()
|
|
||||||
except Exception as e:
|
|
||||||
new_brightness = 1
|
|
||||||
|
|
||||||
print(f"Setting SDR brightness to: {new_brightness}\n")
|
|
||||||
|
|
||||||
config_path = os.path.expanduser("~/.config/hypr/hyprland/monitors.conf")
|
|
||||||
if not os.path.exists(config_path):
|
|
||||||
print(f"Configuration file {config_path} does not exist.")
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
with open(config_path, 'r') as file:
|
|
||||||
lines = file.readlines()
|
|
||||||
for line in lines:
|
|
||||||
if "sdrbrightness" in line:
|
|
||||||
old_line = line.strip()
|
|
||||||
new_line = f" sdrbrightness = {new_brightness}\n"
|
|
||||||
lines[lines.index(line)] = new_line
|
|
||||||
print(f"Updated: {old_line} to {new_line.strip()}\n")
|
|
||||||
break
|
|
||||||
|
|
||||||
with open(config_path, 'w') as file:
|
|
||||||
file.writelines(lines)
|
|
||||||
|
|
||||||
print(f"New {config_path} content: \n")
|
|
||||||
with open(config_path, 'r') as file:
|
|
||||||
print(file.read())
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# Description:
|
# Description:
|
||||||
# Quick snippet for rofi + emoji + wl-copy
|
# Quick snippet for rofi + emoji + wl-copy
|
||||||
@@ -1887,4 +1887,4 @@ AH↗️HA↘️HA↗️HA↘️HA↗️HA↘️HA↗️HA↘️ pekora arrows h
|
|||||||
🔀 git commit message merge
|
🔀 git commit message merge
|
||||||
🔖 git commit message release
|
🔖 git commit message release
|
||||||
⬆️ git commit message upgrade
|
⬆️ git commit message upgrade
|
||||||
⬇️ git commit message downgrade
|
⬇️ git commit message downgrade
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
# Based on: https://gist.github.com/XVilka/8346728
|
# Based on: https://gist.github.com/XVilka/8346728
|
||||||
|
|
||||||
awk -v term_cols="${width:-$(tput cols || echo 80)}" 'BEGIN{
|
awk -v term_cols="${width:-$(tput cols || echo 80)}" 'BEGIN{
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Description:
|
|
||||||
# Restart xdg-desktop-portal and xdg-desktop-portal-hyprland to fix screen sharing issues.
|
|
||||||
# From hyprland documentation.
|
|
||||||
|
|
||||||
sleep 1
|
|
||||||
killall -e xdg-desktop-portal-hyprland
|
|
||||||
killall -e xdg-desktop-portal-wlr
|
|
||||||
killall xdg-desktop-portal
|
|
||||||
/usr/lib/xdg-desktop-portal-hyprland -v &
|
|
||||||
sleep 2
|
|
||||||
/usr/lib/xdg-desktop-portal &
|
|
||||||
+1
@@ -2,6 +2,7 @@
|
|||||||
!.gitignore
|
!.gitignore
|
||||||
!05-done.fish
|
!05-done.fish
|
||||||
!10-env.fish
|
!10-env.fish
|
||||||
|
!10-kitty.fish
|
||||||
!10-niri-env.fish
|
!10-niri-env.fish
|
||||||
!10-sshs.fish
|
!10-sshs.fish
|
||||||
!50-prompt.fish
|
!50-prompt.fish
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
# Workaround: https://github.com/kovidgoyal/kitty/issues/9416
|
||||||
|
if test "$TERM" = "xterm-kitty"; and kitty --version | grep -q "0.45.0"
|
||||||
|
set -xg TERM "xterm-256color"
|
||||||
|
set -xg TERMINFO "/usr/share/terminfo"
|
||||||
|
end
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
> 本篇内容**完全**由 Gemini 生成,虽未验证其准确性,但确实能工作,遂记录于此。
|
||||||
|
|
||||||
这是一个关于 **Linux (Arch) 宿主机** + **Linux (Gentoo) 客户机** 在 KVM/QEMU 环境下启用 **Virtio-GPU 3D 加速** 遇到黑屏问题的**非完整**排查与解决记录。
|
这是一个关于 **Linux (Arch) 宿主机** + **Linux (Gentoo) 客户机** 在 KVM/QEMU 环境下启用 **Virtio-GPU 3D 加速** 遇到黑屏问题的**非完整**排查与解决记录。
|
||||||
|
|
||||||
## What
|
## What
|
||||||
@@ -21,7 +23,6 @@
|
|||||||
```
|
```
|
||||||
|
|
||||||
- **现象**:
|
- **现象**:
|
||||||
|
|
||||||
- 虚拟机启动后黑屏,无法进入图形界面。
|
- 虚拟机启动后黑屏,无法进入图形界面。
|
||||||
- SSH 连接正常,系统内核正常运行。
|
- SSH 连接正常,系统内核正常运行。
|
||||||
- SPICE 窗口内能看到鼠标光标(表示连接建立),但无画面。
|
- SPICE 窗口内能看到鼠标光标(表示连接建立),但无画面。
|
||||||
@@ -92,7 +93,6 @@ sudo systemctl restart libvirtd
|
|||||||
在 Gentoo Guest 内部,确保驱动栈完整。
|
在 Gentoo Guest 内部,确保驱动栈完整。
|
||||||
|
|
||||||
1. **Portage 配置** ( 或其他位置):
|
1. **Portage 配置** ( 或其他位置):
|
||||||
|
|
||||||
- `/etc/portage/make.conf`
|
- `/etc/portage/make.conf`
|
||||||
|
|
||||||
```conf
|
```conf
|
||||||
|
|||||||
Reference in New Issue
Block a user