some ghostty related fix

This commit is contained in:
2025-12-03 20:07:20 +01:00
parent 4a525e2822
commit 916bd6b61e
6 changed files with 34 additions and 26 deletions

View File

@@ -72,27 +72,28 @@ touch "$image"
# Copy image to local wallpaper directory # Copy image to local wallpaper directory
ext=${image##*.} ext=${image##*.}
wallpaper_ext="png"
random_name=$(tr -dc 'a-zA-Z0-9' </dev/urandom | head -c 16) random_name=$(tr -dc 'a-zA-Z0-9' </dev/urandom | head -c 16)
current_dir="$HOME/.local/share/wallpaper/current" current_dir="$HOME/.local/share/wallpaper/current"
image_copied="$current_dir/wallpaper-${random_name}.${ext}" wallpaper_image="$current_dir/wallpaper-${random_name}.${wallpaper_ext}"
mkdir -p "$current_dir" || { mkdir -p "$current_dir" || {
echo "Could not create directory $current_dir" echo "Could not create directory $current_dir"
exit 1 exit 1
} }
temp_img=$(mktemp --suffix=."$ext") || exit 1 temp_img=$(mktemp --suffix=."$wallpaper_ext") || exit 1
trap 'rm -f "$temp_img"' EXIT trap 'rm -f "$temp_img"' EXIT
magick "$image" -resize "${screen_width}x${screen_height}^" -gravity center -extent "${screen_width}x${screen_height}" "$temp_img" || { magick "$image" -resize "${screen_width}x${screen_height}^" -gravity center -extent "${screen_width}x${screen_height}" "$temp_img" || {
echo "Could not resize and crop image" echo "Could not resize and crop image"
exit 1 exit 1
} }
cp "$temp_img" "$image_copied" || exit 1 cp "$temp_img" "$wallpaper_image" || exit 1
hash="$(md5sum "$image" | awk '{print $1}')-${screen_width}x${screen_height}" hash="$(md5sum "$image" | awk '{print $1}')-${screen_width}x${screen_height}"
# Clean up old wallpapers # Clean up old wallpapers
find "$current_dir" -type f -name "wallpaper-*" ! -name "$(basename "$image_copied")" -delete find "$current_dir" -type f -name "wallpaper-*" ! -name "$(basename "$wallpaper_image")" -delete
# Generate blurred wallpaper # Generate blurred wallpaper
@@ -102,8 +103,8 @@ mkdir -p "$blur_dir" "$blur_cache_dir" || {
echo "Could not create cache directory" echo "Could not create cache directory"
exit 1 exit 1
} }
blurred_image="$blur_dir/blurred-${random_name}.$ext" blurred_image="$blur_dir/blurred-${random_name}.${wallpaper_ext}"
blurred_cache_image="$blur_cache_dir/${hash}.$ext" blurred_cache_image="$blur_cache_dir/${hash}.${wallpaper_ext}"
## Time consuming task (magick -blur) in background ## Time consuming task (magick -blur) in background
( (
@@ -125,7 +126,7 @@ blurred_cache_image="$blur_cache_dir/${hash}.$ext"
fi fi
fi fi
sigma=$(magick identify -format "%w %h" "$image_copied" | awk -v f=0.01 '{ sigma=$(magick identify -format "%w %h" "$wallpaper_image" | awk -v f=0.01 '{
m=($1>$2)?$1:$2; m=($1>$2)?$1:$2;
s=m*f; s=m*f;
if(s<2) s=2; if(s<2) s=2;
@@ -134,9 +135,9 @@ blurred_cache_image="$blur_cache_dir/${hash}.$ext"
}') }')
### use a temporary file to avoid incomplete file being used ### use a temporary file to avoid incomplete file being used
temp_blurred=$(mktemp --suffix=."$ext") || exit 1 temp_blurred=$(mktemp --suffix=."$wallpaper_ext") || exit 1
trap 'rm -f "${temp_blurred}"' EXIT trap 'rm -f "${temp_blurred}"' EXIT
magick "$image_copied" -blur 0x"$sigma" "$temp_blurred" || { magick "$wallpaper_image" -blur 0x"$sigma" "$temp_blurred" || {
echo "Could not create blurred image" echo "Could not create blurred image"
exit 1 exit 1
} }
@@ -163,18 +164,18 @@ blurred_cache_image="$blur_cache_dir/${hash}.$ext"
# Apply wallpaper # Apply wallpaper
if [ "$XDG_CURRENT_DESKTOP" = "Hyprland" ]; then if [ "$XDG_CURRENT_DESKTOP" = "Hyprland" ]; then
swww img -n background "$image_copied" --transition-type fade --transition-duration 2 >/dev/null 2>/dev/null swww img -n background "$wallpaper_image" --transition-type fade --transition-duration 2 >/dev/null 2>/dev/null
notify-send -a "change-wallpaper" "Wallpaper Changed" "$image" -i "$image_copied" notify-send -a "change-wallpaper" "Wallpaper Changed" "$image" -i "$wallpaper_image"
change-colortheme -i "$image_copied" || exit 1 change-colortheme -i "$wallpaper_image" || exit 1
elif [ "$XDG_CURRENT_DESKTOP" = "niri" ]; then elif [ "$XDG_CURRENT_DESKTOP" = "niri" ]; then
### Handled in wallpaper-daemon ### Handled in wallpaper-daemon
# swww img -n background "$image_copied" --transition-type fade --transition-duration 2 > /dev/null 2> /dev/null # swww img -n background "$wallpaper_image" --transition-type fade --transition-duration 2 > /dev/null 2> /dev/null
notify-send -a "change-wallpaper" "Wallpaper Changed" "$image" -i "$image_copied" notify-send -a "change-wallpaper" "Wallpaper Changed" "$image" -i "$wallpaper_image"
change-colortheme -i "$image_copied" || exit 1 change-colortheme -i "$wallpaper_image" || exit 1
else else
echo "Unsupported desktop environment: $XDG_CURRENT_DESKTOP" echo "Unsupported desktop environment: $XDG_CURRENT_DESKTOP"
exit 1 exit 1

View File

@@ -2,4 +2,5 @@
!.gitignore !.gitignore
!fetch.fish !fetch.fish
!sshs.fish !sshs.fish
!alias.fish !alias.fish
!ghostty.fish

View File

@@ -94,7 +94,7 @@ if type -q git
function acp function acp
git add . || return 1 git add . || return 1
if test (count $argv) -eq 0 if test (count $argv) -eq 0
git commit -m "too lazy to come up with a helpful commit message :)" || return 1 git commit -m "👐 foo: too lazy to come up with a helpful commit message :)" || return 1
else else
git commit -m "$argv" || return 1 git commit -m "$argv" || return 1
end end

View File

@@ -1,18 +1,18 @@
if not set -q fetch_logo_type if not set -q fetch_logo_type
set -g fetch_logo_type "auto" set -g fetch_logo_type auto
end end
if not set -q fetch_color if not set -q fetch_color
set -g fetch_color "#89b4fa" set -g fetch_color "#89b4fa"
end end
if test "$fetch_logo_type" = "symbols" if test "$fetch_logo_type" = symbols
set -g fetch_args "--logo-type raw --logo-width 42 --logo \"$HOME/.config/fastfetch/logo_ros/42x.symbols\" --color \"$fetch_color\"" set -g fetch_args "--logo-type raw --logo-width 42 --logo \"$HOME/.config/fastfetch/logo_ros/42x.symbols\" --color \"$fetch_color\""
set -g fetch_args_brief "--logo-type raw --logo-width 28 --logo \"$HOME/.config/fastfetch/logo_ros/28x.symbols\" --color \"$fetch_color\"" set -g fetch_args_brief "--logo-type raw --logo-width 28 --logo \"$HOME/.config/fastfetch/logo_ros/28x.symbols\" --color \"$fetch_color\""
else if test "$fetch_logo_type" = "logo" else if test "$fetch_logo_type" = logo
set -g fetch_args "--logo-type builtin" set -g fetch_args "--logo-type builtin"
set -g fetch_args_brief "--logo-type small" set -g fetch_args_brief "--logo-type small"
else if test "$fetch_logo_type" = "sixel" else if test "$fetch_logo_type" = sixel
set -g fetch_args "--logo-type raw --logo-width 42 --logo \"$HOME/.config/fastfetch/logo_ros/42x.sixel\" --color \"$fetch_color\"" set -g fetch_args "--logo-type raw --logo-width 42 --logo \"$HOME/.config/fastfetch/logo_ros/42x.sixel\" --color \"$fetch_color\""
set -g fetch_args_brief "--logo-type raw --logo-width 28 --logo \"$HOME/.config/fastfetch/logo_ros/28x.sixel\" --color \"$fetch_color\"" set -g fetch_args_brief "--logo-type raw --logo-width 28 --logo \"$HOME/.config/fastfetch/logo_ros/28x.sixel\" --color \"$fetch_color\""
else # "kitty" or "auto" and others else # "kitty" or "auto" and others
@@ -24,15 +24,15 @@ if type -q fastfetch
alias ff="fastfetch -c $HOME/.config/fastfetch/config.jsonc $fetch_args" alias ff="fastfetch -c $HOME/.config/fastfetch/config.jsonc $fetch_args"
if test -f "$HOME/.config/fastfetch/brief.jsonc" if test -f "$HOME/.config/fastfetch/brief.jsonc"
alias ff-brief="fastfetch -c $HOME/.config/fastfetch/brief.jsonc $fetch_args_brief" alias ffb="fastfetch -c $HOME/.config/fastfetch/brief.jsonc $fetch_args_brief"
else else
alias ff-brief=ff alias ffb=ff
end end
end end
# add 'set -g no_fetch' somewhere other than post.d to disable fetching # add 'set -g no_fetch' somewhere other than post.d to disable fetching
if not set -q no_fetch if not set -q no_fetch
if type -q ff-brief if type -q ffb
ff-brief ffb
end end
end end

View File

@@ -0,0 +1,6 @@
if string match -q '*ghostty*' $TERM && test $XDG_CURRENT_DESKTOP = niri
if test "$ghostty_niri_initialized" != "1"
set -xg ghostty_niri_initialized 1
niri msg action set-column-width 50%
end
end