-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.bash_profile.Linux
139 lines (120 loc) · 5.76 KB
/
.bash_profile.Linux
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# vim: ft=bash noet:
! declare 2>&1 | grep -wq ^colors= && [ $BASH_VERSINFO -ge 4 ] && source $initDir/.colors
function Debug { test "$debug" -gt 0 && echo "$bold${colors[blue]}$@$normal"; }
if tty -s;then function Echo { echo -e "$@"; } else function Echo { : ; } fi
tty -s && Debug "=> Running $bold${colors[blue]}$(basename ${BASH_SOURCE[0]})$normal ..."
test "$debug" -gt 3 && set -x
#function Time { [ "$debug" -gt 1 ] && eval time "$@" || eval "$@"; }
[ "$debug" -gt 1 ] && time="eval time" || time=eval
trap 'echo "=> Ignoring this step and continuing the script <$(basename $BASH_SOURCE)> ..." >&2' INT
#tty -s && echo "=> MIT-MAGIC-COOKIE-1:" && type -P xauth >/dev/null 2>&1 && timeout 5 xauth list | grep :$(echo $DISPLAY | awk -F '\\.|:' '{print$2}') && echo
trap - INT
test -d ~/local/lib && test $LD_LIBRARY_PATH && export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/local/lib || export LD_LIBRARY_PATH=~/local/lib
# set -x
cacheLinkName=.cache
cd $HOME
#echo "=> COUCOU 0"
#ls -ld $HOME/$cacheLinkName
if [ -e $HOME/$cacheLinkName ];then
if ! [ -L $HOME/$cacheLinkName ];then
rm -fr /tmp/$USER/$cacheLinkName/
mkdir -pv /tmp/$USER
if [ -d $HOME/$cacheLinkName ];then
\mv -v $HOME/$cacheLinkName /tmp/$USER/
else
\rm -v $HOME/$cacheLinkName
fi
\ln -vsf /tmp/$USER/$cacheLinkName
else
:
fi
else
mkdir -pv /tmp/$USER/$cacheLinkName
\ln -vsf /tmp/$USER/$cacheLinkName
fi
if tty -s && ls --color >/dev/null 2>&1
then
cd && ls -ld --color $cacheLinkName | awk /$USER/'{print$(NF-2)" "$(NF-1)" "$NF}'
else
#C'est le cas pour Android
cd && ls -ld $cacheLinkName | awk /$USER/'{print$(NF-2)" "$(NF-1)" "$NF}'
fi
Echo
cd - >/dev/null
#Cleanup previous XFCE Sessions
rm -f ~/$cacheLinkName/sessions/xf*
if [ -z "$system" ];then
if [ -e /etc/os-release ];then
if grep ID=sailfishos /etc/os-release -q;then
declare -gxr system=$(Source /etc/os-release && echo "$NAME $VERSION_ID")
elif type -P lsb_release >/dev/null;then
declare -gxr system="$( ( \lsb_release -sd | grep "[0-9.]" || \lsb_release -sir ) | paste -sd' ')"
else
PRETTY_NAME=$( Source /etc/os-release && echo $PRETTY_NAME )
ID=$( Source /etc/os-release && echo $ID )
case $ID in
debian) declare -gxr system="$(echo $PRETTY_NAME | sed "s/[0-9]\+/$(cat /etc/debian_version)/")" ;;
ubuntu) declare -gxr system="$PRETTY_NAME" ;;
esac
fi
# test -r $initDir/.bash_profile.$osID && SourceProfile $initDir/.bash_profile.$osID
unset ID PRETTY_NAME
else
declare -gxr system=$(echo $HOSTTYPE-$OSTYPE | sed "s/arm[^-]*-/arm-/")
fi
fi
[ $debug = 1 ] && echo "=> system = <$system>."
setxkbmap -layout fr >/dev/null 2>&1
if [ $isAdmin = false ];then
\mkdir -p ~/.local/lib/mlocate/ ~/.local/share/applications/ 2>/dev/null
fi
test -z "$XAUTHORITY" && export XAUTHORITY=$HOME/.Xauthority # If "X11 connection rejected because of wrong authentication", read https://stackoverflow.com/a/56661420/5649639
trap 'echo "=> Ignoring this step and continuing the script <$(basename $BASH_SOURCE)> ..." >&2' INT
$isSudoer && xhost SI:localuser:root >/dev/null 2>&1 #Permet a root de lancer des applis graphiques via sudo
trap - INT
[ $TERM = linux ] && setterm -blength 0
#Choix d'une splash image grub aleatoire
if test -w /boot/grub/today.jpg
then
for dir in /multimedia/ImagesVersets $HOME/ImagesVersets
do
test -d $dir && command find $dir -type f 2>/dev/null | egrep -q '(png|jpg)$' && cp -pv "$(shuf -n1 -e $dir/*/*.{jpg,png})" /boot/grub/today.jpg 2>/dev/null && Echo
done
fi
#printf "=> Server Signature : " >&2;ssh-keygen -lf /etc/ssh/ssh_host_rsa_key >&2
interface=eth0
if tty -s && ip link show $interface >/dev/null 2>&1 && [ -z $DISPLAY ]
then
# printf "=> $interface MAC@ : " >&2 # permet de differentier le noeud du cluster sur lequel on est connecte
# ip link show $interface | awk '/ether/{printf$(NF-2)}' >&2
# Echo " , this helps identify on which node of the cluster I'm connected to."
:
fi
trap 'echo "=> Ignoring this step and continuing the script <$(basename $BASH_SOURCE)> ..." >&2' INT
$time setxkbmap -option terminate:ctrl_alt_bksp
if type -P gsettings >/dev/null 2>&1 && [ $DISPLAY ]
then
if command gsettings help >/dev/null
then
[ "$debug" -gt 0 ] && echo "=> Setting 'gsettings' parameters ..."
[ "$debug" -gt 2 ] && set -x
$time gsettings get org.gnome.desktop.input-sources xkb-options | grep -q GLib-GIO-Message && export GIO_EXTRA_MODULES=/usr/lib/x86_64-linux-gnu/gio/modules/
$time profile=$(gsettings list-schemas | grep -q org.gnome.Terminal.ProfilesList && gsettings get org.gnome.Terminal.ProfilesList default)
$time profile=${profile:1:-1} # remove leading and trailing single quotes if any
if \pgrep -u $USER dconf-service >/dev/null;then
$time test $profile && $time gsettings set org.gnome.Terminal.Legacy.Profile:/org/gnome/terminal/legacy/profiles:/:$profile/ login-shell true
$time gsettings set org.gnome.desktop.wm.preferences resize-with-right-button true
$time gsettings set org.gnome.desktop.wm.preferences mouse-button-modifier "\<Alt\>"
type -P dconf >/dev/null 2>&1 && $time dconf write /org/gnome/desktop/input-sources/xkb-options "\[\'terminate:ctrl_alt_bksp\'\]"
fi
[ "$debug" -lt 4 ] && set +x
[ "$debug" -gt 0 ] && echo "=> DONE."
fi
fi
trap - INT
if \pgrep -u $USER dconf-service >/dev/null && type -P dconf >/dev/null 2>&1 && [ $($time dconf read /org/gnome/shell/favorite-apps | wc -c) != 0 ];then
$time dconf read /org/gnome/shell/favorite-apps | grep -wqi firefox.desktop || $time dconf write /org/gnome/shell/favorite-apps "$($time dconf read /org/gnome/shell/favorite-apps | sed "s/\]/, 'Firefox.desktop']/")" 2>/dev/null
fi
type -P matlab >/dev/null 2>&1 && test -d "$HOME/.matlab" && export MATLAB=$(\ls -d "$HOME/.matlab/"* | head -1)
test "$debug" -lt 3 && set +x
test "$debug" -gt 0 && echo "=> END of $bold${colors[blue]}$(basename ${BASH_SOURCE[0]})$normal"