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
4
dot_config/i3/executable_common_var.sh
Normal file
4
dot_config/i3/executable_common_var.sh
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
MONITOR_CONF=~/.screenlayout/monitor.sh
|
||||||
|
GENERATED_MONITOR_CONF=~/.screenlayout/generated_monitor.sh
|
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
|
40
dot_config/i3/executable_relative_workspace.sh
Normal file
40
dot_config/i3/executable_relative_workspace.sh
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Required jq to be installed with
|
||||||
|
# pacman -S jq arandr
|
||||||
|
|
||||||
|
# Move to layout.sh exported with arandr
|
||||||
|
SCREENS=("DP-3" "DP-1" "DP-5")
|
||||||
|
SCREEN_NUMBER=${#SCREENS[@]}
|
||||||
|
|
||||||
|
# Set command from current WM
|
||||||
|
MSG_COMMAND=i3-msg
|
||||||
|
if [[ $DESKTOP_SESSION =~ ^sway$ ]]; then
|
||||||
|
MSG_COMMAND=swaymsg
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Get current workspace output (Screen)
|
||||||
|
CURRENT_WORKSPACE=$($MSG_COMMAND -t get_workspaces \
|
||||||
|
| jq '.[] | select(.visible == true and .focused == true) | .output' \
|
||||||
|
| sed "s/\"\|'//g")
|
||||||
|
|
||||||
|
|
||||||
|
# Get screen index from screens list and current workspace
|
||||||
|
SCREEN_INDEX=-1
|
||||||
|
for val in ${!SCREENS[@]}
|
||||||
|
do
|
||||||
|
if [[ "${SCREENS[val]}" == "$CURRENT_WORKSPACE" ]]; then
|
||||||
|
SCREEN_INDEX=$val;
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
DESIRED_WORKSPACE=$(($SCREEN_INDEX * 10 + $1))
|
||||||
|
|
||||||
|
# To run in DRY RUN uncomment line in below
|
||||||
|
# MSG_COMMAND=echo
|
||||||
|
if [[ "$2" == "move" ]]; then
|
||||||
|
$MSG_COMMAND move container to workspace number $DESIRED_WORKSPACE
|
||||||
|
else
|
||||||
|
$MSG_COMMAND workspace number $DESIRED_WORKSPACE
|
||||||
|
fi
|
|
@ -1,7 +1,7 @@
|
||||||
{{ if eq .chezmoi.osRelease.idLike "arch" }}
|
{{ if eq .chezmoi.osRelease.idLike "arch" }}
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# All requirements for i3
|
# All requirements for i3
|
||||||
sudo pacman -S curl picom i3-gaps polybar dunst dmenu i3lock bluez-tools blueberry pavucontrol tmux feh dex yay xss-lock network-manager-applet playerctl alacritty git gnome-keyring --noconfirm
|
sudo pacman -S curl picom i3-gaps polybar dunst dmenu i3lock bluez-tools blueberry pavucontrol tmux feh dex yay xss-lock network-manager-applet playerctl alacritty git gnome-keyring jq arandr --noconfirm
|
||||||
|
|
||||||
yay -S nerd-fonts-complete spotify spicetify-cli --noconfirm
|
yay -S nerd-fonts-complete spotify spicetify-cli --noconfirm
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue