diff options
author | Aaron LI <aly@aaronly.me> | 2017-09-21 17:21:38 +0800 |
---|---|---|
committer | Aaron LI <aly@aaronly.me> | 2017-09-21 17:21:38 +0800 |
commit | b998b35adb8f4063cb910e0116928b19e67f59d4 (patch) | |
tree | 812f2e4aca5b0e6f3b3815451278698f43e10ef3 | |
parent | d9326926bfc3895785c907a872afd645415c4d5e (diff) | |
download | dotfiles-b998b35adb8f4063cb910e0116928b19e67f59d4.tar.bz2 |
Add _xsessionrc to source ~/.profile for display managers
Also tweak _profile a bit.
-rw-r--r-- | _profile | 15 | ||||
-rw-r--r-- | _xsessionrc | 25 |
2 files changed, 36 insertions, 4 deletions
@@ -2,11 +2,16 @@ # vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=sh: # # ~/.profile -# Executed by the login shell +# Source by the login shell, or source by the Xsession(5) through the +# `~/.xsessionrc`. # # Aaron LI # +# Avoid this file being sourced again +[ -n "${PROFILE_SOURCED}" ] && return + + # Set file creation mask: be more private! umask 027 @@ -38,7 +43,7 @@ _exists() { ## Check whether the program is running _running() { - pgrep -x -u "${USER}" $1 &> /dev/null + pgrep -x -u "${USER}" "$1" >/dev/null 2>&1 } @@ -88,13 +93,15 @@ if _exists dircolors; then eval $(dircolors -b) fi -## gpg-agent: start it if not running +## Start `gpg-agent` if not running if ! _running gpg-agent; then gpgconf --launch gpg-agent fi -## Set SSH to use 'gpg-agent' +## Set SSH to use `gpg-agent` as the SSH agent is enabled unset SSH_AGENT_PID if [ "${gnupg_SSH_AUTH_SOCK_by:-0}" -ne $$ ]; then export SSH_AUTH_SOCK="/run/user/${UID}/gnupg/S.gpg-agent.ssh" fi + +PROFILE_SOURCED=yes diff --git a/_xsessionrc b/_xsessionrc new file mode 100644 index 0000000..206854a --- /dev/null +++ b/_xsessionrc @@ -0,0 +1,25 @@ +# +# ~/.xsessionrc +# +# Some display managers (e.g., lightdm) do NOT source ~/.profile +# or ~/.xprofile, but some other display managers do. Therefore, +# it is better to use this ~/.xsessionrc to do the initializations, +# as it will be *sourced* by Xsession(5), making the results more +# consistent among different display managers. +# +# See Xsession(5) for more details. +# +# References: +# [1] XFCE/lightdm startup configuration files +# https://superuser.com/a/687401 +# [2] lightdm forgets to source /etc/profile and ~/.profile +# https://bugs.launchpad.net/ubuntu/+source/lightdm/+bug/794315 +# +# +# Aaron LI +# 2017-09-20 +# + +[ -e ${HOME}/.profile ] && . ${HOME}/.profile || true + +# vim: set ts=8 sw=4 tw=0 fenc=utf-8 ft=sh: # |