1
0
Fork 0

add scripts

urosm 2023-08-12 01:23:53 +02:00
parent 7063865996
commit 1ded2948bf
3 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,12 @@
#!/usr/bin/sh
#
# fuzzel_find_file.sh
#
# Search for file and open it. Requires fuzzel and find.
pattern=$(fuzzel --dmenu --prompt "$ find . -type f ") || exit
selection=$(find . -type f -iname "$pattern" | fuzzel --dmenu --prompt "$ open ")
if [ -n "$selection" ]; then
exec open "$selection"
fi

View File

@ -0,0 +1,35 @@
#!/usr/bin/sh
#
# fuzzel_mount.sh
#
# Mount devices. Requires fuzzel and udisksctl.
LSBLK_PART_TYPE="part"
LSBLK_LIST=$(lsblk -Ppo name,type,mountpoint)
while read -r line; do
while read -r keyval; do
eval "$keyval"
done <<- EOF
$line
EOF
expr "$NAME" : "/dev/sda." && continue
[ "$TYPE" = "$LSBLK_PART_TYPE" ] || continue
if [ -n "$MOUNTPOINT" ]; then
option_list=$(printf %s\\n "udisksctl unmount -b $NAME" "$option_list")
else
option_list=$(printf %s\\n "udisksctl mount -b $NAME" "$option_list")
fi
done <<- EOF
$LSBLK_LIST
EOF
selection=$(printf %s "$option_list" | fuzzel --dmenu --prompt "$ ")
if [ -n "$selection" ]; then
# TODO: notification and error reporting
exec $selection
fi

View File

@ -0,0 +1,22 @@
#!/usr/bin/sh
#
# fuzzel_open_file.sh DIR
#
# Open file or terminal in current directory. Requires fuzzel and
# xdg-open.
DIR=${1:-$HOME}
cd "$DIR" || exit 1
DIR="$(pwd)"
selection=$(ls --group-directories-first -a1v | fuzzel --dmenu --prompt "$ open $DIR/")
if [ -n "$selection" ]; then
if [ "$selection" = "." ]; then
exec $TERMINAL -D "$DIR"
elif [ -d "$DIR/$selection" ]; then
exec $0 "$DIR/$selection"
elif [ -f "$DIR/$selection" ]; then
exec open "$DIR/$selection"
fi
fi