summary refs log tree commit diff
path: root/bin/iconez
diff options
context:
space:
mode:
Diffstat (limited to 'bin/iconez')
-rwxr-xr-xbin/iconez103
1 files changed, 0 insertions, 103 deletions
diff --git a/bin/iconez b/bin/iconez
deleted file mode 100755
index 9c78450..0000000
--- a/bin/iconez
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/bin/sh
-
-set -e
-[ -n "$DEBUG" ] && set -x
-
-by_pid=
-by_name=
-fuzzy=
-desktop_files=
-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 ;;
-	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))
-
-data_dirs=$(
-	set -f
-	IFS=":"
-	set -- ${XDG_DATA_DIRS:-"$HOME/.local/share:/usr/local/share:/usr/share"}
-	printf "%s\n" "$@"
-)
-
-desktop_dirs=
-icon_dirs=
-for d in $data_dirs; do
-	desktop_dirs="${desktop_dirs## } ${d}/applications"
-	icon_dirs="${icon_dirs## } ${d}/icons"
-done
-
-by_name() {
-	name=$1
-
-	if [ -n "${desktop_files}" ]; then
-		[ -z "${fuzzy}" ] && name="^${name}$"
-		# try getting .desktop entry for name
-		# shellcheck disable=2086
-		ident=$(fd -e desktop "${name}" ${desktop_dirs} -x grep Icon= 2>/dev/null || true | cut -d= -f2 | uniq)
-	fi
-
-	if [ -z "${fuzzy}" ]; then
-		ident="^${ident:-$name}\."
-	else
-		ident="${ident:-$name}"
-	fi
-
-	filetypes="-e svg"
-	if [ -z "${scalable}" ]; then
-		filetypes="${filetypes} -e png"
-	fi
-
-	# shellcheck disable=2086
-	fd -t f ${filetypes} "${ident}" ${icon_dirs} 2>/dev/null || true
-
-	# avoid selecting svg, can be made to prefer svg if `-v` is removed
-	# svg=$(printf "%s" "${icons}" | grep -v svg)
-	# [ -n "${svg}" ] && icons=${svg}
-
-	# printf "%s\n" "${icons}"
-}
-
-by_pid() {
-	pid=$1
-
-	arg0=
-	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 ;;
-		esac
-	done
-
-	by_name "${arg0}"
-}
-
-# main
-if [ -n "${by_name}" ]; then
-	by_name "${by_name}"
-
-elif [ -n "${by_pid}" ]; then
-	by_pid "${by_pid}"
-
-fi