Browse Source

Fix gensub issue in fish

h7-volume
Kevin Mok 4 days ago
parent
commit
ccd6122336
Signed by: Kevin-Mok GPG Key ID: FB0DA56BEB5D98F3
  1. 5
      aliases/key_aliases.tmpl
  2. 3
      aliases/key_dirs.tmpl
  3. 2
      dot_config/fish/completions/kubectl.fish
  4. 16
      dot_config/fish/functions/buku-fzf.fish
  5. 2
      dot_config/fish/functions/man-vim.fish
  6. 82
      scripts/executable_dual-monitor-slideshow
  7. 23
      scripts/executable_sync-shortcuts

5
aliases/key_aliases.tmpl

@ -54,7 +54,7 @@ mgb "sudo grub-mkconfig -o /boot/grub/grub.cfg"
#b "bat"
b "vimpager"
# ba "bat *"
awkp "awk -F',' '{print \$0}'"
awkp "gawk -F',' '{print \$0}'"
cpr "cp -r"
fd "fdfind"
fdc "fdfind -i"
@ -205,7 +205,8 @@ uzl "unzip -l"
# power options [[[ #
#s "systemctl suspend"
s "xset dpms force off"
#s "xset dpms force off"
s "~/linux-config/scripts/executable_dual-monitor-slideshow"
# sl "i3lock-fancy && systemctl suspend"
# so "xset dpms force off"
xx "exit"

3
aliases/key_dirs.tmpl

@ -77,7 +77,8 @@ b1 ~/coding/mf-site/themes/base16
2d ~/coding/godot-demos/2d-plat
ada ~/coding/ada-mario
# ft ~/coding/face-tracker
hv ~/Documents/hevin
#hv ~/Documents/hevin
hv /mnt/linux-files-2/Pictures/hevin
hvs ~/Documents/hevin/shopping
j ~/Documents/journal
jt ~/Documents/journal/todo/24

2
dot_config/fish/completions/kubectl.fish

@ -364,7 +364,7 @@ function __fish_kubectl_print_resource -d 'Print a list of resources' -a resourc
end
set args $args get "$resource"
__fish_kubectl $args --no-headers 2>/dev/null | awk '{print $1}' | string replace -r '(.*)/' ''
__fish_kubectl $args --no-headers 2>/dev/null | gawk '{print $1}' | string replace -r '(.*)/' ''
end
function __fish_kubectl_get_config -a type

16
dot_config/fish/functions/buku-fzf.fish

@ -1,16 +0,0 @@
function buku-fzf
# buku -p -f 5 | awk -F '\t' 'BEGIN { OFS=FS }; { $2=substr($2, 1, 90); print }' | column -t -s (printf '\t') | fzf --multi | awk '{ print $1 }'
# if test (count $argv) -ge 1 -a "$argv[1]" = "fq"
# set ids (buku -t fq -f4 | awk -F '\t' 'BEGIN { OFS=FS }; { sub(/https?:\/\/(www\.)?/, "", $2); $2=substr($2, 1, 45); $3=substr($3, 1, 50); print }' | column -t -s (printf '\t') | fzf --multi --tiebreak end | awk '{ print $1 }')
if test (count $argv) -eq 1
# TODO: column width? #
set ids (buku -t + "$argv" -f4 | awk -F '\t' 'BEGIN { OFS=FS }; { sub(/https?:\/\/(www\.)?/, "", $2); $2=substr($2, 1, 45); $3=substr($3, 1, 50); print }' | column -t -s (printf '\t') | fzf --multi --tiebreak end | awk '{ print $1 }')
# echo buku -t + "$argv" -f4
else
set ids (buku -p -f4 | awk -F '\t' 'BEGIN { OFS=FS }; { sub(/https?:\/\/(www\.)?/, "", $2); $2=substr($2, 1, 45); $3=substr($3, 1, 50); print }' | column -t -s (printf '\t') | fzf --multi --tiebreak end | awk '{ print $1 }')
end
for id in $ids
buku -o $id
end
end

2
dot_config/fish/functions/man-vim.fish

@ -2,7 +2,7 @@ function man-vim
if count $argv > /dev/null
set prog $argv[1]
else
set prog (apropos . | awk '{ print $1 }' | fzf -e)
set prog (apropos . | gawk '{ print $1 }' | fzf -e)
end
nvim -c ":Man $prog" -c "only"

82
scripts/executable_dual-monitor-slideshow

@ -1,58 +1,13 @@
#!/usr/bin/env fish
# Find a random image
#set image (fdfind -e jpg -e jpeg -e png -e webp . /mnt/linux-files-2/Pictures/hevin | shuf -n 1)
## Create blurred lock image
#convert "$image" -resize 1920x1080^ -gravity center -extent 1920x1080 /tmp/lock.png
## Lock with i3lock-color
#i3lock -n -i /tmp/lock.png
# --------------------
#!/usr/bin/env fish
#set WALLPAPER_DIR "/mnt/linux-files-2/Pictures/hevin"
#set CYCLE_TIME 5 # Seconds between image changes
#set LOCK_AFTER 500 # Activate real lock after 30 seconds of screensaver
## Use a transparent window to cover everything
#while true
#set image (fdfind -e jpg -e jpeg -e png -e webp . $WALLPAPER_DIR | shuf -n 1)
## Create fullscreen image
#convert "$image" -resize (xrandr | grep '*' | head -1 | awk '{print $1}')^ \
#-gravity center -extent (xrandr | grep '*' | head -1 | awk '{print $1}') \
#/tmp/screensaver.png
## Display fullscreen using feh
#feh --fullscreen --hide-pointer --no-fehbg /tmp/screensaver.png &
#set feh_pid $last_pid
## Wait for timeout or mouse movement
#sleep $CYCLE_TIME
#kill $feh_pid
## After longer timeout, activate real lock
#if test (math $CYCLE_TIME \* $count) -ge $LOCK_AFTER
#i3lock -n -i /tmp/screensaver.png
#set count 0
#else
#set count (math $count + 1)
#end
#end
# --------------------
#!/usr/bin/env fish
# Configuration
set WALLPAPER_DIR "/mnt/linux-files-2/Pictures/hevin"
set CYCLE_TIME 2 # Seconds between image changes
set CYCLE_TIME 5 # Seconds between image changes
#set BLUR_AMOUNT "0x5" # Set to "0x0" for no blur
set BLUR_AMOUNT "0x0" # Set to "0x0" for no blur
# Get monitor information - sanitize names by replacing hyphens with underscores
set monitors (xrandr --query | grep " connected" | awk '{print $1}' | string replace -a '-' '_')
# Get monitor information - use exact names from xrandr
set monitors (xrandr --query | grep " connected" | awk '{print $1}')
set geometries (xrandr --query | grep -A1 " connected" | grep -v " connected" | awk '{print $1}')
# Verify we found monitors
@ -73,14 +28,30 @@ for i in (seq (count $monitors))
set monitor_geometries $monitor_geometries "$monitor:$geo"
end
# Function to restore monitor layout
function restore_monitors
xrandr --auto
xrandr --output HDMI-0 --right-of DVI-I-1
end
# Trap to restore monitors on exit
trap restore_monitors EXIT
while true
# Use only the first monitor's geometry
set entry $monitor_geometries[1]
set monitor (echo $entry | cut -d':' -f1)
set primary_monitor (echo $entry | cut -d':' -f1)
set geo (echo $entry | cut -d':' -f2)
set width (echo $geo | cut -d'x' -f1)
set height (echo $geo | cut -d'x' -f2)
# Turn off all other monitors
for monitor in $monitors
if test "$monitor" != "$primary_monitor"
xrandr --output $monitor --off 2>/dev/null || echo "Warning: Could not turn off monitor $monitor"
end
end
# Select and process image
set image (fdfind -e jpg -e jpeg -e png -e webp . $WALLPAPER_DIR | shuf -n 1)
if test -n "$image"
@ -100,7 +71,7 @@ while true
-background black \
-extent {$width}x{$height} \
-blur $BLUR_AMOUNT \
"/tmp/screensaver-$monitor.png"
"/tmp/screensaver-$primary_monitor.png"
else
# Horizontal image - fit to width
convert "$image" \
@ -108,11 +79,11 @@ while true
-gravity center \
-extent {$width}x{$height} \
-blur $BLUR_AMOUNT \
"/tmp/screensaver-$monitor.png"
"/tmp/screensaver-$primary_monitor.png"
end
# Display image on single monitor
feh --no-fehbg --hide-pointer --fullscreen --title 'screensaver' "/tmp/screensaver-$monitor.png" &
feh --no-fehbg --hide-pointer --fullscreen --title 'screensaver' "/tmp/screensaver-$primary_monitor.png" &
set feh_pid $last_pid
# Wait for cycle time
@ -120,6 +91,13 @@ while true
# Kill feh process
kill $feh_pid 2>/dev/null
# Turn other monitors back on
for monitor in $monitors
if test "$monitor" != "$primary_monitor"
xrandr --output $monitor --auto 2>/dev/null || echo "Warning: Could not turn on monitor $monitor"
end
end
else
echo "Error: No images found in $WALLPAPER_DIR"
exit 1

23
scripts/executable_sync-shortcuts

@ -54,12 +54,21 @@ sed "s/\s*#.*$//;/^\s*$/d" "$key_files" | tee \
>(awk '{print "abbr n"$1, "\"$EDITOR "$2"\""}' >> "$fish_abbr") \
| awk '{print "map n"$1" shell $EDITOR "$2}' >> "$ranger_mappings"
#sed -e '/^$/d' -e '/[ ]*#.*/d' "$key_aliases" | sort | tee \
#>(awk '{printf "abbr " $1; $1 = ""; print $0; }' >> "$fish_abbr") \
#| awk '{
#printf $1;
#$1 = "";
#printf "=";
#printf gensub(" ", "", 1, $0);
#print " \\";
#}' >> "$aliases"
sed -e '/^$/d' -e '/[ ]*#.*/d' "$key_aliases" | sort | tee \
>(awk '{printf "abbr " $1; $1 = ""; print $0; }' >> "$fish_abbr") \
| awk '{
printf $1;
$1 = "";
printf "=";
printf gensub(" ", "", 1, $0);
print " \\";
>(awk '{printf "abbr " $1; $1 = ""; print $0; }' >> "$fish_abbr") \
| awk '{
printf $1 "=";
$1 = "";
# Remove leading space
sub(/^ /, "", $0);
print $0 " \\";
}' >> "$aliases"
Loading…
Cancel
Save