-
Notifications
You must be signed in to change notification settings - Fork 39
/
initscreen.sh
executable file
·67 lines (63 loc) · 2.85 KB
/
initscreen.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#! /bin/bash
# exit on error
set -e
#hdmi=$(cat /sys/class/drm/card0-HDMI-A-1/status)
#vga=$(cat /sys/class/drm/card0-VGA-1/status)
if [[ "$WAYLAND_DISPLAY" == "" ]]; then
connected=$(xrandr | grep " connected" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/")
else
connected=$(swaymsg -pt get_outputs | grep -E "^Output" | awk '{print $2}')
fi
#echo "initscreen.sh: hdmi $hdmi; vga $vga"
if [[ $connected =~ "LVDS-0" ]]; then
if [[ $connected =~ "HDMI-0" ]]; then
# hdmi only
# NOTE: i3 fails if no active output is detected, so we have to first enable second output and then disable the first
# xrandr --nograb --output HDMI-0 --auto --primary
# xrandr --nograb --output LVDS-0 --off
# both
# HDMI-0 is primary, LVDS-0 is panned to be vertically aligned to the bottom
# xrandr --nograb --output HDMI-0 --auto --primary --output LVDS-0 --auto --left-of HDMI-0 --panning 1366x768+0+312
xrandr --output HDMI-0 --auto --primary --output LVDS-0 --auto --left-of HDMI-0 --panning 1366x768+0+312
# xrandr --output HDMI-0 --auto --primary --output LVDS-0 --auto --right-of HDMI-0
elif [[ $connected =~ "VGA-0" ]]; then
# xrandr --nograb --output VGA-0 --auto --output LVDS-0 --mode 1024x768 --primary
# TODO: look at --scale argument
xrandr --output VGA-0 --auto --primary --output LVDS-0 --auto --below VGA-0
else
# xrandr --nograb --output LVDS-0 --auto --primary --output HDMI-0 --off
# xrandr --output LVDS-0 --auto --primary --output HDMI-0 --off
xrandr --output LVDS-0 --auto --primary --output HDMI-0 --off --output VGA-0 --off
fi
elif [[ $connected =~ "eDP-1" ]]; then
if [[ -f /proc/acpi/button/lid/LID/state ]]; then
lid=$(cat /proc/acpi/button/lid/LID/state | awk '{print $2}')
else
lid="open"
fi
if [[ "$WAYLAND_DISPLAY" == "" ]]; then
if [[ $connected =~ "HDMI-1" ]] && [[ "$lid" == "closed" ]]; then
xrandr --output HDMI-1 --auto --primary --output eDP-1 --off
echo "Xft.dpi: 96" | xrdb -merge
elif [[ $connected =~ "HDMI-1" ]]; then
xrandr --output HDMI-1 --auto --primary --output eDP-1 --auto --left-of HDMI-1
else
xrandr --output eDP-1 --auto --primary --output HDMI-1 --off
echo "Xft.dpi: 168" | xrdb -merge # scale=1.75
fi
else
if [[ $connected =~ "HDMI-A-1" ]] && [[ "$lid" == "closed" ]]; then
swaymsg output HDMI-A-1 enable
swaymsg output eDP-1 disable
elif [[ $connected =~ "HDMI-A-1" ]]; then
swaymsg output HDMI-A-1 enable
swaymsg output eDP-1 enable
else
swaymsg output eDP-1 enable
swaymsg output HDMI-A-1 disable
fi
fi
else
first=$(echo $connected | cut -f1 -d' ')
xrandr --output ${first} --auto --primary
fi