Add dot_config/i3/executable_common_var.sh
Add dot_config/i3/executable_configure_monitors.sh Add dot_config/i3/executable_relative_workspace.sh Update run_once_prepare_arch.sh.tmpl
This commit is contained in:
parent
53d3d13d68
commit
cbabbf5ac3
4 changed files with 96 additions and 1 deletions
51
dot_config/i3/executable_configure_monitors.sh
Normal file
51
dot_config/i3/executable_configure_monitors.sh
Normal file
|
@ -0,0 +1,51 @@
|
|||
#!/bin/bash
|
||||
|
||||
source ~/.config/i3/common_var.sh
|
||||
|
||||
function set_configuration () {
|
||||
# Display message and wait press any key with -n 1
|
||||
read -n 1 -r -s -p $"Save configuration in $MONITOR_CONF.\nPress any key to continue"
|
||||
|
||||
# Ask set monitor configuration
|
||||
arandr
|
||||
|
||||
$MONITOR_CONF # Apply configuration
|
||||
}
|
||||
|
||||
# set_configuration
|
||||
|
||||
# SCREENS => HashMap | Key => Output name | Value => Position X
|
||||
# SCREENS EX:
|
||||
# SCREENS[DP-1]=1920
|
||||
# SCREENS[DP-2]=0
|
||||
declare -A SCREENS
|
||||
CURRENT_SCREEN="na"
|
||||
for line in $(xrandr --listmonitors); do
|
||||
# Return all line with:
|
||||
# OUTPUT NAME: +DP-3
|
||||
# DETAILS: 1920/510x1080/290+0+0
|
||||
if [[ $line == *"+"* ]]; then
|
||||
INFO=$(echo $line | cut -d '+' -f 2)
|
||||
if [[ $CURRENT_SCREEN == "na" ]]; then
|
||||
CURRENT_SCREEN=$INFO
|
||||
echo "SET CURRENT_SCREEN : $CURRENT_SCREEN"
|
||||
else
|
||||
SCREENS["$CURRENT_SCREEN"]=$INFO
|
||||
echo "ADD SCREEN : $CURRENT_SCREEN -> $INFO"
|
||||
CURRENT_SCREEN="na"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# SCREENS ORDER BY POSITION
|
||||
# FINAL RESULT SCREENS=(DP-2 DP-1)
|
||||
ORDERED_SCREENS=($(for x in ${!SCREENS[@]}; do echo $x; done | sort -r | sed 's/\n/ /g'))
|
||||
|
||||
EXPORT_SCREENS="SCREENS=("
|
||||
for screen in ${!ORDERED_SCREENS[@]}; do
|
||||
EXPORT_SCREENS+="\"${ORDERED_SCREENS[$screen]}\" "
|
||||
done
|
||||
EXPORT_SCREENS="${EXPORT_SCREENS:0:-1})" # Remove last space
|
||||
|
||||
echo "#!/bin/bash" > $GENERATED_MONITOR_CONF
|
||||
echo $EXPORT_SCREENS >> $GENERATED_MONITOR_CONF
|
Loading…
Add table
Add a link
Reference in a new issue