help with kshrc

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

help with kshrc

Marko Cupać
Hi,

in tcsh on FreeBSD, I use the following line in .tcshrc in order to
start xfce when looging on ttyv3:

if  ($tty == ttyv3) then
  startxfce4 --with-ck-launch
  logout
endif

How can I achieve the same with OpenBSD's default ksh and .kshrc?

Thank you in advance,
--
Before enlightenment - chop wood, draw water.
After  enlightenment - chop wood, draw water.

Marko Cupać
https://www.mimar.rs/

Reply | Threaded
Open this post in threaded view
|

Re: help with kshrc

dan mclaughlin
On Mon, 18 Apr 2016 16:42:56 +0200 Marko =?ISO-8859-1?Q?Cupa=3F?= <[hidden email]> wrote:

> Hi,
>
> in tcsh on FreeBSD, I use the following line in .tcshrc in order to
> start xfce when looging on ttyv3:
>
> if  ($tty == ttyv3) then
>   startxfce4 --with-ck-launch
>   logout
> endif
>
> How can I achieve the same with OpenBSD's default ksh and .kshrc?
>
> Thank you in advance,
> --
> Before enlightenment - chop wood, draw water.
> After  enlightenment - chop wood, draw water.
>
> Marko Cupać
> https://www.mimar.rs/
>

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).

Reply | Threaded
Open this post in threaded view
|

Re: help with kshrc

Sean Kamath-5
> On Apr 18, 2016, at 10:03 PM, dan mclaughlin <[hidden email]>
wrote:
>
> On Mon, 18 Apr 2016 16:42:56 +0200 Marko =?ISO-8859-1?Q?Cupa=3F?=
<[hidden email]> 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 | Threaded
Open this post in threaded view
|

Re: help with kshrc

Andreas Kusalananda Kähäri
In reply to this post by Marko Cupać
On Mon, Apr 18, 2016 at 04:42:56PM +0200, Marko Cupa? wrote:

> Hi,
>
> in tcsh on FreeBSD, I use the following line in .tcshrc in order to
> start xfce when looging on ttyv3:
>
> if  ($tty == ttyv3) then
>   startxfce4 --with-ck-launch
>   logout
> endif
>
> How can I achieve the same with OpenBSD's default ksh and .kshrc?
>
> Thank you in advance,
> --
> Before enlightenment - chop wood, draw water.
> After  enlightenment - chop wood, draw water.
>
> Marko Cupać
> https://www.mimar.rs/
>

TTY=$( /usr/bin/tty )
if [[ ${TTY##*/} == "ttyp2" ]]; then
    # your stuff
fi

${TTY##*/} is a quicker way to say $( basename $TTY )

Replace "ttyp2" with the tty of your choice.

I would however opt for putting the desktop startup thingies in
$HOME/.xinitrc instead.

--
Andreas Kusalananda Kähäri, Bioinformatics Developer (NBIS)
Uppsala University, Uppsala, Sweden
NBIS: http://nbis.se OpenPGP: url=https://db.tt/2zaB1E7y; id=46082BDF
------------------------------------------------------------------------

[demime 1.01d removed an attachment of type application/pgp-signature which had a name of signature.asc]