blob: 7718d8954d7d9ba45c6aedf022f40e4960e70ab6 (
plain) (
blame)
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
|
#!/bin/sh
#
# o
# _|_ _ _ _ _ _
# | | / |/ | | | |/ / |/ | | |_
# |_/|_/ | |_/ \_/|/ |__/ | |_/ \/
# /|
# \|
#
# tiny env
# scraps system and user's configuration,
# providing unified env. variables accross exotic setup.
#
# ~ rgoncalves.se
log() {
echo [] "${@}"
}
usage() {
cat <<-EOF
usage: tinyenv [-d]
EOF
}
get_os_distribution() {
# tmp
os=$(uname | tr "[:upper:]" "[:lower:]")
distribution=$(uname -r)
# logic
case "${os}" in
linux)
distribution=$(uname -r)
;;
esac
# return
export _OS_DISTRIBUTION="${os}_${distribution}"
unset -v os distribution
}
get_display() {
# tmp
list="wayland Xorg"
# logic
for display in ${list}; do
# search display and skip export if not found
pgrep "${display}" >/dev/null
[ "${?}" -ne 0 ] && display="none" && continue
# found display server
break
done
# return
export _DISPLAY_SERVER=$(echo "${display}" | tr "[:upper:]" "[:lower:]")
unset -v list display
}
get_screens() {
# tmp
screens="1"
# logic
[ "${_DISPLAY_SERVER}" = "xorg" ] && \
screens=$(xrandr | grep " connected" | wc -l | tr -d " ")
# return
export _SCREENS="${screens}"
unset screens
}
show_env() {
list=$(env | grep "^_.*" | sort -n)
for el in ${list}; do
log "${el}"
done
unset -v list el
}
main() {
# must be first
get_os_distribution
# alpha/numeric ordered
get_display
get_screens
[ -n "${DEBUG}" ] && show_env
}
main $@
|