distro specific fixes
[distro-setup] / i3-sway / gen
1 #!/bin/bash
2 # I, Ian Kelling, follow the GNU license recommendations at
3 # https://www.gnu.org/licenses/license-recommendations.en.html. They
4 # recommend that small programs, < 300 lines, be licensed under the
5 # Apache License 2.0. This file contains or is part of one or more small
6 # programs. If a small program grows beyond 300 lines, I plan to switch
7 # its license to GPL.
8
9 # Copyright 2024 Ian Kelling
10
11 # Licensed under the Apache License, Version 2.0 (the "License");
12 # you may not use this file except in compliance with the License.
13 # You may obtain a copy of the License at
14
15 # http://www.apache.org/licenses/LICENSE-2.0
16
17 # Unless required by applicable law or agreed to in writing, software
18 # distributed under the License is distributed on an "AS IS" BASIS,
19 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20 # See the License for the specific language governing permissions and
21 # limitations under the License.
22
23
24 set -eE -o pipefail
25 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
26
27 x="$(readlink -f -- "${BASH_SOURCE[0]}")"; cd ${x%/*} # directory of this file
28
29 dir=/a/bin/distro-setup/subdir_files/.config/sway
30 mkdir -p $dir
31 cat common.conf sway.conf > $dir/config
32 dir=/a/bin/distro-setup/subdir_files/.config/i3
33 mkdir -p $dir
34 cat common.conf i3.conf > $dir/config
35
36 monitor_count=$(xrandr|grep -c ' connected')
37 if [[ $1 == bar ]] || (( monitor_count >= 2 )); then
38 cat bar.conf >> $dir/config
39 fi
40
41 move_arg=right
42 if xrandr --listmonitors | awk '$2 == "BIG-RIGHT"' |grep . >/dev/null; then
43 cat >>$dir/config <<'EOF'
44 # by default, new workspaces are created on whatever screen doesn't have
45 # one active or else the current one. That is annoying, I have one
46 # primary monitor, I don't want a new workspace created on secondary
47 # monitor just because I happen be focused on it. This fixes that.
48 workspace 1 output primary
49 workspace 2 output BIG-LEFT
50 workspace 3 output BIG-RIGHT
51 workspace 4 output BIG-RIGHT
52 workspace 5 output BIG-RIGHT
53 workspace 6 output BIG-RIGHT
54 workspace 7 output BIG-RIGHT
55 workspace 8 output BIG-RIGHT
56 workspace 9 output BIG-RIGHT
57 workspace 10 output BIG-RIGHT
58 EOF
59 move_arg="BIG-RIGHT primary"
60 else
61 mon2=$(xrandr | awk '$2 == "connected" && $3 != "primary" {print $1}')
62 if [[ $mon2 ]]; then
63 cat >>$dir/config <<EOF
64 # by default, new workspaces are created on whatever screen doesn't have
65 # one active or else the current one. That is annoying, I have one
66 # primary monitor, I don't want a new workspace created on secondary
67 # monitor just because I happen be focused on it. This fixes that.
68 workspace 1 output primary
69 workspace 2 output $mon2
70 workspace 3 output $mon2
71 workspace 4 output primary
72 workspace 5 output $mon2
73 workspace 6 output $mon2
74 workspace 7 output $mon2
75 workspace 8 output $mon2
76 workspace 9 output $mon2
77 workspace 10 output $mon2
78 EOF
79 fi
80 fi
81
82 # shellcheck disable=SC2016
83 echo 'bindsym $mod+Shift+t move workspace to output '$move_arg >>$dir/config
84
85 if [[ $I3SOCK ]]; then
86 echo $0: i3-msg reload
87 i3-msg reload
88 fi