How to pass command line args to startx?

So i have an old computer that i want to use to watch tv. The plan was install freebsd, load up hard drive with content, plug in the hdmi, and simply pass command line args to startx to select the file i want to watch ie
startx vlc path/to/file
i tried just adding
exec $1 $2 $3 $4
and also
exec xterm -e $1 $2 $3 $4
to the system wide xinitrc (single user setup cuz its just a tv box) but this just crashes the x server. i can run vlc from xterm but then i gotta fuck around with a mouse to change focus. for simplicity and viewing comfort i dont wanna have to fuck with a mouse.
 
try startx /path/to/vlc /path/to/file

I've found startx to be flaky about path to executable if it is missing.

Starting the X server and clients can be kind of tricky if you want to do custom stuff. You need to indirectly start the X server in the background, then execute at least one client, and if all clients exit then the X server itself will exit. In the past i've done stuff like

(X {x-options} &; sleep 2; client1&; client2 &; client3)
 
What is the error you get when X crashes?

For me, $1 in .xinitrc is not the first parameter passed to startx, it's "xterm", for some reason, and my first argument comes as $2 (this is a very fresh install). Beside the path resolution problems mentioned by kent_dorfman766, you can try passing values through env variables, if you don't mind them being then exposed to all programs then started by X:

Code:
$ cat ~/.xinitrc
exec xterm -e "$MY_COMMAND"

$ MY_COMMAND="/usr/local/bin/vlc /home/user/Video/whatever.mp4" startx
 
Back
Top