From 174d4b112472c2d3a0b86d1683d5ca30de9f1c0d Mon Sep 17 00:00:00 2001 From: Jakub Fojt Date: Sun, 3 Nov 2019 15:02:26 +0100 Subject: [PATCH] .xinitrc: Add xprofile and i3initrc for launching i3 from GDM --- .i3initrc | 22 ++++++++++++++++++++++ .xinitrc | 16 +--------------- .xprofile | 3 +++ scripts/displays.sh | 15 ++++++--------- 4 files changed, 32 insertions(+), 24 deletions(-) create mode 100644 .i3initrc create mode 100755 .xprofile diff --git a/.i3initrc b/.i3initrc new file mode 100644 index 0000000..9bf00ca --- /dev/null +++ b/.i3initrc @@ -0,0 +1,22 @@ +# Generate my i3 config based on hostname +# Needs to be sourced by .xprofile (GDM) or .xinitrc (startx) + +# Generate i3 config file +i3config="/tmp/i3_${USER}_config" +rm -f $i3config + +if [ -f ~/.i3/base.config ]; then + cat ~/.i3/base.config >> $i3config +fi + +if [ "`hostname`" = "kubaArch" ] && [ -f ~/.i3/home.config ]; then + cat ~/.i3/home.config >> $i3config +elif [ "`hostname`" = "kubaDesktop" ] && [ -f ~/.i3/home.config ]; then + cat ~/.i3/home.config >> $i3config +elif [ "`hostname`" = "JakubArch" ] && [ -f ~/.i3/work.config ]; then + cat ~/.i3/work.config >> $i3config +fi + +#exec i3 -c $i3config -V >> ~/${WM}.log 2>&1 +sh ~/scripts/displays.sh auto +exec i3 -c $i3config diff --git a/.xinitrc b/.xinitrc index f6b8d9b..270563d 100755 --- a/.xinitrc +++ b/.xinitrc @@ -30,21 +30,7 @@ rm -f "~/${WM}.log" rm -f "~/${WM}.log" if [ "$WM" = "i3" ]; then - # Generate i3 config file - i3config="/tmp/i3_${USER}_config" - rm -f $i3config - - if [ -f ~/.i3/base.config ]; then - cat ~/.i3/base.config >> $i3config - fi - - if [ "`hostname`" = "kubaArch" ] && [ -f ~/.i3/home.config ]; then - cat ~/.i3/home.config >> $i3config - elif [ "`hostname`" = "JakubArch" ] && [ -f ~/.i3/work.config ]; then - cat ~/.i3/work.config >> $i3config - fi - #exec i3 -c $i3config -V >> ~/${WM}.log 2>&1 - exec i3 -c $i3config + . ~/.i3initrc else exec $WM >> "~/${WM}.log" 2>&1 fi diff --git a/.xprofile b/.xprofile new file mode 100755 index 0000000..654cecc --- /dev/null +++ b/.xprofile @@ -0,0 +1,3 @@ +if [ "$1" = "i3" ]; then + . ~/.i3initrc +fi diff --git a/scripts/displays.sh b/scripts/displays.sh index 3d1a334..4050141 100755 --- a/scripts/displays.sh +++ b/scripts/displays.sh @@ -1,21 +1,18 @@ #!/bin/bash -#$1 is - - -#echo "DISP:eDP1" -#exit 0 function primary() { xrandr | grep primary | awk '{print $1}' } -#displays=($(xrandr | sed -rn 's/(^|(.* ))([^ ]*) connected(( .*)|$)/\3/g; T; p' )) -displays=$(xrandr | grep " connected" | awk '{print $1}') +displays=$(xrandr --listactivemonitors | grep -v Monitors | awk '{print $NF}') case "$1" in + "auto") + echo "$displays" | while read display; do + xrandr --output $display --auto + done + ;; "connected") echo "$displays" -# for i in "${displays[@]}"; do -# echo "$i" -# done ;; "lemonbar") echo "DISP ${displays[@]}" | sed "s/ /:/g"