blob: bfe55d966380507c8428dd0642da9ef109e16926 (
plain)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
#+TITLE: BSPWM config
#+PROPERTY: header-args :tangle bspwmrc
* Table of contents :toc:
- [[#about][About]]
- [[#the-shebang][The shebang]]
- [[#restart-safety][Restart safety]]
- [[#no-rerun-function][No-rerun function]]
- [[#killing][Killing]]
- [[#detecting-screens][Detecting screens]]
- [[#basic-bspwm-configurations][Basic BSPWM configurations]]
- [[#applications-workspaces-assignations][Applications workspaces assignations]]
- [[#startup-applications][Startup applications]]
- [[#background-applications][Background applications]]
- [[#foreground-applications][Foreground applications]]
- [[#network-applications][Network applications]]
* About
The following is my ~bspwm~ init script.
* The shebang
For my ~bspwm~ init script, I am using the ~dash~ shell for it is very fast.
#+BEGIN_SRC shell
#!/usr/local/bin/dash
#+END_SRC
* Restart safety
** No-rerun function
The following function helps me not restart a specific program in case it is already running,
avoiding creating a new instance everytime I restart ~bspwm~.
#+BEGIN_SRC shell
run() {
if ! pgrep "$1";
then
"$@"
fi
}
#+END_SRC
** Killing
Now let's kill all terminal emulators and compton.
#+BEGIN_SRC shell
pkill alacritty
pkill compton
#+END_SRC
* Detecting screens
This detects if more screens are attached to the terminal. The init script will act differently
depending on the number of screens linked.
#+BEGIN_SRC shell
screens=1
if xrandr | grep VGA1 | grep " connected"; then
screens=3
/usr/home/jozan/.local/bin/triplescreen
elif xrandr | grep DP1 | grep " connected"; then
screens=2
/usr/home/jozan/.local/bin/dualscreen
fi
sleep 1
if [ $screens -eq 1 ]; then
bspc monitor LVDS1 -d 01 02 03 04 05 06 07 08 09 10 11 12
fi
#+END_SRC
* Basic BSPWM configurations
#+BEGIN_SRC shell
bspc config border_width 1
bspc config window_gap 0
bspc config focused_border_color \#b92121
bspc config split_ratio 0.50
bspc config borderless_monocle true
bspc config gapless_monocle true
bspc config single_monocle true
#+END_SRC
* Applications workspaces assignations
#+BEGIN_SRC shell
if [ $screens -eq 3 ]; then
bspc rule -a Emacs desktop=01 follow=true
bspc rule -a Firefox desktop=08 follow=true
bspc rule -a Wine desktop=07 state=floating
elif [ $screens -eq 2 ]; then
bspc rule -a Emacs desktop=01 follow=true
bspc rule -a Firefox desktop=08 follow=true
bspc rule -a Wine desktop=07 state=floating
elif [ $screens -eq 1 ]; then
bspc rule -a Emacs desktop=01 follow=true
bspc rule -a Firefox desktop=08 follow=true
bspc rule -a Wine desktop=04 state=floating
fi
bspc rule -a Dunst layer=above
bspc rule -a Zathura state=tiled
bspc rule -a qTox desktop=12
bspc rule -a DergodsRealmII desktop=4 state=floating
#+END_SRC
* Startup applications
** Background applications
#+BEGIN_SRC shell
run compton >/dev/null 2>&1 &
if [ $screens -eq 3 ]; then
feh --bg-fill /usr/home/jozan/Pictures/wallpaper.jpg --bg-fill /usr/home/jozan/Pictures/wallpaper.jpg >/dev/null 2>&1
elif [ $screens -eq 2 ]; then
feh --bg-fill /usr/home/jozan/Pictures/wallpaper.jpg --bg-fill /usr/home/jozan/Pictures/wallpaper.jpg >/dev/null 2>&1
else
feh --bg-fill /usr/home/jozan/Pictures/wallpaper.jpg >/dev/null 2>&1
fi
xset r rate 200 100 >/dev/null 2>&1
setxkbmap -layout us,fr -option grp:alt_shift_toggle
run dunst > /dev/null 2>&1 &
run lowbat --say "You're low, partner" >/dev/null 2>&1 &
sleep 2
#+END_SRC
** Foreground applications
#+BEGIN_SRC shell
run emacs &
sleep 12
if [ $screens -eq 3 ]; then
bspc desktop -f 09
alacritty -e dash -c 'clear; cowsay "Welcome back, partner! And remember to try glest!"; zsh -i' &
sleep 1
alacritty -e htop &
sleep 1
alacritty -e gotop &
sleep 1
bspc node -f west
alacritty -e vifm &
sleep 1
bspc node -z right 180 0
bspc node -z top 0 70
bspc node -f east
bspc node -f north
bspc node -z bottom 0 -280
bspc node -f north
bspc node -f west
elif [ $screens -eq 2 ]; then
bspc desktop -f 09
alacritty -e dash -c 'clear; cowsay "Welcome back, partner! And remember to try glest!"; zsh -i' &
sleep 1
alacritty -e htop &
sleep 1
alacritty -e gotop &
sleep 1
bspc node -f west
alacritty -e vifm &
sleep 1
bspc node -z right 180 0
bspc node -z top 0 70
bspc node -f east
bspc node -f north
bspc node -z bottom 0 -280
bspc node -f north
bspc node -f west
elif [ $screens -eq 1 ]; then
bspc desktop -f 09
alacritty -e dash -c 'clear; cowsay "Welcome back, partner!"; zsh -i' &
sleep 1
bspc node -p west
alacritty -e htop &
sleep 1
alacritty -e gotop &
sleep 1
bspc node -f east
alacritty -e vifm &
sleep 1
bspc node -f west
bspc node -f north
bspc node -z bottom 0 -280
bspc node -z right -220 0
bspc node -f east
bspc node -z top 0 70
bspc node -f north
fi
sleep 1
#+END_SRC
** Network applications
In case the terminal is linked to the Internet, the following commands are run.
#+BEGIN_SRC shell
if curl https://www.freebsd.org/ >/dev/null 2>&1; then
git -C ~/.elfeed pull origin master >/dev/null 2>&1 &
run qtox &
if [ $screens -eq 3 ]; then
bspc desktop -f 09
elif [ $screens -eq 2 ]; then
bspc desktop -f 09
elif [ $screens -eq 1 ]; then
bspc desktop -f 09
fi
fi
#+END_SRC
|