You are not logged in.
Pages: 1
is there a way to startx with different scripts so I do not have to edit .xinitrc every time I want to do somthing different yet want to keep it for future use. I have looked in the wiki and the man page but to no avail. I was looking for a way to load a different config file(.xinitrc) but it seems to be pretty hard coded wondering if there is some hack or other way of achiving this or if I missed something.
Last edited by bleach (2014-11-02 11:09:51)
Offline
startx is a frontend for xinit. Look there to use a different file.
Offline
Why not just have conditional blocks in your xinitrc? If you really want separate files (not recommended) just use the following as your ~/.xinitrc:
source ~/.xinitrc.$1
This way you could have any number of files like ~/.xinitrc.openbox, ~/.xinitrc.dwm, ~/.xinitrc.gnome and they would be selected simply by passing the wm name to xinit or startx. The downside of this is many files, and a need to set up a default for when no parameter is passed. It'd be much more common (and I'd argue easier to maintain) to have one file with a case statement:
wm=${1:-dwm}
case $wm in
dwm)
# stuff to run for dwm
exec dwm
;;
openbox)
# stuff to run for openbox
exec openbox
;;
gnome)
# stuff to run for gnome
exec gnome
;;
*)
# default stuff for no match
echo "enter a WM name"
;;
esac
EDIT: while I'd still recommend the case statement strategy, something more in line with your original request would be to use an environment variable. Say, for example, you create a variable REPLACE_XINITRC - and that variable contains a file name, then your xinitrc could have the following as the first line:
[[ -x "$REPLACE_XINITRC" ]] && exec $REPLACE_XINITRC $@
This would continue with your normal xinitrc unless the variable existed and named an existing file. In that case, it would use that file instead, and even pass any parameters on to that file. The downside of this is that environment variables do not work the way many people seem to first assume they would: if you set the variable within X, then restart X (exit your current session) the next start of X will not get that variable. Youd have to set it before running xinitrc/startx - note that as written this would also require that those other files be executable.
Last edited by Trilby (2014-11-02 12:20:18)
"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" - Richard Stallman
Offline
Pages: 1