> On Apr 18, 2016, at 10:03 PM, dan mclaughlin <thev...@openmailbox.org>
wrote:
>
> On Mon, 18 Apr 2016 16:42:56 +0200 Marko =?ISO-8859-1?Q?Cupa=3F?=
<marko.cu...@mimar.rs> wrote:
>> if  ($tty == ttyv3) then
>>  startxfce4 --with-ck-launch
>>  logout
>> endif
>>
>> How can I achieve the same with OpenBSD's default ksh and .kshrc?
>
> it's been more years than i can count since i've used either tcsh or
FreeBSD,
> but if you are trying to detect the current tty (which is what i am
assuming
> is what is in $tty), you can use ps (the variable '$$' is a reference to
the
> current shell's pid):
>
> $ ps -o pid,tt | sed -n "s/^$$ //p"
> p3
>
> now i don't know what v3 is, but the console ttys are ttyC? on OpenBSD, so
> if you want only the first window at the console,
>
>  if [[ $(ps -o pid,tt | sed -n "s/^$$ //p") = C0 ]];then
>    startxfce4 --with-ck-launch
>    exit
>  fi
>
> should do the trick. i also assume that 'logout' exits the shell, and thus
> logs you out, hence logout -> exit, which will exit the script (or in this
> case the shell since it's in the startup script).

/usr/bin/tty seems like a nice way to get the tty of the running process. ;-)

I set TTY=`tty` in my .profile.  Then I use ${TTY##?????} a lot. :-)

I start X on boot, so I don’t use startx or equivalent.

Sean

Reply via email to