For Gnome Terminal, which comes with a default Ubuntu install, that can be achieved with a custom profile. In the Preferences dialog, create a new profile, e.g. rootshell
. On the "Command" tab of the new profile, specify your shell script as "Custom command". That can be exactly as you hinted to, however preferably include a shebang.
#!/bin/bash
sudo -i
xhost +
unset XAUTHORITY
export DISPLAY=:0
ssa -local
In your .desktop
launcher, launch this custom terminal as:
Exec=gnome-terminal --window-with-profile=rootshell
Double-clicking the launcher will start Gnome Terminal with the custom profile. On startup, Gnome Terminal will run the script: your user password is asked to elevate priviledges to root. Subsequent commands are executed, and finally, you are dropped at a root prompt, with an environment customized through your script.
If you use a different terminal emulator, a similar approach will apply in most cases. However, details on how to configure will vary.