Perl - what run level

Is there a way to tell what runlevel is currently being used,

for example is a user is using the gui

or is the have pressed Alt+Ctrl+F1 to drop to the terminal??

who -r usually gives the run-level.

But I have no idea what Perl or a GUI or a convoluted keyboard shortcut has to do with it :slight_smile:

Your grammar precludes me understanding your actual requirement.

Sorry about my grammer

I am trying to write a script in perl that if the user is using the GUI will use nedit and if the are using the Terminal will using vim instead

Check the DISPLAY environment variable. If it is empty or unset the user is not using the X GUI environment used by most Linux distros.

Also check for the EDITOR environment variable. If this is set it is the user's preferred editor.

Andrew