2022-02-06 07:15:14 +00:00
|
|
|
#!/bin/zsh
|
|
|
|
source "$HOME/.config/wryn/env.zsh"
|
|
|
|
NATIVE_MONITOR='eDP1'
|
|
|
|
|
|
|
|
GET_PRIMARY_MONITOR() {
|
|
|
|
xrandr \
|
|
|
|
| grep 'primary' \
|
|
|
|
| awk '{print $1;}' \
|
|
|
|
| head -n 1
|
|
|
|
}
|
|
|
|
|
|
|
|
PRIMARY_MONITOR=$(GET_PRIMARY_MONITOR)
|
|
|
|
|
2022-03-07 19:19:02 +00:00
|
|
|
GET_ALL_EXTERNAL_MONITORS() {
|
2022-02-06 07:15:14 +00:00
|
|
|
xrandr \
|
|
|
|
| grep ' connect' \
|
|
|
|
| awk '{print $1;}' \
|
|
|
|
| grep -v "$NATIVE_MONITOR" \
|
2022-03-07 19:19:02 +00:00
|
|
|
2>/dev/null
|
|
|
|
}
|
|
|
|
GET_DEFAULT_EXTERNAL_MONITOR() {
|
|
|
|
GET_ALL_EXTERNAL_MONITORS | head -n 1
|
2022-02-06 07:15:14 +00:00
|
|
|
}
|
|
|
|
EXTERNAL_MONITOR=$(GET_DEFAULT_EXTERNAL_MONITOR)
|
|
|
|
|
|
|
|
DISCONNECT_OTHER() {
|
|
|
|
local SFX="$1"
|
|
|
|
|
2022-03-07 19:19:02 +00:00
|
|
|
local INACTIVE_MONITORS=$(\
|
|
|
|
xrandr --listmonitors \
|
|
|
|
| sed '1d' | awk '{print $NF;}' \
|
|
|
|
| grep -v "^$(GET_PRIMARY_MONITOR)$"
|
|
|
|
)
|
|
|
|
|
|
|
|
for ACTIVE_MONITOR in ${@:2}
|
|
|
|
do
|
|
|
|
INACTIVE_MONITORS=$(echo $INACTIVE_MONITORS | grep -v "^$ACTIVE_MONITOR$")
|
|
|
|
done
|
|
|
|
|
|
|
|
local MONITOR
|
|
|
|
for MONITOR in $INACTIVE_MONITORS
|
2022-02-06 07:15:14 +00:00
|
|
|
do
|
2022-03-07 19:19:02 +00:00
|
|
|
xrandr --output $MONITOR --off
|
2022-02-06 07:15:14 +00:00
|
|
|
done
|
|
|
|
|
2022-02-26 16:11:04 +00:00
|
|
|
sleep 1
|
2022-02-06 07:15:14 +00:00
|
|
|
$DOTWRYN/bin/randomize-background
|
|
|
|
|
|
|
|
[ $SFX ] && ( PLAY_SFX $SFX ) &
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
NOTIFY() {
|
|
|
|
notify-send 'xrandr screenlayout' $@
|
|
|
|
}
|