HOWTO Get Custom Icons With Each New XTerm Terminal Window

Use Xterm? Want to have custom icons for each instance like this?

Here’s how you do it:

1. Alias xterm to

xterm -e “xicons.sh;bash”

Save the script below into your $PATH somewhere (and make it executable):

#!/bin/bash

# icon from https://web.archive.org/web/20120501002411/https://www.iconfinder.com/icondetails/17547/48/prompt_terminal_icon
# xseticon from https://www.leonerd.org.uk/code/xseticon/
# Solutions from
# https://superuser.com/questions/363614/leave-xterm-open-after-task-is-complete
# https://unix.stackexchange.com/questions/3197/how-to-identify-which-xterm-a-shell-or-process-is-running-in
# https://unix.stackexchange.com/questions/16774/how-to-assign-an-icon-to-a-program-in-openbox

running=$(ps aux | grep “xterm” | grep -v “grep” | grep -c “xterm”)

if [ “$running” -gt “7” ];then
running=0
fi

snark=$(echo $WINDOWID)
xseticon -id $snark /home/MYUSERNAME/.icons/terms/terminal_prompt$running.png
wmctrl -i -r “$snark” -T “xterm”

And get the icons from here:
https://imgur.com/a/5Q9dn#0 Note that the filenames should be terminal_prompt0.png, terminal_prompt1.png, and so on.

Result: