various fixes, mostly for etiona
[distro-setup] / desktop-20-autostart.sh
1 #!/bin/bash
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 if [[ $1 ]]; then
18 right_monitor_rotation=left
19 else
20 right_monitor_rotation=normal
21 fi
22
23
24 if ! xout="$(xrandr)"; then
25 # under wayland
26 exit 0
27 fi
28 xe() { echo "$xout"; }
29 x=$(xe | grep -Ec '^(DisplayPort-[0123]|DVI-0|DP-[1234]|DVI-I-1) connected')
30 if (( x > 2 )); then
31 left=$(xe | sed -rn 's/^(DVI[^ ]+) connected .*/\1/p')
32 dps=( $(xe | sed -rn 's/^(DP-[01234]|DisplayPort-[01234]) connected .*/\1/p') )
33
34 middle=${dps[1]}
35 right=${dps[0]}
36 # on older distros, i needed to swap middle and right.
37
38
39 xrandr --output $left --mode 2560x1600 --pos 0x0 --rotate left \
40 --output $middle --mode 2560x1600 --pos 1600x0 --rotate left \
41 --output $right --mode 2560x1600 --pos 3200x0 --rotate $right_monitor_rotation
42 elif (( x == 2 )); then
43 # 3rd monitor not working atm, so doing this.
44 left=$(xe | sed -rn 's/^(DVI[^ ]+) connected .*/\1/p')
45 middle=$(xe | sed -rn 's/^(DP-[01234]|DisplayPort-[01234]) connected .*/\1/p')
46 xrandr --output $left --mode 2560x1600 --pos 0x0 --rotate left \
47 --output $middle --mode 2560x1600 --pos 1600x0 --rotate left
48
49 fi
50 /a/bin/distro-setup/input-setup m
51 if isarch; then
52 pulseaudio --start
53 fi
54
55 #indicator-kdeconnect
56 date "+%A, %B %d, %r, %S seconds" > /tmp/desktop-20-autostart-log