getting renice to work from .xinitrc

From: Gary Aitken <freebsd_at_dreamchaser.org>
Date: Wed, 06 Aug 2025 19:05:27 UTC
I'm trying to get certain xterms reniced when X starts up,
but they don't seem to be working.

relevant lines in xinitrc:

/usr/local/bin/startxfce4 --with-ck-launch &

/usr/local/bin/xterm -sb -sl 2000 -geometry =132x24+10+50 -bg rgb:fa/ea/fa -name trm-1 &
/usr/local/bin/xterm -sb -sl 2000 -geometry =132x24+360+400 -bg powderblue -name root-1 &

bash -c " sleep 30 && sudo renice -n -10 `ps -ao pid,args | grep root-1 | grep -v grep | awk '{ print $1 }'` "

If I execute this from an xterm *after* X is up and stabilized, it works fine:

~$ bash -c " sleep 30 && sudo renice -n -10 `ps -ao pid,args | grep trm-1 | grep -v grep | awk '{ print $1 }'` "
1316: old priority 0, new priority -10
~$ ps -o pid,pri,nice,args | egrep "PID|trm-1" | grep -v egrep
  PID PRI  NI COMMAND
1316  20 -10 /usr/local/bin/xterm -sb -sl 2000 -geometry =132x24+10+50 -bg rgb:fa/ea/fa -name trm-1

The "sleep 30" is supposed to delay the renice until the wm has settled down and
the xterms are up.

What am I missing?

Thanks,

Gary