From 43a5a54ffe23bf2055e946b2608a0699bc534f85 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Fri, 21 Aug 2020 21:09:00 +0200 Subject: [PATCH] Add define_vars function --- ecran | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/ecran b/ecran index 9f3f68b..4e51939 100755 --- a/ecran +++ b/ecran @@ -16,7 +16,6 @@ readonly RESET='\033[0m' readonly COLOR_DEBUG="${PURPLE}" # }}} -# Functions {{{ debug_message() { # {{{ local_message="${1}" @@ -27,9 +26,30 @@ debug_message() { # {{{ return 0 } # }}} +define_vars() { # {{{ + return_second_output_name="0" + + SECOND_OUTPUT=$(xrandr | grep " connected" | grep -v "${MAIN_SCREEN}" | awk 'NR==1{ print $1 }') + + debug_message "define_vars − \ +The second connected output is: ${SECOND_OUTPUT}." + + return "${return_second_output_name}" +} +# }}} +main() { # {{{ + + ## Define all vars + define_vars + +} # }}} +main + +# Manage arguments # {{{ +# This code can't be in a function due to arguments case "${1}" in ds | dockstation | work ) xrandr --output DP-1 --mode 1920x1080 --left-of "${MAIN_SCREEN:=/dev/null}" --output "${MAIN_SCREEN:=/dev/null}" --mode 1366x768 @@ -61,10 +81,13 @@ case "${1}" in ;; * ) printf 'Bad argument, please use [vga|hdmi|ds|work|-|off]' - exit 1;; - + exit 1 + ;; esac +# }}} + +# Update herbstluftWM configuration herbstclient detect_monitors herbstclient reload