From 0f08d04698c814955116b6bae50752e64b774d8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Romain=20Gon=C3=A7alves?= Date: Thu, 23 Dec 2021 18:28:03 +0000 Subject: Thu Dec 23 06:28:03 PM UTC 2021 --- .bin/tenv | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 .bin/tenv (limited to '.bin/tenv') 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 $@ -- cgit v1.2.3