summary refs log tree commit diff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-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