I wanted to set up a button in KDE to open up a terminal and log me in as root. But the behavior I wanted was that if this was the first time I clicked the button, it should spawn a new
screen session; otherwise if a
screen session already existed, it should use that one. Luckily the
-R flag for
screen does exactly this.
I don't have
sudo on my system any more, so I had to use
su for this. So the first thing I tried was setting up a KDE button on kicker that used this command:
urxvt -e su - -c screen -R
This did not work. When I clicked the button, it would prompt me for my root password, but then it would ALWAYS spawn a new screen session, even if a detached one already existed. Can you see what's wrong?
I should have used this:
urxvt -e su - -c 'screen -R'
su was gobbling up the -R flag itself, so
screen never saw it. This second version works just fine.