Return to Snippet

Revision: 50832
at September 5, 2011 08:19 by crackiron


Initial Code
#!/bin/bash

# Thanks to Alberto Ferreira for an initial
# development. You can find it in:
# https://bbs.archlinux.org/viewtopic.php?id=76774
#
# http://www.eneseblog.com

XINIT_FILE="`echo ~`/.xinitrc"
ARGS1="$*"

function GenChanges
{

	echo -n "Making ${XINIT_FILE} backup ... "
	cp -p ${XINIT_FILE} ${XINIT_FILE}_gui_app_bak && echo "ok" || echo "ERROR"
	
	echo -n "Writing ${XINIT_FILE} with \"EXEC ${ARGS1}\" ... "
	echo "exec ${ARGS1}" > ${XINIT_FILE} && echo "ok" || echo "ERROR"
	echo
	echo "Starting X"

	xinit

	echo -n "Restoring ${XINIT_FILE} backup ... "
	mv ${XINIT_FILE}_gui_app_bak ${XINIT_FILE} && echo "ok" || echo "ERROR"

}

if [ -f ${XINIT_FILE} ]; then

	GenChanges

else
	
	rep="yes"
	
	echo "Make a blank ${XINIT_FILE} (yes/no)? [yes] "
	read rep
	
	if [[ $rep == "yes" || $rep == "" ]]; then
	
		echo -n "Making a blank ${XINIT_FILE} ... "
		touch "${XINIT_FILE}" && echo "ok" || echo "ERROR"
		GenChanges
		
	else
	
		echo "ABORTING"
		exit 5
		
	fi
	
fi

Initial URL

                                

Initial Description

                                

Initial Title
Launch a program individually with X thanks to .xinitrc

Initial Tags
Bash

Initial Language
Bash