From 59d9f63238fc9572a81b5ad5cc3fb612c8e500dc Mon Sep 17 00:00:00 2001 From: speedie Date: Sat, 17 Jun 2023 15:26:51 +0200 Subject: [PATCH] Remove example scripts, move them to spmenu-examples repository --- scripts/examples/README.md | 6 --- scripts/examples/install.sh | 7 ---- scripts/examples/spmenu_16cols.sh | 8 ---- scripts/examples/spmenu_imageviewer.sh | 36 ---------------- scripts/examples/spmenu_itemcounter.sh | 20 --------- scripts/examples/spmenu_musiclist.sh | 57 -------------------------- scripts/examples/spmenu_sweden.sh | 23 ----------- 7 files changed, 157 deletions(-) delete mode 100644 scripts/examples/README.md delete mode 100755 scripts/examples/install.sh delete mode 100755 scripts/examples/spmenu_16cols.sh delete mode 100755 scripts/examples/spmenu_imageviewer.sh delete mode 100755 scripts/examples/spmenu_itemcounter.sh delete mode 100755 scripts/examples/spmenu_musiclist.sh delete mode 100755 scripts/examples/spmenu_sweden.sh diff --git a/scripts/examples/README.md b/scripts/examples/README.md deleted file mode 100644 index 2978618..0000000 --- a/scripts/examples/README.md +++ /dev/null @@ -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. diff --git a/scripts/examples/install.sh b/scripts/examples/install.sh deleted file mode 100755 index 01e0c40..0000000 --- a/scripts/examples/install.sh +++ /dev/null @@ -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 diff --git a/scripts/examples/spmenu_16cols.sh b/scripts/examples/spmenu_16cols.sh deleted file mode 100755 index 983faa0..0000000 --- a/scripts/examples/spmenu_16cols.sh +++ /dev/null @@ -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 "$@" diff --git a/scripts/examples/spmenu_imageviewer.sh b/scripts/examples/spmenu_imageviewer.sh deleted file mode 100755 index 79a3c97..0000000 --- a/scripts/examples/spmenu_imageviewer.sh +++ /dev/null @@ -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 "$@" diff --git a/scripts/examples/spmenu_itemcounter.sh b/scripts/examples/spmenu_itemcounter.sh deleted file mode 100755 index 80eb32f..0000000 --- a/scripts/examples/spmenu_itemcounter.sh +++ /dev/null @@ -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!" diff --git a/scripts/examples/spmenu_musiclist.sh b/scripts/examples/spmenu_musiclist.sh deleted file mode 100755 index f5e3a90..0000000 --- a/scripts/examples/spmenu_musiclist.sh +++ /dev/null @@ -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 \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/\&/\&/g" | $RUNLAUNCHER $RUNLAUNCHER_ARGS | sed "s/\&/\&/g")" - play - rm -f "$prefix"/cover*.jpg # cleanup -} - -main "$@" diff --git a/scripts/examples/spmenu_sweden.sh b/scripts/examples/spmenu_sweden.sh deleted file mode 100755 index a59a684..0000000 --- a/scripts/examples/spmenu_sweden.sh +++ /dev/null @@ -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 "$@"