diff --git a/home/.config/autorandr/docked/postswitch b/home/.config/autorandr/docked/postswitch new file mode 100755 index 0000000..1f8a005 --- /dev/null +++ b/home/.config/autorandr/docked/postswitch @@ -0,0 +1,3 @@ +#!/bin/sh + +postrandr diff --git a/home/.config/autorandr/undocked/postswitch b/home/.config/autorandr/undocked/postswitch new file mode 100755 index 0000000..1f8a005 --- /dev/null +++ b/home/.config/autorandr/undocked/postswitch @@ -0,0 +1,3 @@ +#!/bin/sh + +postrandr diff --git a/home/.config/x11/xprofile b/home/.config/x11/xprofile index c027930..984f671 100644 --- a/home/.config/x11/xprofile +++ b/home/.config/x11/xprofile @@ -3,8 +3,6 @@ # This file runs when a DM logs you into a graphical session # if you use startx/xinit this file should also be soruced. -# Set monitor order -xrandr --output HDMI-1 --auto --output eDP-1 --right-of HDMI-1 --auto & # Start xsecurelock lockscreen with xss-lock ~/.local/bin/scripts/lockscreen start & @@ -24,10 +22,6 @@ dunst & # Run network manager applet to show connectivity nm-applet & -# Run trayer-srg for systemtray bar -# if installed normally, command will be `trayer`, not `trayer-srg` command -trayer --monitor 0 --edge top --align right --widthtype request --padding 0 --transparent true --tint 0x282c34 --alpha 0 --height 23 & - # Start flameshot in background flameshot & diff --git a/home/.local/bin/scripts/gui/bspwm/postrandr b/home/.local/bin/scripts/gui/bspwm/postrandr new file mode 100755 index 0000000..e8e7fa5 --- /dev/null +++ b/home/.local/bin/scripts/gui/bspwm/postrandr @@ -0,0 +1,41 @@ +#!/bin/sh + +# Script handling monitor connecting/disconnecting with BSPWM +# This is generally meant to be ran after xrandr call, or as a postswitch hook +# in autorandr tool. + +DISPLAYS="1 2 3 4 5 6 7 8 9 0" +DISPLAYS_AMT="$(echo "$DISPLAYS" | tr " " "\n" | wc -l)" +MONITORS="$(bspc query -M --names)" +MONITOR_AMT="$(echo "$MONITORS" | wc -l)" +DISPLAYS_PER_MONITOR="$((DISPLAYS_AMT / MONITOR_AMT))" + +# TODO: Run xrandr query too, to check which displays are actually connected +# if this isn't in sync with monitors tracked by BSPWM, move all displays from +# the disconnected monitor into the still connected monitors, and leave a temporary +# display on the disconnected monitor, since BSPWM require at least 1 display per mon + +# Split displays evenly across all monitors +i=1 +for monitor in $(echo "$MONITORS" | tr "\n" " ") ; do + start="$((1 + DISPLAYS_PER_MONITOR * (i - 1)))" + end="$((start + DISPLAYS_PER_MONITOR - 1))" + monitor_displays="$(echo "$DISPLAYS" | cut -d' ' -f$start-$end)" + bspc monitor $monitor -d $monitor_displays + ((i++)) +done + +# In case some displays were left out due to integer division error +((end++)) +for display in $(echo "$DISPLAYS" | cut -d' ' -f$end-); do + bspc monitor "$monitor" -a "$display" +done + +# (Re)start trayer +killall trayer +until ! pgrep trayer; do sleep 0.1; done +trayer --monitor primary --edge top --align right --widthtype request --padding 0 --transparent true --tint 0x282c34 --alpha 0 --height 28 --SetDockType true & disown +xdo above -t "$(xdo id -N Bspwm -n root | sort | head -n 1)" "$(xdo id -N trayer)" # Keep trayer above bspwm root window, but below everything else + +# Start lemonbar +launchlemon