Re: Minimum ubuntu post-install recipe for fluxbox

Bob Hepple <[email protected]> Mon, 16 Feb 2015 15:29:32 +1000
Newsgroups gmane.comp.window-managers.fluxbox.user
Message-ID <CAHzpm2hWSar5tRm=ruj0mC_dvvs8sKxWxNdJzHOuiAWy7ujx9Q@mail.gmail.com>
lxdm ?

I use the lxdm spin of fedora on my lappy and it seems reasonably good
- not that I log off very often. It fully supports your ~/.xseesion by
putting this in /usr/share/xsessions/xsession.desktop:

[Desktop Entry]
Encoding=UTF-8
Name=XSession
Comment=This session will run your ~/.xsession
Exec=$HOME/.xsession
Icon=
Type=Application
[Window Manager]
SessionManaged=true

My .xsession file starts up the essentials:


ERRFILE="$HOME/.xsession-errors$DISPLAY"
exec &>> $ERRFILE

echo "==============================================================="
echo "Running .xsession ... $(date)"
export PS4='+$(basename
${BASH_SOURCE}):${LINENO}:${FUNCNAME[0]:+${FUNCNAME[0]}(): }'
set -x

[[ "$WM" ]] || {
    F=~/.config/desktop
    [[ -f $F ]] && source $F
}
[[ "$WM" ]] || WM=$(type $WM 2>/dev/null)

# fallbacks:

[[ "$WM" ]] || {
    WM=$(
        type startfluxbox 2>/dev/null ||
        type awesome 2> /dev/null ||
        type startkde 2> /dev/null ||
        type gnome-session 2> /dev/null
    )
    [[ "$WM" ]] && {
        set -- $WM
        WM=$1
    }
}

[[ "$WM" ]] || {
    F=/etc/sysconfig/desktop
    [[ -f $F ]] && source $F
    [[ -x "$PREFERRED" ]] && WM=$PREFERRED
    WM=$(type $WM 2>/dev/null)
}

# final unction:
[[ "$WM" ]] || WM=myterm

[ "$DBUS_SESSION_BUS_ADDRESS" ] || {
    # eval `dbus-launch --sh-syntax --exit-with-session`
    echo ".xsession: sourcing /etc/X11/xinit/xinitrc.d/*"
    source /etc/X11/xinit/xinitrc.d/* # should do the above
}

echo ".xsession: .Xmodmap etc:"
MODMAP="$HOME/.Xmodmap"
MODMAPVNC="$HOME/.Xmodmap.vnc"
XRESOURCES=$HOME/.Xresources
H=$(hostname -s)
XRESOURCES_HOST=$XRESOURCES.$H
XMODMAP_HOST=$MODMAP.$H

# .Xresources is the modern way - why did they make such a random
# change from .Xdefaults?
[ -r $XRESOURCES ] && xrdb -merge $XRESOURCES
[ -r "$XMODMAP" ] && xmodmap "$XMODMAP"
[ "$VNCDESKTOP" -a -r "$MODMAPVNC" ] && xmodmap "$MODMAPVNC"
[ -z "$NX_CLIENT$VNCDESKTOP$X2GO_SESSION" ] && {
    [ -r $XRESOURCES_HOST ] && xrdb -merge $XRESOURCES_HOST
    [ -r $XMODMAP_HOST ] && xmodmap $XMODMAP_HOST
}

export BH_XSESSION=true

#fix-xft.dpi
xrandr -q | grep "VGA1 connected" && {
    echo ".xsession: VGA1 detected setting up for VGA1 and LVDS1"
    xrandr --output VGA1 --mode 1920x1080 --left-of LVDS1
    xrandr --output LVDS1 --pos 1920x800
}

# g-k-d may have been started by the DM, maybe already initialised
# with the password:
type gnome-keyring-daemon && {
    # --replace is on f19, not RHEL-6. g-k-d does not cache gpg
    # keys so use gpg-agent instead! g-k-d sets .ssh-agent-info
    # but doesn't set the pid - maybe the pid can change and they
    # can't be bothered to update it? Bloody gnome.

        # g-k-d may need these hacks to get the keyring to open at login:
        # /etc/pam.d/xscreensaver: auth optional pam_gnome_keyring.so
        # /etc/pam.d/passwd: password   optional     pam_gnome_keyring.so

    GKD="gnome-keyring-daemon --start --components=secrets,ssh,pkcs11,gpg"
    echo ".xsession: $GKD"
    eval $( $GKD )

    export GNOME_KEYRING_CONTROL GNOME_KEYRING_PID SSH_AUTH_SOCK GPG_AGENT_INFO

    SSH_AGENT_PID=$(pgrep gnome-keyring-daemon )
    [[ "$SSH_AUTH_SOCK" ]] && {
        {
            echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK"
            echo "SSH_AGENT_PID=$SSH_AGENT_PID"
        } > ~/.ssh-agent-info
    }
}

# if you want to kill g-k-d:
#GKD_PID=$(
#    ps -o pid,user  --no-header -C gnome-keyring-daemon |
#    awk "/$USER/ {print \$1; exit}"
#)
#[[ "$GKD_PID" ]] && kill $GKD_PID

[[ -z "$GPG_AGENT_INFO" ]] && type gpg-agent && {
    echo ".xsession: running gpg-agent:"

    # gpg-agent refuses to run if there's another one running:
    EXISTING_GPG=$(
        ps -o pid,user -C gpg-agent --no-header |
        awk "/$USER/ {print \$1; exit}"
    )
    if [[ "$EXISTING_GPG" ]]; then
        echo ".xsession: Re-using an existing gpg-agent with PID $EXISTING_GPG"
        GPG_INFO_FILE="${HOME}/.gpg-agent-info"

        [[ -e $GPG_INFO_FILE ]] && {
            source $GPG_INFO_FILE
            export GPG_AGENT_INFO
        }
    else
        # if possible, don't use gpg-agent for ssh 'cos it sux esp. with
        # batch-ssh - just use it for gpg keys:
        USE_GPG_FOR_SSH=""
        [[ -z "$SSH_AUTH_SOCK" ]] && ! type ssh-agent && USE_GPG_FOR_SSH="yes"

        TTL=$(( 7 * 24 * 60 * 60 ))
        GPG_OPTS="--daemon --write-env-file ${HOME}/.gpg-agent-info"
        GPG_OPTS+=" --default-cache-ttl $TTL"
        GPG_OPTS+=" --max-cache-ttl $TTL"

        [[ "$USE_GPG_FOR_SSH" ]] && {
            GPG_OPTS+=" --enable-ssh"
            GPG_OPTS+=" --default-cache-ttl-ssh $TTL"
            GPG_OPTS+=" --max-cache-ttl-ssh $TTL"
        }

        echo ".xsession: gpg-agent $GPG_OPTS"
        eval $(gpg-agent $GPG_OPTS)
        export GPG_AGENT_INFO

        [[ "$USE_GPG_FOR_SSH" ]] && {
            [[ "$SSH_AUTH_SOCK" ]] && {
                {
                    echo "SSH_AUTH_SOCK=$SSH_AUTH_SOCK"
                    echo "SSH_AGENT_PID=$SSH_AGENT_PID"
                } > ~/.ssh-agent-info
            }
        }
    fi
}

echo ".xsession: SSH_AUTH_SOCK='$SSH_AUTH_SOCK'"

AGENT=
[ "$SSH_AUTH_SOCK" ] || {
    if type ssh-agent; then
        echo ".xsession: no SSH_AUTH_SOCK so running $WM with ssh-agent:"
        AGENT=ssh-agent
    else
        echo ".xsession: WARNING: no SSH_AUTH_SOCK and no ssh-agent!!!"
    fi
}

echo ".xsession: running and waiting for: $AGENT $WM"
$AGENT $WM

# Cleanup

# ssh-agent dies with the WM; gpg-agent might be needed by another
# session for this user (only one per user). If you want to leave
# something running after the session finishes, better unset DISPLAY!!
echo ".xsession: $AGENT $WM finished, cleaning up"
for SIG in TERM KILL; do
    for PID in GNOME_KEYRING_PID; do
        [[ "${!PID}" ]] && kill -0 ${!PID} && kill -$SIG ${!PID}
    done

    # kill processes for this user on this display
    for PID in $( pgrep -u $USER | grep -v "^$$"'$' ); do
        # NB g-k-d's environ is read-only by root so won't match here
        eval $( print_env $PID _ )
        case $_ in
            */gpg-agent) continue ;;
        esac
        D=$( print_env $PID DISPLAY )
        D=${D%.0}
        [[ "$D" == "DISPLAY=${DISPLAY%.0}" ]] && kill -$SIG $PID
    done
    sleep 2
done
echo ".xsession: done cleaning up, exiting"

On 16 February 2015 at 14:37, Tim Johnson <[email protected]> wrote:
> To recap a former thread that I posted to this ML :
> I've done a minimum install of ubuntu 14.04. This install can be
> describe (as per ubuntu 12.04) at the following site:
> http://www.psychocats.net/ubuntu/minimal
>
> I believe this request could be considered outside of the venue of
> this list, but I hope that some leeway could be considered, given
> that I believe that many who use fluxbox do so on minimal
> "hand-rolled" installation deployments. So I'll describe the process
> as follows :
>
> The minimum install for ubuntu 14.04 on this Asus EEEpc 900 does not
> provide for x, window managers etc.
>
> The initial install went flawlessly. I then installed fluxbox
> without a login manager and that seemed to go just fine. I then
> decided that I sould have a backup window manager and then installed
> icewm and xdm. I found that xdm did not appear to provide me with a
> menu of sessions and that it seemed that I was stuck with icewm.
>
> I removed xdm, installed slim and to keep the story short, I ended
> up with a mess. I believe it would best serve my interests by
> re-installing.
>
> >From the psychocats link above there is a "recipe" which can be
> quickly found by doing a search on the following string : "At the
> prompt, type these three commands" etc...
>
> The commands for the "recipe" are provided as follows :
>
> ### begin commands
> sudo apt-get update
>
> sudo apt-get install xorg xterm gdm icewm menu firefox gksu synaptic
> --no-install-recommends
>
> sudo service gdm start
> ### end commands
>
> I would prefer to have *both* fluxbox and icewm as well as mc and
> aptitude (in lieu of synaptic), but that is just me. I believe that
> there are alternative login managers to gdm that still provide for
> picking from any number of alternative wm sessions without the
> "bulk" of gdm.
>
> I would appreciate recommendations for an edited alternative to the
> "recipe" above to suit my goal of having fluxbox with icewm as an
> "backup" wm session and a basic but flexible login manager.
>
> thanks
> --
> Tim
> tim at tee jay forty nine dot com or akwebsoft dot com
> http://www.akwebsoft.com, http://www.tj49.com
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
> _______________________________________________
> Fluxbox-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/fluxbox-users

------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk