#!/usr/bin/wxbasicscript include "/usr/lib/wxbasicscript/basefunctions.inc" // -- copy file to ~/ (/home/user) , rename it to .sh shell( "echo ~>/tmp/wxbaumhome.txt" ) homedir = trim(readfile( "/tmp/wxbaumhome.txt" )) removefile( "/tmp/wxbaumhome.txt" ) alllines = readfiletolist( STARTDIR & "/autostart.cfg" ) writelisttofile( homedir & "/wxb-autostart.sh" , alllines ) // -- make it executable shell( "chmod 755 ~/wxb-autostart.sh" ) // -- now test, if our configuration is already included in .xinitrc // -- if it is, we can end this script without changing anything // -- in this loop, we also delete the first line xinitrclines = readfiletolist( homedir & "/.xinitrc" ) for i=0 to count( xinitrclines ) -1 if xinitrclines[i] = homedir & "/wxb-autostart.sh" then end end if next // -- if this script is not in .xinitrc, we must add it. // -- first, create a backup: writelisttofile( homedir & "/.xinitrc-autostart-backup" , xinitrclines ) // -- now create a new .xinitrc with the command to run autostart.sh // -- We can not put it in the first line, as here the script-interpreter is loaded (normally sh) // -- so we store it in a variable, and replace the first entry in the list with autostart.sh. theshell = xinitrclines[0] xinitrclines[0] = homedir & "/wxb-autostart.sh" // -- Now we can save the stored interpreterline, add finally append the rest of the list. writestringtofile( homedir & "/.xinitrc" , theshell ) appendlisttofile( homedir & "/.xinitrc" , xinitrclines ) |