Tiny Core Linux

Tiny Core Extensions => TCE Q&A Forum => Topic started by: Misalf on June 28, 2016, 10:38:29 AM

Title: One-Liner to restart X?
Post by: Misalf on June 28, 2016, 10:38:29 AM
Hi there!

I'm searching for an one-liner to restart X, that I can then, for example, add to my Window Manager menu or execute via key press.

I was hoping for something like this to work
Code: [Select]
nohup { kill $(cat /tmp/.X${DISPLAY:1:1}-lock) ; sleep 2 ; startx ; }

I tried several combinations using  {} , () , sh -c ""  and  & , but couldn't yet get it to work, since either the command dies together with X or X won't die at all.

Anyone has an idea?
Title: Re: One-Liner to restart X?
Post by: Rich on June 28, 2016, 10:58:29 AM
Hi Misalf
Instead of a one liner maybe break the problem down into two pieces. Create a script with the required commands
called  restartX. Place it in  ~/.local/bin  so it's included by the  $PATH  environmental variable. Your one liner will now
be  restartX.

Title: Re: One-Liner to restart X?
Post by: andyj on June 28, 2016, 11:04:21 AM
A while true loop in .profile and Ctrl-Alt-Bksp to kill X won't work?
Title: Re: One-Liner to restart X?
Post by: Misalf on June 28, 2016, 11:14:29 AM
Thanks Rich, I'll see if that can fit my needs. The reason I'm asking for a one-liner though, is that I would like it to be as portable as possible - user (and maybe distro) independent.

andyj, thanks but no (see above). Also, if I get it right, this would prevent the user from using the Linux console.
Title: Re: One-Liner to restart X?
Post by: Misalf on June 28, 2016, 11:39:41 AM
Yeah, of course. Just when I think i can't get it working...
Code: [Select]
{ kill $(cat /tmp/.X${DISPLAY:1:1}-lock) ; sleep 2 >/dev/tty0 ; startx >/dev/tty0 ; } &

Is  /dev/tty0  always available?
Title: Re: One-Liner to restart X?
Post by: Misalf on June 28, 2016, 11:57:18 AM
This might be better
Code: [Select]
{ kill $(cat /tmp/.X${DISPLAY:1:1}-lock) && { sleep 1 ; startx ; } >/dev/tty0 ; } &