vitorpy's Dotfiles
1#!/bin/sh
2# Shell environment setup after login
3# Copyright (C) 2015-2016 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
4
5# This file is extracted from kde-workspace (kdm/kfrontend/genkdmconf.c)
6# Copyright (C) 2001-2005 Oswald Buddenhagen <ossi@kde.org>
7
8# Copyright (C) 2024 The Fairy Glade
9# This work is free. You can redistribute it and/or modify it under the
10# terms of the Do What The Fuck You Want To Public License, Version 2,
11# as published by Sam Hocevar. See the LICENSE file for more details.
12
13# Set Terminus font for TTY (custom addition)
14setfont ter-v20b 2>/dev/null || true
15
16# Note that the respective logout scripts are not sourced.
17case $SHELL in
18*/bash)
19 [ -z "$BASH" ] && exec $SHELL "$0" "$@"
20 set +o posix
21 [ -f "/etc"/profile ] && . "/etc"/profile
22 if [ -f "$HOME"/.bash_profile ]; then
23 . "$HOME"/.bash_profile
24 elif [ -f "$HOME"/.bash_login ]; then
25 . "$HOME"/.bash_login
26 elif [ -f "$HOME"/.profile ]; then
27 . "$HOME"/.profile
28 fi
29 ;;
30*/zsh)
31 [ -z "$ZSH_NAME" ] && exec $SHELL "$0" "$@"
32 [ -d "/etc"/zsh ] && zdir="/etc"/zsh || zdir="/etc"
33 zhome=${ZDOTDIR:-"$HOME"}
34 # zshenv is always sourced automatically.
35 [ -f "$zdir"/zprofile ] && . "$zdir"/zprofile
36 [ -f "$zhome"/.zprofile ] && . "$zhome"/.zprofile
37 [ -f "$zdir"/zlogin ] && . "$zdir"/zlogin
38 [ -f "$zhome"/.zlogin ] && . "$zhome"/.zlogin
39 emulate -R sh
40 ;;
41*/csh|*/tcsh)
42 # [t]cshrc is always sourced automatically.
43 # Note that sourcing csh.login after .cshrc is non-standard.
44 sess_tmp=$(mktemp /tmp/sess-env-XXXXXX)
45 $SHELL -c "if (-f /etc/csh.login) source /etc/csh.login; if (-f ~/.login) source ~/.login; /bin/sh -c 'export -p' >! $sess_tmp"
46 . "$sess_tmp"
47 rm -f "$sess_tmp"
48 ;;
49*/fish)
50 [ -f "/etc"/profile ] && . "/etc"/profile
51 [ -f "$HOME"/.profile ] && . "$HOME"/.profile
52 sess_tmp=$(mktemp /tmp/sess-env-XXXXXX)
53 $SHELL --login -c "/bin/sh -c 'export -p' > $sess_tmp"
54 . "$sess_tmp"
55 rm -f "$sess_tmp"
56 ;;
57*) # Plain sh, ksh, and anything we do not know.
58 [ -f "/etc"/profile ] && . "/etc"/profile
59 [ -f "$HOME"/.profile ] && . "$HOME"/.profile
60 ;;
61esac
62
63if [ "$XDG_SESSION_TYPE" = "x11" ]; then
64 [ -f "/etc"/xprofile ] && . "/etc"/xprofile
65 [ -f "$HOME"/.xprofile ] && . "$HOME"/.xprofile
66
67 # run all system xinitrc shell scripts.
68 if [ -d "/etc"/X11/xinit/xinitrc.d ]; then
69 for i in "/etc"/X11/xinit/xinitrc.d/* ; do
70 if [ -x "$i" ]; then
71 . "$i"
72 fi
73 done
74 fi
75
76 # Load Xsession scripts
77 # OPTIONFILE, USERXSESSION, USERXSESSIONRC and ALTUSERXSESSION are required
78 # by the scripts to work
79 xsessionddir="/etc"/X11/Xsession.d
80 export OPTIONFILE="/etc"/X11/Xsession.options
81 export USERXSESSION="$HOME"/.xsession
82 export USERXSESSIONRC="$HOME"/.xsessionrc
83 export ALTUSERXSESSION="$HOME"/.Xsession
84
85 if [ -d "$xsessionddir" ]; then
86 for i in $(ls "$xsessionddir"); do
87 script="$xsessionddir/$i"
88 echo "Loading X session script $script"
89 if [ -r "$script" ] && [ -f "$script" ] && expr "$i" : '^[[:alnum:]_-]\+$' > /dev/null; then
90 . "$script"
91 fi
92 done
93 fi
94
95 if [ -f "$USERXSESSION" ]; then
96 . "$USERXSESSION"
97 fi
98
99 if [ -d "/etc"/X11/Xresources ]; then
100 for i in "/etc"/X11/Xresources/*; do
101 [ -f "$i" ] && xrdb -merge "$i"
102 done
103 elif [ -f "/etc"/X11/Xresources ]; then
104 xrdb -merge "/etc"/X11/Xresources
105 fi
106 [ -f "$HOME"/.Xresources ] && xrdb -merge "$HOME"/.Xresources
107 [ -f "$XDG_CONFIG_HOME"/X11/Xresources ] && xrdb -merge "$XDG_CONFIG_HOME"/X11/Xresources
108fi
109
110exec "$@"