add copyright headers, fix a few things
[distro-setup] / desktop-20-autostart.sh
1 #!/bin/bash -l
2 # Copyright (C) 2016 Ian Kelling
3
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7
8 # http://www.apache.org/licenses/LICENSE-2.0
9
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 # first 2 alternatives showed under ubuntu 14.04, second 2 under arch at 11/2015
17
18 right_monitor_rotation=left
19 if [[ $1 ]]; then
20 right_monitor_rotation=normal
21 fi
22
23
24 xout="$(xrandr)"
25 xe() { echo "$xout"; }
26 x=$(xe | grep -E '^(DisplayPort-[0123]|DVI-0|DP-[1234]|DVI-I-1) connected' | wc -l)
27 if (( x > 2 )); then
28 left=$(xe | sed -rn 's/^(DVI[^ ]+) connected .*/\1/p')
29 dps=( $(xe | sed -rn 's/^(DP-[01234]|DisplayPort-[01234]) connected .*/\1/p') )
30
31 middle=${dps[1]}
32 right=${dps[0]}
33 # on older distros, i needed to swap middle and right.
34
35
36 xrandr --output $left --mode 2560x1600 --pos 0x0 --rotate left \
37 --output $middle --mode 2560x1600 --pos 1600x0 --rotate left \
38 --output $right --mode 2560x1600 --pos 3200x0 --rotate $right_monitor_rotation
39 elif (( x == 2 )); then
40 # 3rd monitor not working atm, so doing this.
41 left=$(xe | sed -rn 's/^(DVI[^ ]+) connected .*/\1/p')
42 middle=$(xe | sed -rn 's/^(DP-[01234]|DisplayPort-[01234]) connected .*/\1/p')
43 xrandr --output $left --mode 2560x1600 --pos 0x0 --rotate left \
44 --output $middle --mode 2560x1600 --pos 1600x0 --rotate left
45
46 fi
47 /a/bin/distro-setup/input-setup
48 if isarch; then
49 pulseaudio --start
50 fi
51 date "+%A, %B %d, %r, %S seconds" > /tmp/desktop-20-autostart-log