summary refs log tree commit diff
path: root/bin/iconez
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2022-08-17 15:37:52 +0200
committerRobert Günzler <r@gnzler.io>2022-08-17 15:37:52 +0200
commite0eca3a4bf69cced70dfb935db80287524feaa77 (patch)
tree3d99bfe81d05358209d2450512d829fd2351d542 /bin/iconez
parentb8ca75ba45136017c1b7dec5ba3fa73854866a87 (diff)
bin/iconez: support only selecting scalable icons
Diffstat (limited to 'bin/iconez')
-rwxr-xr-xbin/iconez50
1 files changed, 29 insertions, 21 deletions
diff --git a/bin/iconez b/bin/iconez
index a570064..104158e 100755
--- a/bin/iconez
+++ b/bin/iconez
@@ -7,22 +7,25 @@ by_pid=
 by_name=
 fuzzy=
 desktop_files=
-while getopts n:p:dfh opt; do
+scalable=
+while getopts n:p:dfsh opt; do
 	case "$opt" in
-		n) by_name="${OPTARG}" ;;
-		p) by_pid="${OPTARG}" ;;
-		f) fuzzy=1 ;;
-		d) desktop_files=1 ;;
-		h | ?)
-			printf "usage: %s [-h]\n" "$(basename "$0")"
-			printf "\n"
-			printf "  -p \t PID\n"
-			printf "  -n \t NAME\n"
-			printf "  -f \t enable fuzzy matching (NAME only)\n"
-			printf "  -d \t try to match NAME desktop file\n"
-			printf "\n"
-			exit 2
-			;;
+	n) by_name="${OPTARG}" ;;
+	p) by_pid="${OPTARG}" ;;
+	f) fuzzy=1 ;;
+	d) desktop_files=1 ;;
+	s) scalable=1 ;;
+	h | ?)
+		printf "usage: %s [-h]\n" "$(basename "$0")"
+		printf "\n"
+		printf "  -p \t PID\n"
+		printf "  -n \t NAME\n"
+		printf "  -f \t enable fuzzy matching (NAME only)\n"
+		printf "  -d \t try to match NAME desktop file\n"
+		printf "  -s \t only match scalable icons\n"
+		printf "\n"
+		exit 2
+		;;
 	esac
 done
 shift $((OPTIND - 1))
@@ -46,8 +49,13 @@ by_name() {
 		ident="${ident:-$name}"
 	fi
 
+	filetypes="-e svg"
+	if [ -z "${scalable}" ]; then
+		filetypes="${filetypes} -e png"
+	fi
+
 	# shellcheck disable=2086
-	fd -t f -e png -e svg "${ident}" ${icon_dirs}
+	fd -t f ${filetypes} "${ident}" ${icon_dirs}
 
 	# avoid selecting svg, can be made to prefer svg if `-v` is removed
 	# svg=$(printf "%s" "${icons}" | grep -v svg)
@@ -63,11 +71,11 @@ by_pid() {
 	while true; do
 		arg0=$(awk '{print $1}' /proc/"${pid}"/comm)
 		case ${arg0} in
-			*sh)
-				pid=$(ps -p "${pid}" -o ppid= | xargs)
-				[ "$pid" = 1 ] && exit 1
-				;;
-			*) break ;;
+		*sh)
+			pid=$(ps -p "${pid}" -o ppid= | xargs)
+			[ "$pid" = 1 ] && exit 1
+			;;
+		*) break ;;
 		esac
 	done