diff options
Diffstat (limited to '.bin/tenv')
-rwxr-xr-x | .bin/tenv | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/.bin/tenv b/.bin/tenv new file mode 100755 index 0000000..7718d89 --- /dev/null +++ b/.bin/tenv @@ -0,0 +1,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 $@ |