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
 
the more easy way is the .xinitrc file
remember that you have to put the commands in the background until the last one,and when close the last one,Xorg exit
example
~/.xinitrc

Code:
vlc &
xterm

but you run a window manager?
 
You either add lines in your ~/.xinitrc, as the others said, or do it in your WM's config file, like I start VLC automatically in my fvwm at the start ~/.fvwm/fvwm.config:
Code:
[...]
# Start Function
DestroyFunc StartFunction
AddToFunc   StartFunction
[...]
+ I Test (Init) Exec exec vlc /path/to/myplayist.xspf
+ I GotoDesk 0
[...]
 
beastiegirl for example, I use openbox at times. There is a file $HOME/.config/openbox where it has its configuration, including an autostart file. I just want it to start with a background and tint2 (a window manager bar). So, my $HOME/.config/openbox/autostart reads

feh --bg-scale backgrounds/mybackground.jpg & (sleep 3 && tint2) & (sleep 3 && xbiff) &

That's adding extra stuff as examples, I don't use xbiff very often these days, just trying to show starting multiple things.

I think the first question we have might be, What window manager or desktop environment are you using when you startx?
 
Back
Top