-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathde
executable file
·51 lines (38 loc) · 1.12 KB
/
de
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
#!/bin/sh
set -e
set -u
if [ "$#" -ne 3 ] && [ "$#" -ne 4 ]; then
exit 2
fi
command -v i3-msg > /dev/null
MAIN_DISP="$1"
DISP="$2"
POS="$3"
if [ "$4" = "y" ] ; then
PRIMARY="--primary"
else
PRIMARY=""
fi
if [ "$POS" != "right" ] && [ "$POS" != "left" ]; then
exit 3
fi
I3CONFIG_FILE=${XDG_CONFIG_HOME:-$HOME/.config}/i3/config
xrandr
xrandr --output "$DISP" $PRIMARY
xrandr --output "$DISP" --auto --"$POS"-of "$MAIN_DISP" ; xrandr --output "$MAIN_DISP"
if [ -z "$PRIMARY" ]; then
# shellcheck disable=2016
sed -i --follow-symlinks 's/set $mon2 .*/set $mon2 '"$DISP"'/' "$I3CONFIG_FILE"
# shellcheck disable=2016
sed -i --follow-symlinks 's/set $mon1 .*/set $mon1 '"$MAIN_DISP"'/' "$I3CONFIG_FILE"
else
# shellcheck disable=2016
sed -i --follow-symlinks 's/set $mon2 .*/set $mon2 '"$MAIN_DISP"'/' "$I3CONFIG_FILE"
# shellcheck disable=2016
sed -i --follow-symlinks 's/set $mon1 .*/set $mon1 '"$DISP"'/' "$I3CONFIG_FILE"
fi
# check success
if [ "$(xrandr | grep connected | grep -c -v disconnected)" = "2" ]; then
printf 'GT_PROFILE="Dual"' > "$HOME"/.zsh/12_gnome_terminal_profile.zsh
fi
i3-msg restart