Remove example scripts, move them to spmenu-examples repository

This commit is contained in:
speedie 2023-06-17 15:26:51 +02:00
parent b7a4ef5a99
commit 59d9f63238
7 changed files with 0 additions and 157 deletions

View file

@ -1,6 +0,0 @@
# spmenu example scripts
This folder contains spmenu example scripts which may be used to learn how to
do certain things in spmenu. They are not installed automatically, but feel
free to copy the scripts somewhere and use them to learn. The `install.sh`
script does this for you if you want all of them.

View file

@ -1,7 +0,0 @@
#!/bin/sh
# install.sh
# Install all scripts in the current directory.
#
# See LICENSE file for copyright and license details.
[ "$(id -u)" != "0" ] && printf "Run me as root.\n" && exit 1
cp -f spmenu* /usr/bin

View file

@ -1,8 +0,0 @@
#!/bin/sh
# spmenu_16cols.sh
# Prints 16 foreground and 16 background colors
#
# See LICENSE file for copyright and license details.
printf "\033[0;31mItem 1\n\033[0;32mItem 2\n\033[0;33mItem 3\n\033[0;34mItem 4\n\033[0;35mItem 5\n\033[0;36mItem 6\n\033[0;37mItem 7\n\033[0;38mItem 8\n\033[1;31mItem 9\n\033[1;32mItem 10\n\033[1;33mItem 11\n\033[1;34mItem 12\n\033[1;35mItem 13\n\033[1;36mItem 14\n\033[1;37mItem 15\n\033[1;38mItem 16\n\
\033[0;41mItem 1\n\033[0;42mItem 2\n\033[0;43mItem 3\n\033[0;44mItem 4\n\033[0;45mItem 5\n\033[0;46mItem 6\n\033[0;47mItem 7\n\033[0;48mItem 8\n\033[1;41mItem 9\n\033[1;42mItem 10\n\033[1;43mItem 11\n\033[1;44mItem 12\n\033[1;45mItem 13\n\033[1;46mItem 14\n\033[1;47mItem 15\n\033[1;48mItem 16\n" | spmenu "$@"

View file

@ -1,36 +0,0 @@
#!/bin/sh
# spmenu_imageviewer.sh
# Proof of concept script allowing you to view images in spmenu
# Usage: spmenu_imageviewer.sh image1 image2 ...
#
# See LICENSE file for copyright and license details.
[ ! -f "$1" ] && printf "You must specify an image to view.\n" && exit 1
genlist() {
argc="$(printf "%s\n" "$@" | wc -l)"
for i in $(seq "$argc"); do
arg="$(printf "%s\n" "$@" | sed -n "${i}","${i}"p)"
[ -z "$arg" ] || [ ! -f "$arg" ] && continue
printf "img://%s\t%s\n" "$arg" "$arg"
done
}
main() {
genlist "$@" | spmenu \
--hide-mode \
--hide-match-count \
--hide-left-arrow \
--hide-right-arrow \
--hide-prompt \
--hide-input \
--hide-caret \
--hide-caps \
--hide-highlighting \
--image-size 200 \
--generate-cache \
--lines 20 \
--columns 1
}
main "$@"

View file

@ -1,20 +0,0 @@
#!/bin/sh
# spmenu_itemcounter.sh
# Example script which adds a new entry to spmenu every second.
#
# See LICENSE file for copyright and license details.
func() {
rm -f /tmp/fl
i=0 cnum=0
while true; do
printf "%s \033[0;3${cnum}m%d\n" "Item" "$i" >> /tmp/fl
i=$((i+1))
cnum=$((cnum+1))
[ "$cnum" -gt "9" ] && cnum="1"
sleep 1
done
}
func | spmenu --list-file /tmp/fl --lines 40 --columns 1 --prompt "Updates automatically!"

View file

@ -1,57 +0,0 @@
#!/bin/sh
# spmenu_musiclist.sh
#
# This script lists out songs in a path you give to it and also displays the cover art for that song if it can be found.
# It serves as an example of how image drawing can be done with spmenu.
#
# See LICENSE file for copyright and license details.
[ -z "$dir" ] && dir="$1"
[ -z "$maxcount" ] && maxcount="$2"
[ -z "$startline" ] && startline="$3"
[ -z "$prefix" ] && prefix="/tmp/.list_songs"
[ -z "$RUNLAUNCHER" ] && RUNLAUNCHER="spmenu"
[ -z "$RUNLAUNCHER_ARGS" ] && RUNLAUNCHER_ARGS="--lines 40 --columns 1 --image-size 200 --no-generate-cache"
create_list() {
[ -z "$i" ] && i=1
[ -z "$c" ] && c="$(find "$dir"/* -type f | wc -l)"
while true; do
file="$(find "$dir"/* -type f | sed -n "${i}","${i}"p)" || exit 1
[ -e "$(dirname "$file")/cover.jpg" ] && \
cp "$(dirname "$file")"/cover.jpg "$prefix/cover-$i.jpg" || ffmpeg -i "$file" -map 0:1 "$prefix/cover-$i.jpg" -loglevel quiet
[ -e "$prefix/cover-$i.jpg" ] && imageprefix="img://" && image="$prefix/cover-$i.jpg"
[ "$(basename "$file")" = "cover.jpg" ] && i=$(expr $i + 1) && continue
printf "%s%s\t%s\n" "$imageprefix" "$image" "$(basename "$file")"
i=$(expr $i + 1)
[ "$i" -eq "$c" ] || [ "$i" -gt "$c" ] && break
done
}
usage() {
printf "usage: $0 <music directory> <max file count> <start line>\n"
exit 1
}
play() {
[ -n "$sel_file" ] && \
mpv "$(find "$dir"/* -type f | grep "$sel_file")"
}
main() {
mkdir -p $prefix
[ -z "$dir" ] && usage
[ -z "$RUNLAUNCHER" ] && RUNLAUNCHER="spmenu"
[ -z "$RUNLAUNCHER_ARGS" ] && RUNLAUNCHER_ARGS="-l 40 -g 1 -is 200 -ngc"
[ -n "$maxcount" ] && c="$maxcount"
[ -n "$startline" ] && c="$startline"
sel_file="$(create_list | sed "s/\&/\&amp;/g" | $RUNLAUNCHER $RUNLAUNCHER_ARGS | sed "s/\&amp;/\&/g")"
play
rm -f "$prefix"/cover*.jpg # cleanup
}
main "$@"

View file

@ -1,23 +0,0 @@
#!/bin/sh
# spmenu_sweden.sh
# Just the swedish flag using SGR sequences, serves as a good example on how to do background colors.
#
# See LICENSE file for copyright and license details.
[ -z "$fg_blue" ] && fg_blue='\033[1;34m'
[ -z "$fg_yellow" ] && fg_yellow='\033[1;35m'
[ -z "$bg_blue" ] && bg_blue='\033[1;44m'
[ -z "$bg_yellow" ] && bg_yellow='\033[1;45m'
[ -z "$reset" ] && reset='\033[0m'
[ -z "$color1" ] && color1="#006AA7"
[ -z "$color2" ] && color3="#FECC02"
printf "\n\
${bg_blue} ${bg_yellow} ${bg_blue}\n\
${bg_blue} ${bg_yellow} ${bg_blue}\n\
${bg_yellow} \n\
${bg_blue} ${bg_yellow} ${bg_blue}\n\
${bg_blue} ${bg_yellow} ${bg_blue}\n\
\n\
${reset}${fg_blue}c${fg_yellow}o${fg_blue}o${fg_yellow}l\n\
" | spmenu --sgr4 "$color1" --sgr5 "$color3" --sgr12 "$color1" --sgr13 "$color3" --no-alpha --lines 40 --columns 7 "$@"