Yesterday while reinstalling Arch in the x86_64 flavour :-) I was thinking which will be the best way to start X window system.
I want to start my X window’s without user prompt (so CDM is not an option), and I don’t any of common login-managers (gdm, xdm, kdm or slim)… I’ve tried to use the simplest way, and it works!
Let’s go, deps:
[cc lang=”bash”]
pacman -Ss xorg-xinit screen
[/cc]
And optional:
[cc lang=”bash”]
pacman -Ss xterm xort-twm
[/cc]
Cool? ;-) Of course, you must have the X-window (1 &2) system installed and your preferred lightweight desktop manager.
Add your super-power-user:
[cc lang=”bash”]
useradd -s /bin/bash -c “super-power-user” dodger
[/cc]
And now the script:
[cc lang=”bash”]
vim /etc/rc.d/autofluxbox
[/cc]
[cc lang=”bash”]
#!/bin/bash -x
LOGDIR=/var/log/autofluxbox
[ ! -d $LOGDIR ] && mkdir $LOGDIR
exec 1> $LOGDIR/autofluxbox.$(date +%Y%m%d%H%M).log
exec 2> $LOGDIR/autofluxbox.$(date +%Y%m%d%H%M).err
USER=dodger
STARTX=”/usr/bin/startx”
su – ${USER} -c “screen -S Fluxbox_startup -d -m ${STARTX}”
[/cc]
And:
[cc lang=”bash”]
chmod +x /etc/rc.d/autofluxbox
[/cc]
One thing I’ve just found is ${PATH} seems to be wrong on my X environment ¬¬’… I will continue investigating.
I’ve improved a bit the start script:
[cc lang=”bash”]#!/bin/bash
LOGDIR=/var/log/autofluxbox
[ ! -d $LOGDIR ] && mkdir $LOGDIR
USER=dodger
STARTX=”/usr/bin/startx”
SCREENID=0
getpid()
{
SCREENID=$(while read LINE ; do [[ “$LINE” =~ ^([0-9]{2,})\.Fluxbox_startup.*$ ]] && echo ${BASH_REMATCH[1]} ; done < <(sudo -u dodger screen -ls)) } mystart() { su - ${USER} -c "screen -S Fluxbox_startup -d -m ${STARTX}" echo "$(date) - Autofluxbox started with screen pid $SCREENID" | tee -a $LOGDIR/autofluxbox.$(date +%Y%m%d).log } mystop() { getpid [ $SCREENID -gt 10 ] && kill $SCREENID || echo "No X pid found" for i in $(ps waux | grep ^${USER} | grep xinitrc | awk '{print $2}') ; do kill $i ; done echo "$(date) - Autofluxbox stoped" | tee -a $LOGDIR/autofluxbox.$(date +%Y%m%d).log } usage() { echo "$0 {stop|start|status}" } mystatus() { getpid if [ $SCREENID -gt 10 ] then echo "$(date) - Autofluxbox running with screen pid $SCREENID" | tee -a $LOGDIR/autofluxbox.$(date +%Y%m%d).log else echo "$(date) - No X pid found" | tee -a $LOGDIR/autofluxbox.$(date +%Y%m%d).log fi } case $1 in start) mystart ;; stop) mystop ;; restart) mystop sleep 3 mystart ;; status) mystatus ;; *) usage ;; esac [/cc]