diff --git a/README.md b/README.md index c83f9b9..94fa9c6 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,11 @@ This is often a repository when I work on small ideas until they're big enough to deserve thier own repo and README. This readme may very well be outdated or inaccurate! + +## set-xwindow-icon-by-pid.sh + +Does exactly what it says on the tin. $1 is the string to search, $2 is the path to the icon file + ## sr.sh A transparent wrapper for surfraw that utilizes fzf diff --git a/set-xwindow-icon-by-pid.sh b/set-xwindow-icon-by-pid.sh new file mode 100755 index 0000000..996072c --- /dev/null +++ b/set-xwindow-icon-by-pid.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +############################################################################## +# set-xwindow-icon-by-pid +# (c) Steven Saus 2020 +# Licensed under the MIT license +# +############################################################################## + +ProgramToSearchFor=${1} +IconToUse=$(realpath ${2}) + +# Icon themes in ~/.gtkrc-2.0 and ~/.config/gtk-3.0/settings.ini + +if [ $# -lt 2 ]; then + echo "You must specify a process and FULL PATH to an icon" + exit 1 +else + if [ -f ${IconToUse} ];then + + psx=$(ps aux | grep $1) + num=$(echo "$psx"|grep --color=auto -c -v -e grep -e $0) + if [ $num -gt 0 ];then + MyPID=$(echo "$psx" | awk '{print $2}') + MyWindowID=$(xdotool search --pid "${MyPID}") + xseticon -id ${MyWindowID} ${IconToUse} + fi + else + echo "There was no icon present!" + exit 1 + fi +fi