From b5f8ee46f0b8a97ddbe8b21e1605bfe2b41c0cb5 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 14 Aug 2013 15:07:04 -0400 Subject: re-jigger to have most everything in XDG directories --- .config/login.sh | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) create mode 100644 .config/login.sh (limited to '.config/login.sh') diff --git a/.config/login.sh b/.config/login.sh new file mode 100644 index 0000000..851f4ec --- /dev/null +++ b/.config/login.sh @@ -0,0 +1,106 @@ +#!/bin/sh +# ~/.profile: executed by the command interpreter for login shells. +# Should be whether logging in graphically or not. +# +# This file should be executable by /bin/sh, but I'm going to assume bash(1) +# +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +umask 022 + +## Paths ############################################################# + +# Unix +prefixes=( + "$HOME" + "$HOME/.local.`uname -m`" + "$HOME/.local/bin" + "$HOME/.prefix.`uname -m`" + "$HOME/.prefix" + "$HOME"/.gem/ruby/* +) +for prefix in "${prefixes[@]}"; do + if [[ -d "$prefix/bin" ]]; then + export PATH="$prefix/bin:$PATH" + fi +done + +# Ruby +for dir in "$HOME"/.prefix/lib; do + if [[ -d "$dir" ]]; then + export RUBYLIB="$dir" + fi +done +unset prefixes dir prefix + +# TMPDIR ############################################################# + +if [[ ! -d "$HOME/tmp" ]]; then + tmp="$(mktemp --tmpdir -d "$USER-tmpdir.XXXXXXXXXXXXXXXXXXX")" + ln -sf "$tmp" "$HOME/tmp" + unset tmp +fi +export TMPDIR="$HOME/tmp" + +# XDG ################################################################ + +. "$HOME/.local/lib/xdg.sh" + +# Settings ########################################################### + +# Text editor +if [[ -f "$HOME/.selected_editor" ]]; then + . "$HOME/.selected_editor" + export SELECTED_EDITOR + export ALTERNATE_EDITOR + export EDITOR="${EDITOR:-$SELECTED_EDITOR}" + export VISUAL="${VISUAL:-$SELECTED_EDITOR}" +fi + +# GPG +if [[ -z $GPGKEY ]] && [[ -f "${HOME}/.gnupg/gpg.conf" ]]; then + export GPGKEY=`sed -nr 's/^\s*default-key\s+//p' "${HOME}/.gnupg/gpg.conf"` +fi +if [[ -z "$(pgrep -u `whoami` gpg-agent)" ]] && [[ -n $XDG_RUNTIME_DIR ]] && type gpg-agent &>/dev/null; then + mkdir -p "${XDG_RUNTIME_DIR}/sessions" + gpg-agent --daemon --write-env-file "${XDG_RUNTIME_DIR}/sessions/gpg" &>/dev/null +fi +if [[ -f "${XDG_RUNTIME_DIR}/sessions/gpg" ]]; then + . "${XDG_RUNTIME_DIR}/sessions/gpg" + export GPG_AGENT_INFO + #export SSH_AUTH_SOCK +fi + +# Java +_JAVA_OPTIONS='' +_JAVA_OPTIONS+=' -Dawt.useSystemAAFontSettings=on' +_JAVA_OPTIONS+=' -Dswing.aatext=true' +_JAVA_OPTIONS+=' -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel' +if [[ -n $TMPDIR ]]; then + _JAVA_OPTIONS+=" -Djava.io.tmpdir=$TMPDIR" +fi +export _JAVA_OPTIONS + +# X11 +if [[ -z $XAUTHORITY ]]; then + export XAUTHORITY=$HOME/.Xauthority +fi + +# D-Bus +if [[ -z $DBUS_SESSION_BUS_ADDRESS ]] && type dbus-launch &>/dev/null; then + # I want a separate instance for each login + #dbus-launch > "${HOME}/.cache/sessions/dbus" + #. "${HOME}/.cache/sessions/dbus" + eval `dbus-launch` + + export DBUS_SESSION_BUS_ADDRESS + export DBUS_SESSION_BUS_PID +fi + +# Load any box-specific stuff +if [[ -f "$XDG_CONFIG_HOME/login.local.sh" ]]; then + . "$XDG_CONFIG_HOME/login.local.sh" +fi -- cgit v1.2.3-54-g00ecf From 4652fb938285ad72a3d21042c118361969176f80 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 14 Aug 2013 15:47:40 -0400 Subject: touch up the first line in .config/bash/rc.sh and .config/login.sh --- .config/bash/rc.sh | 2 +- .config/login.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to '.config/login.sh') diff --git a/.config/bash/rc.sh b/.config/bash/rc.sh index dee42b4..447796a 100644 --- a/.config/bash/rc.sh +++ b/.config/bash/rc.sh @@ -1,4 +1,4 @@ -# ~/.bashrc: executed by bash(1) for non-login shells. +# ~/.bashrc: executed by bash(1) for interactive non-login shells. # I include this file for all interactive invocations of bash(1), whether # they are login shells or not. diff --git a/.config/login.sh b/.config/login.sh index 851f4ec..0a358f2 100644 --- a/.config/login.sh +++ b/.config/login.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # ~/.profile: executed by the command interpreter for login shells. # Should be whether logging in graphically or not. # -- cgit v1.2.3-54-g00ecf From 3f570eac4afc3299fa2a55b39c57fae7f457bc84 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 14 Aug 2013 15:51:54 -0400 Subject: re-jigger to allow easier setting of the path --- .config/cron/make-config | 2 +- .config/login.sh | 25 ++---------------------- .local/bin/config-path | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ .local/lib/path.sh | 9 +++++++++ 4 files changed, 63 insertions(+), 24 deletions(-) create mode 100755 .local/bin/config-path create mode 100644 .local/lib/path.sh (limited to '.config/login.sh') diff --git a/.config/cron/make-config b/.config/cron/make-config index afe690d..448475b 100644 --- a/.config/cron/make-config +++ b/.config/cron/make-config @@ -1,2 +1,2 @@ # m h dom mon dow command -*/5 * * * * . $HOME/.local/lib/xdg.sh && make -C $XDG_CONFIG_HOME +*/5 * * * * . $HOME/.local/lib/path.sh && . $HOME/.local/lib/xdg.sh && make -C $XDG_CONFIG_HOME diff --git a/.config/login.sh b/.config/login.sh index 0a358f2..3dad752 100644 --- a/.config/login.sh +++ b/.config/login.sh @@ -13,28 +13,7 @@ umask 022 ## Paths ############################################################# -# Unix -prefixes=( - "$HOME" - "$HOME/.local.`uname -m`" - "$HOME/.local/bin" - "$HOME/.prefix.`uname -m`" - "$HOME/.prefix" - "$HOME"/.gem/ruby/* -) -for prefix in "${prefixes[@]}"; do - if [[ -d "$prefix/bin" ]]; then - export PATH="$prefix/bin:$PATH" - fi -done - -# Ruby -for dir in "$HOME"/.prefix/lib; do - if [[ -d "$dir" ]]; then - export RUBYLIB="$dir" - fi -done -unset prefixes dir prefix +. "$HOME/.local/lib/path.sh" # TMPDIR ############################################################# @@ -86,7 +65,7 @@ export _JAVA_OPTIONS # X11 if [[ -z $XAUTHORITY ]]; then - export XAUTHORITY=$HOME/.Xauthority + export XAUTHORITY="$HOME/.Xauthority" fi # D-Bus diff --git a/.local/bin/config-path b/.local/bin/config-path new file mode 100755 index 0000000..a5c3b0e --- /dev/null +++ b/.local/bin/config-path @@ -0,0 +1,51 @@ +#!/bin/bash + +# All the prefixes to consider +prefixes=( + "$HOME" + "$HOME/.local.`uname -m`" + "$HOME/.local/bin" + "$HOME/.prefix.`uname -m`" + "$HOME/.prefix" + "$HOME"/.gem/ruby/* +) + +###################################################################### + +in_array() { + local needle=$1; shift + local haystack=("$@") + local straw + for straw in "${haystack[@]}"; do + [[ "$needle" == "$straw" ]] && return 0 + done + return 1 +} + +# Import existing values +IFS=: paths=($PATH) +IFS=: rubylibs=($RUBYLIB) + +# Scan through prefixes +for prefix in "${prefixes[@]}"; do + # PATH + dir="$prefix/bin" + if [[ -d "$dir" ]] && ! in_array "$dir" "${paths[@]}"; then + paths+=("$dir") + fi + # RUBYLIB + dir="$prefix/lib" + if [[ -d "$dir" ]] && ! in_array "$dir" "${rubylibs[@]}"; then + rubylibs+=("$dir") + fi +done + +# Finally, print our values +IFS=: PATH="${paths[*]}" +IFS=: RUBYLIB="${rubylibs[*]}" + +# The sed bit here is the only time we call an external program +{ + declare -p PATH + declare -p RUBYLIB +} | sed 's/^declare \(-\S* \)*//' diff --git a/.local/lib/path.sh b/.local/lib/path.sh new file mode 100644 index 0000000..a45f8fd --- /dev/null +++ b/.local/lib/path.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +if type config-path &>/dev/null; then + config_path=config-path +else + # Bootstrap finding config-path + config_path="$HOME/.local/bin/config-path" +fi +eval "$("$config_path" | sed 's/^/export /')" -- cgit v1.2.3-54-g00ecf