Posted By

crackiron on 09/05/11


Tagged

Bash x


Versions (?)

Launch a program individually with X thanks to .xinitrc


 / Published in: Bash
 

  1. #!/bin/bash
  2.  
  3. # Thanks to Alberto Ferreira for an initial
  4. # development. You can find it in:
  5. # https://bbs.archlinux.org/viewtopic.php?id=76774
  6. #
  7. # http://www.eneseblog.com
  8.  
  9. XINIT_FILE="`echo ~`/.xinitrc"
  10. ARGS1="$*"
  11.  
  12. function GenChanges
  13. {
  14.  
  15. echo -n "Making ${XINIT_FILE} backup ... "
  16. cp -p ${XINIT_FILE} ${XINIT_FILE}_gui_app_bak && echo "ok" || echo "ERROR"
  17.  
  18. echo -n "Writing ${XINIT_FILE} with \"EXEC ${ARGS1}\" ... "
  19. echo "exec ${ARGS1}" > ${XINIT_FILE} && echo "ok" || echo "ERROR"
  20. echo
  21. echo "Starting X"
  22.  
  23. xinit
  24.  
  25. echo -n "Restoring ${XINIT_FILE} backup ... "
  26. mv ${XINIT_FILE}_gui_app_bak ${XINIT_FILE} && echo "ok" || echo "ERROR"
  27.  
  28. }
  29.  
  30. if [ -f ${XINIT_FILE} ]; then
  31.  
  32. GenChanges
  33.  
  34. else
  35.  
  36. rep="yes"
  37.  
  38. echo "Make a blank ${XINIT_FILE} (yes/no)? [yes] "
  39. read rep
  40.  
  41. if [[ $rep == "yes" || $rep == "" ]]; then
  42.  
  43. echo -n "Making a blank ${XINIT_FILE} ... "
  44. touch "${XINIT_FILE}" && echo "ok" || echo "ERROR"
  45. GenChanges
  46.  
  47. else
  48.  
  49. echo "ABORTING"
  50. exit 5
  51.  
  52. fi
  53.  
  54. fi

Report this snippet  

You need to login to post a comment.